gitoria

tracker

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Main branchmaind2e6d26bMerge branch 'records-park55' into mainTrackermain/tools/tvmaze-types.hl

2.9 KB

  1. // tools/tvmaze-types.hl — tracker#43 (mission 037): TVmaze's TYPE for every series that has a TVmaze id but no stored type, and
  2. // which titles that moves from /series to /shows (Variety, Talk Show, Game Show, Reality, News, Panel Show, Award Show, Sports —
  3. // shows.hl kindOfTitle). The SAME step the app's TVmaze status backfill runs after the deploy (backfill.hl tvmazeStatusTitle:
  4. // GET <TVMAZE_BASE_URL>/shows/<id>, one request per series, 550 ms apart — TVmaze allows 20 / 10 s; no TMDB token needed).
  5. // ONLY on a COPY or with the app stopped (opening a table rewrites its files; hl:mpackdb: one process per storage):
  6. // TRACKER_STORAGE=/abs/path/storage/mpackdb ./bin/hybriel tools/tvmaze-types.hl [--limit N]
  7. // Prints one line per title whose kind changed ("moved: …") and the totals: series asked, types stored, moved to shows, moved to
  8. // series, the TVmaze types seen, errors. Idempotent: a second run asks nothing (every series has its type, '' = TVmaze gave none).
  9. import { env, args, exit } from 'hl:proc'
  10. import { now, sleep } from 'hl:time'
  11. import { pauseMsAfter } from '../lib/tmdb.hl'
  12. import { tvmazeStatusQueue, tvmazeStatusTitle } from '../lib/backfill.hl'
  13. import { showById, titleKind, titlePath } from '../lib/shows.hl'
  14. import { persistSync } from '../lib/sync.hl'
  15. storageDir = env('TRACKER_STORAGE')
  16. if (storageDir == null || !storageDir.startsWith('/')) { console.log('REFUSED: set TRACKER_STORAGE, absolute (app stopped, or a copy)') exit(2) }
  17. argv = args()
  18. let limit = -1
  19. let i = 0
  20. while (i < argv.length) {
  21. if (argv[i] == '--limit' && i + 1 < argv.length) { limit = toNumber(argv[i + 1]) }
  22. i = i + 1
  23. }
  24. started = now()
  25. queue = tvmazeStatusQueue()
  26. console.log('tvmaze types: ' + queue.length + ' series with a TVmaze id and no TVmaze type or status')
  27. types = {}
  28. let asked = 0
  29. let stored = 0
  30. let toShows = 0
  31. let toSeries = 0
  32. let errors = 0
  33. for (id of queue) {
  34. if (limit < 0 || asked < limit) {
  35. r = tvmazeStatusTitle(&id)
  36. asked = asked + 1
  37. if (r.type != null) {
  38. stored = stored + 1
  39. types[r.type] = types[r.type] == null ? 1 : types[r.type] + 1
  40. }
  41. if (r.error != '') { errors = errors + 1 console.log('error: ' + r.error) }
  42. if (r.moved) {
  43. s = showById(&id)
  44. k = titleKind(&s)
  45. if (k == 'show') { toShows = toShows + 1 } else { toSeries = toSeries + 1 }
  46. console.log('moved: ' + s.title + ' (' + s.year + ') TVmaze ' + s.tvmzId + ' type ' + r.type + ', TMDB type ' + s.tmdbType + ' → ' + titlePath(&s))
  47. }
  48. if (asked % 25 == 0) { persistSync() }
  49. if (asked % 100 == 0) { console.log('tvmaze types: ' + asked + '/' + queue.length + ' asked, ' + toShows + ' moved to shows') }
  50. sleep(pauseMsAfter(&r) / 1000)
  51. }
  52. }
  53. persistSync()
  54. let seen = ''
  55. for (t of types.keys()) { seen = seen + (seen == '' ? '' : ', ') + t + ' ' + types[t] }
  56. console.log('tvmaze types done: asked=' + asked + ' typesStored=' + stored + ' movedToShows=' + toShows + ' movedToSeries=' + toSeries + ' errors=' + errors + ' seconds=' + ((now() - started) / 1000))
  57. console.log('tvmaze types seen: ' + seen)

Branches

Latest commits

  • d2e6d26bMerge branch 'records-park55' into mainTracker
  • f567f025|||PR records: park #55, no Claude workers ruleTracker
  • c21aff6bMerge branch 'records-hm55c' into mainTracker
  • 9ba258d3|||PR records: HM55b resultTracker
  • 64f2d300Merge branch 'records-hm55b2' into mainTracker
  • ae3b80dc|||PR records: HM55b briefTracker
  • 7ef3cb3bMerge branch 'records-st55' into mainTracker
  • fec2e080|||PR records: STATUS HM55Tracker
  • 8e174918Merge branch 'records-hm55b' into mainTracker
  • b1ecee57|||PR records: HM55 stateTracker
  • 28eab08cMerge branch 'records-hm55' into mainTracker
  • d3edaa05|||PR records: HM55 start, PROCEDURES.mdTracker
  • 3059f86cMerge branch 'records-design-rule' into mainTracker
  • 421a4809|||PR records: his-design rule (Apollo 2026-11-13)Tracker
  • d1390692Merge branch 'records-dp75b' into mainTracker
  • a4d1a7d2|||PR records: later steps checked, branch auditTracker
  • e070e16fMerge branch 'records-dp75' into mainTracker
  • 642b4fa8|||PR records: DP75 day62 live, AP62 briefTracker
  • bfc4ea4dMerge branch 'ap62' into mainTracker
  • 2c95ac46|||PR AP62: re-vendor Hybriel set day62 (source 70341ad2, bin a54f5f08)Tracker