gitoria

tracker

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit49f76ecb49f76ecblog: watch toggle slowness = session sweep freeze (tracker#50)mre49f76ecb/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. let 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. let s = showById(id)
  44. let 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

  • 49f76ecblog: watch toggle slowness = session sweep freeze (tracker#50)mre
  • 3daf6eddlog: day37 live, still waiting for day39mre
  • 796ba672records: #277 slips to day39mre
  • a9eb9827records: mpackdb integrity clean, all 12 tablesmre
  • 6cf40dbdrecords: mpackdb integrity check, shows uncheckedmre
  • 1880f42arecords: day38 deploy may swap normallymre
  • 9d806e35records: mpackdb freeze until day38mre
  • a660239drecords: day37 lacks #277, wait for day38mre
  • b0abfdeaLOG: Anton hybriel#277 fix ready for day37mre
  • 7b5b2918Tracker: hybriel#277 fix comes in day37mre
  • 7ddbeec8Tracker: RV28c blocked on day35 regressionmre
  • bf401884Tracker: RV28c startedmre
  • 0ff4ecd4Tracker: RV28c briefmre
  • 06565b1fRecords: day35 relay note, tickets subscription idmre
  • c6dc3e86RV28b: switch to set day35mre
  • 24e401b8Tracker: TR7 watch cleanmre
  • b0412957Tracker: RV28b handed overmre
  • 456940c8Tracker: RULINGS pathmre
  • b87a8fdcTracker: worldapi-conductor paths backmre
  • 641f3b54Tracker: Apollo answermre