diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..9f0fbff --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +FROM python:3.10 +WORKDIR /app/plexwasher + +# Install the application dependencies +COPY config.ini ./ +COPY requirements.txt ./ +RUN pip install --no-cache-dir -r requirements.txt + +# Copy in the source code +COPY plexwasher.py ./ +COPY config.ini ./ + +CMD ./plexwasher.py -g \ No newline at end of file diff --git a/README.md b/README.md index 3877171..8e49c03 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,15 @@ A simple command line to remove media from plex +## Description + +This tool will query a Tautulli server to get the path of all files for a media that was not not been watched for a given period. +The list will then be written to a file in case the user want to double check before deleting all the listed files. + +This tool supports: + - selection of period a media is not beeing watched before deleting it. + - whitelist of files to prevent the deletion of a media even if the not watched period is exeeded. + ## Getting Started ### Dependencies diff --git a/config.exemple.ini b/config.exemple.ini index 3d8eae6..32e6beb 100644 --- a/config.exemple.ini +++ b/config.exemple.ini @@ -15,6 +15,3 @@ files_to_ignore = [ "/share/data/Plex/Films/Nuit D'Ivresse -1986.mkv" ] -[HOST] -; Change le chemin -replace_path = ["/share/CACHEDEV1_DATA/Plex/", "home/antoine-a/plex"] diff --git a/plexwasher.py b/plexwasher.py index da6857b..ed63055 100755 --- a/plexwasher.py +++ b/plexwasher.py @@ -24,8 +24,6 @@ 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): @@ -153,7 +151,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.replace(SOURCE_PATH, DEST_PATH)}\n") + f.write(f"{path}\n") # Delete all files and empty parent folder listed in an input file def delete_files(inputFile): @@ -216,10 +214,6 @@ 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"]) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..e88090c --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +python_dateutil==2.8.2 +Requests==2.32.3