tracker
All repositories: gitoria
2.9 KB
// tools/tvmaze-types.hl — tracker#43 (mission 037): TVmaze's TYPE for every series that has a TVmaze id but no stored type, and// which titles that moves from /series to /shows (Variety, Talk Show, Game Show, Reality, News, Panel Show, Award Show, Sports —// shows.hl kindOfTitle). The SAME step the app's TVmaze status backfill runs after the deploy (backfill.hl tvmazeStatusTitle:// GET <TVMAZE_BASE_URL>/shows/<id>, one request per series, 550 ms apart — TVmaze allows 20 / 10 s; no TMDB token needed).// ONLY on a COPY or with the app stopped (opening a table rewrites its files; hl:mpackdb: one process per storage):// TRACKER_STORAGE=/abs/path/storage/mpackdb ./bin/hybriel tools/tvmaze-types.hl [--limit N]// Prints one line per title whose kind changed ("moved: …") and the totals: series asked, types stored, moved to shows, moved to// series, the TVmaze types seen, errors. Idempotent: a second run asks nothing (every series has its type, '' = TVmaze gave none).import { env, args, exit } from 'hl:proc'import { now, sleep } from 'hl:time'import { pauseMsAfter } from '../lib/tmdb.hl'import { tvmazeStatusQueue, tvmazeStatusTitle } from '../lib/backfill.hl'import { showById, titleKind, titlePath } from '../lib/shows.hl'import { persistSync } from '../lib/sync.hl'storageDir = env('TRACKER_STORAGE')if (storageDir == null || !storageDir.startsWith('/')) { console.log('REFUSED: set TRACKER_STORAGE, absolute (app stopped, or a copy)') exit(2) }argv = args()let limit = -1let i = 0while (i < argv.length) {if (argv[i] == '--limit' && i + 1 < argv.length) { limit = toNumber(argv[i + 1]) }i = i + 1}started = now()queue = tvmazeStatusQueue()console.log('tvmaze types: ' + queue.length + ' series with a TVmaze id and no TVmaze type or status')types = {}let asked = 0let stored = 0let toShows = 0let toSeries = 0let errors = 0for (id of queue) {if (limit < 0 || asked < limit) {let r = tvmazeStatusTitle(id)asked = asked + 1if (r.type != null) {stored = stored + 1types[r.type] = types[r.type] == null ? 1 : types[r.type] + 1}if (r.error != '') { errors = errors + 1 console.log('error: ' + r.error) }if (r.moved) {let s = showById(id)let k = titleKind(s)if (k == 'show') { toShows = toShows + 1 } else { toSeries = toSeries + 1 }console.log('moved: ' + s.title + ' (' + s.year + ') TVmaze ' + s.tvmzId + ' type ' + r.type + ', TMDB type ' + s.tmdbType + ' → ' + titlePath(s))}if (asked % 25 == 0) { persistSync() }if (asked % 100 == 0) { console.log('tvmaze types: ' + asked + '/' + queue.length + ' asked, ' + toShows + ' moved to shows') }sleep(pauseMsAfter(r) / 1000)}}persistSync()let seen = ''for (t of types.keys()) { seen = seen + (seen == '' ? '' : ', ') + t + ' ' + types[t] }console.log('tvmaze types done: asked=' + asked + ' typesStored=' + stored + ' movedToShows=' + toShows + ' movedToSeries=' + toSeries + ' errors=' + errors + ' seconds=' + ((now() - started) / 1000))console.log('tvmaze types seen: ' + seen)
Branches
Latest commits
- 2d4be66fre-vendor Hybriel 5df4eb7e (GC: HL_GC_TABLE_LOAD knob, mission 406)mre
- 99e7c8b9tests: realdata-m035-radii, repro-t38, realdata-060-backfill ports from env (REAL_PORT, REAL_CHROME, REPRO_CHROME), defaults unchangedmre
- 4625aa22re-vendor Hybriel 6f8a0689 (int 6–11: streaming cursors, #203 index heal + close() fix, fd403 listDir/cursor fds, hl:time browser side, hl:web batches 5+6)mre
- a6dfd6ecdeploy: person-lookup gate (tracker#46)mre
- 33ad4bd5Merge commit 'f57f64f'mre
- 7d38cec4docker-compose: nofile 65536 (default soft 1024 refused boot: errno 24 in fs.listDir, Hybriel 528bc89f)mre
- f57f64f0mission 046: report, LOGmre
- 5965963adeploy: backup copies index files first and *.mpack data last (hot-copy skew, hybriel #203)mre
- efe1b485mission 046: re-vendor Hybriel master 60b2817b (integration 8, #203): plugins mpackdb + web (bin/ git-ignored: hybriel, libhlrt.a, hlc.o, hlrt/ from native/zig-out)mre
- 53099ffbmission 046: person page reads a slim per-title credit row cache (no whole-record fetch per credit); gate tests/person-lookup.mjsmre
- 9b3828aemission 046a: report, LOGmre
- 4b37356emission 046: franchise seed supersedeCollections reads the curated timelines once (10 s one-tick block at the end of boot)mre
- ac6268e3mission 046a: re-vendor Hybriel 528bc89f (integration 6): plugins mpackdb/time/web (bin/ git-ignored)mre
- 322b3293mission 046: photoQueue guard for non-row fetch results (damaged persons index)mre
- e5b99aecmission 046: photoQueue in slices (people.hl photoQueueStart/Step, jobs.hl photoTick), tests/photoqueue.hlmre
- 31dcf2admission 045: report, LOGmre
- 9c3971d0tests/persons-skip-count.hlmre
- 4d72e365mission 045mre
- b9cae4c9slices: skip and count non-row values from range(); merge persons pass falls back to iterate; guard testmre
- 3db7dc31merge w44-jobs-slices into w43-trkmemmre