aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-hub
diff options
context:
space:
mode:
authorChristophe Besson <cbesson@gmail.com>2026-08-29 16:42:18 +0200
committerChristophe Besson <cbesson@gmail.com>2026-08-29 17:57:01 +0200
commit32318a64b12c83429c156a36c228769492e41d4e (patch)
tree87305a6977fabafa2f733044c4c0d776295626f3 /packages/meshbay-hub
parent78eef92bfa3513a81ac64d4377f8300c533aaa6c (diff)
downloadmeshbay-32318a64b12c83429c156a36c228769492e41d4e.tar.gz
fix: on restart, serve a video's cached TMDB match instead of re-searching
Root of the 2026-08-29 demo35 storms. `_do_media_meta_request` could not tell "this is a movie" from "this video isn't enriched yet" — both have season/episode None — so during a slow initial scan with a browser on the Videos tab, every show episode requested was run through the *movie* search path with its raw filename as the query (`search/movie?query=Show S01E01 1080p WEB DL ...`), hundreds per second, until TMDB rate-limited and posters stopped loading. Worse, an un-enriched show episode's own valid cached "tv" match was treated as stale (its provisional kind was "movie"), so a file already resolved got re-queried anyway. - While a video is un-enriched (no display_title — enrich.py always sets one), never run a TMDB *search*. Serve the cached match if the content hash has one, honouring the cached kind ("tv"/"movie") rather than the provisional split; otherwise answer confidence 0. - Once enriched, the strict `cached_media_type == media_type` check is unchanged: an enrichment fix that reclassifies a folder movie->tv still drops the stale match and re-resolves. - video-app.js: `useMediaMeta` gains an `enrichSig` dependency (`entry.display_title`) so the client refetches once the enriched fields arrive on an index delta — the fileId is a content hash and never changes, so nothing else would retrigger it. Not caused by the V8-V13 work; it raised the per-file call count so the pre-existing race became a visible storm. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018BMLQjqFGCize2KtNBT79v
Diffstat (limited to 'packages/meshbay-hub')
-rw-r--r--packages/meshbay-hub/src/meshbay_hub/static/video-app.js16
1 files changed, 12 insertions, 4 deletions
diff --git a/packages/meshbay-hub/src/meshbay_hub/static/video-app.js b/packages/meshbay-hub/src/meshbay_hub/static/video-app.js
index 6d13e27..50fbcf6 100644
--- a/packages/meshbay-hub/src/meshbay_hub/static/video-app.js
+++ b/packages/meshbay-hub/src/meshbay_hub/static/video-app.js
@@ -213,7 +213,13 @@ function bumpThumbGeneration() {
for (const fn of _thumbRetryListeners) fn();
}
-function useMediaMeta(transportRef, fileId, active) {
+// `enrichSig` — a value that changes when the entry's index-time
+// enrichment lands (display_title fills in). The node answers confidence 0
+// for a not-yet-enriched video (it can't tell it apart from a movie and
+// would otherwise storm TMDB with its raw filename), so the client must
+// refetch once the enriched fields arrive on an index delta — the fileId
+// (a content hash) never changes, so nothing else would trigger it.
+function useMediaMeta(transportRef, fileId, active, enrichSig) {
const [meta, setMeta] = useState(null);
const [refetchToken, setRefetchToken] = useState(0);
@@ -238,7 +244,7 @@ function useMediaMeta(transportRef, fileId, active) {
} catch { if (!cancelled) setMeta({ confidence: 0 }); }
})();
return () => { cancelled = true; };
- }, [fileId, active, refetchToken]);
+ }, [fileId, active, refetchToken, enrichSig]);
return meta;
}
@@ -280,7 +286,7 @@ function useSeasonMeta(transportRef, tmdbId, season, active) {
function PosterCard({ title, subtitle, repEntry, transportRef, gekRef, onOpen, groupKey, onMetaResolved }) {
const tRef = repEntry._tRef || transportRef;
const gRef = repEntry._gRef || gekRef;
- const meta = useMediaMeta(tRef, repEntry.id, true);
+ const meta = useMediaMeta(tRef, repEntry.id, true, repEntry.display_title || '');
const confident = Boolean(meta && meta.confidence && meta.tmdb_id);
const metaReady = meta !== null;
@@ -708,7 +714,9 @@ function PosterGrid({ movies, shows, transportRef, gekRef, onPreview, tmdbEnable
const openDetail = (title, repEntry, show, files) => setDetail({ title, repEntry, show, files });
const detailTRef = detail && detail.repEntry._tRef ? detail.repEntry._tRef : transportRef;
const detailGRef = detail && detail.repEntry._gRef ? detail.repEntry._gRef : gekRef;
- const detailMeta = useMediaMeta(detailTRef, detail ? detail.repEntry.id : null, !!detail);
+ const detailMeta = useMediaMeta(
+ detailTRef, detail ? detail.repEntry.id : null, !!detail,
+ detail ? (detail.repEntry.display_title || '') : '');
return html`
<div class="video-grid">