From 677d2f312d9b459769c69d5d110c37819dd3b377 Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Sat, 22 Jan 2022 19:09:06 -0500 Subject: [PATCH] imdb convert fix --- modules/tmdb.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/modules/tmdb.py b/modules/tmdb.py index 7c36d53d..ec9acfa8 100644 --- a/modules/tmdb.py +++ b/modules/tmdb.py @@ -1,7 +1,7 @@ import logging from modules import util from modules.util import Failed -from tmdbapis import TMDbAPIs, TMDbException +from tmdbapis import TMDbAPIs, TMDbException, NotFound logger = logging.getLogger("Plex Meta Manager") @@ -82,15 +82,18 @@ class TMDb: return results.tv_results[0].id def convert_imdb_to(self, imdb_id): - results = self.TMDb.find_by_id(imdb_id=imdb_id) - if results.movie_results: - return results.movie_results[0].id, "movie" - elif results.tv_results: - return results.tv_results[0].id, "show" - elif results.tv_episode_results: - item = results.tv_episode_results[0] - return f"{item.tv_id}_{item.season_number}_{item.episode_number}", "episode" - else: + try: + results = self.TMDb.find_by_id(imdb_id=imdb_id) + if results.movie_results: + return results.movie_results[0].id, "movie" + elif results.tv_results: + return results.tv_results[0].id, "show" + elif results.tv_episode_results: + item = results.tv_episode_results[0] + return f"{item.tv_id}_{item.season_number}_{item.episode_number}", "episode" + else: + raise NotFound + except NotFound: raise Failed(f"TMDb Error: No TMDb ID found for IMDb ID {imdb_id}") def get_movie_show_or_collection(self, tmdb_id, is_movie):