aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-node/src/meshbay_node/transport
diff options
context:
space:
mode:
authorChristophe Besson <cbesson@gmail.com>2026-08-29 18:30:30 +0200
committerChristophe Besson <cbesson@gmail.com>2026-08-29 18:30:30 +0200
commit8de80b7e19738b716d9973c0b4ba3b42085f7359 (patch)
tree87305a6977fabafa2f733044c4c0d776295626f3 /packages/meshbay-node/src/meshbay_node/transport
parent78eef92bfa3513a81ac64d4377f8300c533aaa6c (diff)
parent32318a64b12c83429c156a36c228769492e41d4e (diff)
downloadmeshbay-8de80b7e19738b716d9973c0b4ba3b42085f7359.tar.gz
Merge branch 'fix/media-meta-unenriched-guard'
Diffstat (limited to 'packages/meshbay-node/src/meshbay_node/transport')
-rw-r--r--packages/meshbay-node/src/meshbay_node/transport/webrtc_server.py44
1 files changed, 33 insertions, 11 deletions
diff --git a/packages/meshbay-node/src/meshbay_node/transport/webrtc_server.py b/packages/meshbay-node/src/meshbay_node/transport/webrtc_server.py
index af6bf08..1bd7203 100644
--- a/packages/meshbay-node/src/meshbay_node/transport/webrtc_server.py
+++ b/packages/meshbay-node/src/meshbay_node/transport/webrtc_server.py
@@ -2915,6 +2915,17 @@ class WebRTCPeerSession:
"file_id": file_id, "confidence": 0})
return
+ # A video the indexer has seen but not yet *enriched* has no
+ # display_title (enrich.py always sets one) and season/episode still
+ # None — so the movie/show split reads "movie" and would hand its raw
+ # filename to TMDB's movie search. During a slow initial scan with a
+ # browser on the Videos tab that is a storm of
+ # `search/movie?query=<raw filename>` (found live 2026-08-29, an
+ # 8-minute scan). While un-enriched we never *search*: we serve a
+ # cached match if there is one (§ below), else confidence 0 and the
+ # client refetches once the index delta carries the enriched fields.
+ enriched = bool(entry.display_title)
+
is_show = entry.season is not None and entry.episode is not None
media_type = "tv" if is_show else "movie"
@@ -2923,21 +2934,32 @@ class WebRTCPeerSession:
tmdb_id = None
if cached is not None:
cached_tmdb_id, cached_media_type = cached
- # Trustworthy only if it still agrees with what this file
- # resolves to *now*. season/episode come from index-time
- # enrichment (enrich.py), which can reclassify a file between
- # movie and show on a later scan without this cache knowing —
- # it is keyed by the file's content hash alone, which a
- # reclassification never changes. Found live: an enrichment fix
- # to a Specials-folder bug reclassified hundreds of files from
- # "movie" to "tv", and every one kept answering with its
- # stale movie-era match forever, because this was trusted
- # before ever comparing media_type against the current one.
- if cached_media_type == media_type:
+ # Serve the cached match when its kind still agrees with the
+ # entry's current classification — OR when the entry is not
+ # enriched yet: its season/episode aren't populated, so the
+ # movie/show split above is not meaningful, and the cached kind
+ # (set when this file WAS enriched) is the reliable one. This is
+ # what keeps a restart from re-querying TMDB for everything
+ # already resolved: the storm was an un-enriched show episode
+ # looking like a "movie" and treating its own valid "tv" match
+ # as stale.
+ #
+ # Once enriched, the strict `cached_media_type == media_type`
+ # check still stands: an enrichment fix that reclassifies a
+ # folder movie->tv must drop the stale movie-era match and
+ # re-resolve (found live — a Specials-folder fix left hundreds
+ # of files answering with their wrong-kind match forever).
+ if cached_media_type == media_type or not enriched:
+ media_type = cached_media_type
+ is_show = media_type == "tv"
tmdb_id = cached_tmdb_id
meta = await media_cache.get_tmdb_meta(tmdb_id, media_type)
if meta is None:
+ if not enriched:
+ self._send({"type": MNP.MEDIA_META_RESP, "v": MNP_VERSION,
+ "file_id": file_id, "confidence": 0})
+ return
result, ratio = await self._tmdb_search(tmdb_client, entry, is_show)
if result is None or ratio < 0.6:
self._send({"type": MNP.MEDIA_META_RESP, "v": MNP_VERSION,