// THE PER-PLATFORM SEEK RULE, in one place (lane clip-kit): which query parameter a platform's own watch page takes // to start at a second, in what form, and how sure this repository is of it -- and how long a platform keeps a // stream's VOD. Two writers read it, each with its own policy, and neither changed what it writes: // // common/lib/momentUrl.ts platformMomentUrl the archive, the MCP and publishing: only a `verified` parameter is // written; any other platform gets its bare watch page. // common/lib/clips/assist.mjs watchUrlAt the clip finder's citeUrl, the share line, the link policy and umtool's // per-clip QR: every platform's parameter here, `t=` for an unknown // host. // // They disagree on purpose where the rule is unsure: Rumble and Kick. // rumble `?start=`: what the share line and the link policy have written since release 36. momentUrl.ts says // the watch page has "no dependable start param", so it does not write it. // kick NOT CONFIRMED. Nothing in this repository (code, docs or tests) shows that a kick.com VOD page honours // a time parameter. watchUrlAt writes `?t=` as it does for any host it does not know; at worst the // page opens at its start. Kick also deletes free-tier VODs after about 30 days (VOD_RETENTION_DAYS). // Confirm one by hand, then set `verified: true` here and every writer follows. // // Plain ESM, no imports: the TS app code and the plain-node build tools read the same table. /** * @typedef {{ key: string, form: "seconds" | "seconds-s" | "hms", verified: boolean, why: string }} SeekRule */ /** @type {Readonly>} */ export const PLATFORM_SEEK = Object.freeze({ youtube: Object.freeze({ key: "t", form: "seconds-s", verified: true, why: "YouTube's watch page: t=s" }), twitch: Object.freeze({ key: "t", form: "hms", verified: true, why: "Twitch's VOD page: t=hms" }), odysee: Object.freeze({ key: "t", form: "seconds", verified: true, why: "Odysee's page: t=" }), rumble: Object.freeze({ key: "start", form: "seconds", verified: false, why: "Rumble's page: start=, written by the share line; momentUrl.ts finds no dependable start param" }), kick: Object.freeze({ key: "t", form: "seconds", verified: false, why: "Kick's VOD page: no time parameter is confirmed in this repository; t= is the generic guess" }), }); /** A host this rule does not know: the generic guess (watchUrlAt writes it; momentUrl.ts does not). */ export const UNKNOWN_SEEK = Object.freeze({ key: "t", form: "seconds", verified: false, why: "an unknown platform: t= is a guess" }); /** * How long (days) a platform keeps a stream's VOD before it is deleted. Only platforms whose VODs expire; best-effort * thresholds (common/lib/vodExpiry.ts explains each), not promises. */ export const VOD_RETENTION_DAYS = Object.freeze({ kick: 30, twitch: 14 }); /** The platform a watch page's host belongs to, among the ones the rule knows; null for any other. */ export function seekPlatformOfUrl(url) { let host; try { host = new URL(String(url)).hostname.toLowerCase().replace(/^(?:www|m)\./, ""); } catch { return null; } if (host === "youtube.com" || host === "youtu.be" || host.endsWith(".youtube.com")) return "youtube"; if (host === "twitch.tv" || host.endsWith(".twitch.tv")) return "twitch"; if (host === "rumble.com") return "rumble"; if (host === "kick.com" || host.endsWith(".kick.com")) return "kick"; if (host === "odysee.com") return "odysee"; return null; } /** A platform's rule (`platform` a Platform id), else the generic guess. */ export const seekRuleOf = (platform) => (platform && Object.prototype.hasOwnProperty.call(PLATFORM_SEEK, platform) ? PLATFORM_SEEK[platform] : UNKNOWN_SEEK); /** A second written in a rule's form. */ export function seekValue(rule, seconds) { const s = Math.max(0, Math.floor(Number(seconds) || 0)); if (rule.form === "seconds-s") return `${s}s`; if (rule.form === "hms") return `${Math.floor(s / 3600)}h${Math.floor((s % 3600) / 60)}m${s % 60}s`; return String(s); }