gitoria

tracker

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit57d1c0dc57d1c0dcLog: day50 retest requestmre57d1c0dc/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

  • 57d1c0dcLog: day50 retest requestmre
  • 60b1f419Log: Anton #336 result, wake checkmre
  • 919a18aalog: scratchmre
  • 6b504440status tidymre
  • 9332bd10log: DP70 livemre
  • be11daa0DP70 brief fixmre
  • 886a7028DP70 brief, HM67 mergedmre
  • b41cdd6dMerge hm67-searchids: packed search IDsmre
  • 385904eaReport HM67 matched heap measurements and gate proofmre
  • e5c9b659Pack retained search IDs into UTF-8 bytesmre
  • 62a5f6c7HM67 brief, HM66 mergedmre
  • b32b8440Merge hm66-catalogindex: packed catalog indexmre
  • 2db0f7adReport HM66 heap measurements and validationmre
  • 6ce15623Pack catalog lists and membership maps in UTF-8 bytesmre
  • 71134e21HM66 briefmre
  • ed4cbab2status timemre
  • e982c26dlog: HM65 mergedmre
  • 6e72f9d1Merge hm65-fields: episode boot scan reads three fieldsmre
  • 07a5c883HM65 report measured field projection and complete validationmre
  • 0eab858fRead only catalog date fields during the episode boot scanmre