commit e8079ff1cc9b221f95bbc079467ba58701160baf
parent 0869c74d643bf836b70a1969ba42dea01872e0ed
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Sat, 17 Oct 2026 00:09:55 -0400
common: a stored-URL download opens the player's page first (Odysee's CDN serves a file only after a player opened its page, measured 2026-10-17) — storedUrlPageOpen.ts's PageOpener, the real one headless Chromium for ~18 s with a play, injected so tests never launch a browser; opened before the first read and again on a refusal after served bytes; the attempt records pageOpens; the key-count test, no env knob for the gap
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
9 files changed, 320 insertions(+), 15 deletions(-)
diff --git a/common/lib/channelConfigSchema.test.ts b/common/lib/channelConfigSchema.test.ts
@@ -39,7 +39,7 @@ test("one key list: docs = coercions = schema shape, sync-state keys inside it",
assert.deepEqual(Object.keys(CHANNEL_CONFIG_COERCIONS), [...CHANNEL_CONFIG_KEYS]);
assert.deepEqual(Object.keys(channelConfigObjectSchema.shape), [...CHANNEL_CONFIG_KEYS]);
assert.deepEqual(Object.keys(CHANNEL_CONFIG_FIELD_DOCS), [...CHANNEL_CONFIG_KEYS]);
- assert.equal(CHANNEL_CONFIG_KEYS.length, 34);
+ assert.equal(CHANNEL_CONFIG_KEYS.length, 35);
assert.equal(sameKeys, true);
assert.equal(fits, true);
for (const k of CHANNEL_SYNC_STATE_KEYS) assert.ok(CHANNEL_CONFIG_KEYS.includes(k), k);
diff --git a/common/lib/downloadOutcome.ts b/common/lib/downloadOutcome.ts
@@ -87,7 +87,7 @@ export type DownloadAttemptKind =
// the platform's player reads it — sequential Range requests with the page's
// Referer and Origin, no yt-dlp (release 32 R7, ytdlp/storedUrlDownload.ts).
// `ytdlpExitCode` is 0 for a file that came down whole and 1 otherwise;
- // `storedUrl` says from where and why.
+ // `storedUrl` says from where and why. The player's page is opened first.
| "stored-url-ranged";
export type AudioCheckProbeVerdict = "clean" | "partial" | "malformed";
@@ -123,6 +123,9 @@ export type StoredUrlAttempt = {
totalBytes?: number;
resumedFrom?: number;
httpStatus?: number;
+ // How many times the player's page was opened first (Odysee's CDN serves a
+ // file only after a player opened its page; ytdlp/storedUrlPageOpen.ts).
+ pageOpens?: number;
};
// ONE RETRY OF A corrupt-full-source VIDEO (release 30, lane Q), appended to
diff --git a/common/testing/web/fakeRangedCdn.d.mts b/common/testing/web/fakeRangedCdn.d.mts
@@ -17,6 +17,8 @@ export type FakeRangedCdn = {
url(path: string): string;
fetch(url: string | URL, init?: RequestInit): Promise<Response>;
refuseAfterBytes(n: number): void;
+ unlocks: number;
+ unlock(): void;
allowAgain(): void;
close(): Promise<void>;
};
@@ -28,4 +30,6 @@ export function startFakeRangedCdn(opts?: {
corruptOnce?: { path: string; buf: Buffer; from: number; to: number };
ignoreRange?: boolean;
allowUnranged?: boolean;
+ requireUnlock?: boolean;
+ unlockBytes?: number;
}): Promise<FakeRangedCdn>;
diff --git a/common/testing/web/fakeRangedCdn.mjs b/common/testing/web/fakeRangedCdn.mjs
@@ -23,6 +23,9 @@
// the same length) instead: a source that serves malformed audio
// intermittently. Every later read of those bytes is clean.
// - opts.ignoreRange: answer every GET 200 with the whole file.
+// - opts.requireUnlock (2026-10-17's finding): every read answers 429 until
+// `cdn.unlock()` — what a player opening the video's page does — and, with
+// opts.unlockBytes, the unlock lapses after that many bytes are served.
import http from "node:http";
@@ -34,6 +37,7 @@ export async function startFakeRangedCdn(opts = {}) {
let refuseBudget = typeof opts.refuseAfterBytes === "number" ? opts.refuseAfterBytes : null;
const refuseStatus = opts.refuseStatus ?? 429;
const corrupt = opts.corruptOnce ? { ...opts.corruptOnce, used: false } : null;
+ let unlockedBudget = opts.requireUnlock ? 0 : null;
const server = http.createServer((req, res) => {
const u = new URL(req.url ?? "/", "http://x");
@@ -57,6 +61,9 @@ export async function startFakeRangedCdn(opts = {}) {
const file = files[u.pathname];
if (!file) return end(404, { "content-type": "text/plain" }, "not found");
if (!req.headers.referer) return end(403, { "content-type": "text/plain" }, "forbidden");
+ if (unlockedBudget !== null && unlockedBudget <= 0) {
+ return end(429, { "content-type": "text/plain" }, "Too Many Requests");
+ }
if (refuseBudget !== null && refuseBudget <= 0) {
return end(refuseStatus, { "content-type": "text/plain" }, refuseStatus === 429 ? "Too Many Requests" : "Forbidden");
}
@@ -65,12 +72,14 @@ export async function startFakeRangedCdn(opts = {}) {
// [from, to] inclusive, capped by the remaining budget.
let last = to;
if (refuseBudget !== null) last = Math.min(last, from + refuseBudget - 1);
+ if (unlockedBudget !== null && unlockedBudget !== Infinity) last = Math.min(last, from + unlockedBudget - 1);
let body = file.subarray(from, last + 1);
if (corrupt && !corrupt.used && corrupt.path === u.pathname && from < corrupt.to && last >= corrupt.from) {
corrupt.used = true;
body = Buffer.from(corrupt.buf.subarray(from, last + 1));
}
if (refuseBudget !== null) refuseBudget -= body.length;
+ if (unlockedBudget !== null && unlockedBudget !== Infinity) unlockedBudget -= body.length;
rec.bytes = body.length;
const h = { "content-type": "video/mp4", "accept-ranges": "bytes", "content-length": String(body.length), ...headers };
if (status === 206) h["content-range"] = `bytes ${from}-${from + body.length - 1}/${total}`;
@@ -98,6 +107,11 @@ export async function startFakeRangedCdn(opts = {}) {
refuseAfterBytes: (n) => {
refuseBudget = n;
},
+ unlocks: 0,
+ unlock() {
+ this.unlocks++;
+ unlockedBudget = typeof opts.unlockBytes === "number" ? opts.unlockBytes : Infinity;
+ },
allowAgain: () => {
refuseBudget = null;
},
diff --git a/common/ytdlp/downloadOneManaged.ts b/common/ytdlp/downloadOneManaged.ts
@@ -121,6 +121,7 @@ import {
type StoredUrlDownloadDeps,
type StoredUrlDownloadResult,
} from "./storedUrlDownload";
+import { openPlayerPage, PAGE_OPEN_PLATFORMS, type PageOpener } from "./storedUrlPageOpen";
// The `--print` archive marker below implies `--quiet`, which otherwise
@@ -234,6 +235,9 @@ export type ManagedDownloadOpts = {
// between two stored-URL files (default STORED_URL_NEW_FILE_GAP_MS) with
// its sleep. Every production caller passes none.
storedUrlDeps?: StoredUrlDownloadDeps & {
+ // The player-page opener (storedUrlPageOpen.ts). Absent = the real one for
+ // a platform in PAGE_OPEN_PLATFORMS; null = no page open. Tests inject one.
+ openPage?: PageOpener | null;
gapMs?: number;
sleep?: (ms: number, signal?: AbortSignal) => Promise<void>;
};
@@ -1987,16 +1991,6 @@ async function probeShortAudioIn(
// ---------- The stored media URL's whole-file download (release 32 R7) ----------
-// TEST-ONLY: E2E_STORED_URL_GAP_MS replaces the gap between two stored-URL
-// files on a platform (the e2e server's own).
-function storedUrlGapMs(override: number | undefined): number {
- if (override !== undefined) return override;
- const raw = Number(process.env.E2E_STORED_URL_GAP_MS);
- return Number.isFinite(raw) && raw >= 0 && process.env.E2E_STORED_URL_GAP_MS !== undefined
- ? raw
- : STORED_URL_NEW_FILE_GAP_MS;
-}
-
// What a stored-URL download ended as, for the outcome record.
function storedUrlStatus(
r: StoredUrlDownloadResult,
@@ -2061,7 +2055,7 @@ async function runStoredUrlDownload(
const { stored, why, attempts, videoDir, videoId } = ctx;
const deps = opts.storedUrlDeps;
const key = storedUrlGapKey(stored.platform);
- const gapMs = storedUrlGapMs(deps?.gapMs);
+ const gapMs = deps?.gapMs ?? STORED_URL_NEW_FILE_GAP_MS;
const fmt: AudioFormat = opts.audioFormatOverride ?? opts.channelConfig.audioFormat ?? "mp3";
// Keyed on the PAGE url, as every download path's check is.
const audioCheck = audioCheckApplies(opts.channelConfig, opts.videoUrl);
@@ -2112,6 +2106,14 @@ async function runStoredUrlDownload(
channelConfig: opts.channelConfig,
audioFormat: fmt,
audioCheck,
+ // Opened before the first read, and again on a mid-file refusal.
+ pageUrl: opts.videoUrl,
+ openPage:
+ deps?.openPage !== undefined
+ ? deps.openPage
+ : PAGE_OPEN_PLATFORMS.includes(stored.platform)
+ ? openPlayerPage
+ : null,
onLog: opts.onLog,
signal: opts.signal,
...(deps ? { deps } : {}),
@@ -2147,6 +2149,7 @@ async function runStoredUrlDownload(
...(r.totalBytes !== null ? { totalBytes: r.totalBytes } : {}),
...(r.resumedFrom > 0 ? { resumedFrom: r.resumedFrom } : {}),
...(r.httpStatus !== undefined ? { httpStatus: r.httpStatus } : {}),
+ ...(r.pageOpens > 0 ? { pageOpens: r.pageOpens } : {}),
},
});
let { status, failureClass } = storedUrlStatus(r, audioCheck);
diff --git a/common/ytdlp/storedUrlDownload.test.ts b/common/ytdlp/storedUrlDownload.test.ts
@@ -68,6 +68,8 @@ test("the whole file comes down in ranged reads with the player's headers, then
channelConfig: config,
audioFormat: "mp3",
audioCheck: true,
+ pageUrl: PAGE,
+ openPage: null,
onLog: (s) => (log += s),
signal: new AbortController().signal,
deps: { fetch: cdn.fetch, chunkBytes: 16 * 1024, knobs: EVERY_CHUNK },
@@ -111,6 +113,8 @@ test("a 429 mid-file keeps the partial; the next run resumes from its last good
channelConfig: { ...config, keepSourceVideo: true },
audioFormat: "mp3",
audioCheck: true,
+ pageUrl: PAGE,
+ openPage: null,
onLog: () => {},
signal: new AbortController().signal,
deps: { fetch: cdn.fetch, chunkBytes: 8 * 1024, knobs: EVERY_CHUNK },
@@ -153,6 +157,8 @@ test("a 403 stops the same way (the platform backs off)", { skip: !FF }, async (
channelConfig: config,
audioFormat: "mp3",
audioCheck: false,
+ pageUrl: PAGE,
+ openPage: null,
onLog: () => {},
signal: new AbortController().signal,
deps: { fetch: cdn.fetch, chunkBytes: 8 * 1024 },
@@ -184,6 +190,8 @@ test("a malformed chunk is rolled back and read again; the file ends clean", { s
channelConfig: { ...config, keepSourceVideo: true },
audioFormat: "mp3",
audioCheck: true,
+ pageUrl: PAGE,
+ openPage: null,
onLog: (s) => (log += s),
signal: new AbortController().signal,
deps: { fetch: cdn.fetch, chunkBytes: 8 * 1024, knobs: EVERY_CHUNK },
@@ -211,6 +219,8 @@ test("a source malformed at every read: more rollbacks than allowed is failed-co
channelConfig: config,
audioFormat: "mp3",
audioCheck: true,
+ pageUrl: PAGE,
+ openPage: null,
onLog: () => {},
signal: new AbortController().signal,
deps: { fetch: cdn.fetch, chunkBytes: 8 * 1024, knobs: { ...EVERY_CHUNK, maxRollbacks: 1 } },
@@ -239,6 +249,8 @@ test("malformed past every checkpoint: the final probe re-reads once, then corru
channelConfig: config,
audioFormat: "mp3",
audioCheck: true,
+ pageUrl: PAGE,
+ openPage: null,
onLog: (s) => (log += s),
signal: new AbortController().signal,
// No periodic probe at all: only the final one sees the damage.
@@ -274,6 +286,8 @@ test("a partial with no resume state (or another URL's) is discarded, never exte
channelConfig: { ...config, keepSourceVideo: true },
audioFormat: "mp3",
audioCheck: false,
+ pageUrl: PAGE,
+ openPage: null,
onLog: (s) => (log += s),
signal: new AbortController().signal,
deps: { fetch: cdn.fetch, chunkBytes: 32 * 1024 },
@@ -303,6 +317,8 @@ test("a cancel stops between reads with the partial kept", async () => {
channelConfig: config,
audioFormat: "mp3",
audioCheck: false,
+ pageUrl: PAGE,
+ openPage: null,
onLog: () => {},
signal: ac.signal,
deps: {
@@ -336,6 +352,8 @@ test("a CDN that ignores the range: the whole body is the file", { skip: !FF },
channelConfig: { ...config, keepSourceVideo: true },
audioFormat: "mp3",
audioCheck: true,
+ pageUrl: PAGE,
+ openPage: null,
onLog: () => {},
signal: new AbortController().signal,
deps: { fetch: cdn.fetch, chunkBytes: 8 * 1024, knobs: EVERY_CHUNK },
@@ -360,6 +378,8 @@ test("a 404 is an http-error, nothing kept", async () => {
channelConfig: config,
audioFormat: "mp3",
audioCheck: true,
+ pageUrl: PAGE,
+ openPage: null,
onLog: () => {},
signal: new AbortController().signal,
deps: { fetch: cdn.fetch },
@@ -372,3 +392,103 @@ test("a 404 is an http-error, nothing kept", async () => {
await rm(root, { recursive: true, force: true });
}
});
+
+// The orchestrator's finding (2026-10-17): the CDN serves a file only after a
+// player opened its page. The opener is injected; no browser here.
+function fakeOpener(cdn: { unlock(): void }, calls: string[]) {
+ return async ({ pageUrl, cdnHost }: { pageUrl: string; cdnHost: string }) => {
+ calls.push(`${pageUrl} ${cdnHost}`);
+ cdn.unlock();
+ return { ok: true, mediaStatuses: [206] };
+ };
+}
+
+test("the player's page is opened before the first read; a locked CDN then serves the file", { skip: !FF }, async () => {
+ const { root, videoDir } = await setup();
+ const { clean } = await recording(root);
+ const cdn = await startFakeRangedCdn({ files: { [FILE_PATH]: clean }, requireUnlock: true });
+ const calls: string[] = [];
+ try {
+ const r = await storedUrlDownload({
+ paths,
+ videoDir,
+ stored: storedFor(cdn.url(FILE_PATH)),
+ channelConfig: { ...config, keepSourceVideo: true },
+ audioFormat: "mp3",
+ audioCheck: true,
+ pageUrl: PAGE,
+ openPage: fakeOpener(cdn, calls),
+ onLog: () => {},
+ signal: new AbortController().signal,
+ deps: { fetch: cdn.fetch, chunkBytes: 16 * 1024, knobs: EVERY_CHUNK },
+ });
+ assert.equal(r.kind, "ok");
+ assert.equal(r.pageOpens, 1);
+ assert.deepEqual(calls, [`${PAGE} player.odycdn.com`]);
+ assert.ok(cdn.requests.every((q) => q.status === 206), "no read before the open");
+ assert.deepEqual(await readFile(path.join(videoDir, "audio.mp4")), clean);
+ } finally {
+ await cdn.close();
+ await rm(root, { recursive: true, force: true });
+ }
+});
+
+test("an unlock that lapses mid-file: the page is opened again and the read goes on", { skip: !FF }, async () => {
+ const { root, videoDir } = await setup();
+ const { clean } = await recording(root);
+ const cdn = await startFakeRangedCdn({ files: { [FILE_PATH]: clean }, requireUnlock: true, unlockBytes: 24 * 1024 });
+ const calls: string[] = [];
+ try {
+ let log = "";
+ const r = await storedUrlDownload({
+ paths,
+ videoDir,
+ stored: storedFor(cdn.url(FILE_PATH)),
+ channelConfig: { ...config, keepSourceVideo: true },
+ audioFormat: "mp3",
+ audioCheck: true,
+ pageUrl: PAGE,
+ openPage: fakeOpener(cdn, calls),
+ onLog: (s) => (log += s),
+ signal: new AbortController().signal,
+ deps: { fetch: cdn.fetch, chunkBytes: 8 * 1024, knobs: EVERY_CHUNK },
+ });
+ assert.equal(r.kind, "ok", log);
+ assert.ok(r.pageOpens >= 3, `opened ${r.pageOpens}×`);
+ assert.match(log, /HTTP Error 429 at \d+ bytes after \d+ served since the page was opened; opening it again/);
+ assert.deepEqual(await readFile(path.join(videoDir, "audio.mp4")), clean);
+ } finally {
+ await cdn.close();
+ await rm(root, { recursive: true, force: true });
+ }
+});
+
+test("an open that does not unlock: one open, then rate-limited — no loop of opens", async () => {
+ const { root, videoDir } = await setup();
+ const cdn = await startFakeRangedCdn({ files: { [FILE_PATH]: Buffer.alloc(64 * 1024, 3) }, requireUnlock: true });
+ let opens = 0;
+ try {
+ const r = await storedUrlDownload({
+ paths,
+ videoDir,
+ stored: storedFor(cdn.url(FILE_PATH)),
+ channelConfig: config,
+ audioFormat: "mp3",
+ audioCheck: false,
+ pageUrl: PAGE,
+ openPage: async () => {
+ opens++;
+ return { ok: false, mediaStatuses: [429], error: "the player's media requests were not served" };
+ },
+ onLog: () => {},
+ signal: new AbortController().signal,
+ deps: { fetch: cdn.fetch, chunkBytes: 8 * 1024 },
+ });
+ assert.equal(r.kind, "rate-limited");
+ assert.equal(opens, 1);
+ assert.equal(r.pageOpens, 1);
+ } finally {
+ await cdn.close();
+ await rm(root, { recursive: true, force: true });
+ }
+});
diff --git a/common/ytdlp/storedUrlDownload.ts b/common/ytdlp/storedUrlDownload.ts
@@ -47,6 +47,7 @@ import { resolveKnobs, type CheckpointRecord, type Knobs } from "./audioCheckedD
import { backoffInterval, formatInterval, recoverInterval, type CadenceParams } from "./audioCheckCadence";
import type { StreamVerdict } from "./ffmpegStreamClassify";
import { probeAudioStream } from "./ffmpegStreamProbe";
+import type { PageOpener } from "./storedUrlPageOpen";
// One ranged read. The player asks for a few MiB at a time; 8 MiB keeps a 3 GB
// file to ~400 requests of one connection each, one after another.
@@ -84,6 +85,8 @@ export type StoredUrlDownloadResult = {
finalProbeVerdict?: StreamVerdict;
// The container's file name in the video dir (`audio.<ext>`).
container: string;
+ // How many times the player's page was opened (storedUrlPageOpen.ts).
+ pageOpens: number;
};
export type StoredUrlDownloadDeps = {
@@ -105,6 +108,13 @@ export type StoredUrlDownloadOpts = {
audioFormat: AudioFormat;
// audioCheckApplies(config, PAGE url) — decided by the caller.
audioCheck: boolean;
+ // THE PLAYER'S PAGE IS OPENED FIRST (storedUrlPageOpen.ts): Odysee's CDN
+ // serves a file only after a player opened its page. Null: no page open
+ // (a platform that does not need one). Opened before the first read of a
+ // run, and again on a refusal that follows reads it served — given up when
+ // a refusal comes straight after an open.
+ pageUrl: string;
+ openPage: PageOpener | null;
onLog: (s: string) => void;
signal: AbortSignal;
deps?: StoredUrlDownloadDeps;
@@ -225,6 +235,19 @@ export async function storedUrlDownload(
recoverAfterClean: knobs.recoverAfterClean,
};
+ // ---- The player's page ----
+ let pageOpens = 0;
+ // Bytes read since the last open: a refusal with none means the open did
+ // not unlock the file, and a second open will not either.
+ let bytesSinceOpen = 0;
+ const openPage = async (): Promise<void> => {
+ if (!opts.openPage || signal.aborted) return;
+ pageOpens++;
+ bytesSinceOpen = 0;
+ const r = await opts.openPage({ pageUrl: opts.pageUrl, cdnHost: stored.host, signal, onLog });
+ if (!r.ok) onLog(`The page open did not show the player served (${r.error ?? "no media request"}); reading anyway.\n`);
+ };
+
// ---- Resume, or start clean ----
let total: number | null = null;
let offset = 0;
@@ -277,6 +300,7 @@ export async function storedUrlDownload(
restarts,
...(finalProbeVerdict ? { finalProbeVerdict } : {}),
container: names.container,
+ pageOpens,
});
// A stop that keeps the partial for a resume: the good bytes recorded.
@@ -400,6 +424,8 @@ export async function storedUrlDownload(
`(Referer ${stored.referer}); audio check ${opts.audioCheck ? "on" : "off"}.\n`,
);
+ await openPage();
+
// ---- The loop: one ranged read at a time ----
for (;;) {
if (signal.aborted) return keepPartial("aborted", { error: "cancelled" });
@@ -425,6 +451,16 @@ export async function storedUrlDownload(
}
if (res.status === 429 || res.status === 403) {
await res.body?.cancel().catch(() => {});
+ // The unlock may have lapsed: open the page again and ask once more —
+ // unless nothing was read since the last open.
+ if (opts.openPage && bytesSinceOpen > 0 && !signal.aborted) {
+ onLog(
+ `HTTP Error ${res.status} at ${offset} bytes after ${bytesSinceOpen} served since the page was opened; ` +
+ `opening it again.\n`,
+ );
+ await openPage();
+ continue;
+ }
onLog(
`HTTP Error ${res.status}: ${res.status === 429 ? "Too Many Requests" : "Forbidden"} — the CDN refused ` +
`the read at ${offset} bytes; the partial is kept for a resume.\n`,
@@ -478,6 +514,7 @@ export async function storedUrlDownload(
if (signal.aborted) break;
await fh.write(chunk);
offset += chunk.byteLength;
+ bytesSinceOpen += chunk.byteLength;
progress();
}
}
diff --git a/common/ytdlp/storedUrlManaged.test.ts b/common/ytdlp/storedUrlManaged.test.ts
@@ -88,7 +88,7 @@ function run(f: Fixture, over: Partial<ManagedDownloadOpts> = {}, log: { s: stri
videoUrl: PAGE,
onLog: (s) => (log.s += s),
signal: new AbortController().signal,
- storedUrlDeps: { fetch: f.cdn.fetch, chunkBytes: 16 * 1024, knobs: FAST, gapMs: 0 },
+ storedUrlDeps: { fetch: f.cdn.fetch, chunkBytes: 16 * 1024, knobs: FAST, gapMs: 0, openPage: null },
...over,
});
}
@@ -241,7 +241,7 @@ test("one new file per rest: the second stored-URL download on a platform waits
waits.push(ms);
clearPlatformGaps();
};
- const deps = { fetch: f.cdn.fetch, chunkBytes: 16 * 1024, knobs: FAST, gapMs: 60_000, sleep };
+ const deps = { fetch: f.cdn.fetch, chunkBytes: 16 * 1024, knobs: FAST, gapMs: 60_000, sleep, openPage: null };
const log = { s: "" };
await run(f, { storedUrl: "only", storedUrlDeps: deps }, log);
assert.deepEqual(waits, [], "the first asks no gap");
@@ -282,3 +282,29 @@ test("a corrupt full source refetched from the stored URL: clean, the kept file
await done(f);
}
});
+
+test("the managed download opens the player's page (the injected opener) and records it", { skip: !FF }, async () => {
+ const f = await fixture({ cdn: { requireUnlock: true } });
+ try {
+ const pages: string[] = [];
+ const record = await run(f, {
+ storedUrl: "only",
+ storedUrlDeps: {
+ fetch: f.cdn.fetch,
+ chunkBytes: 16 * 1024,
+ knobs: FAST,
+ gapMs: 0,
+ openPage: async ({ pageUrl }) => {
+ pages.push(pageUrl);
+ f.cdn.unlock();
+ return { ok: true, mediaStatuses: [206] };
+ },
+ },
+ });
+ assert.equal(record.status, "ok-audio-checked");
+ assert.deepEqual(pages, [PAGE], "the PAGE url, once");
+ assert.equal(storedUrlAttemptOf(record)?.pageOpens, 1);
+ } finally {
+ await done(f);
+ }
+});
diff --git a/common/ytdlp/storedUrlPageOpen.ts b/common/ytdlp/storedUrlPageOpen.ts
@@ -0,0 +1,98 @@
+// OPEN THE PLAYER'S PAGE FIRST (release 32 R7, the orchestrator's live finding
+// of 2026-10-17): Odysee's CDN serves a stream's original file to a connection
+// only AFTER a player has opened that video's page. Cold ranged reads with the
+// player's headers got 429 (four windows, 20–40 minutes apart); right after a
+// headless Chromium page view of the same video — the odysee.com page, ~10 s,
+// play, ~8 s — the player's own requests got 200/206 and the ranged cut landed.
+// How long the unlock lasts is unknown.
+//
+// So a stored-URL download opens the page before its first ranged read, and
+// once more on a refusal mid-file before giving up (storedUrlDownload.ts). The
+// opener is a named, injected step: tests pass a fake (never a browser), the
+// managed download passes `openPlayerPage` for a platform in
+// PAGE_OPEN_PLATFORMS. No cookies, a fresh context each time.
+
+import { importPlaywright } from "../social/playwrightRuntime";
+
+export const PAGE_OPEN_PLATFORMS: readonly string[] = ["odysee"];
+
+// What the measured open did: let the page load, press play, let it play.
+export const PAGE_OPEN_SETTLE_MS = 10_000;
+export const PAGE_OPEN_PLAY_MS = 8_000;
+export const PAGE_OPEN_GOTO_TIMEOUT_MS = 45_000;
+
+export type PageOpenResult = {
+ ok: boolean;
+ // The statuses of the player's own requests of the platform's CDN, in order.
+ mediaStatuses: number[];
+ error?: string;
+};
+
+export type PageOpener = (opts: {
+ pageUrl: string;
+ // The CDN host whose responses say whether the player was served.
+ cdnHost: string;
+ signal: AbortSignal;
+ onLog: (s: string) => void;
+}) => Promise<PageOpenResult>;
+
+function abortableWait(ms: number, signal: AbortSignal): Promise<void> {
+ return new Promise((resolve) => {
+ if (signal.aborted) return resolve();
+ const t = setTimeout(() => {
+ signal.removeEventListener("abort", onAbort);
+ resolve();
+ }, ms);
+ const onAbort = () => {
+ clearTimeout(t);
+ resolve();
+ };
+ signal.addEventListener("abort", onAbort, { once: true });
+ });
+}
+
+// The real opener: headless Chromium (the workspace's Playwright), the video's
+// page, a click on play, a few seconds of playing. Never throws: a page that
+// could not be opened is `ok: false` with the reason, and the caller reads on
+// regardless (the CDN may serve it anyway).
+export const openPlayerPage: PageOpener = async ({ pageUrl, cdnHost, signal, onLog }) => {
+ const mediaStatuses: number[] = [];
+ let browser: { close: () => Promise<void> } | null = null;
+ try {
+ const { chromium } = await importPlaywright();
+ const b = await chromium.launch({ headless: true });
+ browser = b;
+ const ctx = await b.newContext({});
+ const page = await ctx.newPage();
+ page.on("response", ((r: { url: () => string; status: () => number }) => {
+ try {
+ if (new URL(r.url()).hostname === cdnHost) mediaStatuses.push(r.status());
+ } catch {
+ /* not a URL */
+ }
+ }) as never);
+ onLog(`Opening the player's page first (${pageUrl}).\n`);
+ await page.goto(pageUrl, { waitUntil: "domcontentloaded", timeout: PAGE_OPEN_GOTO_TIMEOUT_MS }).catch(() => {});
+ await abortableWait(PAGE_OPEN_SETTLE_MS, signal);
+ if (!signal.aborted) {
+ await page
+ .evaluate(
+ `(() => { const b = document.querySelector(".vjs-big-play-button, [aria-label*='Play']"); if (b) { b.click(); return; } const v = document.querySelector("video"); if (v) { v.muted = true; v.play().catch(() => {}); } })()`,
+ )
+ .catch(() => {});
+ await abortableWait(PAGE_OPEN_PLAY_MS, signal);
+ }
+ const served = mediaStatuses.some((s) => s === 200 || s === 206);
+ onLog(
+ `The player's page was open ${Math.round((PAGE_OPEN_SETTLE_MS + PAGE_OPEN_PLAY_MS) / 1000)}s; ` +
+ `its media requests answered ${mediaStatuses.length ? mediaStatuses.join(",") : "nothing"}.\n`,
+ );
+ return { ok: served, mediaStatuses, ...(served ? {} : { error: "the player's media requests were not served" }) };
+ } catch (err) {
+ const error = (err as Error).message;
+ onLog(`Could not open the player's page: ${error}\n`);
+ return { ok: false, mediaStatuses, error };
+ } finally {
+ await browser?.close().catch(() => {});
+ }
+};