commit 6f4ab8558445a64ee2756c89a6b453e24770a2ff
parent 38b24c1a85ee4a3ba4df5a73a2aa4addf142969e
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Thu, 15 Oct 2026 15:25:51 -0400
common, editor, scripts: a copy's window is cut with a lenient format selector, and only a copy's own failure is held against it (release 29 live fix) — find-copy's archive.org file is one direct file of unknown height, which every clip rung filtered out ("Requested format is not available"); a window with `copy` now asks copyClipFormatSelector: the clip rungs, then the same heights tolerant of an unknown height, then `b` (still written as the window's .mp4, re-encoded at the cuts; prepare re-encodes to H.264 anyway); fetch-windows records a failed copy only on a source-side failure (404/410/403, unreachable, not archived — isSourceSideCopyFailure), never on our selector, ffmpeg or an unplaceable error; `find-copy {…, retryFailed: true}` tries recorded copies again; ops help and COMMANDS.md
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
14 files changed, 142 insertions(+), 23 deletions(-)
diff --git a/COMMANDS.md b/COMMANDS.md
@@ -146,7 +146,7 @@ Drives a running editor over HTTP (`/api/ops/*`, the same actions its pages run)
| `archive-item` | archive-item answers one archive.org item's files from its metadata: {"item"} -> {item: {identifier, url, title?, date?, mediatype?, creator?, collections, restricted, mediaFiles, mediaBytes, files: \[{name, format?, source?, size?, seconds?, media, restricted, original?}\]}}. media marks the originals an import takes (one record each); restricted, what archive.org will not hand out. Read only; nothing is downloaded. | `pnpm ops archive-item --json '{"item":"example-item"}'` |
| `import-post` | import-post imports ONE post by its URL into a posts channel of its platform: {"slug", "url"} — an X status (x.com/<handle>/status/<id>) or a Bluesky post (bsky.app/profile/<handle>/post/<id>, or its at:// URI). Read through the channel's own fetcher (gallery-dl for X, with the channel's login; the public AppView for Bluesky) as an import-post job on the platform's queue. Refused, before any job: a URL that is not a post, a channel that is not a posts channel of that platform or whose fetcher cannot read one post, a post the URL names as another account's, the platform held or cooling down. A post already archived is not read again; one the platform says is another account's is not written. The log ends with @@import-post {ok, slug, url, id, written, already?, post?, error?}. | `pnpm ops import-post --json '{"slug":"demo-x","url":"https://x.com/example/status/1700000000000000001"}' --wait` |
| `wayback-lookup` | wayback-lookup answers the Wayback Machine's captures of a page (its CDX API): {"url"} or a record's {"slug", "id"} (its metadata's page, else its availability check's, else the playlist's), "okOnly"?: only the captures that recorded a 200, "limit"?: 100 (at most 500) -> {url, found, captures: \[{timestamp, status, mimetype?, replayUrl}\]}, oldest first. One request through the editor's Wayback client, with archive.org's manners (one at a time, 2 s apart, 429s waited out). Read only. | `pnpm ops wayback-lookup --json '{"slug":"demo-channel","id":"dQw4w9WgXcQ","okOnly":true}'` |
-| `find-copy` | find-copy looks for a copy of every gone recording (deleted or private) a report cites, and fetches the cited windows from it, as a find-copy job: {"article"} \| {"articles": true} \| {"siteId"}, "dryRun"? -> {jobId}. Per YouTube recording, one at a time: the Wayback Machine when it holds the video (the check yt-dlp makes, not a capture of the page), then archive.org (a mirror of the upload: its identifier, a file name or its original URL names the id, and the file has the recording's length). A copy a fetch failed from before is not picked again. Every copy's windows go to ONE fetch-windows job on the archive.org clip queue, the copy's URL as each window's page, so the clips land in the recording's own clips/ with the copy (wayback or archive.org, and its URL) in each window's provenance. A recording with no copy is left: its moments show their words only, marked "Source deleted". The log ends with @@find-copy {recordings: \[{slug, id, gone, watchUrl, youtubeId, windows, failedBefore, tried, copy?, outcome}\], items, stopped?, fetchJobId?, refused?}. dryRun looks and starts no fetch; a cancelled job starts none. | `pnpm ops find-copy --json '{"article":"demo-article","dryRun":true}'`<br>`pnpm ops find-copy --json '{"article":"demo-article"}' --wait` |
+| `find-copy` | find-copy looks for a copy of every gone recording (deleted or private) a report cites, and fetches the cited windows from it, as a find-copy job: {"article"} \| {"articles": true} \| {"siteId"}, "dryRun"?, "retryFailed"? -> {jobId}. Per YouTube recording, one at a time: the Wayback Machine when it holds the video (the check yt-dlp makes, not a capture of the page), then archive.org (a mirror of the upload: its identifier, a file name or its original URL names the id, and the file has the recording's length). A copy a fetch failed from at its source (404, 410, 403, unreachable; never our own format selector) is not picked again, unless "retryFailed": true. A copy's windows are cut with a lenient selector (a direct file of unknown height: then the best single file). Every copy's windows go to ONE fetch-windows job on the archive.org clip queue, the copy's URL as each window's page, so the clips land in the recording's own clips/ with the copy (wayback or archive.org, and its URL) in each window's provenance. A recording with no copy is left: its moments show their words only, marked "Source deleted". The log ends with @@find-copy {recordings: \[{slug, id, gone, watchUrl, youtubeId, windows, failedBefore, tried, copy?, outcome}\], items, stopped?, fetchJobId?, refused?}. dryRun looks and starts no fetch; a cancelled job starts none. | `pnpm ops find-copy --json '{"article":"demo-article","dryRun":true}'`<br>`pnpm ops find-copy --json '{"article":"demo-article"}' --wait`<br>`pnpm ops find-copy --json '{"article":"demo-article","retryFailed":true}' --wait` |
| `report-draft` | report-draft runs a generation over an article's iteration as a report-draft job: {"task": "sweep" \| "revise-report" \| "revise-video" \| "research" \| a media draft, "article", ...} -> {jobId, iteration, warnings?}. A sweep takes "question" and "channels" (and "from"/"to"): a new iteration; a revision takes "iteration" (the one it revises) and "feedback": a new iteration. A media draft — "narrate", "cut", "onscreen", "teaser", "flips", "threads", "youtube" — takes "iteration" (a done one; "entries"? entry ids, "force"? re-drafts a field that is a draft already; narrate "cards"?) and is a step on it: it drafts fields of the iteration's video manifest, never one the operator wrote. "copyOf" N runs iteration N again on "model". "extractorModel" is an API sweep's extractor (a Claude model id; default settings.generation.models.extractor). "model" defaults to settings.generation's route for the task (one routed to code needs a model named). A Claude model runs on draft:api, capped at "maxUsd" (default by task, never above caps.max), and is refused when the day's API total has reached caps.daily; a local model runs on draft:local, through the GPU arbiter, and is unloaded when it ends. The corpus is "source" (a handle), "build" (a composed build), or the newest build holding the channels. `job cancel <id>` stops it. The log ends with @@report-draft {article, iteration, task, status, summary, usd, minutes}; --wait prints it. A research run takes "question" ("channels"? "from"/"to"?) and "autonomy" (propose \| limits \| auto; default settings.generation.research): it searches the corpus, the web and archive.org and proposes acquisitions (archive.org imports, videos, new channels — always on no site —, posts, transcription, persisting), each with its reason and evidence, enqueuing what its autonomy and the settings' caps allow through the editor's own actions; the rest waits in the iteration's proposals.json. A sweep with "iteration" N CONTINUES research run N: its question, over its channels and every channel a done acquisition wrote into, the sweep's parent N; refused while N still waits, unless "force" (what is done so far). "seed" (a new sweep's, on a Claude model) is cited markdown in the /sweep shape — umtool's research board: kept as the iteration's seed.md, the report starts from it, and the sweep verifies and extends it. "ids" (a sweep's) restricts it to those recordings: an enumeration reads only their pages and answers only their rows, a read of another is refused. A "refresh" re-fetches an iteration's scope and folds in what changed: "iteration" (default: the current report's) — its question, its recorded enumerations and every channel its citations touch. One job on draft:refresh: the editor's own sync / refresh-report / transcribe-bucket (what landed) per video channel and fetch-posts per posts channel (a platform held or cooling down is skipped; transcribe-bucket is skipped, and said, while transcription is paused or no worker is enabled), then a local build of the site holding them (never a deploy); the enumerations again (new and changed recordings) and every cited quote read again (changed words, en vs en-orig, a source gone); nothing changed ends no-change, $0 — or partial, naming what a capped search did not reach. Else, within the caps ("model", "maxUsd", "extractorModel"; past one it ends held-by-cap with the delta and the estimate), a sweep restricted to the new recordings and a revision of the report: a new refresh iteration, refresh.json beside it. "fetch": false skips the fetch and the build; "dryRun": true answers {plan} and writes nothing. Its log ends with @@report-draft {…, refresh: {status, newIds, changed, drifted, deleted, summary}}. "verdicts" proposes a verdict for each UNRULED claim of a fact-check ("article"; "claims"? only those; "model"?, "maxUsd"?): the verdict bench's prompt, one claim per call, on a model in settings.generation.verdicts.models only (refused otherwise; none named: the first of them on the verdicts route). No iteration (iteration 0): the proposals go to the article's verdicts.proposed.json, never report.json; a claim the operator ruled, or whose proposal was reviewed, is not asked. Its log ends with @@report-draft {…, verdicts: {proposed, failed, skipped, promptVersion}}. | `pnpm ops report-draft --json '{"task":"sweep","article":"demo-article","question":"What does she say about the shop?","channels":["demo-channel"]}' --wait`<br>`pnpm ops report-draft --json '{"task":"revise-report","article":"demo-article","iteration":1,"feedback":"Drop the second finding."}'`<br>`pnpm ops report-draft --json '{"task":"research","article":"demo-article","question":"Where did the shop story start?","autonomy":"propose"}' --wait`<br>`pnpm ops report-draft --json '{"task":"sweep","article":"demo-article","iteration":1}'`<br>`pnpm ops report-draft --json '{"task":"refresh","article":"demo-article"}' --wait`<br>`pnpm ops report-draft --json '{"task":"refresh","article":"demo-article","dryRun":true}'`<br>`pnpm ops report-draft --json '{"task":"triage","article":"co-host-watch","question":"Who co-hosts?","channels":["demo-channel"],"terms":"co-host"}' --wait`<br>`pnpm ops report-draft --json '{"task":"verdicts","article":"demo-factcheck"}' --wait` |
| `research-approve` | research-approve settles a research run's acquisitions: {"article", "iteration", "ids"?: \["p01", …\], "approve"?: true \| false, "note"?} -> {outcomes: \[{id, status?, jobId?, note?, error?}\], research: {phase, autonomy, limits, spent, proposals, waitingOn: {approval, jobs}, continuedBy, autoContinue?}}. It first refreshes every enqueued acquisition from its jobs (all done: done; one failed: failed, naming it). approve: true runs each proposal through the editor's own action (past the run's autonomy and caps, never past a standing rule); false rejects it, note saying why. No ids: the run's state now. The phase is wait (approvals or jobs pending), ready (nothing pending: continue with report-draft {"task": "sweep", "iteration": N}) or continued. An `auto` run is continued by the editor itself once ready; autoContinue says how (continued by, held for a build, refused by a cap, and why). Refused while the run's job is going. | `pnpm ops research-approve --json '{"article":"demo-article","iteration":1,"ids":["p01","p03"],"approve":true}'` |
| `verdict-review` | verdict-review settles one verdict proposal: {"article", "claim", "decision": "approve" \| "reject", "verdict", "at", "note"?} -> {proposal}. "verdict" and "at" are the proposal you were shown (its verdicts.proposed.json entry): a compare-and-set, refused (409) when the proposal was replaced or reviewed since, its claim changed (the proposal is stale) or was ruled meanwhile. approve sets the claim's verdict to it (through the registry); reject leaves the claim unruled. Synchronous. | `pnpm ops verdict-review --json '{"article":"demo-factcheck","claim":"c04","decision":"approve","verdict":"PARTLY","at":"2026-10-15T10:00:00.000Z"}'` |
diff --git a/common/controller/fetchWindows.test.ts b/common/controller/fetchWindows.test.ts
@@ -41,6 +41,7 @@ const fail = (msg) => { process.stderr.write(msg + "\\n"); process.exit(1); };
if (url.includes("/403")) fail("ERROR: [download] Got error: HTTP Error 403: Forbidden");
if (url.includes("/429")) fail("ERROR: [youtube] x: HTTP Error 429: Too Many Requests");
if (url.includes("/gone")) fail("ERROR: [youtube] x: Video unavailable. This video has been removed by the uploader");
+if (url.includes("/noformat")) fail("ERROR: [generic] x: Requested format is not available. Use --list-formats for a list of available formats");
writeFileSync(args[args.indexOf("-o") + 1], "mp4");
`,
);
@@ -447,6 +448,11 @@ test("a copy whose fetch failed is recorded beside the recording (find-copy will
assert.equal(recorded.length, 1);
assert.equal(recorded[0]![0], path.join(paths.channelsDir, "c", "data", "v1"));
assert.deepEqual({ ...(recorded[0]![1] as object), at: undefined, error: undefined }, { ...copy, at: undefined, error: undefined });
+ // Our own selector matching nothing says nothing about the copy (release 29 live fix).
+ const ours = { ...copy, url: "https://archive.org/download/x/noformat.webm" };
+ const r2 = await go(paths, [{ slug: "c", id: "v3", from: 10, to: 20, webpageUrl: ours.url, copy: ours }], h);
+ assert.equal(r2.failed.length, 1);
+ assert.equal(recorded.length, 1, "a selector failure is not the copy's");
const limited = { ...copy, url: "https://www.youtube.com/429" };
await go(paths, [{ slug: "c", id: "v2", from: 10, to: 20, webpageUrl: limited.url, copy: limited }], h);
assert.equal(recorded.length, 1, "a rate limit says nothing about the copy");
diff --git a/common/controller/fetchWindows.ts b/common/controller/fetchWindows.ts
@@ -5,7 +5,7 @@ import type { SiteSettings } from "../lib/settings";
import { getSettings } from "../lib/settings";
import type { DownloadFailureClass } from "../lib/availability";
import type { ClipCopy } from "../lib/clipWindow";
-import { recordFailedCopy, type FailedCopy } from "../lib/copyAttempts-server";
+import { isSourceSideCopyFailure, recordFailedCopy, type FailedCopy } from "../lib/copyAttempts-server";
import { resolveCookiePolicy } from "../lib/cookiePolicy";
import { assertChannelTextReadable } from "../lib/channelMedia";
import { detectPlatform } from "../lib/platform";
@@ -556,10 +556,11 @@ export async function fetchWindows({
const cls: FetchWindowsFailureClass =
e instanceof FetchWindowError ? e.failureClass : "unknown";
fail(item, cls, message);
- // A COPY THAT FAILED (find-copy's, release 29 review) is recorded beside
- // the recording, so the next find-copy falls through to another copy. A
- // rate limit says nothing about the copy, and neither does a cancel.
- if (item.copy && cls !== "rate_limit" && !fetchSignal.aborted) {
+ // A COPY THAT FAILED AT ITS SOURCE (find-copy's, release 29 review) is
+ // recorded beside the recording, so the next find-copy falls through to
+ // another copy. Only a source-side failure (isSourceSideCopyFailure): a
+ // rate limit, a cancel, our own selector or ffmpeg say nothing about it.
+ if (item.copy && cls !== "rate_limit" && !fetchSignal.aborted && isSourceSideCopyFailure(cls, message)) {
await deps
.recordFailedCopy(videoDir, { ...item.copy, at: new Date().toISOString(), error: message })
.catch(() => {});
diff --git a/common/lib/copyAttempts-server.ts b/common/lib/copyAttempts-server.ts
@@ -32,6 +32,21 @@ export function coerceCopyAttempts(value: unknown): CopyAttempts | null {
export const copyAttemptsSidecar = sidecar(COPY_ATTEMPTS_FILENAME, sidecarField(coerceCopyAttempts));
+// WHETHER A FAILED FETCH SAYS THE COPY ITSELF IS BAD (release 29 live fix).
+// Only a source-side failure is recorded against a copy: the file or page gone
+// or refused (404, 410, 403), the source unreachable, the video not archived.
+// Our own side — the format selector matching nothing ("Requested format is
+// not available"), ffmpeg, a disk — says nothing about the copy, and neither
+// does a failure nobody can place: those are never recorded, so the next run
+// tries the same copy again.
+export function isSourceSideCopyFailure(failureClass: string | undefined, message: string): boolean {
+ if (/requested format is not available|requested formats are incompatible/i.test(message)) return false;
+ if (failureClass === "per_video" || failureClass === "network") return true;
+ return /http error (?:403|404|410)|404[: ]+not found|410[: ]+gone|not archived or indexed|unable to download webpage|name or service not known|could not resolve host|connection refused/i.test(
+ message,
+ );
+}
+
export async function readFailedCopies(videoDir: string): Promise<FailedCopy[]> {
return (await copyAttemptsSidecar.load(videoDir).catch(() => null))?.failed ?? [];
}
diff --git a/common/lib/copyAttempts.test.ts b/common/lib/copyAttempts.test.ts
@@ -8,7 +8,7 @@ import assert from "node:assert/strict";
import { mkdtemp, rm } from "node:fs/promises";
import os from "node:os";
import path from "node:path";
-import { COPY_ATTEMPTS_FILENAME, readFailedCopies, recordFailedCopy } from "./copyAttempts-server";
+import { COPY_ATTEMPTS_FILENAME, isSourceSideCopyFailure, readFailedCopies, recordFailedCopy } from "./copyAttempts-server";
test("recordFailedCopy appends one per URL, newest last; readFailedCopies reads them", async () => {
const dir = await mkdtemp(path.join(os.tmpdir(), "copy-attempts-"));
@@ -29,3 +29,15 @@ test("recordFailedCopy appends one per URL, newest last; readFailedCopies reads
await rm(dir, { recursive: true, force: true });
}
});
+
+test("isSourceSideCopyFailure: the copy's 404/410/403 or unreachability, never our selector, ffmpeg or the unplaceable", () => {
+ assert.equal(isSourceSideCopyFailure("unknown", "ERROR: [generic] x: Requested format is not available. Use --list-formats"), false);
+ assert.equal(isSourceSideCopyFailure("network", "ERROR: [generic] x: Requested format is not available"), false);
+ assert.equal(isSourceSideCopyFailure("unknown", "ERROR: [generic] Unable to download webpage: HTTP Error 404: Not Found"), true);
+ assert.equal(isSourceSideCopyFailure("unknown", "ERROR: HTTP Error 410: Gone"), true);
+ assert.equal(isSourceSideCopyFailure("network", "ERROR: HTTP Error 403: Forbidden"), true);
+ assert.equal(isSourceSideCopyFailure("per_video", "Video unavailable"), true);
+ assert.equal(isSourceSideCopyFailure("unknown", "ERROR: [web.archive:youtube] x: The requested video is not archived or indexed"), true);
+ assert.equal(isSourceSideCopyFailure("unknown", "ERROR: ffmpeg exited with code 1"), false);
+ assert.equal(isSourceSideCopyFailure("unknown", "No space left on device"), false);
+});
diff --git a/common/publish/findCopy.test.ts b/common/publish/findCopy.test.ts
@@ -214,6 +214,11 @@ test("a copy that failed before is not picked again: Wayback falls through to ar
]);
assert.match(r.recordings[0]!.tried[0]!.detail ?? "", /failed before/);
assert.equal(one.wb.requests.length, 0, "the Wayback is not asked again");
+ // retryFailed (the release 29 live fix: a failure later found to be ours)
+ // tries the recorded copy again, and still lists it.
+ const again = await findCopies({ ...opts(one.deps), retryFailed: true });
+ assert.equal(again.recordings[0]!.copy?.from, "wayback");
+ assert.deepEqual(again.recordings[0]!.failedBefore.map((f) => f.from), ["wayback"]);
} finally {
await one.close();
}
diff --git a/common/publish/findCopy.ts b/common/publish/findCopy.ts
@@ -23,9 +23,10 @@
// Only a record whose page is a YouTube URL is looked for: the id is the
// page's, never guessed from a Twitch or Rumble record's own id.
//
-// A COPY THAT FAILED is not picked again: fetch-windows records a copy whose
-// fetch failed beside the recording (lib/copyAttempts-server.ts), and the next
-// run falls through — Wayback → archive.org → the next mirror.
+// A COPY THAT FAILED AT ITS SOURCE is not picked again: fetch-windows records
+// a copy whose fetch failed source-side beside the recording
+// (lib/copyAttempts-server.ts), and the next run falls through — Wayback →
+// archive.org → the next mirror. `retryFailed` tries them again.
//
// A copy found: the recording's cited windows go to fetch-windows with the
// copy's URL as each item's `webpageUrl` (controller/fetchWindows.ts), so the
@@ -359,6 +360,9 @@ const describeAttempt = (t: FindCopyAttempt) =>
export async function findCopies(opts: {
paths: Paths;
host: ReportHost;
+ // Try copies recorded as failed again (they are still listed, as
+ // `failedBefore`): for a failure later found to be ours, not the copy's.
+ retryFailed?: boolean;
signal?: AbortSignal;
onLog?: (line: string) => void;
deps?: Partial<FindCopyDeps>;
@@ -384,7 +388,7 @@ export async function findCopies(opts: {
const facts = await deps.facts(opts.paths, r.slug, r.id);
const youtubeId = youtubeIdOf(facts.webpageUrl);
const failedBefore = (await deps.failedCopies(facts.videoDir).catch(() => [] as FailedCopy[])).map(({ from, url }) => ({ from, url }));
- const failedUrls = new Set(failedBefore.map((f) => f.url));
+ const failedUrls = new Set(opts.retryFailed ? [] : failedBefore.map((f) => f.url));
const rec: FindCopyRecording = { ...r, watchUrl: facts.webpageUrl, youtubeId, failedBefore, tried: [], outcome: "text-only" };
result.recordings.push(rec);
let refused: string | undefined;
@@ -398,7 +402,7 @@ export async function findCopies(opts: {
rec.tried.push({ from: "wayback", found: false, detail: "not a YouTube recording: no copy is looked for" });
} else {
// 1. The Wayback Machine — when it holds the video, and no fetch from it failed before.
- if (failedBefore.some((f) => f.from === "wayback")) {
+ if (!opts.retryFailed && failedBefore.some((f) => f.from === "wayback")) {
rec.tried.push({ from: "wayback", found: false, detail: "a fetch from its Wayback copy failed before" });
} else {
try {
@@ -498,6 +502,7 @@ export async function runFindCopy<T>(opts: {
paths: Paths;
host: ReportHost;
dryRun?: boolean;
+ retryFailed?: boolean;
signal?: AbortSignal;
onLog?: (line: string) => void;
deps?: Partial<FindCopyDeps>;
diff --git a/common/ytdlp/downloadFormat.ts b/common/ytdlp/downloadFormat.ts
@@ -67,6 +67,26 @@ export function clipFormatSelector(maxHeight: number): string {
);
}
+// THE SELECTOR A WINDOW OF A COPY IS CUT FROM (release 29 live fix): a
+// find-copy copy — an archive.org file, a Wayback capture — is often ONE
+// direct file whose format yt-dlp's generic extractor knows nothing about (no
+// height, no codec), which every rung above filters out ("Requested format is
+// not available"). So the clip rungs first (a copy that does list its formats
+// gets the same file a platform fetch would), then the same heights tolerant
+// of an unknown height (`height<=?N`), then `b`: the best single file. The
+// output is still `-o <window>.part.mp4` with --force-keyframes-at-cuts, so
+// ffmpeg writes the cut as an mp4 (re-encoded at the cuts); prepare re-encodes
+// every clip to H.264 anyway (lib/evidenceClip-server.ts).
+export function copyClipFormatSelector(maxHeight: number): string {
+ return [
+ clipFormatSelector(maxHeight),
+ `bv*[height<=?${maxHeight}]+ba`,
+ `b[ext=mp4][height<=?${maxHeight}]`,
+ `b[height<=?${maxHeight}]`,
+ "b",
+ ].join("/");
+}
+
// The clip selector's two halves. SPLIT: separate H.264 video + AAC audio
// streams, merged. SINGLE-FILE: one file carrying both (mp4 first). Split
// first, because a single-file format at these heights is often a low rung
diff --git a/common/ytdlp/fetchWindowManaged.test.ts b/common/ytdlp/fetchWindowManaged.test.ts
@@ -10,7 +10,8 @@ import assert from "node:assert/strict";
import { chmod, mkdir, mkdtemp, readFile, writeFile } from "node:fs/promises";
import os from "node:os";
import path from "node:path";
-import { fetchWindowManaged, HLS_PICKY_RETRY_ARGS } from "./fetchWindowManaged";
+import { clipFormatSelector, fetchWindowManaged, HLS_PICKY_RETRY_ARGS } from "./fetchWindowManaged";
+import { copyClipFormatSelector } from "./downloadFormat";
import type { Paths } from "../lib/paths";
import type { ChannelConfig } from "../lib/channelConfig";
@@ -34,6 +35,15 @@ const fail = (msg) => { process.stderr.write(msg + "\\nERROR: ffmpeg exited with
if (mode === "broken") fail("ERROR: something else entirely");
if (mode === "rumble" && !picky) fail("[in#0] URL https://cdn.example/x.tar?r_file=media-0.ts is not in allowed_segment_extensions");
if (mode === "progressive" && picky) fail("Option extension_picky not found.");
+// =generic: ONE direct file whose height and codec yt-dlp's generic extractor
+// does not know (an archive.org .webm): any rung that filters on a known
+// height or codec matches nothing; one tolerant of an unknown height, or "b",
+// takes it.
+if (mode === "generic") {
+ const sel = args[args.indexOf("-f") + 1];
+ const takes = sel.split("/").some((r) => r === "b" || r.includes("height<=?"));
+ if (!takes) fail("ERROR: [generic] v1: Requested format is not available. Use --list-formats for a list of available formats");
+}
writeFileSync(args[args.indexOf("-o") + 1], "mp4");
`,
);
@@ -144,3 +154,29 @@ test("a cached unpadded window does not cover a padded ask; a padded one covers
// The tightest window that holds the ask: the unpadded one for the unpadded span.
assert.deepEqual([exact.from, exact.to], [10, 20]);
});
+
+// Release 29 live fix: a find-copy copy (an archive.org file) is one direct
+// file of unknown height; the clip selector matched nothing there.
+test("a window of a copy (one direct file of unknown height) is fetched with the lenient selector; a platform window keeps the clip one", async () => {
+ process.env.FAKE_MODE = "generic";
+ const before = (await runs()).length;
+ const copy = { from: "archive.org" as const, url: "https://archive.org/download/youtube-x/x.webm" };
+ const res = await fetchWindowManaged({
+ ...opts(await setup("generic-copy")),
+ videoUrl: copy.url,
+ provenance: { requestedBy: "find-copy", copy },
+ });
+ assert.equal(res.cached, false);
+ assert.deepEqual(res.provenance?.copy, copy);
+ assert.ok(res.file.endsWith(".mp4"), "the window lands as the .mp4 clip");
+ const mine = (await runs()).slice(before);
+ assert.equal(mine.length, 1);
+ assert.equal(mine[0]![mine[0]!.indexOf("-f") + 1], copyClipFormatSelector(720));
+ assert.ok(copyClipFormatSelector(720).startsWith(clipFormatSelector(720) + "/"), "the clip rungs first");
+ assert.ok(copyClipFormatSelector(720).endsWith("/b"));
+ // The same file asked for as a platform window keeps the strict selector, and fails as before.
+ await assert.rejects(
+ fetchWindowManaged({ ...opts(await setup("generic-plain")), videoUrl: copy.url }),
+ /Requested format is not available/,
+ );
+});
diff --git a/common/ytdlp/fetchWindowManaged.ts b/common/ytdlp/fetchWindowManaged.ts
@@ -46,7 +46,7 @@ import {
import { channelExtraArgs, configForVideoUrl } from "./channelArgs";
import { runOneYtdlp } from "./runOneYtdlp";
import { FULL_LOG_PROGRESS_ARGS } from "./downloadOneManaged";
-import { clipFormatSelector } from "./downloadFormat";
+import { clipFormatSelector, copyClipFormatSelector } from "./downloadFormat";
// The source height a clip is worth fetching at. 720 is umtool's number and the
// reason is the render: the deliverable is 1080p with a clip inset, so pixels
@@ -93,7 +93,9 @@ export type FetchWindowProvenance = {
reason?: string;
pad?: number;
requestedAt?: string;
- // The copy of a gone recording the URL is (release 29 E2, find-copy).
+ // The copy of a gone recording the URL is (release 29 E2, find-copy). A
+ // window of a copy — often one direct file of unknown height — is fetched
+ // with the lenient selector (copyClipFormatSelector).
copy?: ClipCopy;
};
@@ -216,7 +218,7 @@ export async function fetchWindowManaged(
// citation.
"--force-keyframes-at-cuts",
"-f",
- clipFormatSelector(maxHeight),
+ opts.provenance.copy ? copyClipFormatSelector(maxHeight) : clipFormatSelector(maxHeight),
"--merge-output-format",
"mp4",
...FULL_LOG_PROGRESS_ARGS,
diff --git a/editor/app/api/ops/_research.test.ts b/editor/app/api/ops/_research.test.ts
@@ -93,6 +93,9 @@ test("find-copy: exactly one of article, articles, siteId; an unknown one is ref
const noArticle = await callPost(find, { article: "no-such-article", dryRun: true });
assert.equal(noArticle.status, 400);
assert.match(String(noArticle.body.error), /no article "no-such-article"/);
+ const badRetry = await callPost(find, { article: "a", retryFailed: "yes" });
+ assert.equal(badRetry.status, 400);
+ assert.match(String(badRetry.body.error), /"retryFailed" must be a boolean/);
const noSite = await callPost(find, { siteId: "no-such-site" });
assert.equal(noSite.status, 400);
assert.match(String(noSite.body.error), /No site "no-such-site"/);
diff --git a/editor/app/api/ops/find-copy/route.ts b/editor/app/api/ops/find-copy/route.ts
@@ -3,7 +3,7 @@ import { OpsInputError, jobResponse, ops, optBool, optString } from "../_lib";
export const dynamic = "force-dynamic";
-// POST { article } | { siteId } | { articles: true }, dryRun? -> { ok, jobId }
+// POST { article } | { siteId } | { articles: true }, dryRun?, retryFailed? -> { ok, jobId }
//
// A COPY OF EVERY GONE RECORDING THE REPORTS CITE (release 29 E2,
// publish/findCopy.ts), as a `find-copy` job: of one article (`article`),
@@ -12,8 +12,9 @@ export const dynamic = "force-dynamic";
// Per YouTube recording, one at a time: the Wayback Machine when it holds the
// video (the check yt-dlp makes), then archive.org (a mirror of the upload —
// its identifier, a file name or its original URL names the id — whose file
-// has the recording's length). A copy a fetch failed from before is not picked
-// again. The windows of every copy found go to ONE fetch-windows job on the
+// has the recording's length). A copy a fetch failed from at its source
+// before (404, 410, 403, unreachable — never our own selector) is not picked
+// again, unless `retryFailed`. The windows of every copy found go to ONE fetch-windows job on the
// archive.org clip queue, each with the copy's URL as its page, so the clips
// land in the recording's own clips/ with the copy in their provenance. A
// recording with no copy is left: its moments show their words only ("source
@@ -22,7 +23,7 @@ export const dynamic = "force-dynamic";
// failedBefore, tried, copy?, outcome}], items, stopped?, fetchJobId?,
// refused?}`; `--wait` follows it.
export async function POST(request: Request) {
- return ops(request, ["article", "siteId", "articles", "dryRun"], async (body) => {
+ return ops(request, ["article", "siteId", "articles", "dryRun", "retryFailed"], async (body) => {
const article = optString(body, "article")?.trim();
const siteId = optString(body, "siteId")?.trim();
const articles = optBool(body, "articles") === true;
@@ -34,6 +35,7 @@ export async function POST(request: Request) {
...(article ? { article } : {}),
...(siteId ? { siteId } : {}),
dryRun: optBool(body, "dryRun") === true,
+ retryFailed: optBool(body, "retryFailed") === true,
}),
);
});
diff --git a/editor/app/channels/[slug]/videos/findCopyAction.ts b/editor/app/channels/[slug]/videos/findCopyAction.ts
@@ -23,7 +23,13 @@ const FIND_COPY_QUEUE = "find-copy";
// The archive.org clip queue: every copy's windows, one job, one stream.
const FETCH_QUEUE = clipWindowQueueKey(platformQueueKey("archiveorg"));
-export async function findCopyAction(req: { article?: string; siteId?: string; dryRun?: boolean }): Promise<StreamActionResult> {
+export async function findCopyAction(req: {
+ article?: string;
+ siteId?: string;
+ dryRun?: boolean;
+ // Try copies recorded as failed again (publish/findCopy.ts).
+ retryFailed?: boolean;
+}): Promise<StreamActionResult> {
const paths = getPaths();
let host: ReportHost;
try {
@@ -49,6 +55,7 @@ export async function findCopyAction(req: { article?: string; siteId?: string; d
paths,
host,
dryRun: req.dryRun,
+ retryFailed: req.retryFailed,
signal,
onLog,
startFetch: async (items) => {
diff --git a/scripts/archilyzer-ops.mjs b/scripts/archilyzer-ops.mjs
@@ -107,6 +107,7 @@
// pnpm ops wayback-lookup --json '{"slug":"demo-channel","id":"dQw4w9WgXcQ","okOnly":true}'
// pnpm ops find-copy --json '{"article":"demo-article","dryRun":true}'
// pnpm ops find-copy --json '{"article":"demo-article"}' --wait
+// pnpm ops find-copy --json '{"article":"demo-article","retryFailed":true}' --wait
// pnpm ops import-post --json '{"slug":"demo-x","url":"https://x.com/example/status/1700000000000000001"}' --wait
// pnpm ops report-draft --json '{"task":"sweep","article":"demo-article","question":"What does she say about the shop?","channels":["demo-channel"]}' --wait
// pnpm ops report-draft --json '{"task":"revise-report","article":"demo-article","iteration":1,"feedback":"Drop the second finding."}'
@@ -1270,12 +1271,16 @@ export function usage() {
"",
'find-copy looks for a copy of every gone recording (deleted or private) a',
' report cites, and fetches the cited windows from it, as a find-copy job:',
- ' {"article"} | {"articles": true} | {"siteId"}, "dryRun"? -> {jobId}. Per',
+ ' {"article"} | {"articles": true} | {"siteId"}, "dryRun"?, "retryFailed"?',
+ ' -> {jobId}. Per',
' YouTube recording, one at a time: the Wayback Machine when it holds the',
' video (the check yt-dlp makes, not a capture of the page), then',
' archive.org (a mirror of the upload: its identifier, a file name or its',
' original URL names the id, and the file has the recording\'s length). A',
- ' copy a fetch failed from before is not picked again. Every copy\'s windows',
+ ' copy a fetch failed from at its source (404, 410, 403, unreachable; never',
+ ' our own format selector) is not picked again, unless "retryFailed": true.',
+ " A copy's windows are cut with a lenient selector (a direct file of unknown",
+ " height: then the best single file). Every copy's windows",
" go to ONE fetch-windows job on the archive.org clip queue, the copy's URL",
" as each window's page, so the clips land in the recording's own clips/",
" with the copy (wayback or archive.org, and its URL) in each window's",