gitoriaLog in with ident

tracker

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commitf83571c3f83571c3tracker#18 (mission 067): daily sync by change lists — TMDB /tv|movie/changes (since the stored day, paged) + TVmaze /updates/shows → only our changed titles (followed: full step, unfollowed: light step — changed seasons, no TVmaze), full walk on first run / gap > 14 days / failed list; show record refreshed (title, tmdbSummary, tagline, status, genres …; renamed titles re-indexed); summary = the creator's own text (page: summary > tmdbSummary > tvmazeSummary), one-time clear of copied summaries (9,647 on the live copy); gate 261, tests/realdata-018*.mjs, README + STATUSmref83571c3/tmdbsync.hl

41.0 KB

  1. // tmdbsync.hl — THE TMDB SYNC (tracker.worldapi.org#9): for every show SOMEONE follows, fetch the show's
  2. // details, seasons and episodes from TMDB and bring storage/mpackdb/ up to date, plus the show's poster.
  3. // Used by BOTH runners: the daily run inside the app (project.hl `syncTick`, one show per step) and the
  4. // command-line tool (tools/sync-tmdb.hl). Reference for the API use: the old tracker's
  5. // crates/sync/commands/sync.js (read-only).
  6. //
  7. // GET <TMDB_BASE_URL>/tv/<tmdbId>?append_to_response=external_ids,aggregate_credits the details (status,
  8. // counts, overview, poster_path, seasons[])
  9. // + external_ids (imdb_id, tvdb_id) + the cast/crew
  10. // of every season (tracker#28: the answer goes back
  11. // as `res.details`, the caller stores the credits —
  12. // details.hl applyCredits; no extra request)
  13. // GET <TMDB_BASE_URL>/tv/<tmdbId>?append_to_response=season/1,season/2… up to 20 seasons with their
  14. // episodes in ONE request
  15. // GET <TMDB_IMAGE_URL>/w342<poster_path> the poster → storage/mpackdb/posters/
  16. // Authorization: Bearer $TMDB_READ_TOKEN
  17. // GET <TVMAZE_BASE_URL>/lookup/shows?imdb=tt… (else ?thetvdb=<id>) the TVmaze id, ONLY when the show
  18. // has none (301 → /shows/<id>, 404 = unknown)
  19. // GET <TVMAZE_BASE_URL>/shows/<tvmzId>?embed=episodes a SERIES on TVmaze with its episodes (#15), see
  20. // below; its summary → `tvmazeSummary` (tracker#18)
  21. // A MOVIE (`type = 'movie'`, 7814 of the migrated rows, 1 followed): only
  22. // GET <TMDB_BASE_URL>/movie/<tmdbId>?append_to_response=external_ids,credits its imdb id + poster (+ credits); no seasons,
  23. // status, overview (it is no TV show)
  24. //
  25. // EXTERNAL IDS (tracker.worldapi.org#12, the show page's link icons): a MISSING imdbId/tvdbId is filled from TMDB's
  26. // external_ids, a missing tvmzId from TVmaze's lookup — an id the show already has is NEVER overwritten.
  27. // RULES (ticket): new seasons/episodes are ADDED, existing ones UPDATED (title, summary, release) —
  28. // matched by tmdbId, never duplicated; NOTHING is deleted. An episode without a tmdbId (161 migrated ones)
  29. // is matched by its S/E number instead and gets the tmdbId. A season (no tmdbId in the migrated data) is
  30. // matched by (show, seasonNumber). A TMDB value that is empty/null never overwrites a stored one.
  31. // Season 0 ("Specials") is only synced for a show that already has a season 0 (else every followed show
  32. // would suddenly flood /my/unwatched with specials); a TMDB season with no episodes is not created.
  33. //
  34. // TVMAZE MERGE (tracker.worldapi.org#15): AFTER TMDB, a series with a tvmzId gets TVmaze's episode list (one request)
  35. // and TVmaze FILLS GAPS only — matched by season/episode number: a missing episode (and its season) is ADDED, an empty
  36. // title or air date of an existing one is FILLED; a value TMDB gave is never overwritten. A placeholder title
  37. // ("Episode 4", "TBA") counts as empty — and TMDB's own placeholder never overwrites a real title either (else the
  38. // two would flip it every day). When TMDB later lists the episode, the TMDB step adopts it by number (it has no tmdbId)
  39. // and TMDB's values win. TVmaze specials (no episode number) are skipped, season 0 only if the show has one. SAFETY:
  40. // when the two number a show differently (fewer than 80 % of the episodes both know air within a day of each other or
  41. // share the title — `numberingAgrees`), TVmaze is ignored for that show (`tvmazeSkipped`). Summaries are not taken
  42. // (TVmaze's are HTML; the ticket asks for episodes, air dates, titles). The SHOW's TVmaze summary is kept, HTML stripped, as
  43. // `tvmazeSummary` (tracker#18; the page shows summary > tmdbSummary > tvmazeSummary, shows.hl summaryOf).
  44. //
  45. // WHICH TITLES, WHEN (tracker#18): the daily run asks TMDB's and TVmaze's change lists first and syncs only the titles of ours
  46. // that changed — deltasync.hl. THE SHOW RECORD (title, tagline, homepage, status, genres …) is refreshed from the same details
  47. // answer by details.hl `applySynced`.
  48. //
  49. // ADULT FLAG (mission 054): every details answer carries TMDB's `adult` — the sync, the import (search.hl) and the
  50. // BACKFILL below store it as show.adult (true/false; null = not known yet, hidden from the public lists, shows.hl
  51. // isPublicTitle). THE BACKFILL (`backfillTitle`, run one title per step by project.hl `backfillTick`, like the daily sync):
  52. // GET <TMDB_BASE_URL>/movie|tv/<tmdbId>?append_to_response=external_ids ONE request: adult, poster_path, imdb/tvdb id
  53. // GET <TMDB_IMAGE_URL>/w342<poster_path> the poster when its file is missing (not for
  54. // an adult title — never shown, mission 056)
  55. // for every title whose adult flag is unknown (no TVmaze, no seasons — the daily sync does those for followed shows). A
  56. // title TMDB answers 404 for (or one without tmdbId) gets `adultCheck` = why, stays unknown (hidden) and is not asked again.
  57. //
  58. // IDS ARE SELF-ASSIGNED (randomBytes, like watches.hl): hl:mpackdb's own generated @id can repeat within
  59. // one millisecond, which is what made update() lose rows (hybriel#113, fixed upstream, not in the vendored
  60. // build) — a table holding only unique ids is safe to update().
  61. //
  62. // ONE PROCESS PER STORAGE: hl:mpackdb does not coordinate two processes (hybriel#21) — the in-app run uses
  63. // the app's own open tables (imported from shows.hl); the tool only ever runs against a stopped app or a copy.
  64. //
  65. // Env: TMDB_READ_TOKEN (required unless TMDB_BASE_URL points at a fake), TMDB_BASE_URL
  66. // (https://api.themoviedb.org/3), TMDB_IMAGE_URL (https://image.tmdb.org/t/p) — the gate points both at its
  67. // fake TMDB (tests/browser.mjs).
  68. import { fetch } from 'hl:fetch'
  69. import { env } from 'hl:proc'
  70. import { now } from 'hl:time'
  71. import { randomBytes } from 'hl:crypto'
  72. import { writeFile, mkDir, exists } from 'hl:fs'
  73. import { showsTable, seasonsTable, episodesTable, storageDir } from './shows.hl'
  74. static envOr = (name, fallback) => {
  75. let v = env(name)
  76. return v != null && v.trim() != '' ? v.trim() : fallback
  77. }
  78. static tmdbBase = envOr('TMDB_BASE_URL', 'https://api.themoviedb.org/3')
  79. static tmdbImageBase = envOr('TMDB_IMAGE_URL', 'https://image.tmdb.org/t/p')
  80. static tmdbToken = envOr('TMDB_READ_TOKEN', '')
  81. static postersDir = storageDir + '/posters'
  82. static tvmazeBase = envOr('TVMAZE_BASE_URL', 'https://api.tvmaze.com')
  83. // the sync can run: a token is set (never printed) — the dev .env on Loreana has one, a gate sets its own
  84. static syncEnabled = tmdbToken != ''
  85. // TMDB allows 40 requests / 10 s: every runner waits this long per request it made before the next show
  86. static msPerRequest = 260
  87. // TVmaze allows 20 requests / 10 s (its API docs): 550 ms per lookup made
  88. static msPerTvmazeRequest = 550
  89. // how long a runner waits after a show before the next one (both runners: project.hl syncTick, tools/sync-tmdb.hl)
  90. static pauseMsAfter = (r) => { return r.requests * msPerRequest + r.tvmazeRequests * msPerTvmazeRequest }
  91. // one GET → the parsed JSON, or { failed = '<why>' }. A refused/timed-out fetch is an Error event (absorbed
  92. // by the runner's `on Error`), the fetch then yields null.
  93. static tmdbGet = (path) => {
  94. let r = fetch(tmdbBase + path, { headers = { 'authorization' = 'Bearer ' + tmdbToken 'accept' = 'application/json' 'user-agent' = 'tracker.worldapi.org (tmdb sync)' } timeoutMs = 20000 })
  95. if (r == null || r.status == null || r.status == 0) { return { failed = 'no answer for ' + path } }
  96. if (r.status != 200) { return { failed = 'HTTP ' + r.status + ' for ' + path status = r.status } }
  97. let j = r.json()
  98. if (j == null) { return { failed = 'no JSON for ' + path } }
  99. return j
  100. }
  101. static textOr = (v) => { return v != null && hlTypeName(v) == 'String' && v.trim() != '' ? v : null }
  102. // ---- external ids (tracker.worldapi.org#12) -----------------------------------------------------
  103. static hasId = (v) => { return v != null && ('' + v).trim() != '' }
  104. // an IMDb id as TMDB gives it ('tt' + digits), else null
  105. static imdbOr = (v) => {
  106. let t = textOr(v)
  107. if (t == null || t.length < 3 || t.slice(0, 2) != 'tt') { return null }
  108. let i = 2
  109. while (i < t.length) {
  110. if (!'0123456789'.includes(t[i])) { return null }
  111. i = i + 1
  112. }
  113. return t
  114. }
  115. // a positive numeric id (TMDB's tvdb_id, TVmaze's id), else null
  116. static numIdOr = (v) => { return v != null && hlTypeName(v) == 'Number' && v > 0 ? v : null }
  117. // TVmaze's lookup by one external id: { id } (null = TVmaze doesn't know it, 404) or { failed }. hl:fetch follows the
  118. // 301 to /shows/<id> by itself, so a hit answers the show's own JSON.
  119. static tvmazeLookup = (param, value) => {
  120. let r = fetch(tvmazeBase + '/lookup/shows?' + param + '=' + value, { headers = { 'accept' = 'application/json' 'user-agent' = 'tracker.worldapi.org (tmdb sync)' } timeoutMs = 20000 })
  121. if (r == null || r.status == null || r.status == 0) { return { failed = 'TVmaze: no answer for ' + param + '=' + value } }
  122. if (r.status == 404) { return { id = null } }
  123. if (r.status != 200) { return { failed = 'TVmaze: HTTP ' + r.status + ' for ' + param + '=' + value } }
  124. let j = r.json()
  125. if (j == null || numIdOr(j.id) == null) { return { failed = 'TVmaze: no id for ' + param + '=' + value } }
  126. return { id = j.id }
  127. }
  128. // the ids to SET on a show from TMDB's external_ids (+ TVmaze for a series): { imdbId, tvdbId, tvmzId } — each the
  129. // show's own value when it has one (never overwritten), else the found one, else null — plus { filled, tvmazeRequests,
  130. // failed }. TVmaze is asked by imdb, then by thetvdb, only while the show (after TMDB) still has no tvmzId — and only
  131. // when `askTvmaze` (the adult backfill does not: one request per title)
  132. static externalIdsFor = (show, ext, isSeries, askTvmaze) => {
  133. let out = { imdbId = show.imdbId tvdbId = show.tvdbId tvmzId = show.tvmzId filled = 0 tvmazeRequests = 0 failed = null }
  134. let e = ext != null ? ext : {}
  135. if (!hasId(out.imdbId) && imdbOr(e.imdb_id) != null) { out.imdbId = e.imdb_id out.filled = out.filled + 1 }
  136. if (!isSeries) { return out }
  137. if (!hasId(out.tvdbId) && numIdOr(e.tvdb_id) != null) { out.tvdbId = e.tvdb_id out.filled = out.filled + 1 }
  138. if (hasId(out.tvmzId) || !askTvmaze) { return out }
  139. let tries = []
  140. if (imdbOr('' + out.imdbId) != null) { tries.push({ param = 'imdb' value = '' + out.imdbId }) }
  141. if (numIdOr(out.tvdbId) != null) { tries.push({ param = 'thetvdb' value = '' + out.tvdbId }) }
  142. for (t of tries) {
  143. if (!hasId(out.tvmzId) && out.failed == null) {
  144. out.tvmazeRequests = out.tvmazeRequests + 1
  145. let found = tvmazeLookup(t.param, t.value)
  146. if (found.failed != null) { out.failed = found.failed } else if (found.id != null) { out.tvmzId = found.id out.filled = out.filled + 1 }
  147. }
  148. }
  149. return out
  150. }
  151. // ---- TVmaze merge (tracker.worldapi.org#15) ------------------------------------------------------
  152. // a title that is none yet: empty, "TBA"/"TBD", or "Episode <n>" (what TMDB and TVmaze name an untitled episode; also
  153. // French/German/Spanish: real data has TVmaze "Épisode 1" where TMDB says "Episode 1")
  154. static placeholderWords = ['episode', 'épisode', 'Épisode', 'folge', 'episodio']
  155. static isPlaceholderTitle = (v) => {
  156. let t = textOr(v)
  157. if (t == null) { return true }
  158. let l = t.trim().toLowerCase()
  159. if (l == 'tba' || l == 'tbd' || l == 'tba.' || l == 'to be announced') { return true }
  160. let parts = l.split(' ')
  161. if (parts.length != 2 || !placeholderWords.includes(parts[0]) || parts[1].length == 0) { return false }
  162. let i = 0
  163. while (i < parts[1].length) {
  164. if (!'0123456789'.includes(parts[1][i])) { return false }
  165. i = i + 1
  166. }
  167. return true
  168. }
  169. // 'YYYY-MM-DD' → a day number (only differences matter), null when it is no such date
  170. static dayNumber = (v) => {
  171. let t = textOr(v)
  172. if (t == null || t.length < 10) { return null }
  173. let y = toNumber(t.slice(0, 4))
  174. let m = toNumber(t.slice(5, 7))
  175. let d = toNumber(t.slice(8, 10))
  176. if (y == null || m == null || d == null || m < 1 || m > 12) { return null }
  177. let before = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334]
  178. let py = m <= 2 ? y - 1 : y
  179. let leaps = (py - py % 4) / 4 - (py - py % 100) / 100 + (py - py % 400) / 400
  180. return y * 365 + leaps + before[m - 1] + d
  181. }
  182. static daysApart = (a, b) => {
  183. let x = dayNumber(a)
  184. let y = dayNumber(b)
  185. if (x == null || y == null) { return null }
  186. return x > y ? x - y : y - x
  187. }
  188. // TVmaze's text without its HTML (tracker#18: `tvmazeSummary`): tags dropped — a block tag (p, br, div, li) becomes a space —
  189. // the common entities decoded, white space collapsed; null when nothing is left
  190. static blockTags = ['p', 'br', 'div', 'li', 'ul', 'ol', 'h1', 'h2', 'h3', 'h4', 'blockquote']
  191. static entities = [['&nbsp;', ' '], ['&quot;', '"'], ['&#39;', "'"], ['&apos;', "'"], ['&lt;', '<'], ['&gt;', '>'], ['&ndash;', '–'], ['&mdash;', '—'], ['&hellip;', '…'], ['&amp;', '&']]
  192. static stripHtml = (v) => {
  193. let t = textOr(v)
  194. if (t == null) { return null }
  195. let out = ''
  196. let i = 0
  197. while (i < t.length) {
  198. if (t[i] == '<') {
  199. let close = t.indexOf('>', i)
  200. if (close < 0) { close = t.length }
  201. let name = t.slice(i + 1, close).trim().toLowerCase()
  202. if (name.startsWith('/')) { name = name.slice(1) }
  203. let sp = name.indexOf(' ')
  204. if (sp >= 0) { name = name.slice(0, sp) }
  205. if (name.endsWith('/')) { name = name.slice(0, name.length - 1) }
  206. if (blockTags.includes(name)) { out = out + ' ' }
  207. i = close + 1
  208. } else {
  209. // a line break / tab (a control character) is a space too (strings have no escapes to name them)
  210. out = out + (t.charCodeAt(i) < 32 ? ' ' : t[i])
  211. i = i + 1
  212. }
  213. }
  214. for (e of entities) { out = out.replaceAll(e[0], e[1]) }
  215. let words = []
  216. for (w of out.split(' ')) { if (w != '') { words.push(w) } }
  217. return words.length > 0 ? words.join(' ') : null
  218. }
  219. // TVmaze's show WITH its episode list, one request (tracker#18: `?embed=episodes` brings the show's own summary too — before
  220. // it was `/shows/<id>/episodes`): { list, summary (HTML stripped, or null) } or { failed }
  221. static tvmazeEpisodes = (tvmzId) => {
  222. let r = fetch(tvmazeBase + '/shows/' + tvmzId + '?embed=episodes', { headers = { 'accept' = 'application/json' 'user-agent' = 'tracker.worldapi.org (tmdb sync)' } timeoutMs = 20000 })
  223. if (r == null || r.status == null || r.status == 0) { return { failed = 'TVmaze: no answer for episodes of ' + tvmzId } }
  224. if (r.status != 200) { return { failed = 'TVmaze: HTTP ' + r.status + ' for episodes of ' + tvmzId } }
  225. let j = r.json()
  226. if (j == null || j._embedded == null || j._embedded.episodes == null || j._embedded.episodes.length == null) { return { failed = 'TVmaze: no episode list for ' + tvmzId } }
  227. return { list = j._embedded.episodes summary = stripHtml(j.summary) }
  228. }
  229. // do we and TVmaze number a show the same way? Of the episodes both know (same S/E), at least 80 % must air within a day
  230. // of each other OR carry the same title (a streaming show TVmaze dates all on its release day, TMDB week by week, still
  231. // agrees by title). A show we have episodes of but TVmaze numbers none of the same (e.g. seasons by year) never agrees.
  232. // Answers { known, compared, agree, ok }.
  233. static sameTitle = (a, b) => { return !isPlaceholderTitle(a) && !isPlaceholderTitle(b) && a.trim().toLowerCase() == b.trim().toLowerCase() }
  234. static numberingAgrees = (epByNumber, list) => {
  235. let out = { known = 0 compared = 0 agree = 0 ok = true }
  236. let localCount = epByNumber.keys().length
  237. for (te of list) {
  238. let e = epByNumber[te.season + 'x' + te.number]
  239. if (e != null) {
  240. out.known = out.known + 1
  241. let apart = daysApart(e.release, te.airdate)
  242. let titled = !isPlaceholderTitle(e.title) && !isPlaceholderTitle(te.name)
  243. if (apart != null || titled) {
  244. out.compared = out.compared + 1
  245. if ((apart != null && apart <= 1) || sameTitle(e.title, te.name)) { out.agree = out.agree + 1 }
  246. }
  247. }
  248. }
  249. out.ok = !((localCount > 0 && out.known == 0) || (out.compared > 0 && out.agree * 5 < out.compared * 4))
  250. return out
  251. }
  252. // Merge TVmaze's episodes of a series into what we have AFTER the TMDB step (gaps only, rules at the top).
  253. // `seasonsByNumber` / `epByNumber` = the show's seasons by number and episodes by '<s>x<e>', as the TMDB step left them.
  254. // Answers { tvmazeRequests, newSeasons, newEpisodes, filledEpisodes, skipped, errors, error, showSeasons }.
  255. static mergeTvmaze = (title, showKey, tvmzId, seasonsIn, episodesIn, showSeasonsIn) => {
  256. let seasonsByNumber = seasonsIn
  257. let epByNumber = episodesIn
  258. let out = { tvmazeRequests = 1 newSeasons = 0 newEpisodes = 0 filledEpisodes = 0 skipped = 0 errors = 0 error = '' showSeasons = showSeasonsIn summary = null }
  259. let got = tvmazeEpisodes(tvmzId)
  260. if (got.failed != null) { out.errors = 1 out.error = title + ': ' + got.failed return out }
  261. out.summary = got.summary
  262. // the numbered episodes TVmaze has in seasons we take (no specials; season 0 only when the show has one)
  263. let list = []
  264. for (te of got.list) {
  265. if (numIdOr(te.season) != null && numIdOr(te.number) != null) { list.push(te) }
  266. else if (te.season == 0 && numIdOr(te.number) != null && seasonsByNumber['0'] != null) { list.push(te) }
  267. }
  268. if (!numberingAgrees(epByNumber, list).ok) { out.skipped = 1 return out }
  269. let added = {}
  270. let addedFirstDate = {}
  271. for (te of list) {
  272. let key = te.season + 'x' + te.number
  273. let e = epByNumber[key]
  274. if (e == null) {
  275. let seasonKey = seasonsByNumber['' + te.season] != null ? seasonsByNumber['' + te.season].id : null
  276. if (seasonKey == null) {
  277. if (added['' + te.season] == null) { added['' + te.season] = [] addedFirstDate['' + te.season] = textOr(te.airdate) seasonsByNumber['' + te.season] = { id = newId() isNew = true } }
  278. seasonKey = seasonsByNumber['' + te.season].id
  279. }
  280. let fresh = { id = newId() episodeNumber = te.number seasonNumber = te.season
  281. title = textOr(te.name) summary = '' release = textOr(te.airdate)
  282. show = showKey season = seasonKey tmdbId = null tvmzId = te.id oldId = 'tvmaze-episode:' + te.id }
  283. if (episodesTable.put(fresh) == null) {
  284. out.errors = out.errors + 1
  285. out.error = title + ': TVmaze episode ' + te.id + ' not stored: ' + episodesTable.lastError()
  286. } else {
  287. if (added['' + te.season] == null) { added['' + te.season] = [] }
  288. let l = added['' + te.season]
  289. l.push(fresh.id)
  290. added['' + te.season] = l
  291. epByNumber[key] = fresh
  292. out.newEpisodes = out.newEpisodes + 1
  293. }
  294. } else {
  295. let changed = false
  296. if (isPlaceholderTitle(e.title) && !isPlaceholderTitle(te.name)) { e.title = te.name changed = true }
  297. if (textOr(e.release) == null && textOr(te.airdate) != null) { e.release = te.airdate changed = true }
  298. if (changed) {
  299. if (episodesTable.update(e.id, e) == null) {
  300. out.errors = out.errors + 1
  301. out.error = title + ': episode ' + e.id + ' not filled from TVmaze: ' + episodesTable.lastError()
  302. } else {
  303. epByNumber[key] = e
  304. out.filledEpisodes = out.filledEpisodes + 1
  305. }
  306. }
  307. }
  308. }
  309. // the seasons that got episodes: an existing one is updated, a new one stored and linked to the show
  310. let showSeasons = []
  311. for (sid of showSeasonsIn) { showSeasons.push(sid) }
  312. for (n of added.keys()) {
  313. let ids = added[n]
  314. let s = seasonsByNumber[n]
  315. if (ids.length > 0 && s.isNew == true) {
  316. let season = { id = s.id seasonNumber = toNumber(n) title = 'Season ' + n release = addedFirstDate[n] summary = ''
  317. show = showKey episodes = ids oldId = 'tvmaze-season:' + tvmzId + ':' + n }
  318. if (seasonsTable.put(season) == null) {
  319. out.errors = out.errors + 1
  320. out.error = title + ': TVmaze season ' + n + ' not stored: ' + seasonsTable.lastError()
  321. } else {
  322. showSeasons.push(season.id)
  323. out.newSeasons = out.newSeasons + 1
  324. }
  325. } else if (ids.length > 0) {
  326. let season = seasonsTable.fetch(s.id)
  327. let eps = []
  328. for (eid of season.episodes) { eps.push(eid) }
  329. for (eid of ids) { eps.push(eid) }
  330. season.episodes = eps
  331. if (seasonsTable.update(season.id, season) == null) {
  332. out.errors = out.errors + 1
  333. out.error = title + ': season ' + season.id + ' not updated: ' + seasonsTable.lastError()
  334. }
  335. }
  336. }
  337. out.showSeasons = showSeasons
  338. return out
  339. }
  340. // ---- posters ----------------------------------------------------------------------------------
  341. // the extension of a TMDB poster_path ('/abc.jpg' → 'jpg'); only the ones the poster route knows
  342. static posterExt = (posterPath) => {
  343. let parts = posterPath.split('.')
  344. let ext = parts[parts.length - 1].toLowerCase()
  345. if (ext == 'jpg' || ext == 'jpeg' || ext == 'png' || ext == 'webp') { return ext }
  346. return null
  347. }
  348. // downloads the w342 poster when the file is missing or TMDB has a new one; answers { requests, saved, failed }
  349. // and sets show.image / show.tmdbPoster on the (caller's) record — the file is <oldId>.<ext>, the name
  350. // shows.hl posterName() already builds, served by project.hl's /posters/:name route
  351. static syncPoster = (show, posterPath) => {
  352. let out = { requests = 0 saved = 0 failed = null image = show.image tmdbPoster = show.tmdbPoster }
  353. if (textOr(posterPath) == null || show.oldId == null) { return out }
  354. let ext = posterExt(posterPath)
  355. if (ext == null) { return out }
  356. let file = postersDir + '/' + show.oldId + '.' + ext
  357. if (exists(file) && show.tmdbPoster == posterPath && show.image == ext) { return out }
  358. out.requests = 1
  359. let r = fetch(tmdbImageBase + '/w342' + posterPath, { headers = { 'user-agent' = 'tracker.worldapi.org (tmdb sync)' } timeoutMs = 20000 })
  360. if (r == null || r.status != 200 || r.body == null || r.body.length == 0) {
  361. out.failed = 'poster ' + posterPath + ': ' + (r == null ? 'no answer' : 'HTTP ' + r.status)
  362. return out
  363. }
  364. mkDir(postersDir)
  365. writeFile(file, toBytes(r.body), 420)
  366. out.saved = 1
  367. out.image = ext
  368. out.tmdbPoster = posterPath
  369. return out
  370. }
  371. // ---- one show -----------------------------------------------------------------------------------
  372. static newId = () => { return randomBytes(8, 'hex') }
  373. // TMDB's adult flag of a details/search answer: true / false, null when it has none (mission 054)
  374. static adultOf = (j) => {
  375. if (j == null) { return null }
  376. if (j.adult == true) { return true }
  377. if (j.adult == false) { return false }
  378. return null
  379. }
  380. // which TMDB seasons to sync: every numbered one with episodes; 0 only when the show has a season 0 already
  381. static wantedSeasonNumbers = (details, localByNumber) => {
  382. let out = []
  383. if (details.seasons == null) { return out }
  384. for (s of details.seasons) {
  385. let n = s.season_number
  386. if (n != null && (n > 0 || localByNumber['' + n] != null) && (s.episode_count == null || s.episode_count > 0 || localByNumber['' + n] != null)) { out.push(n) }
  387. }
  388. return out
  389. }
  390. // the seasons in batches of 20 (TMDB's append_to_response limit)
  391. static batchesOf = (list, size) => {
  392. let out = []
  393. let cur = []
  394. for (x of list) {
  395. cur.push(x)
  396. if (cur.length == size) { out.push(cur) cur = [] }
  397. }
  398. if (cur.length > 0) { out.push(cur) }
  399. return out
  400. }
  401. // fields of an episode/season from TMDB that differ from the stored record (null/empty never overwrites)
  402. static changedText = (stored, fresh) => { return fresh != null && fresh != stored }
  403. // a MOVIE: one request — its imdb id (if missing) and its poster; nothing else of the record is touched. `pre` = that
  404. // request's answer when the caller already made it (details.hl firstStep, tracker#26), else null
  405. static syncMovie = (show, res, pre) => {
  406. let out = res
  407. out.requests = 1
  408. let details = pre != null ? pre : tmdbGet('/movie/' + show.tmdbId + '?append_to_response=external_ids,credits')
  409. if (details.failed != null) { out.errors = 1 out.error = show.title + ': ' + details.failed return out }
  410. if (pre == null) { out.details = details }
  411. let ids = externalIdsFor(show, details.external_ids, false, false)
  412. out.ids = ids.filled
  413. let poster = syncPoster(show, details.poster_path)
  414. out.requests = out.requests + poster.requests
  415. out.posters = poster.saved
  416. if (poster.failed != null) { out.errors = out.errors + 1 out.error = show.title + ': ' + poster.failed }
  417. let m = show
  418. m.imdbId = ids.imdbId
  419. m.image = poster.image
  420. m.tmdbPoster = poster.tmdbPoster
  421. if (adultOf(details) != null) { m.adult = adultOf(details) }
  422. m.tmdbSync = now()
  423. if (showsTable.update(m.id, m) == null) { out.errors = out.errors + 1 out.error = show.title + ': movie not updated: ' + showsTable.lastError() }
  424. return out
  425. }
  426. // Sync ONE show (by our id). Answers counts: { requests, tvmazeRequests, newSeasons, newEpisodes, updatedEpisodes,
  427. // updatedSeasons, posters, ids, tvmazeEpisodes, tvmazeSeasons, tvmazeFilled, tvmazeSkipped, errors, error } + `details` (the
  428. // details answer with its credits when this call asked for it, else null — tracker#28: the caller stores the credits). Never throws for a TMDB failure — it is counted and the show left as is.
  429. static syncShow = (showId) => { return syncShowPart(showId, null, null) }
  430. // the same with the details request (`/tv|movie/<id>?append_to_response=external_ids…`) already answered — `pre`, counted as
  431. // this show's first request — so details.hl (tracker#26) asks TMDB once for details, ids AND the cast
  432. static syncShowWith = (showId, pre) => { return syncShowPart(showId, pre, null) }
  433. // ONE PART of a series' sync (tracker#26: a talk show with 4,000 episodes took 10 s in one step, blocking every request):
  434. // `only` = { seasons (the TMDB season numbers of this part), finish (false: only those seasons — new ones linked to the show,
  435. // nothing else; true: the ids, TVmaze, poster and the show record), tvmaze (false: no TVmaze lookup/merge — tracker#18's light
  436. // step) }; null = everything at once. `pre` is required with `only` (its request is the caller's: a part counts only its own
  437. // requests).
  438. static emptyResult = () => { return { requests = 0 tvmazeRequests = 0 newSeasons = 0 newEpisodes = 0 updatedEpisodes = 0 updatedSeasons = 0 posters = 0 ids = 0 tvmazeEpisodes = 0 tvmazeSeasons = 0 tvmazeFilled = 0 tvmazeSkipped = 0 errors = 0 error = '' details = null } }
  439. static syncShowPart = (showId, pre, only) => {
  440. let res = emptyResult()
  441. let show = showsTable.fetch(showId)
  442. if (show == null) { res.errors = 1 res.error = 'no show ' + showId return res }
  443. if (show.tmdbId == null) { res.errors = 1 res.error = show.title + ': no tmdbId' return res }
  444. if (show.type == 'movie') { return syncMovie(show, res, pre) }
  445. res.requests = only != null ? 0 : 1
  446. let details = pre != null ? pre : tmdbGet('/tv/' + show.tmdbId + '?append_to_response=external_ids,aggregate_credits')
  447. if (details.failed != null) { res.errors = 1 res.error = show.title + ': ' + details.failed return res }
  448. if (pre == null) { res.details = details }
  449. // what we have: seasons by number, episodes by tmdbId and by S/E number
  450. // (tracker#18: a part reads only ITS seasons' episodes, unless it finishes with the TVmaze merge, which compares them all —
  451. // Today, 15,716 episodes, read them all for a one-season change: 20 s and GBs of memory)
  452. let tvmazeToo = only == null || only.tvmaze != false
  453. let allEpisodes = only == null || (only.finish && tvmazeToo)
  454. let seasonsByNumber = {}
  455. let epByTmdb = {}
  456. let epByNumber = {}
  457. for (sid of show.seasons) {
  458. let s = seasonsTable.fetch(sid)
  459. if (s != null) {
  460. seasonsByNumber['' + s.seasonNumber] = s
  461. let epIds = allEpisodes || only.seasons.includes(s.seasonNumber) ? s.episodes : []
  462. for (eid of epIds) {
  463. let e = episodesTable.fetch(eid)
  464. if (e != null) {
  465. if (e.tmdbId != null) { epByTmdb['' + e.tmdbId] = e }
  466. epByNumber[e.seasonNumber + 'x' + e.episodeNumber] = e
  467. }
  468. }
  469. }
  470. }
  471. // plain locals for the record literals below: inside a literal, an entry named `show`/`season` would shadow
  472. // the variable for every later entry (SPEC "A literal's entries are evaluated in order")
  473. let showKey = show.id
  474. let showTmdb = show.tmdbId
  475. let showSeasons = []
  476. for (sid of show.seasons) { showSeasons.push(sid) }
  477. let showChanged = false
  478. let wanted = wantedSeasonNumbers(details, seasonsByNumber)
  479. if (only != null) {
  480. let part = []
  481. for (n of wanted) { if (only.seasons.includes(n)) { part.push(n) } }
  482. wanted = part
  483. }
  484. for (batch of batchesOf(wanted, 20)) {
  485. let names = []
  486. for (n of batch) { names.push('season/' + n) }
  487. res.requests = res.requests + 1
  488. let withSeasons = tmdbGet('/tv/' + show.tmdbId + '?append_to_response=' + names.join(','))
  489. if (withSeasons.failed != null) {
  490. res.errors = res.errors + 1
  491. res.error = show.title + ': ' + withSeasons.failed
  492. } else {
  493. for (n of batch) {
  494. let ts = withSeasons['season/' + n]
  495. if (ts != null && ts.episodes != null) {
  496. let season = seasonsByNumber['' + n]
  497. let seasonIsNew = season == null
  498. let seasonChanged = false
  499. if (seasonIsNew) {
  500. season = { id = newId() seasonNumber = n title = textOr(ts.name) != null ? ts.name : 'Season ' + n
  501. release = textOr(ts.air_date) summary = textOr(ts.overview) != null ? ts.overview : ''
  502. show = showKey episodes = [] oldId = 'tmdb-season:' + showTmdb + ':' + n }
  503. } else {
  504. if (changedText(season.title, textOr(ts.name))) { season.title = ts.name seasonChanged = true }
  505. if (changedText(season.summary, textOr(ts.overview))) { season.summary = ts.overview seasonChanged = true }
  506. if (changedText(season.release, textOr(ts.air_date))) { season.release = ts.air_date seasonChanged = true }
  507. }
  508. let seasonKey = season.id
  509. let seasonEpisodes = []
  510. for (eid of season.episodes) { seasonEpisodes.push(eid) }
  511. for (te of ts.episodes) {
  512. if (te.id != null && te.episode_number != null) {
  513. let e = epByTmdb['' + te.id]
  514. if (e == null) {
  515. let byNum = epByNumber[n + 'x' + te.episode_number]
  516. if (byNum != null && byNum.tmdbId == null) { e = byNum }
  517. }
  518. if (e == null) {
  519. let fresh = { id = newId() episodeNumber = te.episode_number seasonNumber = n
  520. title = textOr(te.name) summary = textOr(te.overview) != null ? te.overview : '' release = textOr(te.air_date)
  521. show = showKey season = seasonKey tmdbId = te.id oldId = 'tmdb-episode:' + te.id }
  522. let putId = episodesTable.put(fresh)
  523. if (putId == null) {
  524. res.errors = res.errors + 1
  525. res.error = show.title + ': episode ' + te.id + ' not stored: ' + episodesTable.lastError()
  526. } else {
  527. seasonEpisodes.push(fresh.id)
  528. epByTmdb['' + te.id] = fresh
  529. epByNumber[n + 'x' + te.episode_number] = fresh
  530. res.newEpisodes = res.newEpisodes + 1
  531. seasonChanged = true
  532. }
  533. } else {
  534. let changed = false
  535. if (e.tmdbId == null) { e.tmdbId = te.id changed = true }
  536. // #15: TMDB's "Episode 4" never replaces a real title (one TVmaze filled, or the migrated one)
  537. if (changedText(e.title, textOr(te.name)) && !(isPlaceholderTitle(te.name) && !isPlaceholderTitle(e.title))) { e.title = te.name changed = true }
  538. if (changedText(e.summary, textOr(te.overview))) { e.summary = te.overview changed = true }
  539. if (changedText(e.release, textOr(te.air_date))) { e.release = te.air_date changed = true }
  540. if (changed) {
  541. if (episodesTable.update(e.id, e) == null) {
  542. res.errors = res.errors + 1
  543. res.error = show.title + ': episode ' + e.id + ' not updated: ' + episodesTable.lastError()
  544. } else {
  545. epByTmdb['' + e.tmdbId] = e
  546. epByNumber[e.seasonNumber + 'x' + e.episodeNumber] = e
  547. res.updatedEpisodes = res.updatedEpisodes + 1
  548. }
  549. }
  550. }
  551. }
  552. }
  553. season.episodes = seasonEpisodes
  554. if (seasonIsNew) {
  555. if (seasonsTable.put(season) == null) {
  556. res.errors = res.errors + 1
  557. res.error = show.title + ': season ' + n + ' not stored: ' + seasonsTable.lastError()
  558. } else {
  559. seasonsByNumber['' + n] = season
  560. showSeasons.push(season.id)
  561. showChanged = true
  562. res.newSeasons = res.newSeasons + 1
  563. }
  564. } else if (seasonChanged) {
  565. if (seasonsTable.update(season.id, season) == null) {
  566. res.errors = res.errors + 1
  567. res.error = show.title + ': season ' + season.id + ' not updated: ' + seasonsTable.lastError()
  568. } else {
  569. res.updatedSeasons = res.updatedSeasons + 1
  570. }
  571. }
  572. }
  573. }
  574. }
  575. }
  576. // a part that is not the last: only the new seasons are linked to the show (the next part reads them)
  577. if (only != null && !only.finish) {
  578. if (showChanged) {
  579. show.seasons = showSeasons
  580. if (showsTable.update(show.id, show) == null) { res.errors = res.errors + 1 res.error = show.title + ': show not updated: ' + showsTable.lastError() }
  581. }
  582. return res
  583. }
  584. // the external ids (tracker.worldapi.org#12): missing ones from TMDB's external_ids, a missing TVmaze id from TVmaze
  585. let ids = externalIdsFor(show, details.external_ids, true, tvmazeToo)
  586. res.ids = ids.filled
  587. res.tvmazeRequests = ids.tvmazeRequests
  588. if (ids.failed != null) { res.errors = res.errors + 1 res.error = show.title + ': ' + ids.failed }
  589. // tracker.worldapi.org#15: what TVmaze has and TMDB not yet (new episodes/seasons, empty titles and air dates)
  590. let tvmazeSummary = null
  591. if (numIdOr(ids.tvmzId) != null && tvmazeToo) {
  592. let tvm = mergeTvmaze(show.title, showKey, ids.tvmzId, seasonsByNumber, epByNumber, showSeasons)
  593. res.tvmazeRequests = res.tvmazeRequests + tvm.tvmazeRequests
  594. res.tvmazeEpisodes = tvm.newEpisodes
  595. res.tvmazeSeasons = tvm.newSeasons
  596. res.tvmazeFilled = tvm.filledEpisodes
  597. res.tvmazeSkipped = tvm.skipped
  598. if (tvm.errors > 0) { res.errors = res.errors + tvm.errors res.error = tvm.error }
  599. showSeasons = tvm.showSeasons
  600. tvmazeSummary = tvm.summary
  601. }
  602. // the show itself: status, counts, TMDB's overview, the poster, when it was synced
  603. let poster = syncPoster(show, details.poster_path)
  604. res.requests = res.requests + poster.requests
  605. res.posters = poster.saved
  606. if (poster.failed != null) { res.errors = res.errors + 1 res.error = show.title + ': ' + poster.failed }
  607. show.seasons = showSeasons
  608. if (textOr(details.status) != null) { show.status = details.status }
  609. if (details.number_of_seasons != null) { show.seasonsCount = details.number_of_seasons }
  610. if (details.number_of_episodes != null) { show.episodesCount = details.number_of_episodes }
  611. // tracker#18: TMDB's text → tmdbSummary, TVmaze's → tvmazeSummary; `summary` is the creator's own text, never written here
  612. if (textOr(details.overview) != null) { show.tmdbSummary = details.overview }
  613. if (tvmazeSummary != null) { show.tvmazeSummary = tvmazeSummary }
  614. show.image = poster.image
  615. show.tmdbPoster = poster.tmdbPoster
  616. show.imdbId = ids.imdbId
  617. show.tvdbId = ids.tvdbId
  618. show.tvmzId = ids.tvmzId
  619. if (adultOf(details) != null) { show.adult = adultOf(details) }
  620. show.tmdbSync = now()
  621. if (showsTable.update(show.id, show) == null) { res.errors = res.errors + 1 res.error = show.title + ': show not updated: ' + showsTable.lastError() }
  622. return res
  623. }
  624. // ---- the LIGHT step of the daily delta run (tracker#18) ---------------------------------------------------------------
  625. // A changed title NOBODY follows (deltasync.hl): its details (+ ids + credits: the record, applySynced) and only the seasons
  626. // that can have changed — the ones we don't have, the ones where TMDB counts MORE episodes than we have (fewer: TVmaze's
  627. // extras, nothing to fetch), and the newest one (new or renamed episodes land there). No TVmaze (its merge only matters for the followed shows' lists; their full step still does
  628. // it). Real data (2026-10-01): Today (67 seasons / 15,716 episodes) and EastEnders (43 / 7,349) change every day; their full
  629. // sync blocked the server 20.8 s each and grew the process by ~5 GB each.
  630. static changedSeasonNumbers = (details, show) => {
  631. let ours = {}
  632. for (sid of show.seasons) {
  633. let s = seasonsTable.fetch(sid)
  634. if (s != null) { ours['' + s.seasonNumber] = s.episodes.length }
  635. }
  636. let latest = -1
  637. for (x of (details.seasons != null ? details.seasons : [])) {
  638. if (x != null && x.season_number != null && x.season_number > latest && (x.episode_count == null || x.episode_count > 0)) { latest = x.season_number }
  639. }
  640. let out = []
  641. for (x of (details.seasons != null ? details.seasons : [])) {
  642. if (x != null && x.season_number != null) {
  643. let n = x.season_number
  644. if (n == latest || ours['' + n] == null || (x.episode_count != null && x.episode_count > ours['' + n])) { out.push(n) }
  645. }
  646. }
  647. return out
  648. }
  649. static syncShowDelta = (showId) => {
  650. let show = showsTable.fetch(showId)
  651. if (show == null || show.tmdbId == null || show.type == 'movie') { return syncShow(showId) }
  652. let details = tmdbGet('/tv/' + show.tmdbId + '?append_to_response=external_ids,aggregate_credits')
  653. if (details.failed != null) {
  654. let res = emptyResult()
  655. res.requests = 1
  656. res.errors = 1
  657. res.error = show.title + ': ' + details.failed
  658. return res
  659. }
  660. let r = syncShowPart(showId, details, { seasons = changedSeasonNumbers(details, show) finish = true tvmaze = false })
  661. r.requests = r.requests + 1
  662. r.details = details
  663. return r
  664. }
  665. // ---- the adult backfill (mission 054) ------------------------------------------------------------
  666. // a title still to ask: its adult flag unknown, it has a tmdbId and TMDB never answered "no such title" for it
  667. static needsAdultFlag = (show) => { return show.adult != true && show.adult != false && show.adultCheck == null && show.tmdbId != null }
  668. // the ids of every title the backfill still has to ask, in table order (read once when the backfill starts — so after a
  669. // restart it goes on with what is left)
  670. static adultBackfillQueue = () => {
  671. let out = []
  672. for (s of showsTable.find(null, null)) { if (needsAdultFlag(s)) { out.push(s.id) } }
  673. return out
  674. }
  675. // ONE title: one TMDB details request (adult, poster_path, external ids) + its poster when the file is missing. Answers
  676. // { requests (TMDB API requests: what the pause counts), posters, adult (true / false / null), ids, errors, error, retry
  677. // (a passing failure: no answer, 429, 5xx — ask again later) }. A 404 marks the title `adultCheck` (never asked again).
  678. static backfillTitle = (showId) => {
  679. let out = { requests = 0 posters = 0 adult = null ids = 0 errors = 0 error = '' retry = false }
  680. let show = showsTable.fetch(showId)
  681. if (show == null || !needsAdultFlag(show)) { return out }
  682. let movie = show.type == 'movie'
  683. out.requests = 1
  684. let details = tmdbGet((movie ? '/movie/' : '/tv/') + show.tmdbId + '?append_to_response=external_ids')
  685. if (details.failed != null) {
  686. out.errors = 1
  687. out.error = show.title + ': ' + details.failed
  688. if (details.status == 404) {
  689. show.adultCheck = 'TMDB 404'
  690. showsTable.update(show.id, show)
  691. } else { out.retry = true }
  692. return out
  693. }
  694. let ids = externalIdsFor(show, details.external_ids, !movie, false)
  695. out.ids = ids.filled
  696. out.adult = adultOf(details)
  697. // an ADULT title's poster is never shown publicly → not downloaded (mission 056: ~170 MB of the live data); its flag and
  698. // ids are stored as for any other title
  699. let poster = { saved = 0 failed = null image = show.image tmdbPoster = show.tmdbPoster }
  700. if (out.adult != true) { poster = syncPoster(show, details.poster_path) }
  701. out.posters = poster.saved
  702. if (poster.failed != null) { out.errors = out.errors + 1 out.error = show.title + ': ' + poster.failed }
  703. if (out.adult == null) { show.adultCheck = 'TMDB gave no adult flag' } else { show.adult = out.adult }
  704. show.imdbId = ids.imdbId
  705. show.tvdbId = ids.tvdbId
  706. show.image = poster.image
  707. show.tmdbPoster = poster.tmdbPoster
  708. if (showsTable.update(show.id, show) == null) { out.errors = out.errors + 1 out.error = show.title + ': not updated: ' + showsTable.lastError() }
  709. return out
  710. }
  711. // flush the three tables' index/meta state to disk (after a run, and every few shows)
  712. static persistSync = () => {
  713. showsTable.persist()
  714. seasonsTable.persist()
  715. episodesTable.persist()
  716. return true
  717. }
  718. // totals of a run: the per-show counts added up
  719. static emptyTotals = () => { return { shows = 0 requests = 0 tvmazeRequests = 0 newSeasons = 0 newEpisodes = 0 updatedEpisodes = 0 updatedSeasons = 0 posters = 0 ids = 0 tvmazeEpisodes = 0 tvmazeSeasons = 0 tvmazeFilled = 0 tvmazeSkipped = 0 errors = 0 } }
  720. static addTotals = (t, r) => {
  721. let o = t
  722. o.shows = o.shows + 1
  723. o.requests = o.requests + r.requests
  724. o.tvmazeRequests = o.tvmazeRequests + r.tvmazeRequests
  725. o.ids = o.ids + r.ids
  726. o.newSeasons = o.newSeasons + r.newSeasons
  727. o.newEpisodes = o.newEpisodes + r.newEpisodes
  728. o.updatedEpisodes = o.updatedEpisodes + r.updatedEpisodes
  729. o.updatedSeasons = o.updatedSeasons + r.updatedSeasons
  730. o.posters = o.posters + r.posters
  731. o.tvmazeEpisodes = o.tvmazeEpisodes + r.tvmazeEpisodes
  732. o.tvmazeSeasons = o.tvmazeSeasons + r.tvmazeSeasons
  733. o.tvmazeFilled = o.tvmazeFilled + r.tvmazeFilled
  734. o.tvmazeSkipped = o.tvmazeSkipped + r.tvmazeSkipped
  735. o.errors = o.errors + r.errors
  736. return o
  737. }
  738. static totalsLine = (t) => {
  739. return 'shows=' + t.shows + ' newSeasons=' + t.newSeasons + ' newEpisodes=' + t.newEpisodes + ' updatedEpisodes=' + t.updatedEpisodes
  740. + ' updatedSeasons=' + t.updatedSeasons + ' posters=' + t.posters + ' ids=' + t.ids + ' requests=' + t.requests + ' tvmazeRequests=' + t.tvmazeRequests + ' errors=' + t.errors
  741. + ' tvmazeEpisodes=' + t.tvmazeEpisodes + ' tvmazeSeasons=' + t.tvmazeSeasons + ' tvmazeFilled=' + t.tvmazeFilled + ' tvmazeSkipped=' + t.tvmazeSkipped
  742. }

Branches

Latest commits

  • f83571c3tracker#18 (mission 067): daily sync by change lists — TMDB /tv|movie/changes (since the stored day, paged) + TVmaze /updates/shows → only our changed titles (followed: full step, unfollowed: light step — changed seasons, no TVmaze), full walk on first run / gap > 14 days / failed list; show record refreshed (title, tmdbSummary, tagline, status, genres …; renamed titles re-indexed); summary = the creator's own text (page: summary > tmdbSummary > tvmazeSummary), one-time clear of copied summaries (9,647 on the live copy); gate 261, tests/realdata-018*.mjs, README + STATUSmre
  • 10bb3f93tracker#28 (mission 061): full cast (all seasons, main cast by episodes, guest stars) + crew (created by, directed by, written by, screenplay, story, music) — stored by the details completion, the daily sync, the search import (one details request) and a background credits job (resumes, RSS limit); show page collapsed after 20 with client-side Show all; showBySlug via a slug map; gate 249, tests/realdata-028.mjs, README + STATUSmre
  • 25a50bc4tracker#26 (mission 059): titles from a filmography are completed — on open (skeleton, step-wise face showComplete, no reload) and by the in-app details repair (resumes, TMDB-paced, series in parts); cast from TMDB credits; gate 231, tests/realdata-026.mjs, README + STATUSmre
  • 1704ec45tracker#17 (mission 057): season caret down/up, skeleton rows while a season loads, sessionless showSeasonEpisodes face (no page re-mount), client-only close; gate 214, tests/realdata-057.mjs, README + STATUSmre
  • f2fe3e36mission 056: README + STATUS (merge, fixes, Hybriel 8590df63, real-data check), tests/realdata-056.mjs, tools/check-public-slugs.hlmre
  • f40c250emission 056: re-vendor hybriel master 8590df63 (#121, #122); an adult title's page is Not found for non-followers; gate: leave the page before stopping the servermre
  • 2b7fdd6cmission 056: signed-out header one row on phones ("Log in", nowrap), backfill skips adult titles' posters, gate checksmre
  • 2c53d5efMerge branch 't16-person' (tracker#16 person pages) into main; filmography shows only public titles (054 adult flag), gate race fix (backfill start line)mre
  • c171227emission 054: hide adult/unknown titles from the public lists and the search; in-app adult-flag backfill (TMDB details + poster per title, resumes), gate + real-data proofmre
  • 139fafd8tracker#16: short bio (4 lines, click = all), real-data check script, README + STATUSmre
  • 93be9476tracker#16: person pages /person/<slug> with the filmography fetched from TMDB on the first visit (step by step), gatemre
  • 47a3cae6STATUS: mission 053 merge commit idsmre
  • dcc5eecaMerge branch 't14-search'mre
  • 03edc783Merge branch 't15-tvmaze'mre
  • 71b46345tracker#15: numbering check by date or title, placeholder titles in other languages, docs + real-data proofmre
  • 6bb2daf1tracker#13: homepage (tiles, intro, latest movies/shows), /shows, /movies/page/N, /my/movies; lists cached in memorymre
  • b8bd1157tracker#14: README + STATUS (search, real-data numbers, gate, merge notes)mre
  • 65c694a8tracker#14: search — header magnifier, /search/<text> (in-memory word-prefix index over titles + people), Fetch from web (TMDB search/multi, ours left out), Add = import via syncShow; gate +25 checks, real-data scriptmre
  • 34f2c15btracker#15: TVmaze merge in the sync (gaps only: new episodes/seasons, empty titles/air dates; numbering check), fake TVmaze episodes + gatemre
  • cbdc4ea7tracker#12: link icons TMDB/IMDb/TVDB/TVmaze; sync fills missing ids (TVmaze lookup); movies fetched via /movie/mre