fix for wrong rating keys

This commit is contained in:
meisnate12 2021-09-21 14:42:32 -04:00
parent 5a37bca5dd
commit aa6fea52e3

View file

@ -1,4 +1,7 @@
import logging import logging
from plexapi.video import Movie, Show
from modules import util from modules import util
from modules.util import Failed from modules.util import Failed
from plexapi.exceptions import BadRequest, NotFound from plexapi.exceptions import BadRequest, NotFound
@ -40,7 +43,9 @@ class Tautulli:
for item in items: for item in items:
if item["section_id"] == section_id and count < int(params['list_size']): if item["section_id"] == section_id and count < int(params['list_size']):
try: try:
library.fetchItem(int(item["rating_key"])) item = library.fetchItem(int(item["rating_key"]))
if not isinstance(item, (Movie, Show)):
raise BadRequest
rating_keys.append(item["rating_key"]) rating_keys.append(item["rating_key"])
except (BadRequest, NotFound): except (BadRequest, NotFound):
new_item = library.exact_search(item["title"], year=item["year"]) new_item = library.exact_search(item["title"], year=item["year"])
@ -65,5 +70,5 @@ class Tautulli:
else: raise Failed(f"Tautulli Error: No Library named {library_name} in the response") else: raise Failed(f"Tautulli Error: No Library named {library_name} in the response")
def _request(self, url): def _request(self, url):
logger.debug(f"Tautulli URL: {url.replace(self.apikey, '###############')}") logger.debug(f"Tautulli URL: {url.replace(self.apikey, 'APIKEY').replace(self.url, 'URL')}")
return self.config.get_json(url) return self.config.get_json(url)