fix error in case data is empty when retrieving metadata from tautulli

This commit is contained in:
Akiya 2025-06-09 17:20:17 +02:00
parent 3d541cc75e
commit 21b9d080b3
1 changed files with 14 additions and 2 deletions

View File

@ -16,6 +16,9 @@ import re
class RequestError(Exception):
pass
class EntryNotFoundError(Exception):
pass
class ApplicationError(Exception):
pass
@ -100,6 +103,10 @@ def get_media_paths(rating_key):
if response["response"]['result'] == 'error':
raise RequestError("Could not request media path for {} : {}".format(rating_key, response["response"]['message']))
if not response["response"]["data"]:
logger.warning("empty response data for rating_key: {}. The media might have already been deleteted. Ignoring it".format(rating_key))
raise EntryNotFoundError("Could not request media path for {} : {}".format(rating_key, response["response"]['message']))
match response["response"]["data"]["media_type"]:
case "movie" | "episode":
# If the media is a video file we return it as a list of single element
@ -132,7 +139,12 @@ def get_files_to_remove(unwatched):
logger.info("Getting path of unwatched medias")
pathToRemove = []
for media in unwatched:
paths = get_media_paths(media)
try:
paths = get_media_paths(media)
except EntryNotFoundError as err:
#skipping in case path could not be retrieved
continue
for path in paths:
if path not in FILES_TO_KEEP:
pathToRemove.append(path)