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) {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) {s = showById(&id)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
- c41587d2Merge branch 'bs2' into mainTracker
- 0dd538a6|||PR BS2: finish the boot index in slices so a booting instance keeps answeringTracker
- 019d5cedMerge branch 'records-1110' into mainTracker
- f88ae8b9|||PR records: day56 toggle live, reviewTracker
- b6b3bb4dMerge branch 'ap56e' into mainTracker
- 29a26da9|||PR AP56e: guard hidden show helpers during session syncTracker
- 7c9ec236|||PR AP56e: re-vendor Hybriel set day56 (source 36ae83a8, bin c1f595a2)Tracker
- 4b54f6f9Merge branch 'records-audit' into mainTracker
- cab4a3bc|||PR records: branch audit, PR-onlyTracker
- 641e1c4cMerge branch 'records-dp71' into mainTracker
- 85a6e9f5|||PR records: DP71 checked in ChromeTracker
- f5be5f18records: gitoria PR-only planTracker
- 46a37036records: DP71 liveTracker
- 3bcb7039Status/log: DP71 in progressTracker
- 5b3a5693Log: SR1b merged via PR 2, DP71 startedTracker
- 783957c2Merge branch 'sr1-search' into mainTracker
- 792b9652README: search results come from the routeTracker
- fd8570b1|||PR search: one server exchange per keystrokeTracker
- e8f5cbcaLog: SR1 result, SR1bTracker
- 8ad275a4Log/status: tracker 68, SR1Tracker