Skip to content

fix(tmdb): reject zero-confidence auto-match candidates#1379

Merged
revam merged 1 commit into
ShokoAnime:masterfrom
Foowy:fix/tmdb-auto-match-confidence-floor
Jul 6, 2026
Merged

fix(tmdb): reject zero-confidence auto-match candidates#1379
revam merged 1 commit into
ShokoAnime:masterfrom
Foowy:fix/tmdb-auto-match-confidence-floor

Conversation

@Foowy

@Foowy Foowy commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Summary

  • AutoSearchForShowUsingTitle/AutoSearchMovieUsingTitle previously auto-linked the top-scored TMDB candidate even when it had zero title or date correlation to the AniDB entry (MatchRating.FirstAvailable) — it only reached scoring because TMDB's search returned it and it happened to carry the animation genre tag. This let unrelated content (e.g. adult titles genre-tagged as animation on TMDB) get auto-linked to legitimate anime (reported: "One Piece" matching unrelated adult content).
  • Added IsAcceptableAutoMatch to reject FirstAvailable before linking in both the show and movie auto-match paths, and applied the same floor to the transient-outage fallback (which previously guessed blindly when GetTvShowAsync/GetMovieAsync failed for every candidate).
  • This mirrors the existing convention in TmdbLinkingService's episode-level matching, which already treats FirstAvailable as "no match."
  • Does not affect adult-content handling — include_adult is still driven entirely by anime.IsRestricted from AniDB, so correctly-matched restricted anime are unaffected. The fix only requires that AniDB's own title or air-date data actually corroborate the TMDB candidate before auto-linking.

Test plan

  • Added IsAcceptableAutoMatch_RejectsOnlyFirstAvailable theory covering all MatchRating values
  • dotnet build Shoko.Server.sln — 0 errors
  • dotnet test Shoko.Tests/Shoko.Tests.csproj — full suite passes

… and manual search

`AutoSearchForShowUsingTitle`/`AutoSearchMovieUsingTitle` always auto-linked the
top-scored candidate even when it had no title or date correlation to the AniDB
entry at all (`MatchRating.FirstAvailable`) — it only reached scoring because
TMDB's search returned it and it happened to carry the `animation` genre tag.
This let unrelated content (e.g. adult titles genre-tagged as animation on TMDB)
get auto-linked to legitimate anime like "One Piece" purely by coincidence.

- Added `IsAcceptableAutoMatch` to reject `FirstAvailable` before linking in
  both the show and movie auto-match paths, and applied the same floor to the
  transient-outage fallback (which previously guessed blindly when
  `GetTvShowAsync`/`GetMovieAsync` failed for every candidate). This mirrors
  the existing convention in `TmdbLinkingService`'s episode-level matching,
  which already treats `FirstAvailable` as "no match."
- Manual TMDB search (used by the WebUI's link-selection panel) returned TMDB's
  raw search order, which ranks purely on title-text relevance with no genre
  awareness. Added a stable sort (by `animation` genre membership) to the paged
  results in `SearchMoviesRaw`/`SearchShowsRaw` — nothing is filtered out, a
  human still picks the result, this only reorders the page so genuine anime
  surfaces first.
- Extracted the repeated `"animation"` literal into an `AnimationGenre` constant.

This does not affect adult-content handling — `include_adult` is still driven
entirely by `anime.IsRestricted` from AniDB, so correctly-matched restricted
anime are unaffected in both paths. The fix only requires that AniDB's own
title or air-date data actually corroborate the TMDB candidate before
auto-linking, and reorders (without hiding) manual search results by genre.
@Foowy
Foowy force-pushed the fix/tmdb-auto-match-confidence-floor branch from e021114 to e307506 Compare July 6, 2026 15:47
@sonarqubecloud

sonarqubecloud Bot commented Jul 6, 2026

Copy link
Copy Markdown

@revam
revam merged commit 4ad5d34 into ShokoAnime:master Jul 6, 2026
4 checks passed
@Foowy
Foowy deleted the fix/tmdb-auto-match-confidence-floor branch July 13, 2026 03:36
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.

2 participants