tracker
All repositories: gitoria
5.1 KB
// tools/tmdb-check.hl — tracker#36 (mission 038): every migrated title's title + year against its TMDB entry (lib/tmdbcheck.hl —// the rule and the verdicts ok / ambiguous / clear are there). READ-ONLY: changes NOTHING in the data (no put/update/persist; but// hl:mpackdb rewrites a table's files when it opens one, so ONLY on a COPY or a stopped app, hybriel#21/#40).// TMDB_READ_TOKEN=<token from your environment, never printed> TRACKER_STORAGE=/abs/copy/storage/mpackdb \// ./bin/hybriel tools/tmdb-check.hl [--from N] [--limit N] [--all]// TRACKER_STORAGE=/abs/copy/storage/mpackdb ./bin/hybriel tools/tmdb-check.hl --stored (no token, no request)// Default prints only the mismatches, `clear …` and `ambiguous …` lines (--all: the `ok …` ones too), then the totals. One request// per title, 260 ms apart (TMDB: 40 / 10 s); a passing failure (dropped connection / TLS error / timeout, 429, 5xx) never ends the run:// it is asked again at the end, once, and a title that still fails is a `failed …` line with the reason. --from N skips the first N// titles (the order of the `tmdb check: N migrated titles` count, the same every run) so an aborted run can resume: --from 6500.// --stored: no TMDB request — the TMDB names the app already stored (details/sync) against the migrated titles: a title-only preview.import { env, args, exit } from 'hl:proc'import { now, sleep } from 'hl:time'import { syncEnabled, msPerRequest } from '../lib/tmdb.hl'import { allShows, showById } from '../lib/shows.hl'import { tcWanted, tcCheckTitle, tcStoredLine } from '../lib/tmdbcheck.hl'static runCheck36 = () => {ck36Storage = env('TRACKER_STORAGE')if (ck36Storage == null || !ck36Storage.startsWith('/')) { console.log('REFUSED: set TRACKER_STORAGE, absolute (a copy, or the app stopped)') return 2 }ck36Args = args()ck36Stored = ck36Args.includes('--stored')ck36All = ck36Args.includes('--all')let ck36Limit = -1let ck36From = 0let ck36K = 0while (ck36K < ck36Args.length) {if (ck36Args[ck36K] == '--limit' && ck36K + 1 < ck36Args.length) { ck36Limit = toNumber(ck36Args[ck36K + 1]) }if (ck36Args[ck36K] == '--from' && ck36K + 1 < ck36Args.length) { ck36From = toNumber(ck36Args[ck36K + 1]) }ck36K = ck36K + 1}if (!ck36Stored && !syncEnabled) { console.log('REFUSED: TMDB_READ_TOKEN is not set (or run with --stored: no request)') return 2 }ck36Start = now()ck36Ids = []for (ck36S of allShows()) { if (tcWanted(ck36S)) { ck36Ids.push(ck36S.id) } }console.log('tmdb check: ' + ck36Ids.length + ' migrated titles with a TMDB id' + (ck36Stored ? ' (--stored: no request)' : ''))ck36N = { asked = 0 ok = 0 ambiguous = 0 clear = 0 errors = 0 failed = 0 retried = 0 stored = 0 }if (ck36Stored) {for (ck36S of allShows()) {if (tcWanted(ck36S)) {let ck36L = tcStoredLine(ck36S)if (ck36L != null) { ck36N.stored = ck36N.stored + 1 console.log('stored-title ' + ck36L) }}}console.log('tmdb check (--stored) done: titles=' + ck36Ids.length + ' storedNameDiffers=' + ck36N.stored + ' seconds=' + ((now() - ck36Start) / 1000))return 0}let ck36Queue = []let ck36Pos = 0for (ck36Id of ck36Ids) {if (ck36Pos >= ck36From && (ck36Limit < 0 || ck36Queue.length < ck36Limit)) { ck36Queue.push(ck36Id) }ck36Pos = ck36Pos + 1}if (ck36From > 0) { console.log('tmdb check: --from ' + ck36From + ' → ' + ck36Queue.length + ' titles to ask') }// round 1 = every title, round 2 = the passing failures of round 1 (once)let ck36Round = 1while (ck36Round <= 2 && ck36Queue.length > 0) {let ck36Again = []for (ck36Id of ck36Queue) {let ck36R = tcCheckTitle(showById(ck36Id))if (ck36Round == 1) { ck36N.asked = ck36N.asked + 1 } else { ck36N.retried = ck36N.retried + 1 }if (ck36R.retry && ck36Round == 1) { ck36Again.push(ck36Id) }else if (ck36R.verdict == 'ok') { ck36N.ok = ck36N.ok + 1 if (ck36All) { console.log('ok ' + ck36R.line) } }else if (ck36R.verdict == 'clear') { ck36N.clear = ck36N.clear + 1 console.log('clear ' + ck36R.line) }else if (ck36R.verdict == 'ambiguous') { ck36N.ambiguous = ck36N.ambiguous + 1 console.log('ambiguous ' + ck36R.line) }else if (ck36R.retry) { ck36N.failed = ck36N.failed + 1 console.log('failed ' + ck36R.line) }else { ck36N.errors = ck36N.errors + 1 console.log('error ' + ck36R.line) }if (ck36Round == 1 && ck36N.asked % 500 == 0) { console.log('tmdb check: ' + ck36N.asked + '/' + ck36Queue.length + ' asked, clear=' + ck36N.clear + ' ambiguous=' + ck36N.ambiguous) }sleep(msPerRequest / 1000)}ck36Queue = ck36Againck36Round = ck36Round + 1}console.log('tmdb check done: asked=' + ck36N.asked + ' ok=' + ck36N.ok + ' ambiguous=' + ck36N.ambiguous + ' clear=' + ck36N.clear + ' errors=' + ck36N.errors + ' failed=' + ck36N.failed + ' retried=' + ck36N.retried + ' seconds=' + ((now() - ck36Start) / 1000))return 0}exit(runCheck36())// a dropped connection / TLS handshake error / timeout is an Error event (lib/tmdb.hl tmdbGet): absorbed here, the fetch yields null// and the title is asked again at the end (tracker#36, mission 039)on Error(e) { console.log(' error absorbed: ' + e.message) }
Branches
Latest commits
- 8b3cbddaTracker: status, TR7 fix livemre
- ec30162aTracker: TR7 fix livemre
- 54cbec80compose: ignore SIGPIPE (TR7 crash loop, exit 141)mre
- 3e164b63Tracker: status after CL1mre
- 9d686bb3Tracker: CL1 reviewedmre
- b8bba562CL1: crash loop report (SIGPIPE confirmed, trap wrapper option)mre
- 298785f2Tracker: CL1 startedmre
- 36b22710Tracker: port slot, CL1 briefmre
- a401190fTracker: GO for the crash loopmre
- e195d372Tracker: token pathsmre
- 7f541d11Tracker conductor: CONDUCTOR.md, short STATUS.md, old status + decisions archive to archive/2026-10-31mre
- 8dd423f7README: login.js stays by caramboleyo's explicit rulemre
- d8df1493tracker: standby service on port 45018 and a gap-free hand-over in deploy.sh step 4mre
- 36dd1686ident#31: the selector's sign-in returns to the page the user started on (return attribute = the login callback with next), gate checkmre
- ff9b838etracker: the Ended status pill uses the same red as layouts (pill danger); gate updatedmre
- 40d9719eTP2: LOG line and report for the tracker pillsmre
- ab3f2ba5tracker: status, genres, TMDB/IMDb/TVDB/TVmaze links and list kinds use the theme's pill; dense season list with the season check centred on its title line; gates for bothmre
- 521061d6tracker header on phones: signed in, the brand fits whole at 360 and 390 px (tighter gaps and side paddings, slightly smaller brand, narrow screens and signed in only); mobile gate checks itmre
- 18114a53tracker: franchises gate waits for the signed-out selector instead of the removed Log in buttonmre
- 08561d73ident selector back in the header (creator 2026-10-24): selector top right signed in and out on phone and desktop, no second Log in button, new gate checks (WIP: gates not re-run after the last edits)mre