{"id":16831827,"url":"https://github.com/antifuchs/sonarr-plex-cleaner","last_synced_at":"2025-03-22T04:30:39.028Z","repository":{"id":66465537,"uuid":"190162982","full_name":"antifuchs/sonarr-plex-cleaner","owner":"antifuchs","description":"Garbage-collect your \"broadcatching\" TV library by deleting seasons that Sonarr has fully downloaded and that are completely watched in Plex.","archived":false,"fork":false,"pushed_at":"2024-06-10T14:56:02.000Z","size":99,"stargazers_count":14,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-18T08:11:14.257Z","etag":null,"topics":["cli","plex-media-server","rust-lang","sonarr"],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/antifuchs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-06-04T08:42:14.000Z","updated_at":"2025-02-26T19:38:38.000Z","dependencies_parsed_at":null,"dependency_job_id":"5393164f-709c-4615-91c1-12419ebe1dff","html_url":"https://github.com/antifuchs/sonarr-plex-cleaner","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antifuchs%2Fsonarr-plex-cleaner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antifuchs%2Fsonarr-plex-cleaner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antifuchs%2Fsonarr-plex-cleaner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antifuchs%2Fsonarr-plex-cleaner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/antifuchs","download_url":"https://codeload.github.com/antifuchs/sonarr-plex-cleaner/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244907420,"owners_count":20529850,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","plex-media-server","rust-lang","sonarr"],"created_at":"2024-10-13T11:45:31.546Z","updated_at":"2025-03-22T04:30:38.629Z","avatar_url":"https://github.com/antifuchs.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sonarr-plex-cleaner: Garbage-collect your TV broadcatching library\n\nIf you use Sonarr, you might be pleased by how good it is at\ndownloading data. Unfortunately, it's not as good at cleaning up that\ndata you no longer need (somewhat because sonarr doesn't know when you\nno longer need that data!).\n\nThis tool exists to fill that gap: It queries both sonarr (the thing\ndownloading media) and plex (the thing keeping track of whether you\nwatched that media), and deletes everything that has been fully\ndownloaded and watched.\n\n## Installation\n\n1. Get a rust installation: https://rustup.rs/\n2. Install the CLI tool in this repo via cargo: `cargo install --git=https://github.com/antifuchs/sonarr-plex-cleaner.git`\n\n## Prerequisites\n\nYou need to have Sonarr and a media server (Plex or Jellyfin) running.\nFrom them, you'll need:\n\n* Your Sonarr API's base URL. This is usually the URL that you use to reach Sonarr, plus `/api`.\n* Your Sonarr API key. You can find it in `Settings -\u003e General`.\n\nIf you're running Plex,\n* Your Plex server's URL. Use the one that you use to reach the Plex Web server.\n* Your Plex API key. Find it via this article: https://support.plex.tv/articles/204059436-finding-an-authentication-token-x-plex-token/\n\nIf you're running emby or jellyfin (I have only tested with the latter),\n* Your jellyfin server's URL. Use the base URL that you use to reach the jellyfin server on.\n* A jellyfin API token. An admin can make one for you\n* The username whose watched states you want to consider.\n\n## Planning to use this tool\n\nBy default, this tool does *not* make any changes, unless you pass the\n`-f` / `--delete-files` command line parameter. Don't do that and your\ndata will be safe. In the default mode, the CLI will only output what\nseasons it would clean up.\n\nIf you wish to prevent the CLI from deleting a show you want to keep\naround, tag the show (you can do this in sonarr's \"Edit\" screen for\nthe show). You can use a tag named `retain` to indicate that the show\nis manually managed.\n\n## The configuration file\n\n`sonarr-plex-cleaner` reads all this data from a configuration file;\non Linux, it lives in `~/.config/sonarr-plex-cleaner.yaml`; on macOS,\nit lives in `~/Library/Preferences/sonarr-plex-cleaner.toml`. Create\nthe appropriate file for your platform, with contents like the\nfollowing:\n\n``` toml\n[tv]\nurl = \"https://sonarr.example.com/api/\"  # Your sonarr installation's API URL\napi_key = \"deadbeef5ec9e7\"               # sonarr API key\n\n# Either [plex] or [jellyfin] - delete the one that doesn't apply to you:\n[plex]\nurl = \"http://plex.example.com:32400/\"   # Your plex API URL\napi_key = \"deadbeef5ec9e7\"               # Plex API key\n[jellyfin]\nurl = \"http://jellyfin.example.com:8096/\" # your jellyfin API URL\napi_key = \"aaaaaaaaaaaaaaaaaaaa\"          # Jellyfin API key\nuser = \"your_username\"                    # User to consider for watched states\n\n[retention]\n# Tag that marks a show as manually managed\nretain_tag = \"retain\"\n\n# Wait 14 days after last air date before deleting even a completely watched show:\nretain_duration = \"14d\"\n```\n\n## Usage\n\nYou've collected the four items from prerequisites, made the\nconfiguration file and have tagged the shows that you wish to\nkeep. Great, let's see what it would delete:\n\n``` sh\nsonarr-plex-cleaner tv\n```\n\nwhich will output something like:\n\n```\nINFO [sonarr_plex_cleaner] delete 10 files: Piracy On The High Seas S03: 9.64 GiB\nINFO [sonarr_plex_cleaner] delete 7 files: Piracy On The High Seas S04: 9.05 GiB\n```\n\n### Actually deleting files\n\nRun:\n\n``` sh\nsonarr-plex-cleaner tv --delete-files\n```\n\nto unmonitor each of the seasons above in Sonarr, and delete the files in that season.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantifuchs%2Fsonarr-plex-cleaner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fantifuchs%2Fsonarr-plex-cleaner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantifuchs%2Fsonarr-plex-cleaner/lists"}