fix error in case data is empty when retrieving metadata from tautulli
This commit is contained in:
parent
3d541cc75e
commit
4bf5c8cf54
|
|
@ -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:
|
||||||
|
try:
|
||||||
paths = get_media_paths(media)
|
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)
|
||||||
|
|
|
||||||
24
test.ini
24
test.ini
|
|
@ -1,24 +0,0 @@
|
||||||
[TAUTULLI]
|
|
||||||
SERVER_URL = https://tautulli.antoinesanchez.fr
|
|
||||||
API_KEY = e18e33df8f7c4fae92d3aa410b0f2f60
|
|
||||||
|
|
||||||
[MEDIA_FILTER]
|
|
||||||
; Section_id de la librairie film à nettoyer
|
|
||||||
film_section_ids = [1,2]
|
|
||||||
; nb de mois avant suppression pour un film jamais regardé
|
|
||||||
deadline_never_watched = 60
|
|
||||||
; nb de mois avant suppression depuis le dernier visionage
|
|
||||||
deadline_last_watched = 12
|
|
||||||
files_to_ignore = [
|
|
||||||
"/share/CACHEDEV1_DATA/Plex/Films/Inglourious Basterds - 2009/Inglourious Basterds - 2009.mkv",
|
|
||||||
"/share/CACHEDEV1_DATA/Plex/Films/N'oublie jamais - 2004/The Notebook - 2004.mkv",
|
|
||||||
"/share/CACHEDEV1_DATA/Plex/Films/Nuit D'Ivresse -1986.mkv"
|
|
||||||
]
|
|
||||||
|
|
||||||
[RADARR]
|
|
||||||
SERVER_URL = https://rdr.antoinesanchez.fr
|
|
||||||
API_KEY = 7de301419d1743f4bdf5b5bcbebbf239
|
|
||||||
|
|
||||||
[SONARR]
|
|
||||||
SERVER_URL = https://snr.antoinesanchez.fr
|
|
||||||
API_KEY = 799f2068ecbf4d57ba4519de8bc65eb0
|
|
||||||
Loading…
Reference in New Issue