From 0adacc625f9df85cbf83e65207fdd33022511f1b Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Wed, 23 Jun 2021 15:44:00 -0400 Subject: [PATCH] OMDb fix for items not found --- modules/omdb.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/modules/omdb.py b/modules/omdb.py index 52363f92..bcf513fe 100644 --- a/modules/omdb.py +++ b/modules/omdb.py @@ -6,8 +6,11 @@ from retrying import retry logger = logging.getLogger("Plex Meta Manager") class OMDbObj: - def __init__(self, data): + def __init__(self, imdb_id, data): + self._imdb_id = imdb_id self._data = data + if data["Response"] == "False": + raise Failed(f"OMDb Error: {data['Error']} IMDb ID: {imdb_id}") self.title = data["Title"] try: self.year = int(data["Year"]) @@ -45,10 +48,10 @@ class OMDb: if self.Cache: omdb_dict, expired = self.Cache.query_omdb(imdb_id) if omdb_dict and expired is False: - return OMDbObj(omdb_dict) + return OMDbObj(imdb_id, omdb_dict) response = requests.get(self.url, params={"i": imdb_id, "apikey": self.apikey}) if response.status_code < 400: - omdb = OMDbObj(response.json()) + omdb = OMDbObj(imdb_id, response.json()) if self.Cache: self.Cache.update_omdb(expired, omdb) return omdb