add path replacement in case path retrieved from tautulli does not match the real path on filesystem

This commit is contained in:
Akiya 2025-06-08 19:55:47 +02:00
parent 2c3bb5811f
commit 480378b9f1
2 changed files with 15 additions and 5 deletions

View File

@ -1,4 +1,4 @@
[SERVER] [TAUTULLI]
SERVER_URL = https://tautulli.exemple.com/ SERVER_URL = https://tautulli.exemple.com/
API_KEY = e18e33df8f7sdfae92d3a2344f2f60 API_KEY = e18e33df8f7sdfae92d3a2344f2f60
@ -14,3 +14,7 @@ files_to_ignore = [
"/share/data/Plex/Films/N'oublie jamais - 2004/The Notebook - 2004.mkv", "/share/data/Plex/Films/N'oublie jamais - 2004/The Notebook - 2004.mkv",
"/share/data/Plex/Films/Nuit D'Ivresse -1986.mkv" "/share/data/Plex/Films/Nuit D'Ivresse -1986.mkv"
] ]
[HOST]
; Change le chemin
replace_path = ["/share/CACHEDEV1_DATA/Plex/", "home/antoine-a/plex"]

View File

@ -24,6 +24,8 @@ FILM_SECTION_IDS = []
DEADLINE_NEVER_WATCHED = "" DEADLINE_NEVER_WATCHED = ""
DEADLINE_LAST_WATCHED = "" DEADLINE_LAST_WATCHED = ""
FILES_TO_KEEP = [] FILES_TO_KEEP = []
SOURCE_PATH = "" # Path retrieved from tautulli api to be replaced
DEST_PATH = "" # Path to the film folder on host
# Retrieve the list of records that does not follow the deadline policies from tautulli # Retrieve the list of records that does not follow the deadline policies from tautulli
def get_unwatched_rating_keys(sectionId): def get_unwatched_rating_keys(sectionId):
@ -151,7 +153,7 @@ def get_and_store_files_to_remove():
with open(outputfile, 'w') as f: with open(outputfile, 'w') as f:
logger.debug("writing to '{}'".format(outputfile)) logger.debug("writing to '{}'".format(outputfile))
for path in pathToRemove: for path in pathToRemove:
f.write(f"{path}\n") f.write(f"{path.replace(SOURCE_PATH, DEST_PATH)}\n")
# Delete all files and empty parent folder listed in an input file # Delete all files and empty parent folder listed in an input file
def delete_files(inputFile): def delete_files(inputFile):
@ -209,11 +211,15 @@ logger.info("Initializing...")
config_obj = configparser.ConfigParser() config_obj = configparser.ConfigParser()
config_obj.read("config.ini") config_obj.read("config.ini")
# -- Read SERVER section -- # -- Read TAUTULLI section --
serverParam = config_obj["SERVER"] serverParam = config_obj["TAUTULLI"]
SERVER_URL = serverParam["server_url"] SERVER_URL = serverParam["server_url"]
API_KEY = serverParam["api_key"] API_KEY = serverParam["api_key"]
# -- Read HOST section --
hostParam = config_obj["HOST"]
REPLACE_PATH = ast.literal_eval(hostParam["replace_path"])
# -- Read MEDIA_FILTER section -- # -- Read MEDIA_FILTER section --
mediaParam = config_obj["MEDIA_FILTER"] mediaParam = config_obj["MEDIA_FILTER"]
FILM_SECTION_IDS = ast.literal_eval(mediaParam["film_section_ids"]) FILM_SECTION_IDS = ast.literal_eval(mediaParam["film_section_ids"])