A simple Python utility to automatically delete empty collections and playlists from your Plex server. It can be run locally or inside a Docker container at user-defined intervals.
-
Clone the repository:
git clone https://github.com/Prince25/plex-cleaner cd plex-cleaner -
Install dependencies:
pip install -r requirements.txt
-
Pull the image:
docker pull ghcr.io/prince25/plex-cleaner:main
-
Run the container (mount a folder to edit the config file):
docker run -v ./plex-cleaner:/plex-cleaner/config ghcr.io/prince25/plex-cleaner:main
-
Create a
docker-compose.ymlfile:version: "3" services: plex-cleaner: image: ghcr.io/prince25/plex-cleaner:main container_name: plex-cleaner restart: unless-stopped depends_on: - plex volumes: - ./plex-cleaner:/plex-cleaner/config
-
Run with Docker Compose:
docker-compose up -d
You need to create a config.yaml file in the /config directory with your Plex server details and preferences. For convenience, you can edit the example config.yaml in the project root and place it in the /config directory.
Use this template:
PLEX_BASEURL: "http://your-plex-server:32400"
PLEX_TOKEN: "your-plex-token"
LIBRARIES:
movies: ["Movies", "4K Movies"]
shows: ["TV Shows"]
DELETE_COLLECTIONS: true
DELETE_PLAYLISTS: true
INTERVAL_HOURS: 24The application will wait until this file is created and properly configured before proceeding.
Follow the official guide to retrieve your X-Plex-Token: https://support.plex.tv/articles/204059436-finding-an-authentication-token-x-plex-token/
python main.py --oncepython main.py- The container starts and creates the
configdirectory if it doesn't exist - You need to create and place the
config.yamlfile in the mounted config directory (you can copy and edit the example file from the project root) - If you use the default Plex token, the script will pause and wait for your edit
- The script checks every 30 seconds for the config file or for changes when a default token is found
- Changes to interval hours or other settings are picked up automatically between runs
The container will automatically clean up empty collections and playlists based on your configuration.
This project is licensed under the MIT License - see the LICENSE file for details.