gitoria

tracker

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commitd25bd14ad25bd14amission 044: sliced merge prepare + sliced collections prepare; jobs-dump old/new check + bulk fixturemred25bd14a/tools/tmdb-check.hl

5.1 KB

  1. // tools/tmdb-check.hl — tracker#36 (mission 038): every migrated title's title + year against its TMDB entry (lib/tmdbcheck.hl —
  2. // the rule and the verdicts ok / ambiguous / clear are there). READ-ONLY: changes NOTHING in the data (no put/update/persist; but
  3. // hl:mpackdb rewrites a table's files when it opens one, so ONLY on a COPY or a stopped app, hybriel#21/#40).
  4. // TMDB_READ_TOKEN=<token from your environment, never printed> TRACKER_STORAGE=/abs/copy/storage/mpackdb \
  5. // ./bin/hybriel tools/tmdb-check.hl [--from N] [--limit N] [--all]
  6. // TRACKER_STORAGE=/abs/copy/storage/mpackdb ./bin/hybriel tools/tmdb-check.hl --stored (no token, no request)
  7. // Default prints only the mismatches, `clear …` and `ambiguous …` lines (--all: the `ok …` ones too), then the totals. One request
  8. // per title, 260 ms apart (TMDB: 40 / 10 s); a passing failure (dropped connection / TLS error / timeout, 429, 5xx) never ends the run:
  9. // 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
  10. // titles (the order of the `tmdb check: N migrated titles` count, the same every run) so an aborted run can resume: --from 6500.
  11. // --stored: no TMDB request — the TMDB names the app already stored (details/sync) against the migrated titles: a title-only preview.
  12. import { env, args, exit } from 'hl:proc'
  13. import { now, sleep } from 'hl:time'
  14. import { syncEnabled, msPerRequest } from '../lib/tmdb.hl'
  15. import { allShows, showById } from '../lib/shows.hl'
  16. import { tcWanted, tcCheckTitle, tcStoredLine } from '../lib/tmdbcheck.hl'
  17. static runCheck36 = () => {
  18. ck36Storage = env('TRACKER_STORAGE')
  19. if (ck36Storage == null || !ck36Storage.startsWith('/')) { console.log('REFUSED: set TRACKER_STORAGE, absolute (a copy, or the app stopped)') return 2 }
  20. ck36Args = args()
  21. ck36Stored = ck36Args.includes('--stored')
  22. ck36All = ck36Args.includes('--all')
  23. let ck36Limit = -1
  24. let ck36From = 0
  25. let ck36K = 0
  26. while (ck36K < ck36Args.length) {
  27. if (ck36Args[ck36K] == '--limit' && ck36K + 1 < ck36Args.length) { ck36Limit = toNumber(ck36Args[ck36K + 1]) }
  28. if (ck36Args[ck36K] == '--from' && ck36K + 1 < ck36Args.length) { ck36From = toNumber(ck36Args[ck36K + 1]) }
  29. ck36K = ck36K + 1
  30. }
  31. if (!ck36Stored && !syncEnabled) { console.log('REFUSED: TMDB_READ_TOKEN is not set (or run with --stored: no request)') return 2 }
  32. ck36Start = now()
  33. ck36Ids = []
  34. for (ck36S of allShows()) { if (tcWanted(ck36S)) { ck36Ids.push(ck36S.id) } }
  35. console.log('tmdb check: ' + ck36Ids.length + ' migrated titles with a TMDB id' + (ck36Stored ? ' (--stored: no request)' : ''))
  36. ck36N = { asked = 0 ok = 0 ambiguous = 0 clear = 0 errors = 0 failed = 0 retried = 0 stored = 0 }
  37. if (ck36Stored) {
  38. for (ck36S of allShows()) {
  39. if (tcWanted(ck36S)) {
  40. let ck36L = tcStoredLine(ck36S)
  41. if (ck36L != null) { ck36N.stored = ck36N.stored + 1 console.log('stored-title ' + ck36L) }
  42. }
  43. }
  44. console.log('tmdb check (--stored) done: titles=' + ck36Ids.length + ' storedNameDiffers=' + ck36N.stored + ' seconds=' + ((now() - ck36Start) / 1000))
  45. return 0
  46. }
  47. let ck36Queue = []
  48. let ck36Pos = 0
  49. for (ck36Id of ck36Ids) {
  50. if (ck36Pos >= ck36From && (ck36Limit < 0 || ck36Queue.length < ck36Limit)) { ck36Queue.push(ck36Id) }
  51. ck36Pos = ck36Pos + 1
  52. }
  53. if (ck36From > 0) { console.log('tmdb check: --from ' + ck36From + ' → ' + ck36Queue.length + ' titles to ask') }
  54. // round 1 = every title, round 2 = the passing failures of round 1 (once)
  55. let ck36Round = 1
  56. while (ck36Round <= 2 && ck36Queue.length > 0) {
  57. let ck36Again = []
  58. for (ck36Id of ck36Queue) {
  59. let ck36R = tcCheckTitle(showById(ck36Id))
  60. if (ck36Round == 1) { ck36N.asked = ck36N.asked + 1 } else { ck36N.retried = ck36N.retried + 1 }
  61. if (ck36R.retry && ck36Round == 1) { ck36Again.push(ck36Id) }
  62. else if (ck36R.verdict == 'ok') { ck36N.ok = ck36N.ok + 1 if (ck36All) { console.log('ok ' + ck36R.line) } }
  63. else if (ck36R.verdict == 'clear') { ck36N.clear = ck36N.clear + 1 console.log('clear ' + ck36R.line) }
  64. else if (ck36R.verdict == 'ambiguous') { ck36N.ambiguous = ck36N.ambiguous + 1 console.log('ambiguous ' + ck36R.line) }
  65. else if (ck36R.retry) { ck36N.failed = ck36N.failed + 1 console.log('failed ' + ck36R.line) }
  66. else { ck36N.errors = ck36N.errors + 1 console.log('error ' + ck36R.line) }
  67. if (ck36Round == 1 && ck36N.asked % 500 == 0) { console.log('tmdb check: ' + ck36N.asked + '/' + ck36Queue.length + ' asked, clear=' + ck36N.clear + ' ambiguous=' + ck36N.ambiguous) }
  68. sleep(msPerRequest / 1000)
  69. }
  70. ck36Queue = ck36Again
  71. ck36Round = ck36Round + 1
  72. }
  73. 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))
  74. return 0
  75. }
  76. exit(runCheck36())
  77. // a dropped connection / TLS handshake error / timeout is an Error event (lib/tmdb.hl tmdbGet): absorbed here, the fetch yields null
  78. // and the title is asked again at the end (tracker#36, mission 039)
  79. on Error(e) { console.log(' error absorbed: ' + e.message) }

Branches

Latest commits

  • d25bd14amission 044: sliced merge prepare + sliced collections prepare; jobs-dump old/new check + bulk fixturemre
  • 633ee210mission 044: sliced table scans (slices.hl, pk-range slices) for the adult/kind/status/art/credits/details-repair queuesmre
  • 6648ba44mission 042: real-browser E2E on ce6f2e0a re-vendor 69/0 at 390 + 1280mre
  • 3ed3a0efmission 042: gates old/new equal (browser #41 route-table regex accepts unescaped hl:web output), real-data TTFB, E2E blocked by lisbeth lockmre
  • d5b61e90LOG 042mre
  • 4acdbaccmission 042: memory comparison old vs ce6f2e0a (stopped: warm VmHWM higher), reportmre
  • d0f620d6mission 042: re-vendor Hybriel ce6f2e0a (plugins incl. mpackdb; bin runtime built from the same archive, git-ignored), compact=false keptmre
  • 5bd14e12mission 040: theme 76f99f6 gates + E2E green; 44 px fixes (skeleton row, type-word, genre-link/pill); README, reportmre
  • 77cfa45cmission 040: partial report (theme/modal/pagination re-copied, tilelist onPage, 44 px taps; gates new + E2E pending)mre
  • 4b14822fe2e-theme: menu marker by colourmre
  • 09780f4emission 040 WIP: theme, modal, pagination, tokens re-copied from layouts 76f99f6; tilelist uses onPage; tap sizes 44 px for tracker's own small buttons; tests/e2e-theme.mjsmre
  • fb80bb8chotfix: open the 5 show stores without compaction (compact = false) — compact-on-open left another handle on stale offsets, every read gave a bare Number (hybriel mpackdb refresh after a shrink); live down 2026-10-20 05:11mre
  • e00d3bf7paths: projects moved into /media/STORAGE/projects/WorldAPI/mre
  • a8c7f234tracker#36 (mission 039): tools/tmdb-check.hl survives a dropped connection (on Error, asked again, failed lines) and resumes with --from N; tests/tmdbcheck.mjs 6/6 against a fake TMDBmre
  • 9c230516mission brief w39mre
  • 3609121dmission 038 docs + report (quota stop): README/kinds.md for #43 #42 #36, STATUS, LOG; HEAD browser gate 374/8 in the in-app daily run block (hour-boundary suspected, rerun pending), other gates green; #36 real run needs TMDB_READ_TOKENmre
  • a5d06e79tracker#36 (mission 038): tools/tmdb-check.hl + lib/tmdbcheck.hl — every live migrated title's migrated title + year against its TMDB entry (one GET /movie|tv/<id>?append_to_response=alternative_titles, 260 ms apart, passing failures asked once more): ok / ambiguous (one of title, year disagrees) / clear (both, or 404); read-only; token only from TMDB_READ_TOKEN; --stored = a title-only preview from the TMDB names already stored (no request). Tested against a fake TMDB (.scratch/w38/t36): 7 titles, 3 ok, 2 ambiguous, 2 clear, data unchangedmre
  • 982554f3tracker#42 (mission 038): series pages — an unknown slug no longer scans every title (lib/shows.hl showBySlug: the slug map only; new titles are noted by refreshTitleCaches, which both title puts already reach): 10.7–15.7 s → 0.013 s on the real copy (the one-request-at-a-time server was blocked meanwhile); cast/crew rows take name + slug from a person-link cache (personLinkOf) instead of whole person records (SNL: 303 cast with 4,761 credits, ~49k allocations per render) — allocations per series page −5…−40 %; HTML of 20 pages identical to beforemre
  • 4586b6e3docker-compose: init: true (hybriel#156)mre
  • 085c2e5ftracker#43 (mission 038): TVmaze's type makes Variety / Talk Show / Game Show / Reality / News / Panel Show / Award Show / Sports titles Shows (TMDB calls Saturday Night Live UK Scripted) — the #43 part of parked w37-wip a79c8c1 only (no re-vendor, no cache volume): tvmazeType stored by the sync and the TVmaze status backfill (asks every series with a TVmaze id once), kindOfTitle/kindWithTvmaze, tools/tvmaze-types.hl, gate fixture Variety Gate Series; start waits 150 smre