diff options
| author | Christophe Besson <cbesson@gmail.com> | 2026-08-29 14:58:30 +0200 |
|---|---|---|
| committer | Christophe Besson <cbesson@gmail.com> | 2026-08-29 14:58:58 +0200 |
| commit | 71b7a310ce938f072fe20f27eeeadd40685f1ad1 (patch) | |
| tree | 75a7d93d58fda0e742dd9b1c94538b532c34464a /packages/meshbay-node/tests/test_media_cache.py | |
| parent | b7733e812fadd6007976d262bd1d793572a36ba7 (diff) | |
| download | meshbay-71b7a310ce938f072fe20f27eeeadd40685f1ad1.tar.gz | |
fix(node): correct TMDB movie matching, per-file overrides, rematch
A batch of wrong poster-grid matches found live on a real library
(2026-08-29): a two-volume film's second part matched the first; a
numbered sequel matched a same-year making-of documentary; several
entries of one franchise matched a single early entry whose localized
TMDB title is the franchise name; one matched nothing. One mechanism:
_tmdb_search returned the first candidate query whose title-similarity
ratio merely cleared 0.6, before alternative_title / the Roman-numeral
variant was ever tried.
Matching:
- title_parse: fold guessit's volume/part number back into display_title
so the parts of a multi-part film stay distinct in the query, the card
and the override.
- _tmdb_search: keep a strong PASS 1 fast path (ratio >= 0.85, one
request), otherwise score every candidate query and pick the best. A
year-exact rescue lifts a sub-0.6 top hit to the confidence floor only
when TMDB's own year-filtered result lands exactly on the filename's
year. No local re-ranking of any single result list; no tmdb.py change.
Fix match / rematch:
- _admin_exec_tmdb_override: a movie override touches its own file only
(guessit gives a whole franchise one display_title); a show override
still fans out. Corrected files are marked in media_cache.tmdb_override.
- media_cache: tmdb_override table; clear_file_tmdb / clear_tmdb_matches
drop auto-resolved matches while sparing manual corrections.
- ops.rematch_video + `meshbay-node video rematch` (loopback endpoint +
CLI verb): re-resolve a group's video matches after a matcher fix.
file_tmdb is keyed by content hash and otherwise only pruned on
deletion, so nothing dislodged a cached match before.
- a rename now drops the stale auto match too (daemon
_reenrich_renamed_video_entries).
UI:
- VideoDetailModal shows the source filename and resolved TMDB id; an
unmatched poster gets a badge (3 new video.* i18n keys x 10 locales).
So a wrong match can actually be identified before hitting Fix match.
docs/mediacenter.md 10.1 records this and the V8-V13 follow-up backlog
(show-branch ladder, year-aware _best_match, wider sequel_variants, the
0.6-0.85 extra calls, movie grid merge, per-card rematch).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018BMLQjqFGCize2KtNBT79v
Diffstat (limited to 'packages/meshbay-node/tests/test_media_cache.py')
| -rw-r--r-- | packages/meshbay-node/tests/test_media_cache.py | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/packages/meshbay-node/tests/test_media_cache.py b/packages/meshbay-node/tests/test_media_cache.py index e70ef43..4e65b24 100644 --- a/packages/meshbay-node/tests/test_media_cache.py +++ b/packages/meshbay-node/tests/test_media_cache.py @@ -71,6 +71,55 @@ async def test_prune_file_removes_thumb_and_mapping_but_not_shared_meta(cache): assert await cache.get_tmdb_meta("555", "tv") == {"name": "A Show"} +# ── auto-resolved matches vs manual "Fix match" corrections ───────────────── + +@pytest.mark.asyncio +async def test_clear_tmdb_matches_drops_auto_matches_but_keeps_overrides(cache): + await cache.set_file_tmdb("auto1", "10", "movie") + await cache.set_file_tmdb("auto2", "20", "movie") + await cache.set_file_tmdb("fixed", "30", "movie") + await cache.mark_tmdb_override("fixed") + + removed = await cache.clear_tmdb_matches(["auto1", "auto2", "fixed", "never-seen"]) + + assert removed == 2 + assert await cache.get_file_tmdb("auto1") is None + assert await cache.get_file_tmdb("auto2") is None + assert await cache.get_file_tmdb("fixed") == ("30", "movie"), ( + "a manual Fix match correction must survive ops.rematch_video") + + +@pytest.mark.asyncio +async def test_clear_tmdb_matches_empty_list_is_a_noop(cache): + assert await cache.clear_tmdb_matches([]) == 0 + + +@pytest.mark.asyncio +async def test_clear_file_tmdb_drops_one_auto_match_but_keeps_an_override(cache): + await cache.set_file_tmdb("renamed", "10", "movie") + await cache.clear_file_tmdb("renamed") + assert await cache.get_file_tmdb("renamed") is None + + await cache.set_file_tmdb("renamed-fixed", "11", "movie") + await cache.mark_tmdb_override("renamed-fixed") + await cache.clear_file_tmdb("renamed-fixed") + assert await cache.get_file_tmdb("renamed-fixed") == ("11", "movie") + + +@pytest.mark.asyncio +async def test_prune_file_also_clears_the_override_marker(cache): + await cache.set_file_tmdb("gone", "10", "movie") + await cache.mark_tmdb_override("gone") + + await cache.prune_file("gone") + + # the marker must not linger after the file leaves the index and then + # shield a later match on the same id from ops.rematch_video + assert await cache.get_file_tmdb("gone") is None + await cache.set_file_tmdb("gone", "99", "movie") + assert await cache.clear_tmdb_matches(["gone"]) == 1 + + # ── Music app (docs/musicbay.md §6) — file_mbid/mbid_meta ──────────────────── @pytest.mark.asyncio |