Skip to content

fix(filebot): reject wrong-year movie matches and email unprocessed downloads - #217

Merged
twistedmelonman merged 2 commits into
mainfrom
claude/fix-filebot-year-guard-216
Oct 16, 2026
Merged

twistedmelonman merged 2 commits into
mainfrom
claude/fix-filebot-year-guard-216

Conversation

@twistedmelonman

Copy link
Copy Markdown
Member

Summary

Fixes #216: non-strict TheMovieDB filed the 1989 NBC miniseries Around the World in 80 Days as the 1988 animated film after strict auto-detection had refused it.

Year guard. Before TheMovieDB or OMDb move anything, process_with_database dry-runs the match. filebot_year_mismatch compares each destination's (YYYY) with the years in the source filename (or its folder name). The preview runs the same check. On a mismatch:

  • nothing moves, and the database chain stops (filebot_chain_should_stop)
  • a YEAR MISMATCH: line makes classify_failure return no-match, ahead of any conflict line, so a wrong-title duplicate never reaches media-compare
  • a dry run with no match lines also moves nothing (fail closed)

Exact match only. A one-year tolerance would not have caught 1989 → 1988, so a correct match whose TMDB year is one off the release name now goes to triage with an email. A filename with no year is not checked, and TV databases are not guarded.

Email. A download triaged as no-match or failed sends one email to alerts.email from config.yml, through alert-lib.sh. It names the torrent, the triage folder and the reason. already-in-plex sends nothing. The email goes out after the triage move, so watcher retries do not resend it. CR/LF in the torrent name are stripped from the subject. transmission-filebot-setup.sh writes alerts.email from MONITORING_EMAIL.

Deployment

Live transmission-done is a symlink into the main checkout, so the code goes live when main is pulled there. No email is sent until the live config.yml has an alerts.email key. It is not there today. Add it by hand or re-run setup.

Testing

  • 528 BATS tests pass locally (full suite; this repo has no CI test job)
  • The new tests were checked against the code with each fix removed: the guard, fail-closed and header-injection tests fail without them
  • shellcheck and shfmt are clean on both scripts

Review notes

The pre-push review warned that dry_run=$(run_filebot ...) could abort under errexit. The script runs set -uo pipefail without -e (line 25), and the real-run assignment next to it uses the same pattern, so no change was made.

Claude Code Bot added 2 commits October 16, 2026 11:13
…ownloads

Non-strict TheMovieDB matched "Around.The.World.In.80.Days.1989.Part1.avi"
to the 1988 animated film after strict auto-detection had refused it, and
moved the 1989 miniseries into Movies under the wrong title.

Year guard: before TheMovieDB or OMDb move anything, dry-run the match and
compare each destination's (YYYY) with the years in the source filename (or
its folder). The preview runs the same check. On a mismatch nothing moves,
the database chain stops, and a YEAR MISMATCH line classifies the download as
no-match, ahead of any conflict line, so a wrong-title duplicate never reaches
media-compare. Exact match only: a one-year tolerance would not have caught
1989 -> 1988. TV databases are not guarded.

Email: when a download is triaged as no-match or failed, send one email to
alerts.email (config.yml) through alert-lib.sh, naming the torrent, the
triage folder and the reason. already-in-plex sends nothing. The setup script
writes alerts.email from MONITORING_EMAIL in config.conf.

Closes #216
Review findings on the year guard and alert email:

- A TheMovieDB/OMDb dry run with no match lines (a TMDB error, say) let
  the real move run unchecked. Now nothing moves.
- The torrent name goes into the Subject header; CR/LF in it could add
  headers. Replace them with spaces.
- Two grep pipelines without a match failed under errexit; add || true.

Tests: an empty dry run moves nothing, header injection, and exactly one
email per triaged download. Three plumbing tests that used TheMovieDB with
the empty-output FileBot mock now use TheTVDB, which has no guard.

Advances #216
@twistedmelonman
twistedmelonman merged commit c712e7d into main Oct 16, 2026
2 checks passed
@twistedmelonman
twistedmelonman deleted the claude/fix-filebot-year-guard-216 branch October 16, 2026 18:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FileBot: non-strict TheMovieDB fallback misfiled a 1989 TV miniseries as a 1988 movie

1 participant