fix error in case data is empty when retrieving metadata from tautulli
This commit is contained in:
parent
3d541cc75e
commit
d647c28f59
|
|
@ -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:
|
||||
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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue