add dockerfile

This commit is contained in:
Akiya 2025-06-08 21:20:23 +02:00
parent 480378b9f1
commit 1da63a16a1
5 changed files with 25 additions and 10 deletions

13
Dockerfile Normal file
View File

@ -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

View File

@ -2,6 +2,15 @@
A simple command line to remove media from plex 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 ## Getting Started
### Dependencies ### Dependencies

View File

@ -15,6 +15,3 @@ files_to_ignore = [
"/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,8 +24,6 @@ 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):
@ -153,7 +151,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.replace(SOURCE_PATH, DEST_PATH)}\n") f.write(f"{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):
@ -216,10 +214,6 @@ 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"])

2
requirements.txt Normal file
View File

@ -0,0 +1,2 @@
python_dateutil==2.8.2
Requests==2.32.3