commit 7580213d653ac8cea827966d4c3f5b3328febcc3
parent 4dab1d7b597b6e1663b261efed0b147e429b51ae
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Wed, 11 Nov 2026 12:15:55 -0500
archives: an archive is untrusted input -- a record's page must be its channel's video platform's, and every document is read on the archive's own origin (demo epic D1 review, blocker 2a-b)
A remote-only channel's page URL (an archive record's webpageUrl, or one an
ask carries for it) was accepted on ^https?:// alone, and a manifest could be
any URL the archive's corpus.json named: a connected archive could make the
editor fetch localhost, a private address or any host, outside every
platform's paced queue. Now (recordPageRefusal) the URL must be http(s) with
no credentials, its host a video platform's (youtube, rumble, odysee, twitch,
kick, archive.org, bitchute -- never xenforo, which is a path on any host),
and that the channel's own platform; anything else is unresolved (fetch-windows)
or a 400 (fetch-window) with one sentence, before any request; the chain only
sends such a URL. Manifests, shards and every follow-up document are read on
the archive's origin only: a manifest named elsewhere is not followed, and a
redirect is followed (up to three) only on the same scheme, host and port
(fetchOnOrigin; the probe, the plain reader and the disk cache).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat:
11 files changed, 209 insertions(+), 13 deletions(-)
diff --git a/common/controller/remoteOnlyChannel.ts b/common/controller/remoteOnlyChannel.ts
@@ -30,7 +30,7 @@ import type { Paths } from "../lib/paths";
import type { ChannelConfig } from "../lib/channelConfig";
import { PLATFORM_VALUES, type Platform } from "../lib/platform";
import { corpusUrl, manifestUrl, pageUrl } from "../lib/archive/contract";
-import { WHOLE_RECORDING_REFUSED, archiveOriginOf, type ConnectedArchive } from "../lib/remoteArchives";
+import { WHOLE_RECORDING_REFUSED, archiveOriginOf, sameOrigin, type ConnectedArchive } from "../lib/remoteArchives";
import { archiveChannelFacts, plainGetJson, type ArchiveChannelFacts, type GetJson } from "../lib/remoteArchives-server";
import { createChannel, readChannelConfig } from "./channels";
@@ -95,7 +95,10 @@ export async function archiveRecordOf(origin: string, slug: string, id: string,
const getJson = deps.getJson ?? plainGetJson();
const corpus = (await getJson(corpusUrl(base)).catch(() => null)) as { channels?: { slug?: string; manifests?: { transcripts?: string } }[] } | null;
const entry = corpus?.channels?.find((c) => c?.slug === slug);
- const at = entry?.manifests?.transcripts ?? manifestUrl("transcripts", slug, base);
+ // Only the archive's own origin is read (an archive is untrusted input): a
+ // manifest its corpus.json names elsewhere is not followed.
+ const named = entry?.manifests?.transcripts;
+ const at = typeof named === "string" && sameOrigin(named, base) ? named : manifestUrl("transcripts", slug, base);
const manifest = (await getJson(at).catch(() => null)) as { slugToPage?: Record<string, number> } | null;
const page = manifest?.slugToPage?.[id] ?? manifest?.slugToPage?.[`${slug}/${id}`];
if (typeof page !== "number") return null;
diff --git a/common/lib/archiveCache-server.ts b/common/lib/archiveCache-server.ts
@@ -39,7 +39,7 @@ import { mkdir, readdir, readFile, rm, stat, utimes } from "node:fs/promises";
import path from "node:path";
import { getPaths } from "./paths";
import { writeFileAtomic } from "./atomicFile.mjs";
-import { plainGetJson, type FetchLike, type GetJson } from "./remoteArchives-server";
+import { OffOriginError, fetchOnOrigin, plainGetJson, type FetchLike, type GetJson } from "./remoteArchives-server";
export const CORPUS_TTL_MS = 10 * 60_000;
export const GAP_MS = 250;
@@ -193,8 +193,11 @@ export class ArchiveDiskCache {
if (meta?.lastModified) headers["if-modified-since"] = meta.lastModified;
let res: Response;
try {
- res = await this.paced(() => this.doFetch(url, { ...(init?.signal ? { signal: init.signal } : {}), headers }));
+ // On the archive's own origin only: a redirect elsewhere is refused (fetchOnOrigin).
+ res = await this.paced(() => fetchOnOrigin(this.doFetch, url, { ...(init?.signal ? { signal: init.signal } : {}), headers }));
} catch (e) {
+ // An off-origin redirect is a refusal, never an outage: nothing on disk answers it.
+ if (e instanceof OffOriginError) throw e;
// The archive did not answer: what is on disk is the answer.
if (meta) return this.fromDisk(file, meta, base, corpus);
throw e;
diff --git a/common/lib/archiveTrust.test.ts b/common/lib/archiveTrust.test.ts
@@ -0,0 +1,62 @@
+import { test } from "node:test";
+import assert from "node:assert/strict";
+import { recordPageRefusal, sameOrigin } from "./remoteArchives";
+import { fetchOnOrigin, OffOriginError, plainGetJson, type FetchLike } from "./remoteArchives-server";
+import { detectPlatform } from "./detectPlatform.mjs";
+import { archiveRecordOf } from "../controller/remoteOnlyChannel";
+
+// demo epic D1 review, blocker 2: an archive is untrusted input.
+
+test("a record's page URL: only a video platform's host, the channel's own platform, no credentials", () => {
+ const r = (u: string, p: string | null = null) => recordPageRefusal(u, p, detectPlatform);
+ assert.equal(r("https://www.youtube.com/watch?v=a1", "youtube"), null);
+ assert.equal(r("https://rumble.com/v9-x.html"), null);
+ assert.match(r("http://127.0.0.1:3001/api/ops/settings")!, /127\.0\.0\.1:3001 is not a video platform's host/);
+ assert.match(r("http://10.0.0.5/threads/123/")!, /is not a video platform's host/, "xenforo is a path on any host: never a window's page");
+ assert.match(r("https://evil.example/watch?v=a1")!, /is not a video platform's host/);
+ assert.match(r("https://rumble.com/v9-x.html", "youtube")!, /rumble\.com is rumble, and the channel is youtube's/);
+ assert.match(r("https://user:pw@www.youtube.com/watch?v=a1")!, /is not a page URL a window is fetched from/);
+ assert.match(r("file:///etc/passwd")!, /is not a page URL a window is fetched from/);
+ assert.equal(r(undefined), "no page URL");
+});
+
+function redirecting(map: Record<string, { status: number; location?: string; body?: unknown }>): FetchLike & { asked: string[] } {
+ const asked: string[] = [];
+ const f = (async (url: string) => {
+ asked.push(url);
+ const d = map[url];
+ if (!d) return new Response("nope", { status: 404 });
+ return new Response(d.body === undefined ? null : JSON.stringify(d.body), { status: d.status, headers: d.location ? { location: d.location } : {} });
+ }) as FetchLike & { asked: string[] };
+ f.asked = asked;
+ return f;
+}
+
+test("an archive's documents are read on its own origin: a same-origin redirect is followed, one elsewhere refused unfollowed", async () => {
+ const f = redirecting({
+ "https://stub.test/corpus.json": { status: 301, location: "/v2/corpus.json" },
+ "https://stub.test/v2/corpus.json": { status: 200, body: { ok: 1 } },
+ "https://stub.test/transcripts/a/manifest.json": { status: 302, location: "http://127.0.0.1:3001/api/ops/settings" },
+ });
+ assert.deepEqual(await plainGetJson(f)("https://stub.test/corpus.json"), { ok: 1 });
+ await assert.rejects(fetchOnOrigin(f, "https://stub.test/transcripts/a/manifest.json"), (e: unknown) => e instanceof OffOriginError && /redirects to http:\/\/127\.0\.0\.1:3001/.test((e as Error).message));
+ assert.equal(f.asked.includes("http://127.0.0.1:3001/api/ops/settings"), false);
+ assert.equal(sameOrigin("https://stub.test:443/x", "https://stub.test"), true);
+ assert.equal(sameOrigin("https://stub.test:8443/x", "https://stub.test"), false);
+});
+
+test("a manifest the corpus names on another origin is not followed: the archive's own is read", async () => {
+ const asked: string[] = [];
+ const docs: Record<string, unknown> = {
+ "https://stub.test/corpus.json": { channels: [{ slug: "a", manifests: { transcripts: "http://192.168.1.1/admin.json" } }] },
+ "https://stub.test/transcripts/a/manifest.json": { slugToPage: { v1: 0 } },
+ "https://stub.test/transcripts/a/page-0000.json": [{ id: "v1", webpageUrl: "https://www.youtube.com/watch?v=v1" }],
+ };
+ const getJson = async (url: string) => {
+ asked.push(url);
+ if (!(url in docs)) throw new Error("404");
+ return docs[url];
+ };
+ assert.equal((await archiveRecordOf("https://stub.test", "a", "v1", { getJson }))?.webpageUrl, "https://www.youtube.com/watch?v=v1");
+ assert.equal(asked.some((u) => u.includes("192.168")), false);
+});
diff --git a/common/lib/remoteArchives-server.ts b/common/lib/remoteArchives-server.ts
@@ -6,7 +6,7 @@
// One request per probe, sequential, never in a loop. The fetch is injectable
// (every test passes a fake; no test calls a real site).
-import { archiveOriginOf } from "./remoteArchives";
+import { archiveOriginOf, sameOrigin } from "./remoteArchives";
import { corpusUrl, manifestUrl, pageUrl } from "./archive/contract";
import { detectPlatform } from "./detectPlatform.mjs";
@@ -44,6 +44,34 @@ export class ArchiveProbeError extends Error {
}
const PROBE_TIMEOUT_MS = 15_000;
+const MAX_REDIRECTS = 3;
+
+export class OffOriginError extends Error {
+ constructor(message: string) {
+ super(message);
+ this.name = "OffOriginError";
+ }
+}
+
+/**
+ * A GET that stays on `url`'s own origin (demo epic D1 review, blocker 2): a
+ * redirect is followed (up to three) only to the same scheme, host and port;
+ * one that leaves it is refused before it is followed. An archive is someone
+ * else's server, and nothing it answers may send this machine elsewhere.
+ */
+export async function fetchOnOrigin(doFetch: FetchLike, url: string, init: { signal?: AbortSignal; headers?: Record<string, string> } = {}): Promise<Response> {
+ let at = url;
+ for (let hop = 0; ; hop++) {
+ const res = await doFetch(at, { ...init, redirect: "manual" } as never);
+ if (res.status < 300 || res.status > 399 || res.status === 304) return res;
+ const location = res.headers.get("location");
+ if (!location) return res;
+ const next = new URL(location, at).href;
+ if (!sameOrigin(next, url)) throw new OffOriginError(`${at} redirects to ${new URL(next).origin}: an archive's documents are read from its own origin only`);
+ if (hop >= MAX_REDIRECTS) throw new OffOriginError(`${url} redirects more than ${MAX_REDIRECTS} times`);
+ at = next;
+ }
+}
const str = (v: unknown): string | null => (typeof v === "string" && v.trim() ? v.trim() : null);
const num = (v: unknown): number | null => (typeof v === "number" && Number.isFinite(v) ? v : null);
@@ -61,8 +89,9 @@ export async function probeArchive(rawOrigin: string, opts: { fetch?: FetchLike;
const url = `${origin}/corpus.json`;
let res: Response;
try {
- res = await doFetch(url, { signal: AbortSignal.timeout(opts.timeoutMs ?? PROBE_TIMEOUT_MS), headers: { accept: "application/json" } });
+ res = await fetchOnOrigin(doFetch, url, { signal: AbortSignal.timeout(opts.timeoutMs ?? PROBE_TIMEOUT_MS), headers: { accept: "application/json" } });
} catch (e) {
+ if (e instanceof OffOriginError) throw new ArchiveProbeError(e.message, 502);
throw new ArchiveProbeError(`${url} did not answer: ${(e as Error).message}`, 502);
}
if (!res.ok) throw new ArchiveProbeError(`${url} answered HTTP ${res.status} — is ${origin} a published archive?`, 502);
@@ -152,7 +181,7 @@ export type GetJson = (url: string) => Promise<unknown>;
export function plainGetJson(doFetch: FetchLike = fetch as unknown as FetchLike): GetJson {
return async (url) => {
- const res = await doFetch(url, { signal: AbortSignal.timeout(PROBE_TIMEOUT_MS), headers: { accept: "application/json" } });
+ const res = await fetchOnOrigin(doFetch, url, { signal: AbortSignal.timeout(PROBE_TIMEOUT_MS), headers: { accept: "application/json" } });
if (!res.ok) throw new ArchiveChannelError(`${url} answered HTTP ${res.status}`, res.status === 404 ? 404 : 502);
return res.json();
};
@@ -179,7 +208,9 @@ export async function archiveChannelFacts(origin: string, slug: string, opts: {
if (platform) return { slug, name, platform, url: url && /^https?:\/\//i.test(url) ? url : null, from: "corpus" };
// An older archive: the first record's page.
const manifests = (entry.manifests && typeof entry.manifests === "object" ? entry.manifests : {}) as Record<string, unknown>;
- const manifestAt = str(manifests.transcripts) ?? manifestUrl("transcripts", slug, base);
+ // Only the archive's own origin is read: a manifest the corpus names elsewhere is not followed.
+ const named = str(manifests.transcripts);
+ const manifestAt = named && sameOrigin(named, base) ? named : manifestUrl("transcripts", slug, base);
const manifest = (await getJson(manifestAt).catch(() => null)) as { slugToPage?: Record<string, unknown> } | null;
const pages = Object.values(manifest?.slugToPage ?? {}).filter((n): n is number => typeof n === "number" && Number.isInteger(n) && n >= 0);
if (pages.length > 0) {
diff --git a/common/lib/remoteArchives.ts b/common/lib/remoteArchives.ts
@@ -181,3 +181,46 @@ export function findConnectedArchive(list: readonly ConnectedArchive[], origin:
* looks for it to offer the one-press override (`allowWholeRecording`).
*/
export const WHOLE_RECORDING_REFUSED = "whole recording refused:";
+
+// ─── An archive is untrusted input (demo epic D1 review, blocker 2) ───
+
+// The platforms a clip window of an archive's channel may be fetched from:
+// the video platforms, each recognised by its HOST (lib/detectPlatform.mjs).
+// Never the post platforms, and never xenforo, which is recognised by a
+// thread path on any host.
+export const RECORD_PAGE_PLATFORMS = ["youtube", "rumble", "odysee", "twitch", "kick", "archiveorg", "bitchute"] as const;
+
+/**
+ * Why a remote-only channel's page URL — an archive record's `webpageUrl`, or
+ * one an ask carried for it — is not fetched, or null when it may be. The
+ * archive is someone else's JSON: a URL is accepted only when it is http(s)
+ * with no credentials, its host names a known video platform, and that is the
+ * channel's own platform when the channel has one. Refused before any request.
+ */
+export function recordPageRefusal(url: string | null | undefined, channelPlatform: string | null | undefined, detect: (u: string) => string | null): string | null {
+ if (!url) return "no page URL";
+ let u: URL;
+ try {
+ u = new URL(url);
+ } catch {
+ return `"${url}" is not a page URL`;
+ }
+ if ((u.protocol !== "https:" && u.protocol !== "http:") || u.username || u.password) return `${u.protocol}//${u.host} is not a page URL a window is fetched from`;
+ const platform = detect(url);
+ if (!platform || !(RECORD_PAGE_PLATFORMS as readonly string[]).includes(platform)) {
+ return `${u.host} is not a video platform's host (${RECORD_PAGE_PLATFORMS.join(", ")}): the archive's page URL is not fetched`;
+ }
+ if (channelPlatform && channelPlatform !== platform) {
+ return `${u.host} is ${platform}, and the channel is ${channelPlatform}'s: the archive's page URL is not fetched`;
+ }
+ return null;
+}
+
+/** Whether `url` is on `origin`'s own scheme, host and port. */
+export function sameOrigin(url: string, origin: string): boolean {
+ try {
+ return new URL(url).origin === new URL(origin).origin;
+ } catch {
+ return false;
+ }
+}
diff --git a/editor/app/api/media/fetch-window/route.remote.test.ts b/editor/app/api/media/fetch-window/route.remote.test.ts
@@ -20,7 +20,15 @@ delete process.env.TRANSCRIPT_SITE_URL;
const ORIGIN = "https://stub.test";
await writeFile(process.env.SETTINGS_FILE, JSON.stringify({ remoteArchives: [{ id: "stub", origin: ORIGIN, title: "Stub", addedAt: "2026-11-11T00:00:00Z" }] }));
const DOCS: Record<string, unknown> = {
- [`${ORIGIN}/corpus.json`]: { spec: 6, channels: [{ slug: "rb-remote", name: "RB Remote", platform: "rumble", manifests: { transcripts: `${ORIGIN}/transcripts/rb-remote/manifest.json` } }] },
+ [`${ORIGIN}/corpus.json`]: {
+ spec: 6,
+ channels: [
+ { slug: "rb-remote", name: "RB Remote", platform: "rumble", manifests: { transcripts: `${ORIGIN}/transcripts/rb-remote/manifest.json` } },
+ { slug: "yt-evil", name: "Evil", platform: "youtube", manifests: { transcripts: `${ORIGIN}/transcripts/yt-evil/manifest.json` } },
+ ],
+ },
+ [`${ORIGIN}/transcripts/yt-evil/manifest.json`]: { slugToPage: { e1: 0 } },
+ [`${ORIGIN}/transcripts/yt-evil/page-0000.json`]: [{ id: "e1", webpageUrl: "http://169.254.169.254/latest/meta-data/" }],
[`${ORIGIN}/transcripts/rb-remote/manifest.json`]: { slugToPage: { rb9: 0 } },
[`${ORIGIN}/transcripts/rb-remote/page-0000.json`]: [{ id: "rb9", duration: 600, webpageUrl: "https://rumble.com/vrb9-x.html" }],
};
@@ -55,3 +63,9 @@ test("without its archive named, a channel not held is a 404 as before", async (
const r = await post({ channelSlug: "nope-remote", videoId: "x1", from: 10, to: 20, requestedBy: "test", reason: "a test" });
assert.equal(r.status, 404);
});
+
+test("a single window whose archive record points at a non-platform host is refused (400), nothing fetched", async () => {
+ const r = await post({ channelSlug: "yt-evil", videoId: "e1", from: 10, to: 20, requestedBy: "test", reason: "a test", archive: ORIGIN });
+ assert.equal(r.status, 400);
+ assert.match(r.json.error ?? "", /^yt-evil\/e1: 169\.254\.169\.254 is not a video platform's host/);
+});
diff --git a/editor/app/api/media/fetch-window/route.ts b/editor/app/api/media/fetch-window/route.ts
@@ -22,7 +22,7 @@ import { getPaths } from "yt-dlp-transcript-common/lib/paths";
import { getSettings } from "yt-dlp-transcript-common/lib/settings";
import { detectPlatform } from "yt-dlp-transcript-common/lib/platform";
import { isRemoteOnlyChannel } from "yt-dlp-transcript-common/lib/channelConfig";
-import { connectedArchives, findConnectedArchive } from "yt-dlp-transcript-common/lib/remoteArchives";
+import { connectedArchives, findConnectedArchive, recordPageRefusal } from "yt-dlp-transcript-common/lib/remoteArchives";
import { cachedArchiveGetJson } from "yt-dlp-transcript-common/lib/archiveCache-server";
import { readChannelConfig } from "yt-dlp-transcript-common/controller/channels";
import { wholeRecordingFor } from "yt-dlp-transcript-common/controller/fetchWindows";
@@ -229,6 +229,10 @@ export async function POST(request: Request) {
if (config && isRemoteOnlyChannel(config)) {
const record = config.remoteArchive ? await archiveRecordOf(config.remoteArchive, channelSlug, videoId, { getJson }).catch(() => null) : null;
webpageUrl ||= record?.webpageUrl;
+ // An archive is untrusted input (demo epic D1 review): its page URL must
+ // name the channel's own video platform's host, before any request.
+ const refused = recordPageRefusal(webpageUrl, config.platform ?? null, detectPlatform);
+ if (refused) return NextResponse.json({ error: `${channelSlug}/${videoId}: ${refused}` }, { status: 400 });
const platform = detectPlatform(webpageUrl) ?? config.platform ?? "unknown";
const whole = body.full === true || wholeRecordingFor(getSettings(), platform, {}, undefined);
if (whole && body.allowWholeRecording !== true) {
diff --git a/editor/app/api/ops/fetch-windows/route.remote.test.ts b/editor/app/api/ops/fetch-windows/route.remote.test.ts
@@ -29,10 +29,17 @@ const DOCS: Record<string, unknown> = {
channels: [
{ slug: "yt-remote", name: "YT Remote", videoCount: 1, platform: "youtube", url: "https://www.youtube.com/@ytr", manifests: { transcripts: `${ORIGIN}/transcripts/yt-remote/manifest.json` } },
{ slug: "rb-remote", name: "RB Remote", videoCount: 1, platform: "rumble", manifests: { transcripts: `${ORIGIN}/transcripts/rb-remote/manifest.json` } },
+ { slug: "evil-remote", name: "Evil", videoCount: 1, platform: "youtube", manifests: { transcripts: `${ORIGIN}/transcripts/evil-remote/manifest.json` } },
],
},
[`${ORIGIN}/transcripts/rb-remote/manifest.json`]: { pageCount: 1, slugToPage: { rb9: 0 } },
[`${ORIGIN}/transcripts/rb-remote/page-0000.json`]: [{ id: "rb9", duration: 5400, webpageUrl: "https://rumble.com/vrb9-x.html" }],
+ // An archive pointing the editor at its own API (review of 9fddc3bb, blocker 2).
+ [`${ORIGIN}/transcripts/evil-remote/manifest.json`]: { slugToPage: { e1: 0, e2: 0 } },
+ [`${ORIGIN}/transcripts/evil-remote/page-0000.json`]: [
+ { id: "e1", webpageUrl: "http://127.0.0.1:3001/api/ops/settings" },
+ { id: "e2", webpageUrl: "https://rumble.com/ve2-x.html" },
+ ],
};
const asked: string[] = [];
globalThis.fetch = (async (input: RequestInfo | URL) => {
@@ -94,3 +101,13 @@ test("a run registers the remote-only channel from the archive, and refuses its
assert.equal(groups[0].platform, "rumble");
assert.equal(groups[0].items[0].webpageUrl, "https://rumble.com/vrb9-x.html");
});
+
+test("an archive's record pointing anywhere but its channel's video platform is refused before any request", async () => {
+ const r = await post({ requestedBy: "test", archive: ORIGIN, items: [{ slug: "evil-remote", id: "e1", from: 1, to: 5 }, { slug: "evil-remote", id: "e2", from: 1, to: 5 }] });
+ assert.equal(r.status, 200, r.json.error);
+ const errors = (r.json.unresolved as Unresolved).map((u) => u.error);
+ assert.match(errors[0], /127\.0\.0\.1:3001 is not a video platform's host/);
+ assert.match(errors[1], /rumble\.com is rumble, and the channel is youtube's/);
+ assert.deepEqual(r.json.jobIds, []);
+ assert.equal(asked.some((u) => u.startsWith("http://127.0.0.1")), false);
+});
diff --git a/editor/app/channels/[slug]/videos/fetchWindowsAction.ts b/editor/app/channels/[slug]/videos/fetchWindowsAction.ts
@@ -62,7 +62,7 @@ import {
} from "yt-dlp-transcript-common/jobs/streamCommand";
import { safeRevalidate } from "../../../lib/safeRevalidate";
import { isRemoteOnlyChannel } from "yt-dlp-transcript-common/lib/channelConfig";
-import { connectedArchives, findConnectedArchive, type ConnectedArchive } from "yt-dlp-transcript-common/lib/remoteArchives";
+import { connectedArchives, findConnectedArchive, recordPageRefusal, type ConnectedArchive } from "yt-dlp-transcript-common/lib/remoteArchives";
import {
archiveRecordOf,
ensureRemoteOnlyChannel,
@@ -355,6 +355,16 @@ async function planFetchWindows(
item.webpageUrl?.trim() ||
record?.webpageUrl ||
(isRemoteOnlyChannel(config) ? null : await findVideoSourceUrl(paths, item.slug, dirId, config));
+ // An archive is untrusted input (demo epic D1 review): a remote-only
+ // channel's page URL must name its own video platform's host, or nothing
+ // is asked of it.
+ if (url && isRemoteOnlyChannel(config)) {
+ const why = recordPageRefusal(url, config.platform ?? null, detectPlatform);
+ if (why) {
+ unresolved.push({ item, error: why });
+ continue;
+ }
+ }
if (!url) {
unresolved.push({
item,
diff --git a/editor/e2e/remote-archive.spec.ts b/editor/e2e/remote-archive.spec.ts
@@ -91,6 +91,13 @@ test.beforeAll(async () => {
// A build of its own, so no other run's cached copy answers for it.
const corpus = JSON.parse(await readFile(join(dir, "corpus.json"), "utf8"));
await writeFile(join(dir, "corpus.json"), JSON.stringify({ ...corpus, spec: 5, generatedAt: new Date().toISOString() }));
+ // A record's page is a video platform's (an archive's own URL is refused
+ // otherwise): YouTube's watch pages, which the fake yt-dlp answers.
+ for (const c of corpus.channels as { slug: string }[]) {
+ const page = join(dir, "transcripts", c.slug, "page-0000.json");
+ const records = JSON.parse(await readFile(page, "utf8")) as { id: string; webpageUrl?: string }[];
+ await writeFile(page, JSON.stringify(records.map((r) => ({ ...r, webpageUrl: `https://www.youtube.com/watch?v=${r.id}` }))));
+ }
stub = await startStubArchive(dir);
ol = await startFakeOllama();
});
diff --git a/umtool/lib/report/chain-run.mjs b/umtool/lib/report/chain-run.mjs
@@ -59,7 +59,8 @@ import { PIPELINE_DIR } from "./driver.mjs";
import { resolveLocalSource } from "umtool-report-to-video/sources";
import { dedupeMedia, seedFromParent } from "./iterations.mjs";
import { tmpPathFor } from "yt-dlp-transcript-common/lib/atomicFile.mjs";
-import { WHOLE_RECORDING_REFUSED, originOfHandle } from "yt-dlp-transcript-common/lib/remoteArchives";
+import { WHOLE_RECORDING_REFUSED, originOfHandle, recordPageRefusal } from "yt-dlp-transcript-common/lib/remoteArchives";
+import { detectPlatform } from "yt-dlp-transcript-common/lib/detectPlatform.mjs";
import { archiveRecordOf } from "yt-dlp-transcript-common/controller/remoteOnlyChannel";
import { cachedArchiveGetJson } from "yt-dlp-transcript-common/lib/archiveCache-server";
@@ -127,7 +128,8 @@ async function fetchWindowsStep(ctx, body, what) {
for (const item of body.items) {
if (item.webpageUrl) continue;
const r = await archiveRecordOf(origin, item.slug, item.id, { getJson }).catch(() => null);
- if (r?.webpageUrl) item.webpageUrl = r.webpageUrl;
+ // Only a video platform's page (the editor refuses any other, too).
+ if (r?.webpageUrl && !recordPageRefusal(r.webpageUrl, null, detectPlatform)) item.webpageUrl = r.webpageUrl;
}
if (ctx.allowWholeRecording) body.allowWholeRecording = true;
const dry = await editorCall(await editorEnv(), "POST", "/api/ops/fetch-windows", { ...body, dryRun: true });