- Go 94.8%
- Shell 5.2%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
qBittorrent 5.2 introduced API keys sent as "Authorization: Bearer". They sidestep the login endpoint, the SID cookie and its Secure flag, and IP whitelisting, all of which caused trouble in 0.1.0 to 0.1.2. A new [qbittorrent] api_key setting uses them; username/password stay as the fallback for older versions and are ignored when api_key is set. 403 responses now explain what to check for the active mode. Release 0.1.3. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01J4uXuUgwH22xBMsf18x88y |
||
| .forgejo/workflows | ||
| cmd/filterr | ||
| internal | ||
| packaging | ||
| .gitignore | ||
| config.example.toml | ||
| go.mod | ||
| go.sum | ||
| LICENSE | ||
| README.md | ||
filterr
A small daemon that watches the Radarr and Sonarr download queues and removes torrents that are obviously not the film or episode they claim to be: executables, archives with no video inside, "install this codec" bait, implausibly small payloads.
It runs as a systemd --user service, talks only to the APIs (no filesystem
access to the download folder needed), logs every decision with its reasons,
and every automatic action can be undone.
How it works
Every interval (default 30 s) filterr:
- fetches the queue of each configured Radarr/Sonarr instance,
- looks up each torrent item in qBittorrent by info hash and reads its file list (as soon as metadata is known, usually before much has downloaded),
- runs the rules below,
- on a hit, deletes the queue item through the Radarr/Sonarr API with remove from client and blocklist set, so the torrent and its data are removed from qBittorrent, the release is blocklisted, and Radarr/Sonarr immediately search for a replacement,
- appends the action, the file list and the reasons to
~/.local/state/filterr/actions.jsonl.
Only torrents present in a Radarr/Sonarr queue are ever touched. Torrents whose metadata qBittorrent has not fetched yet are skipped until it has.
Rules
| Rule | Rejects when |
|---|---|
| blocked extension | any file has an extension in blocked_extensions (.exe, .scr, .zip, .arj, …) |
| suspicious name | any file's name matches a glob in suspicious_names (*password*, *codec*, …) |
| no video | no file with a video_extensions extension is at least min_video_size |
| archive only | archives present and no video (scene rar sets with a video next to them pass) |
| too small | total size is below min_movie_size (Radarr) or min_episode_size (Sonarr) |
All matching reasons are recorded, not just the first.
Install
Debian/Ubuntu, from the package registry on kode.naiv.no (amd64 and arm64):
sudo curl -fsSL https://kode.naiv.no/api/packages/olemd/debian/repository.key \
-o /etc/apt/keyrings/forgejo-olemd.asc
sudo tee /etc/apt/sources.list.d/filterr.sources > /dev/null <<'SOURCES'
Types: deb
URIs: https://kode.naiv.no/api/packages/olemd/debian/
Suites: trixie
Components: main
Signed-By: /etc/apt/keyrings/forgejo-olemd.asc
Architectures: amd64 arm64
SOURCES
sudo apt update && sudo apt install filterr
The package installs /usr/bin/filterr, the user unit
/usr/lib/systemd/user/filterr.service and an example config in
/usr/share/doc/filterr/examples/config.toml. Releases on
https://kode.naiv.no/olemd/filterr/releases carry the same .deb files as
attachments if you prefer dpkg -i.
Then, as the user that should run the service:
install -Dm600 /usr/share/doc/filterr/examples/config.toml ~/.config/filterr/config.toml
$EDITOR ~/.config/filterr/config.toml # URLs and API keys
filterr check # connectivity + one dry-run pass
systemctl --user enable --now filterr
loginctl enable-linger "$USER" # keep it running after logout
The config file must be mode 600; filterr refuses to start otherwise because it contains API keys.
Building from source instead: go build ./cmd/filterr gives a single static
binary; packaging/build-deb.sh builds the same .deb files the pipeline
publishes (needs dpkg-deb).
API keys: Radarr/Sonarr → Settings → General → Security → API Key.
qBittorrent 5.2 or newer: Tools → Options → Web UI → API keys, create one
and put it in api_key. Older qBittorrent: set username/password
instead (or whitelist the host filterr runs on and leave all empty).
Dry run first
dry_run defaults to true. In that mode filterr logs DRY RUN: would remove and blocklist … and records the decision in the action log, but changes
nothing. Watch it for a while:
journalctl --user -u filterr -f
filterr list
When the verdicts look right, set dry_run = false and
systemctl --user restart filterr.
Audit log and undo
filterr list # every action: id, time, instance, state, title, reasons
filterr list -all # …including each torrent's file list
filterr undo 20261109-153012 # remove the blocklist entry
filterr undo -search 20261109-153012 # …and ask Radarr/Sonarr to search again
Undo deletes the blocklist entry filterr created, so the same release can be grabbed again. The downloaded data itself was removed by Radarr/Sonarr and is not restored; a new grab re-downloads it. The undo is itself appended to the log, so the history stays complete.
The log is plain JSON lines, one record per line, append-only:
{"type":"reject","id":"20261109-153012","time":"…","instance":"radarr","kind":"radarr","title":"Some.Movie.2024","hash":"…","queue_id":42,"media_ids":[17],"total_size":2147483648,"files":["Some.Movie.2024/Some.Movie.mkv","Some.Movie.2024/Codec.Setup.exe"],"reasons":["blocked file type: codec.setup.exe"],"dry_run":false,"blocklist_id":913}
{"type":"undo","id":"20261109-160001","time":"…","undo_of":"20261109-153012","note":"removed blocklist entry 913; search triggered"}
Development
go test ./...
go vet ./...
shellcheck packaging/build-deb.sh
The rule engine (internal/rules) is a pure function and is where most
behaviour lives; internal/agent has an end-to-end test against fake
qBittorrent and Radarr servers.
CI and releases
.forgejo/workflows/ci.yml runs gofmt, vet, tests, shellcheck, unit
verification and a .deb build on every push and pull request.
To release:
- Add a new top entry to
packaging/changelogfor the version (the build refuses a release whose changelog does not start with it). - Commit, push, and create a release on Forgejo with tag
vX.Y.Z.
The release job then builds filterr_X.Y.Z_{amd64,arm64}.deb, uploads them
to the Debian registry (trixie/main) and attaches them to the release. It
needs the secret PACKAGE_TOKEN, already defined at user level on kode.naiv.no
(a token with write:package). Attaching the files to the release also needs
write:repository, either on that token or on a separate RELEASE_TOKEN;
without it the job warns and you attach them by hand:
fj release asset create vX.Y.Z filterr_X.Y.Z_amd64.deb.
License
MIT, see LICENSE.