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):
|
class RequestError(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
class EntryNotFoundError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
class ApplicationError(Exception):
|
class ApplicationError(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
@ -100,6 +103,10 @@ def get_media_paths(rating_key):
|
||||||
if response["response"]['result'] == 'error':
|
if response["response"]['result'] == 'error':
|
||||||
raise RequestError("Could not request media path for {} : {}".format(rating_key, response["response"]['message']))
|
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"]:
|
match response["response"]["data"]["media_type"]:
|
||||||
case "movie" | "episode":
|
case "movie" | "episode":
|
||||||
# If the media is a video file we return it as a list of single element
|
# 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")
|
logger.info("Getting path of unwatched medias")
|
||||||
pathToRemove = []
|
pathToRemove = []
|
||||||
for media in unwatched:
|
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:
|
for path in paths:
|
||||||
if path not in FILES_TO_KEEP:
|
if path not in FILES_TO_KEEP:
|
||||||
pathToRemove.append(path)
|
pathToRemove.append(path)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue