web: watch-party layer for the Discord Activity

party.js is inert unless a transport attaches. The host publishes route changes
and playback snapshots; viewers mirror the route, load the host's stream without
scraping and follow its clock. Also: forceProxy playback, bug-tv-tmdb/bug-tv-img
meta overrides, relative API bases (/tv), trailer hidden in party mode, and the
web package no longer ships web/test.
This commit is contained in:
4DBug committed 2026-10-27 10:00:34 -05:00
1 parent 5ab3683f44
commit ee0e36d2c7
14 files changed
+800 -17

No files matched your search

+10 -3
View File
@@ -11,15 +11,22 @@
import { getTmdbKey } from './config.js';
import { safe } from './util.js';
const API = 'https://api.themoviedb.org/3';
export const IMG_BASE = 'https://image.tmdb.org/t/p/';
// <meta name="bug-tv-tmdb"> / <meta name="bug-tv-img"> override the bases (the Discord Activity
// maps them to /tmdb/3 and /img/t/p/). Relative values resolve against the page origin.
function metaBase(name) {
const el = typeof document !== 'undefined' && document.querySelector(`meta[name="${name}"]`);
const v = el && (el.getAttribute('content') || '').trim();
return v && !/^@.*@$/.test(v) ? v : '';
}
const API = (metaBase('bug-tv-tmdb') || 'https://api.themoviedb.org/3').replace(/\/+$/, '');
export const IMG_BASE = (metaBase('bug-tv-img') || 'https://image.tmdb.org/t/p/').replace(/\/*$/, '/');
const SESSION_PREFIX = 'bug-tv.tmdb.';
const SESSION_TTL = 30 * 60 * 1000;
const mem = new Map();
function buildUrl(path, params) {
const url = new URL(API + path);
const url = new URL(API + path, typeof location !== 'undefined' ? location.href : undefined);
url.searchParams.set('api_key', getTmdbKey());
if (!params || params.language === undefined) url.searchParams.set('language', 'en-US');
for (const [k, v] of Object.entries(params || {})) {