diff --git a/src/imdb.ts b/src/imdb.ts index 6f9b003..975bb27 100644 --- a/src/imdb.ts +++ b/src/imdb.ts @@ -249,9 +249,19 @@ export class Episode extends Movie { * * @throws TypeError when the episode number is invalid */ - constructor(obj: OmdbEpisode, season: number) { + constructor(obj: OmdbEpisode, season?: number) { super(obj); - this.season = season; + + + if (season !== undefined) { + this.season = season + } else { + this.season = parseInt(obj.Season, 10); + if (isNaN(this.season)) { + throw new TypeError("invalid season"); + } + } + if (obj.hasOwnProperty("Episode")) { this.episode = parseInt(obj.Episode, 10); if (isNaN(this.episode)) { @@ -584,7 +594,7 @@ export class Client { } else if (isTvshow(data)) { ret = new TVShow(data, opts); } else if (isEpisode(data)) { - ret = new Episode(data, 30); + ret = new Episode(data); } else { throw new ImdbError(`type: '${data.Type}' is not valid`); } diff --git a/src/interfaces.ts b/src/interfaces.ts index 99d9873..edd60c4 100644 --- a/src/interfaces.ts +++ b/src/interfaces.ts @@ -49,6 +49,7 @@ export interface OmdbTvshow { export interface OmdbEpisode { Title: string; Released: string; + Season: string; Episode: string; Type: string; imdbRating: string;