Auto-Managing Your Movie Library with Radarr and Plex

Running a home media server means one thing accumulates faster than anything else: disk space consumed by movies you've already watched and will never watch again. Radarr downloads them, Plex plays them, and then they just... sit there. Forever. Eating storage.

I got tired of manually reviewing the library and built Radarr Autodelete — a Python tool that runs on a schedule, checks what you've watched in Plex, and cleans up accordingly through Radarr's API.

The problem with manual cleanup

Most people deal with this by periodically going into Radarr, filtering by "unmonitored" or sorting by date added, and manually deleting things. It works, but it's tedious and you'll forget to do it. The automation angle also lets you set policies you'd never apply consistently by hand — like deleting anything not watched in 90 days, or removing everything not in English or Japanese.

How the deletion logic works

The script runs through three phases:

1. Watch status sync

It queries the Plex API for every movie in your library and checks whether it's been watched. If it has, it tells Radarr to unmonitor that title. This is the critical first step — Radarr won't delete monitored content, so unmonitoring is what enables cleanup.

2. Language filtering

Optionally, you can configure a list of accepted languages. Anything not matching gets unmonitored automatically — useful if you only want English and Japanese titles and don't want random foreign-language downloads eating space indefinitely.

3. Collection protection

This was the important edge case. Some movies I want to keep regardless of watch status — things in a "Keep Forever" Plex collection, for example. The script checks for a configured collection name and protects anything in it from deletion, even if it's unmonitored in Radarr.

# Core deletion logic
for movie in radarr.get_movies():
    if is_protected(movie, plex_collection):
        continue
    if plex.is_watched(movie["title"]) or not_in_language(movie):
        radarr.unmonitor(movie["id"])
        radarr.delete_files(movie["id"])

Dry-run mode

Before running the script for real, you can set DRY_RUN=true in your environment. In this mode it logs every action it would take without actually doing anything. I ran it in dry-run for a week before trusting it — highly recommended before you let it loose on your library.

Docker deployment

The tool ships as a Docker image, which makes scheduling straightforward. A simple docker-compose.yml with a cron-based restart policy handles the scheduling, and all configuration is done through environment variables — no config files to manage.

environment:
  - RADARR_URL=http://radarr:7878
  - RADARR_API_KEY=your_key
  - PLEX_URL=http://plex:32400
  - PLEX_TOKEN=your_token
  - KEEP_COLLECTION=Keep Forever
  - LANGUAGES=en,ja
  - DRY_RUN=false

After two months running this, my movie library storage stayed flat despite continuous new downloads. The script typically reclaims 20–40GB per week on my setup.


← Back to all posts  ·  View on GitHub ↗