fix(plex): find TV series in addition to movies from IMDb IDs (#1830)

This commit is contained in:
TheCatLady
2022-03-14 09:29:58 -04:00
committed by GitHub
parent 4c50727a32
commit 30644f65ea
2 changed files with 19 additions and 12 deletions

View File

@@ -561,13 +561,13 @@ class TheMovieDb extends ExternalAPI {
}
}
public async getMovieByImdbId({
public async getMediaByImdbId({
imdbId,
language = 'en',
}: {
imdbId: string;
language?: string;
}): Promise<TmdbMovieDetails> {
}): Promise<TmdbMovieDetails | TmdbTvDetails> {
try {
const extResponse = await this.getByExternalId({
externalId: imdbId,
@@ -583,12 +583,19 @@ class TheMovieDb extends ExternalAPI {
return movie;
}
throw new Error(
'[TMDb] Failed to find a title with the provided IMDB id'
);
if (extResponse.tv_results[0]) {
const tvshow = await this.getTvShow({
tvId: extResponse.tv_results[0].id,
language,
});
return tvshow;
}
throw new Error(`No movie or show returned from API for ID ${imdbId}`);
} catch (e) {
throw new Error(
`[TMDb] Failed to get movie by external imdb ID: ${e.message}`
`[TMDb] Failed to find media using external IMDb ID: ${e.message}`
);
}
}