commit f3da0c50775bcee3470966eb3aa3db1e03de8317
parent c578224a3744ef34262d4e42ee45174662fd9f8c
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Thu, 15 Oct 2026 08:27:51 -0400
common, editor, scripts: find-copy runs as a job; the fetch-windows door names its way out; members-only is its own unfetchable reason (review 6, 7, 8) — `pnpm ops find-copy` starts a `find-copy` job (its own queue; cancelled, it starts no fetch) whose log ends with @@find-copy {…, fetchJobId?}; a gone recording's window is refused naming the availability re-check, and an item's "force": true fetches from its own page anyway; missingEvidenceWindows says "unfetchable: members-only" when the channel has no cookies to send (with a cookie source it is a window to fetch), never gone; ops help and COMMANDS.md
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
12 files changed, 200 insertions(+), 103 deletions(-)
diff --git a/COMMANDS.md b/COMMANDS.md
@@ -129,7 +129,7 @@ Drives a running editor over HTTP (`/api/ops/*`, the same actions its pages run)
| `tag-videos` | tag-videos pins, unpins, suppresses or unsuppresses one tag on many videos in ONE write: {"tag", "op": "add" \| "remove" \| "suppress" \| "unsuppress", "videos": \[{"slug", "id"}, ...\]}. "remove" unpins only — a rule's hit survives; "suppress" rejects it. The write records who asked (ARCHILYZER\_AGENT); a big list goes in --file. | `pnpm ops tag-videos --file ids.json` |
| `keep-videos` | keep-videos sets the "Do not clean" marker on every held video of a channel whose title or description matches a download-filter pattern: {"slug", "match", "fields"?: \["title" \| "description"\], "note"?, "dryRun"?}. A match not held is reported in "notDownloaded", never created; a fresh channel wants metadata-scan first. | |
| `persist-videos` | persist-videos saves specific videos, across channels, to the saved-video store: {"items": \[{"slug", "id"}, ...\]}. "format": "original" \| "video\_720" (default: each channel's own). "replace": "above-height" also re-fetches a saved one whose height is unknown or above that quality (default "never"). "gapMs" pauses between downloads (default the batch gap), "minFreeMemMb" waits for that much free memory before each. "dryRun": true answers with the buckets (saved, wrongHeight, toFetch, noUrl, unknown) and starts nothing. One job per channel, on its download queue; a low disk or a rate limit stops it, and running the same body again resumes — saved videos are skipped. | `pnpm ops persist-videos --file list.json --wait` |
-| `fetch-windows` | fetch-windows fetches clip windows, one paced job per platform queue (YouTube and Rumble side by side): {"siteId"} fetches every window the site's published reports cite and the disk does not hold; {"items": \[{"slug", "id", "from", "to", "clipId"?, "reason"?, "pad"?, "webpageUrl"?}, ...\], "requestedBy", "manifest"?} fetches a list. "maxHeight" caps the source height (default 720). "dryRun": true lists the windows per platform, the ones already on disk ("cached") and the ones no fetch can fill ("unfetchable": deleted, off the site) and starts nothing. A platform cooling down or held is refused for its group; a 429, or two 403s in a row, backs the platform off and stops its job. Running the same body again resumes — fetched windows are cached, and a window a queued or running job will already write is answered in "inFlight" with that job, whose id joins "jobIds" (so --wait follows it) and no second job is queued. Windows run on the platform's clip queue (clips:youtube), never behind its long downloads. | `pnpm ops fetch-windows --json '{"siteId":"demo-site","dryRun":true}'`<br>`pnpm ops fetch-windows --file windows.json --wait` |
+| `fetch-windows` | fetch-windows fetches clip windows, one paced job per platform queue (YouTube and Rumble side by side): {"siteId"} fetches every window the site's published reports cite and the disk does not hold; {"items": \[{"slug", "id", "from", "to", "clipId"?, "reason"?, "pad"?, "webpageUrl"?, "force"?}, ...\], "requestedBy", "manifest"?} fetches a list. A window of a recording whose availability says deleted or private is refused (unresolved) unless the item names a "webpageUrl" (a copy: find-copy) or "force": true (a stale reading; or check its availability again on the channel page's Diagnostics). "maxHeight" caps the source height (default 720). "dryRun": true lists the windows per platform, the ones already on disk ("cached") and the ones no fetch can fill ("unfetchable": deleted, off the site) and starts nothing. A platform cooling down or held is refused for its group; a 429, or two 403s in a row, backs the platform off and stops its job. Running the same body again resumes — fetched windows are cached, and a window a queued or running job will already write is answered in "inFlight" with that job, whose id joins "jobIds" (so --wait follows it) and no second job is queued. Windows run on the platform's clip queue (clips:youtube), never behind its long downloads. | `pnpm ops fetch-windows --json '{"siteId":"demo-site","dryRun":true}'`<br>`pnpm ops fetch-windows --file windows.json --wait` |
| `cut-release` | cut-release turns a changelog's \[Unreleased\] into "## \[<version>\] - <date>": {"workspace": "editor" \| "export" \| "all", "version": "X.Y.Z" \| "next" \| "next-minor", "commit": boolean (default false), "date": "YYYY-MM-DD" (default today)}. "all" cuts both with ONE version and commits each ("Release <workspace> <version>") — or neither: every check runs before either file is written. Only an editor built from release 10 or later has the route (an older one answers 404); with no editor running, `archilyzer release cut` does the same locally. | `pnpm ops cut-release --json '{"workspace":"all","version":"next","commit":true}'` |
| `transcribe` | transcribe runs ONE local file through a local transcription worker, as a job: {"path": "/abs/file"} (audio or video), "start"/"end" (seconds) for a window, "workerId" (a settings worker id; default: the one auto-transcribe would get), "out" (an absolute path for the result JSON, never inside the corpus). The result is {path, window, worker: {id, appId, model, device}, cues: \[{start, end, text}\], text, ...}, cue times on the file's own clock. "words": true adds words: \[{w, start, end, conf?}\] on the same clock -- from parakeet, which keeps its word timestamps; \[\] from an engine that does not. With --wait it is printed on stdout (the response and the log go to stderr), so `pnpm ops transcribe ... --wait \| jq -r .text` works. | `pnpm ops transcribe --json '{"path":"/abs/clip.mp4","start":120,"end":150}' --wait`<br>`pnpm ops transcribe --json '{"path":"/abs/a.wav","workerId":"parakeet-cpu","out":"/tmp/a.json"}' --wait` |
| `tts` | tts speaks a line with a local text-to-speech engine and a STOCK voice, as a job on the `tts` queue: {"text": "..."} or {"file": "/abs/script.txt"} (UTF-8, at most 20,000 characters), "engine" (kokoro \| orpheus \| espeak-ng), "voice" (one of the engine's stock voices; kokoro: af\_heart, bm\_george, ...; orpheus: leah, zac, ...), "speed" (0.5-2; orpheus has none) — defaults from settings.tts (kokoro, af\_heart, 1) — and "out" (an absolute .wav path the result is copied to, never inside the corpus). The expressive tags <laugh> <chuckle> <sigh> <cough> <sniffle> <groan> <yawn> <gasp> are performed by orpheus and stripped for the others; any other <...> is refused. Numbers, years, money and times are spoken (2024: "twenty twenty-four"). The result is {wav, seconds, engine, voice, cached, durationMs, waitedMs, sha, sampleRate, speed, disclosure}: wav is the 48 kHz mono WAV the editor wrote (out, or its cache), disclosure the line a narrated export carries. The same ask again is answered from the cache (cached: true, no engine run). Kokoro and orpheus need `archilyzer tts setup [--engine orpheus]` first; orpheus runs on the GPU (a local llama-server the editor starts and stops) and waits while a transcription holds it. With --wait the result is printed on stdout. | `pnpm ops tts --json '{"text":"In 2024 the archive spoke."}' --wait`<br>`pnpm ops tts --json '{"file":"/abs/script.txt","voice":"bm_george","out":"/abs/line.wav"}' --wait` |
@@ -142,11 +142,11 @@ Drives a running editor over HTTP (`/api/ops/*`, the same actions its pages run)
| `cleanup` | cleanup runs one of a channel's cleanup sweeps as a job: {"slug", "sweep": "transcribed" (audio of transcribed videos — the /cleanup total) \| "extra-formats" \| "wrong-format" \| "failed-transcriptions" (clears the list; deletes nothing)}. Do-not-clean videos are skipped; `get cleanup <slug>` says what each would reclaim. | `pnpm ops cleanup --json '{"slug":"x","sweep":"transcribed"}' --wait` |
| `web-search` | web-search searches the web (DuckDuckGo's HTML page) and answers the results: {"query", "n"?: 6 (at most 20)} -> {results: \[{title, url, snippet}\]}. Read only, through the editor's one web queue: one request at a time, 3 s apart, backing off on a 429 or 503. For context; a web page is never cited as what someone said. | `pnpm ops web-search --json '{"query":"second shop opening","n":5}'` |
| `web-fetch` | web-fetch reads one web page as plain text: {"url", "maxChars"?: 12000 (at most 60000)} -> {page: {url, finalUrl, status, contentType, title?, text, truncated}}. http and https only; a private or loopback host (by name, by address, or by what its name resolves to, every redirect checked) is refused before any request, and so is a page that is not text (a PDF, an image). Read only, on the same web queue as web-search. | `pnpm ops web-fetch --json '{"url":"https://example.com/news/item","maxChars":4000}'` |
-| `archive-search` | archive-search searches archive.org (its advanced-search syntax) and answers the items: {"query", "limit"?: 50 (at most 500)} -> {found, items: \[{identifier, title?}\]}, in identifier order. One request through the editor's archive.org client, paced and backed off as an import is. Read only; import-archive-org with "query" imports what a search finds. {"youtubeId", "limit"?: 10} looks for mirrors of one YouTube upload instead: items naming the id in their identifier, title, description or original URL, each read for its files -> {query, found, items: \[{identifier, title?, file, url, source, size?}\], skipped: \[{identifier, why}\]}: each mirror's direct video file URL, an original preferred. | `pnpm ops archive-search --json '{"query":"title:(kitchen) AND mediatype:movies","limit":20}'`<br>`pnpm ops archive-search --json '{"youtubeId":"dQw4w9WgXcQ"}'` |
+| `archive-search` | archive-search searches archive.org (its advanced-search syntax) and answers the items: {"query", "limit"?: 50 (at most 500)} -> {found, items: \[{identifier, title?}\]}, in identifier order. One request through the editor's archive.org client, paced and backed off as an import is. Read only; import-archive-org with "query" imports what a search finds. {"youtubeId", "limit"?: 10} looks for mirrors of one YouTube upload instead: items OF it (their identifier, a file name or their original URL names the id; a title or description that mentions it is not enough), each read for its files -> {query, found, items: \[{identifier, title?, file, url, source, size?, seconds?, namedBy}\], skipped: \[{identifier, why}\]}: each mirror's direct video file URL, an original preferred. | `pnpm ops archive-search --json '{"query":"title:(kitchen) AND mediatype:movies","limit":20}'`<br>`pnpm ops archive-search --json '{"youtubeId":"dQw4w9WgXcQ"}'` |
| `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: {"article"} \| {"articles": true} \| {"siteId"}, "dryRun"?. Per recording, one at a time: the Wayback Machine (the newest capture of its page that recorded a 200), then archive.org (a mirror naming its YouTube id, an original video file preferred). 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". -> {recordings: \[{slug, id, gone, watchUrl, youtubeId, windows, tried: \[{from, found, url?, detail?, error?}\], copy?, outcome: fetch \| text-only \| error}\], items, stopped?, jobId?, refused?}. dryRun answers the lookups and starts nothing. | `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"? -> {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` |
| `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}}. | `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` |
| `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}'` |
| `bench-verdicts` | bench-verdicts runs the verdict bench as a bench-verdicts job: {"models": \["…"\], "run"?, "reports"?: \["<article>"\], "window"? (seconds, default 60), "maxUsd"? (default 5), "limit"?} -> {jobId, run}. Every claim of the registry's fact-checks (or of "reports") with the operator's verdict and a citation with cues is asked of each model, one claim per call (the claim, its quotes, the transcript within the window; never the findings or the verdict), and scored against the rulings. On draft:local when any model is local (through the GPU arbiter; unloaded at the end), else draft:api; the run stops at maxUsd, and an API run is refused past caps.daily. A "run" that exists continues (answered pairs are skipped). Results stay local, in .generation/bench/verdicts/<run>/ (umtool's /bench). The log ends with @@bench-verdicts {run, status, items, skipped, spentUsd, stopped?}. | `pnpm ops bench-verdicts --json '{"models":["claude-sonnet-5-5","qwen3:8b"],"maxUsd":5}' --wait` |
diff --git a/common/jobs/jobKinds.test.ts b/common/jobs/jobKinds.test.ts
@@ -101,6 +101,8 @@ const ADDED_KINDS: Record<string, { label: string; drainable: boolean }> = {
"tts-file": { label: "Text to speech", drainable: false },
// The verdict bench (pnpm ops bench-verdicts, release 28 M7): one run.
"bench-verdicts": { label: "Verdict bench", drainable: false },
+ // find-copy (release 29 E2): the lookups, then one fetch-windows job.
+ "find-copy": { label: "Find copies", drainable: false },
};
test("added kinds carry their pinned label and drainability", () => {
diff --git a/common/jobs/jobKinds.ts b/common/jobs/jobKinds.ts
@@ -962,6 +962,16 @@ const JOB_KINDS: Record<string, JobKindMeta> = {
// the article registry and cues' text, and writes only under the checkout's
// `.generation/bench/`; neither guard. Not replayable: a re-run of the same
// run id resumes it.
+ // find-copy (release 29 E2): the Wayback and archive.org lookups for the
+ // gone recordings a report cites, then (unless a dry run) ONE fetch-windows
+ // job for the copies found. Its own queue; the clients pace the requests.
+ "find-copy": {
+ kind: "find-copy",
+ label: "Find copies",
+ drainable: false,
+ replayable: false,
+ queueKeyStrategy: "custom",
+ },
"bench-verdicts": {
kind: "bench-verdicts",
label: "Verdict bench",
diff --git a/common/publish/missingEvidenceWindows.test.ts b/common/publish/missingEvidenceWindows.test.ts
@@ -150,6 +150,27 @@ test("a cited-only channel (citedChannels) is citable: its window is one to fetc
);
});
+// Release 29 review: members-only is not gone. With no cookies to send it is
+// "unfetchable: members-only"; with a cookie source it is a window to fetch.
+test("a members-only video: unfetchable with no cookies, a window to fetch with a cookie source — never gone", async () => {
+ const SITE2 = "demo-members";
+ writeJson(path.join(videoDir(CH, "member1"), "availability.json"), { checkedAt: "2026-10-01T00:00:00.000Z", availability: "members_only" });
+ writeJson(path.join(paths.sitesDir, SITE2, "site.json"), { title: "Members", channels: [{ slug: CH }], reports: ["r4"] });
+ writeJson(
+ path.join(paths.sitesDir, SITE2, "reports", "r4", "report.json"),
+ report("r4", { m01: { kind: "video", channel: CH, id: "member1", start: 5, end: 6, quote: "members only" } }),
+ );
+ const none = await missingEvidenceWindows(paths, SITE2, { settings: {} });
+ assert.deepEqual(none.unfetchable.map((u) => [u.id, u.why, u.gone]), [["member1", "members-only", undefined]]);
+ assert.deepEqual(none.missing, []);
+ const withCookies = await missingEvidenceWindows(paths, SITE2, { settings: { cookiesFromBrowser: "firefox" } });
+ assert.deepEqual(withCookies.unfetchable, []);
+ assert.deepEqual(withCookies.missing.map((m) => m.id), ["member1"]);
+ // A deferred cookie mode sends none: still unfetchable.
+ const deferred = await missingEvidenceWindows(paths, SITE2, { settings: { cookiesFromBrowser: "firefox", cookieMode: "defer" } });
+ assert.deepEqual(deferred.unfetchable.map((u) => u.why), ["members-only"]);
+});
+
test("a site that does not exist is an error", async () => {
await assert.rejects(missingEvidenceWindows(paths, "no-such-site"), /no site "no-such-site"/);
});
diff --git a/common/publish/reportMedia.ts b/common/publish/reportMedia.ts
@@ -68,6 +68,8 @@ import { isReportId, type Report } from "../lib/report/schema";
import { resolveVideoDir } from "../lib/videoDir-server.mjs";
import { SOURCE_GONE_LABELS, type GoneState } from "../lib/sourceGone";
import { postGoneState, sourceGoneState } from "../lib/sourceGone-server";
+import { resolveEffectiveAvailability } from "../lib/availability-server";
+import { authRetryCookies, resolveCookiePolicy, type CookiePolicyInputs } from "../lib/cookiePolicy";
import { MAX_CLIP_WINDOW_SECONDS } from "../lib/clipWindow";
import {
citedEvidenceSpan,
@@ -472,6 +474,9 @@ export async function readStoreMediaIndex(store: Pick<ReportStore, "stagingDir">
// gone the source says the video is deleted or private (the one
// reading, lib/sourceGone.ts; `gone` names which) — no window
// can be fetched from it; find-copy looks for a copy
+// members-only the source says members-only, and the channel has no
+// cookies to fetch it with (with a cookie source it is a
+// window to fetch: the auth retry sends them). Never gone
// audio-only a feed record: its media is the episode's audio, which a
// download fetches; a window selector has no picture to pick
// too-long longer than one window may be — persist the video instead
@@ -493,7 +498,7 @@ export type EvidenceWindow = {
reason?: string;
};
-export type UnfetchableReason = "not-in-site" | "unreachable" | "gone" | "audio-only" | "too-long";
+export type UnfetchableReason = "not-in-site" | "unreachable" | "gone" | "members-only" | "audio-only" | "too-long";
export type UnfetchableEvidenceWindow = EvidenceWindow & {
why: UnfetchableReason;
@@ -517,7 +522,12 @@ export type MissingEvidenceWindows = {
const floor2 = (n: number) => Math.floor(n * 100 + 1e-6) / 100;
const ceil2 = (n: number) => Math.ceil(n * 100 - 1e-6) / 100;
-export async function missingEvidenceWindows(paths: Paths, siteOrHost: string | ReportHost): Promise<MissingEvidenceWindows> {
+export async function missingEvidenceWindows(
+ paths: Paths,
+ siteOrHost: string | ReportHost,
+ o: { settings?: CookiePolicyInputs } = {},
+): Promise<MissingEvidenceWindows> {
+ const settings = o.settings ?? getSettings();
const host = typeof siteOrHost === "string" ? siteHostFor(paths, siteOrHost) : siteOrHost;
const { reports, problems } = await loadHostReports(host);
const quotes = new Map<string, string>();
@@ -576,11 +586,24 @@ export async function missingEvidenceWindows(paths: Paths, siteOrHost: string |
unfetchable("unreachable", `the channel's media is ${where.status}${where.detail ? ` (${where.detail})` : ""}`);
continue;
}
- const gone = await sourceGoneState(await resolveVideoDir(paths.channelsDir, slug, id));
+ const videoDir = await resolveVideoDir(paths.channelsDir, slug, id);
+ const gone = await sourceGoneState(videoDir);
if (gone) {
out.unfetchable.push({ ...window, why: "gone", gone, message: `the source says the video is ${gone}` });
continue;
}
+ // MEMBERS-ONLY is not gone: a member's cookies fetch it (the auth retry).
+ // With none to send, no fetch can fill it.
+ if (
+ (await resolveEffectiveAvailability(videoDir).catch(() => null)) === "members_only" &&
+ !authRetryCookies(resolveCookiePolicy(settings, config))
+ ) {
+ unfetchable(
+ "members-only",
+ "the source says the video is members-only, and this channel has no cookies to fetch it with (a cookie source on the channel or in Settings)",
+ );
+ continue;
+ }
if (audioOnly) {
unfetchable("audio-only", "a feed record's media is its audio download, not a window");
continue;
diff --git a/editor/app/api/ops/archive-search/route.ts b/editor/app/api/ops/archive-search/route.ts
@@ -4,7 +4,7 @@ import {
ARCHIVE_ORG_SEARCH_MAX_ROWS,
searchArchiveOrgItems,
} from "yt-dlp-transcript-common/controller/archiveOrgImport";
-import { findArchiveOrgMirrors } from "yt-dlp-transcript-common/publish/findCopy";
+import { findArchiveOrgMirrors, isYoutubeId } from "yt-dlp-transcript-common/publish/findCopy";
import { OpsInputError, ops, opsFail, optPositiveInt, optString, reqString } from "../_lib";
export const dynamic = "force-dynamic";
@@ -20,13 +20,15 @@ export const dynamic = "force-dynamic";
// `limit` items (default 50, at most 500) in identifier order. Nothing is
// written; `import-archive-org` with `query` imports what a search finds.
//
-// `youtubeId` (release 29 E2) looks for MIRRORS of one YouTube upload: items
-// naming the id in their identifier, title, description or original URL
-// (publish/findCopy.ts), each read for its files (one request each), and
-// answers each mirror's direct video file URL
-// (`https://archive.org/download/<identifier>/<file>`, an original preferred).
-// An item that does not name the id, is restricted, or holds no file the
-// upload can be told by is `skipped`, with why. `limit` defaults to 10 here.
+// `youtubeId` (release 29 E2) looks for MIRRORS of one YouTube upload
+// (publish/findCopy.ts): the search finds items mentioning the id, each is
+// read for its files (one request each), and only an item OF the upload — its
+// identifier, a file's name or its `originalurl`/`source` names the id, not
+// merely its title or description — is a mirror, answered with its direct
+// video file URL (`https://archive.org/download/<identifier>/<file>`, an
+// original preferred). Anything else is `skipped`, with why. `limit`
+// defaults to 10 here. (find-copy also checks the file's length against the
+// recording's.)
const ARCHIVE_SEARCH_DEFAULT_LIMIT = 50;
const MIRROR_DEFAULT_LIMIT = 10;
@@ -37,7 +39,7 @@ export async function POST(request: Request) {
throw new OpsInputError('send either "query" or "youtubeId", not both');
}
if (youtubeId !== undefined) {
- if (!/^[A-Za-z0-9_-]{6,20}$/.test(youtubeId)) throw new OpsInputError(`"${youtubeId}" is not a YouTube id`);
+ if (!isYoutubeId(youtubeId)) throw new OpsInputError(`"${youtubeId}" is not a YouTube id`);
const limit = optPositiveInt(body, "limit") ?? MIRROR_DEFAULT_LIMIT;
if (limit > ARCHIVE_ORG_SEARCH_MAX_ROWS) throw new OpsInputError(`"limit" is at most ${ARCHIVE_ORG_SEARCH_MAX_ROWS}`);
try {
diff --git a/editor/app/api/ops/fetch-windows/route.ts b/editor/app/api/ops/fetch-windows/route.ts
@@ -26,7 +26,7 @@ import {
export const dynamic = "force-dynamic";
// POST { siteId, maxHeight?, dryRun? }
-// | { items: [{ slug, id, from, to, clipId?, reason?, pad?, webpageUrl? }, …],
+// | { items: [{ slug, id, from, to, clipId?, reason?, pad?, webpageUrl?, force? }, …],
// requestedBy, manifest?, maxHeight?, dryRun? }
// dryRun -> { ok, dryRun: true, groups: [{ platform, queueKey, items }],
// cached, inFlight, unresolved[, onDisk, unfetchable] }
@@ -44,9 +44,13 @@ export const dynamic = "force-dynamic";
// down or held is `refused` for its group, and the other groups still start.
// Re-running the same body is the resume: fetched windows are cached.
//
+// A window of a recording its availability says is deleted or private is
+// refused (unresolved) unless the item names a `webpageUrl` (a copy: find-copy)
+// or `"force": true` (the reading is stale — or check its availability again).
+//
// A big list goes in a file: `pnpm ops fetch-windows --file list.json`.
-const ITEM_KEYS = ["slug", "id", "from", "to", "clipId", "reason", "pad", "webpageUrl"];
+const ITEM_KEYS = ["slug", "id", "from", "to", "clipId", "reason", "pad", "webpageUrl", "force"];
function optItemString(e: OpsBody, key: string, where: string): string | undefined {
const v = e[key];
@@ -55,6 +59,11 @@ function optItemString(e: OpsBody, key: string, where: string): string | undefin
return v.trim() || undefined;
}
+function reqItemForce(v: unknown, where: string): boolean {
+ if (typeof v !== "boolean") throw new OpsInputError(`"${where}.force" must be a boolean`);
+ return v;
+}
+
function reqSeconds(e: OpsBody, key: string, where: string): number {
const v = e[key];
if (typeof v !== "number" || !Number.isFinite(v) || v < 0) {
@@ -106,6 +115,7 @@ function reqWindowItems(body: OpsBody): FetchWindowsItem[] {
reason: optItemString(e, "reason", where)?.slice(0, 400),
...(typeof pad === "number" ? { pad } : {}),
webpageUrl: optItemString(e, "webpageUrl", where),
+ ...(e.force !== undefined ? { force: reqItemForce(e.force, where) } : {}),
};
});
}
diff --git a/editor/app/api/ops/find-copy/route.ts b/editor/app/api/ops/find-copy/route.ts
@@ -1,26 +1,26 @@
-import { NextResponse } from "next/server";
import { findCopyAction } from "../../../channels/[slug]/videos/findCopyAction";
-import { OpsInputError, ops, opsFail, optBool, optString } from "../_lib";
+import { OpsInputError, jobResponse, ops, optBool, optString } from "../_lib";
export const dynamic = "force-dynamic";
-// POST { article } | { siteId } | { articles: true }, dryRun?
-// -> { ok, dryRun, host, recordings: [{ slug, id, gone, watchUrl, youtubeId,
-// windows, tried: [{ from, found, url?, detail?, error? }], copy?,
-// outcome: fetch | text-only | error }], items, stopped?, jobId? }
+// POST { article } | { siteId } | { articles: true }, dryRun? -> { ok, jobId }
//
// A COPY OF EVERY GONE RECORDING THE REPORTS CITE (release 29 E2,
-// publish/findCopy.ts): of one article (`article`), every published
-// article (`articles`), or a site's reports (`siteId`), the cited windows
-// whose recording is deleted or private ("unfetchable: gone"). Per recording,
-// one at a time: the Wayback Machine (a capture of its page that recorded a
-// 200, the newest) then archive.org (a mirror naming its YouTube id, an
-// original video file preferred). 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 deleted"). `dryRun` answers the lookups and starts
-// nothing. The lookups run in the request, paced.
+// publish/findCopy.ts), as a `find-copy` job: of one article (`article`),
+// every published article (`articles`), or a site's reports (`siteId`), the
+// cited windows whose recording is deleted or private ("unfetchable: gone").
+// 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
+// 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
+// deleted"). `dryRun` looks and starts no fetch. The job's log ends with
+// `@@find-copy {recordings: [{slug, id, gone, watchUrl, youtubeId, windows,
+// 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) => {
const article = optString(body, "article")?.trim();
@@ -29,12 +29,12 @@ export async function POST(request: Request) {
if ([article, siteId, articles || undefined].filter(Boolean).length !== 1) {
throw new OpsInputError('send one of "article" (an article id), "articles": true or "siteId"');
}
- const r = await findCopyAction({
- ...(article ? { article } : {}),
- ...(siteId ? { siteId } : {}),
- dryRun: optBool(body, "dryRun") === true,
- });
- if (!r.ok) return opsFail(r.error);
- return NextResponse.json(r);
+ return jobResponse(
+ await findCopyAction({
+ ...(article ? { article } : {}),
+ ...(siteId ? { siteId } : {}),
+ dryRun: optBool(body, "dryRun") === true,
+ }),
+ );
});
}
diff --git a/editor/app/channels/[slug]/videos/fetchWindowsAction.test.ts b/editor/app/channels/[slug]/videos/fetchWindowsAction.test.ts
@@ -178,4 +178,15 @@ test("a gone recording's window is refused at the door unless the item names a c
if (!viaCopy.ok) return;
assert.deepEqual(viaCopy.unresolved, []);
assert.deepEqual(viaCopy.groups.flatMap((g) => g.items.map((i) => i.webpageUrl)), [copy]);
+ // A stale reading: "force" fetches from the recording's own page; the refusal named the re-check.
+ assert.match(plain.unresolved[0].error, /Check availability.*"force": true/);
+ const forced = await fetchWindowsAction({
+ items: [{ slug: SLUG, id: "deleted1", from: 1, to: 3, force: true }],
+ requestedBy: "test",
+ dryRun: true,
+ });
+ assert.ok(forced.ok);
+ if (!forced.ok) return;
+ assert.deepEqual(forced.unresolved, []);
+ assert.deepEqual(forced.groups.flatMap((g) => g.items.map((i) => i.webpageUrl)), ["https://www.youtube.com/watch?v=deleted1"]);
});
diff --git a/editor/app/channels/[slug]/videos/fetchWindowsAction.ts b/editor/app/channels/[slug]/videos/fetchWindowsAction.ts
@@ -225,17 +225,18 @@ async function planFetchWindows(
}
// A RECORDING GONE FROM ITS PLATFORM (lib/sourceGone.ts) has no page to
// fetch a window from: refused here, before any request — unless the item
- // names a copy's URL (`webpageUrl`: find-copy's Wayback capture or
- // archive.org file, release 29 E2), which is the only way such a window is
- // fetched.
- if (!item.webpageUrl?.trim()) {
+ // names a copy's URL (`webpageUrl`: find-copy's Wayback or archive.org copy,
+ // release 29 E2) or says `force` (a stale reading). The refusal names the
+ // re-check that clears a stale one.
+ if (!item.webpageUrl?.trim() && !item.force) {
const gone = await sourceGoneState(videoDir);
if (gone) {
unresolved.push({
item,
error:
`The source says the video is ${gone}: there is no page to fetch a window from. ` +
- "pnpm ops find-copy looks for a copy (Wayback, archive.org) and fetches from it.",
+ "If it is back, check its availability again (the channel page's Diagnostics → Check availability) " +
+ 'or send the item with "force": true; pnpm ops find-copy looks for a copy (Wayback, archive.org).',
});
continue;
}
diff --git a/editor/app/channels/[slug]/videos/findCopyAction.ts b/editor/app/channels/[slug]/videos/findCopyAction.ts
@@ -5,30 +5,26 @@ import { getSite, isValidSiteId, listSiteIds } from "yt-dlp-transcript-common/li
import { clipWindowQueueKey } from "yt-dlp-transcript-common/lib/queueKeys";
import { platformQueueKey } from "yt-dlp-transcript-common/lib/platform";
import { articlesWorkHost, siteReportHost, type ReportHost } from "yt-dlp-transcript-common/publish/reportHost";
-import { runFindCopy, type FindCopyResult } from "yt-dlp-transcript-common/publish/findCopy";
+import { runFindCopy } from "yt-dlp-transcript-common/publish/findCopy";
+import { runManagedFunction, type StreamActionResult } from "yt-dlp-transcript-common/jobs/streamCommand";
import { fetchWindowsJobAction } from "./fetchWindowsAction";
// FIND A COPY OF THE GONE RECORDINGS A REPORT CITES, and fetch their windows
-// from it (release 29 E2; the lookups are publish/findCopy.ts). The windows
-// of every copy found go to ONE fetch-windows job on the archive.org clip
-// queue — Wayback captures and archive.org files are both archive.org's — so
-// they are fetched one at a time, paced, one stream.
-
-export type FindCopyActionResult =
- | { ok: false; error: string }
- | (FindCopyResult & {
- ok: true;
- dryRun: boolean;
- // The fetch-windows job, when one started.
- jobId?: string;
- // Why the fetch did not start, when it did not.
- refused?: string;
- });
+// from it (release 29 E2; the lookups are publish/findCopy.ts) — AS A JOB
+// (`find-copy`, its own queue): the lookups take seconds per recording, paced,
+// and a request must not hold them (nor start a fetch after its caller gave
+// up). A cancelled job starts no fetch. The windows of every copy found go to
+// ONE fetch-windows job on the archive.org clip queue — Wayback copies and
+// archive.org files are both archive.org's — so they are fetched one at a
+// time, paced, one stream. The job's log ends with
+// `@@find-copy {recordings, items, stopped?, fetchJobId?, refused?}`.
+export const FIND_COPY_RESULT_MARKER = "@@find-copy ";
+const FIND_COPY_QUEUE = "find-copy";
// The archive.org clip queue: every copy's windows, one job, one stream.
-const FIND_COPY_QUEUE = clipWindowQueueKey(platformQueueKey("archiveorg"));
+const FETCH_QUEUE = clipWindowQueueKey(platformQueueKey("archiveorg"));
-export async function findCopyAction(req: { article?: string; siteId?: string; dryRun?: boolean }): Promise<FindCopyActionResult> {
+export async function findCopyAction(req: { article?: string; siteId?: string; dryRun?: boolean }): Promise<StreamActionResult> {
const paths = getPaths();
let host: ReportHost;
try {
@@ -44,28 +40,41 @@ export async function findCopyAction(req: { article?: string; siteId?: string; d
} catch (e) {
return { ok: false, error: (e as Error).message };
}
- let refused: string | undefined;
- const r = await runFindCopy({
+ return runManagedFunction({
+ kind: "find-copy",
+ queueKey: FIND_COPY_QUEUE,
paths,
- host,
- dryRun: req.dryRun,
- startFetch: async (items) => {
- const res = await fetchWindowsJobAction({ items, requestedBy: "find-copy", manifest: host.id, queueKey: FIND_COPY_QUEUE });
- if (!res.ok) {
- refused = res.error;
- return null;
- }
- // Nobody reads the stream: the job's log is on disk.
- void res.stream.cancel().catch(() => {});
- return res.jobId;
+ fn: async (onLog, signal) => {
+ let refused: string | undefined;
+ const r = await runFindCopy({
+ paths,
+ host,
+ dryRun: req.dryRun,
+ signal,
+ onLog,
+ startFetch: async (items) => {
+ const res = await fetchWindowsJobAction({ items, requestedBy: "find-copy", manifest: host.id, queueKey: FETCH_QUEUE });
+ if (!res.ok) {
+ refused = res.error;
+ return null;
+ }
+ // Nobody reads the stream: the job's log is on disk.
+ void res.stream.cancel().catch(() => {});
+ onLog(`find-copy: fetch-windows job ${res.jobId} fetches ${items.length} window(s) from the copies found.`);
+ return res.jobId;
+ },
+ });
+ const { fetch: fetchJobId, ...found } = r;
+ onLog(
+ `${FIND_COPY_RESULT_MARKER}${JSON.stringify({
+ ...found,
+ dryRun: req.dryRun === true,
+ ...(typeof fetchJobId === "string" ? { fetchJobId } : {}),
+ ...(refused ? { refused } : {}),
+ })}`,
+ );
+ if (refused) throw new Error(`the fetch was refused: ${refused}`);
+ if (signal.aborted) throw new Error("cancelled");
},
});
- const { fetch: jobId, ...found } = r;
- return {
- ok: true,
- dryRun: req.dryRun === true,
- ...found,
- ...(typeof jobId === "string" ? { jobId } : {}),
- ...(refused ? { refused } : {}),
- };
}
diff --git a/scripts/archilyzer-ops.mjs b/scripts/archilyzer-ops.mjs
@@ -1148,7 +1148,11 @@ export function usage() {
' (YouTube and Rumble side by side): {"siteId"} fetches every window the',
' site\'s published reports cite and the disk does not hold; {"items":',
' [{"slug", "id", "from", "to", "clipId"?, "reason"?, "pad"?,',
- ' "webpageUrl"?}, ...], "requestedBy", "manifest"?} fetches a list.',
+ ' "webpageUrl"?, "force"?}, ...], "requestedBy", "manifest"?} fetches a list.',
+ ' A window of a recording whose availability says deleted or private is',
+ ' refused (unresolved) unless the item names a "webpageUrl" (a copy:',
+ ' find-copy) or "force": true (a stale reading; or check its availability',
+ " again on the channel page's Diagnostics).",
' "maxHeight" caps the source height (default 720). "dryRun": true lists',
' the windows per platform, the ones already on disk ("cached") and the',
' ones no fetch can fill ("unfetchable": deleted, off the site) and starts',
@@ -1234,10 +1238,12 @@ export function usage() {
" editor's archive.org client, paced and backed off as an import is. Read",
' only; import-archive-org with "query" imports what a search finds.',
' {"youtubeId", "limit"?: 10} looks for mirrors of one YouTube upload',
- ' instead: items naming the id in their identifier, title, description or',
- ' original URL, each read for its files -> {query, found, items:',
- ' [{identifier, title?, file, url, source, size?}], skipped: [{identifier,',
- ' why}]}: each mirror\'s direct video file URL, an original preferred.',
+ ' instead: items OF it (their identifier, a file name or their original',
+ ' URL names the id; a title or description that mentions it is not',
+ ' enough), each read for its files -> {query, found, items: [{identifier,',
+ ' title?, file, url, source, size?, seconds?, namedBy}], skipped:',
+ " [{identifier, why}]}: each mirror's direct video file URL, an original",
+ ' preferred.',
"",
'archive-item answers one archive.org item\'s files from its metadata:',
' {"item"} -> {item: {identifier, url, title?, date?, mediatype?, creator?,',
@@ -1255,19 +1261,21 @@ export function usage() {
" manners (one at a time, 2 s apart, 429s waited out). Read only.",
"",
'find-copy looks for a copy of every gone recording (deleted or private) a',
- ' report cites, and fetches the cited windows from it: {"article"} |',
- ' {"articles": true} | {"siteId"}, "dryRun"?. Per recording, one at a time:',
- " the Wayback Machine (the newest capture of its page that recorded a 200),",
- " then archive.org (a mirror naming its YouTube id, an original video file",
- " preferred). 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". ->',
- " {recordings: [{slug, id, gone, watchUrl, youtubeId, windows, tried:",
- " [{from, found, url?, detail?, error?}], copy?, outcome: fetch | text-only",
- " | error}], items, stopped?, jobId?, refused?}. dryRun answers the lookups",
- " and starts nothing.",
+ ' 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.",
"",
'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',