gitoriaLog in with ident

tracker

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit2fa9d9972fa9d997tracker#9: TMDB sync (followed shows: seasons, episodes, posters), tools/sync-tmdb.hl + daily run 04:00 UTC, fake TMDB in gatemre2fa9d997/tests/faketmdb.mjs

3.2 KB

  1. // tests/faketmdb.mjs — A FAKE TMDB for the gate (tracker.worldapi.org#9): a tiny local HTTP server that answers
  2. // the three calls tmdbsync.hl makes, from fixed JSON — no real TMDB call ever happens in the gate. The app is
  3. // pointed at it with TMDB_BASE_URL=<base>/3 and TMDB_IMAGE_URL=<base>/t/p.
  4. //
  5. // GET /3/tv/<id> details (shows[id] minus the episodes)
  6. // GET /3/tv/<id>?append_to_response=season/1,… the same + "season/<n>" = { name, overview, air_date, episodes }
  7. // GET /t/p/w342/<file>.png a 1×1 png
  8. //
  9. // `fake.shows` is mutable (the gate adds an episode before the in-app run), `fake.delayMs` slows every answer
  10. // down, `fake.requests` records every request (path, authorization) so the gate can prove what was asked.
  11. import http from 'node:http';
  12. export const PNG = Buffer.from('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==', 'base64');
  13. export async function startFakeTmdb({ port, shows }) {
  14. const fake = { shows, delayMs: 0, requests: [], base: `http://127.0.0.1:${port}` };
  15. const details = (s) => ({
  16. id: s.id, name: s.name, overview: s.overview, status: s.status, poster_path: s.poster_path,
  17. number_of_seasons: s.seasons.filter(x => x.season_number > 0).length,
  18. number_of_episodes: s.seasons.filter(x => x.season_number > 0).reduce((a, x) => a + x.episodes.length, 0),
  19. seasons: s.seasons.map(x => ({ id: x.id, season_number: x.season_number, name: x.name, overview: x.overview || '', air_date: x.air_date, episode_count: x.episodes.length })),
  20. });
  21. const server = http.createServer((req, res) => {
  22. const url = new URL(req.url, fake.base);
  23. fake.requests.push({ path: url.pathname + url.search, authorization: req.headers['authorization'] || null });
  24. const answer = () => {
  25. let m = url.pathname.match(/^\/3\/tv\/(\d+)$/);
  26. if (m && fake.shows[m[1]]) {
  27. const s = fake.shows[m[1]];
  28. const out = details(s);
  29. for (const part of (url.searchParams.get('append_to_response') || '').split(',').filter(Boolean)) {
  30. const sm = part.match(/^season\/(\d+)$/);
  31. const season = sm && s.seasons.find(x => x.season_number === Number(sm[1]));
  32. if (season) out[part] = { id: season.id, season_number: season.season_number, name: season.name, overview: season.overview || '', air_date: season.air_date,
  33. episodes: season.episodes.map(e => ({ id: e.id, season_number: season.season_number, episode_number: e.episode_number, name: e.name, overview: e.overview || '', air_date: e.air_date })) };
  34. }
  35. res.writeHead(200, { 'content-type': 'application/json' });
  36. return res.end(JSON.stringify(out));
  37. }
  38. if (/^\/t\/p\/w342\/[a-z0-9]+\.png$/.test(url.pathname)) { res.writeHead(200, { 'content-type': 'image/png' }); return res.end(PNG); }
  39. res.writeHead(404, { 'content-type': 'application/json' });
  40. res.end('{"status_code":34,"status_message":"The resource you requested could not be found."}');
  41. };
  42. if (fake.delayMs > 0) setTimeout(answer, fake.delayMs); else answer();
  43. });
  44. await new Promise((ok, fail) => { server.once('error', fail); server.listen(port, '127.0.0.1', ok); });
  45. fake.stop = () => new Promise(r => server.close(() => r()));
  46. return fake;
  47. }

Branches

Latest commits

  • 2fa9d997tracker#9: TMDB sync (followed shows: seasons, episodes, posters), tools/sync-tmdb.hl + daily run 04:00 UTC, fake TMDB in gatemre
  • 49e1f61edeploy.sh: back up live storage/.sessions/.env before every deploy (newest 5 kept)mre
  • 54070a4etracker#8: /my/unwatched + /my/schedule (301 from old), S01E01, title (year), 1 episode, watched-set lookup (unwatched 15s -> 1s)mre
  • 3251488atracker#7: /my/shows (followed shows, newest follow first, poster, title, last watched SxxEyy); gate can take screenshots (TRACKER_GATE_SHOTS)mre
  • 44b7d9f9tracker#6: /schedule — upcoming episodes of followed shows, soonest firstmre
  • 91c9fc8ctracker#5: /unwatched — unwatched released episodes of followed shows, newest firstmre
  • a97c0295tracker#4: show page /shows/:slug (header, seasons, episodes, watch checks) + tools/relink-episode-seasons.hlmre
  • 05f407c5tracker: no border on any button except inverted ones (Log out, ident status and identities too); header brand weight 100mre
  • 17375427tracker#2: tools/migrate.hl + tools/verify.hl — old MongoDB data into mpackdb with new idsmre
  • 31aac936tracker#3: no border on the header and on filled buttons; inverted buttons keep theirsmre
  • 2ad9d29ctracker#1: login exactly like calendar (identity selector in the header, empty homepage)mre
  • 3691e176tracker#1: empty tracker with the ident login (state of 2026-09-27)mre