diff --git a/config.exemple.ini b/config.exemple.ini index 462b701..3d8eae6 100644 --- a/config.exemple.ini +++ b/config.exemple.ini @@ -1,4 +1,4 @@ -[SERVER] +[TAUTULLI] SERVER_URL = https://tautulli.exemple.com/ API_KEY = e18e33df8f7sdfae92d3a2344f2f60 @@ -13,4 +13,8 @@ files_to_ignore = [ "/share/data/Plex/Films/Inglourious Basterds - 2009/Inglourious Basterds - 2009.mkv", "/share/data/Plex/Films/N'oublie jamais - 2004/The Notebook - 2004.mkv", "/share/data/Plex/Films/Nuit D'Ivresse -1986.mkv" - ] \ No newline at end of file + ] + +[HOST] +; Change le chemin +replace_path = ["/share/CACHEDEV1_DATA/Plex/", "home/antoine-a/plex"] diff --git a/plexwasher.py b/plexwasher.py index 33b6df2..da6857b 100755 --- a/plexwasher.py +++ b/plexwasher.py @@ -24,6 +24,8 @@ FILM_SECTION_IDS = [] DEADLINE_NEVER_WATCHED = "" DEADLINE_LAST_WATCHED = "" 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 def get_unwatched_rating_keys(sectionId): @@ -151,7 +153,7 @@ def get_and_store_files_to_remove(): with open(outputfile, 'w') as f: logger.debug("writing to '{}'".format(outputfile)) 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 def delete_files(inputFile): @@ -209,11 +211,15 @@ logger.info("Initializing...") config_obj = configparser.ConfigParser() config_obj.read("config.ini") -# -- Read SERVER section -- -serverParam = config_obj["SERVER"] +# -- Read TAUTULLI section -- +serverParam = config_obj["TAUTULLI"] SERVER_URL = serverParam["server_url"] API_KEY = serverParam["api_key"] +# -- Read HOST section -- +hostParam = config_obj["HOST"] +REPLACE_PATH = ast.literal_eval(hostParam["replace_path"]) + # -- Read MEDIA_FILTER section -- mediaParam = config_obj["MEDIA_FILTER"] FILM_SECTION_IDS = ast.literal_eval(mediaParam["film_section_ids"])