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
- a18957falog: evening re-measure after CBmre
- aac9a98dlog: evening re-measure startmre
- 45163bd4log: person/tmdb error hypothesismre
- cb38de2blog: swap 503 causemre
- fd10c3d5log: CB livemre
- 7557c025log: CB deploy try 2mre
- 06a7534aMerge branch 'cb'mre
- 2f8030d6log: CB gates greenmre
- 498bf644log: CB gates startmre
- f59c2847gc1: bound the five request caches (shows.hl cacheLimit)mre
- 6ea2c6d6log: morning re-measure 11-04mre
- 446290f0log: GC1 livemre
- 8e6aa91dlog: GC1 deploy retrymre
- 87ad2dc1log: GC1 deployingmre
- 53f10fb8Merge branch 'gc1-deploy'mre
- 7fcbf1d2log: GC1 deploy GOmre
- 1fb6664bcompose: TRACKER_QSTATS=1 (GC1 measurement)mre
- 6576c1cdgc1: release the people-view scan lists once the view is builtmre
- 94f8a373gc1: back out the kept episode-id set (no measurable gain on /my/unwatched: 4.69 -> 4.61 GB per 150 loads)mre
- a1a88bd4gc1: search skips the stale-key string while no entry is stale; /my/unwatched asks a kept id set instead of building a key string per episode rowmre