Skip to content
Garbage-collect your "broadcatching" TV library by deleting seasons that Sonarr has fully downloaded and that are completely watched in Plex.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci
src
.gitignore
CONTRIBUTING.md
Cargo.toml
CoC.md
LICENSE.txt
README.md
bors.toml

README.md

sonarr-plex-cleaner: Garbage-collect your TV broadcatching library

If you use Sonarr, you might be pleased by how good it is at downloading data. Unfortunately, it's not as good at cleaning up that data you no longer need (somewhat because sonarr doesn't know when you no longer need that data!).

This tool exists to fill that gap: It queries both sonarr (the thing downloading media) and plex (the thing keeping track of whether you watched that media), and deletes everything that has been fully downloaded and watched.

Installation

  1. Get a rust installation: https://rustup.rs/
  2. Install the CLI tool in this repo via cargo: cargo install --git=https://github.com/antifuchs/sonarr-plex-cleaner.git

Prerequisites

You need to have Sonarr and Plex running. From them, you'll need:

Planning to use this tool

By default, this tool does not make any changes, unless you pass the -f / --delete-files command line parameter. Don't do that and your data will be safe. In the default mode, the CLI will only output what seasons it would clean up.

If you wish to prevent the CLI from deleting a show you want to keep around, tag the show (you can do this in sonarr's "Edit" screen for the show). By default, the tag name retain will prevent the show from being garbage-collectable.

Usage

You've collected the four items from prerequisites, and have tagged the shows that you wish to keep. Great, let's see what it would delete:

sonarr-plex-cleaner --sonarr=https://sonarr.example.com/api/ --sonarr-api-key=ffffffffffff --plex http://plex.example.com:32400/ --plex-api-key=fffffffffffff

which will output something like:

INFO [sonarr_plex_cleaner] delete 10 files: Piracy On The High Seas S03: 9.64 GiB
INFO [sonarr_plex_cleaner] delete 7 files: Piracy On The High Seas S04: 9.05 GiB

Actually deleting files

Run:

sonarr-plex-cleaner --sonarr=https://sonarr.example.com/api/ --sonarr-api-key=ffffffffffff --plex http://plex.example.com:32400/ --plex-api-key=fffffffffffff --delete-files

to unmonitor each of the seasons above in Plex, and delete the files in that season.

You can’t perform that action at this time.