Skip to content

Commit a554d00

Browse files
committed
fix(tvdb): ensure that seasons contain data
1 parent d539229 commit a554d00

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

server/api/tvdb/index.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,11 @@ class Tvdb extends ExternalAPI implements TvShowIndexer {
125125
try {
126126
const tvdbData = await this.fetchTvdbShowData(tvdbId);
127127
const seasons = this.processSeasons(tvdbData);
128+
129+
if (!seasons.length) {
130+
return tmdbTvShow;
131+
}
132+
128133
return { ...tmdbTvShow, seasons };
129134
} catch (error) {
130135
logger.error(
@@ -143,6 +148,10 @@ class Tvdb extends ExternalAPI implements TvShowIndexer {
143148
}
144149

145150
private processSeasons(tvdbData: TvdbTvShowDetail): TmdbTvSeasonResult[] {
151+
if (!tvdbData || !tvdbData.seasons) {
152+
return [];
153+
}
154+
146155
return tvdbData.seasons
147156
.filter((season) => season.seasonNumber !== 0)
148157
.map((season) => this.createSeasonData(season, tvdbData));
@@ -204,6 +213,10 @@ class Tvdb extends ExternalAPI implements TvShowIndexer {
204213
seasonNumber: number,
205214
tvId: number
206215
): TmdbTvEpisodeResult[] {
216+
if (!tvdbSeason || !tvdbSeason.episodes) {
217+
return [];
218+
}
219+
207220
return tvdbSeason.episodes
208221
.filter((episode) => episode.seasonNumber === seasonNumber)
209222
.map((episode, index) => this.createEpisodeData(episode, index, tvId));

0 commit comments

Comments
 (0)