commit e027f701ec5ddc8ef57e24091a8138ca088d41da
parent fa307601909d8608b7cce602771e9268cc3566ce
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Wed, 21 Oct 2026 19:41:50 -0400
fetch-windows: "minGapSeconds" sets one run's gap floor in place of the platform's
Rumble's 120 s floor stays the default; an operator who wants a batch faster
asks for it per run (30–3600 s, still jittered, the channel's pace still on
top). A Retry keeps it.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
8 files changed, 71 insertions(+), 10 deletions(-)
diff --git a/COMMANDS.md b/COMMANDS.md
@@ -143,7 +143,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"?, "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. "storedUrl": "fallback" \| "only" (default "never") cuts a window from the media URL its record's metadata.info.json stores — Odysee's CDN file (\*.odycdn.com), the only platform allowed — when the page lookup is rate-limited ("fallback": after a 429) or without asking the page at all ("only"). A held or cooling platform still runs its windows that have one; the rest are refused or left for a later run. Same queue, same gaps; the window's provenance says source "stored-media-url". | `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. "storedUrl": "fallback" \| "only" (default "never") cuts a window from the media URL its record's metadata.info.json stores — Odysee's CDN file (\*.odycdn.com), the only platform allowed — when the page lookup is rate-limited ("fallback": after a 429) or without asking the page at all ("only"). A held or cooling platform still runs its windows that have one; the rest are refused or left for a later run. Same queue, same gaps; the window's provenance says source "stored-media-url". "minGapSeconds" (items only, 30–3600) sets this run's pause between two fetches in place of the platform's floor (Rumble's 120 s); still jittered up to half again. Shorter than the default risks Rumble's IP-wide Cloudflare challenge; a Retry keeps it. | `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. "whilePaused": true runs it during a pause-all on a worker the pause alone switched off (never one drained, degraded or disabled by hand); the pause stays on. 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` |
diff --git a/common/controller/fetchWindows.test.ts b/common/controller/fetchWindows.test.ts
@@ -282,6 +282,23 @@ test("rumble windows are further apart, whatever platform their channel names",
assert.ok(h.rec.sleeps[0] <= floor * 1.5 + 60_000);
});
+test("minGapSeconds replaces rumble's floor for one run, never below the global floor", async () => {
+ const rumble = (id: string): FetchWindowsItem => ({ slug: "c", id, from: 10, to: 20, webpageUrl: `https://rumble.com/${id}-x.html` });
+ for (const [asked, floor] of [[60, 60], [5, CLIP_WINDOW_MIN_GAP_SECONDS]] as const) {
+ const h = harness();
+ await fetchWindows({
+ paths: await corpus(),
+ items: [rumble("v1"), rumble("v2")],
+ provenance: { requestedBy: "test" },
+ minGapSeconds: asked,
+ deps: h.deps,
+ });
+ assert.equal(h.rec.sleeps.length, 1);
+ assert.ok(h.rec.sleeps[0] >= floor * 1000, `${h.rec.sleeps[0]} is at least ${floor}s`);
+ assert.ok(h.rec.sleeps[0] < CLIP_WINDOW_PLATFORM_MIN_GAP_SECONDS.rumble * 1000, "under rumble's default floor");
+ }
+});
+
test("a second run on the same platform waits out the gap the first one set", async () => {
const next = new Map<string, number>();
const shared = {
diff --git a/common/controller/fetchWindows.ts b/common/controller/fetchWindows.ts
@@ -333,6 +333,7 @@ export async function fetchWindows({
provenance,
maxHeight,
gapMs,
+ minGapSeconds,
storedUrl: storedMode = "never",
onLog,
signal,
@@ -347,6 +348,11 @@ export async function fetchWindows({
// The pause between two network fetches. Absent = the platform's batch gap,
// floored at CLIP_WINDOW_MIN_GAP_SECONDS.
gapMs?: number;
+ // The operator's floor for this run, in place of the platform's
+ // (CLIP_WINDOW_PLATFORM_MIN_GAP_SECONDS — Rumble's 120 s): never below
+ // CLIP_WINDOW_MIN_GAP_SECONDS. Still jittered, still the channel's pace on
+ // top; a shorter gap risks Rumble's IP-wide Cloudflare challenge.
+ minGapSeconds?: number;
// Cut from the stored media URL: never (default) | fallback | only (above).
storedUrl?: StoredUrlMode;
onLog?: (line: string) => void;
@@ -559,11 +565,14 @@ export async function fetchWindows({
channelPaceSeconds(paced),
staticSleepRequestsSeconds(channelPlatform(paced)),
{
- minSeconds: Math.max(
- CLIP_WINDOW_MIN_GAP_SECONDS,
- platformMinGapSeconds(channelPlatform(paced)),
- CLIP_WINDOW_PLATFORM_MIN_GAP_SECONDS[platform] ?? 0,
- ),
+ minSeconds:
+ minGapSeconds !== undefined
+ ? Math.max(CLIP_WINDOW_MIN_GAP_SECONDS, minGapSeconds)
+ : Math.max(
+ CLIP_WINDOW_MIN_GAP_SECONDS,
+ platformMinGapSeconds(channelPlatform(paced)),
+ CLIP_WINDOW_PLATFORM_MIN_GAP_SECONDS[platform] ?? 0,
+ ),
},
);
const gapKey = `clip-window:${platform}`;
diff --git a/editor/app/api/ops/fetch-windows/route.test.ts b/editor/app/api/ops/fetch-windows/route.test.ts
@@ -81,6 +81,9 @@ test("an item list is validated at the door", async () => {
[{ items: [item()], requestedBy: "t", maxHeight: 50 }, /"maxHeight" must be a whole number of pixels/],
[{ items: [item()], requestedBy: "t", storedUrl: "always" }, /"storedUrl" must be one of "never", "fallback", "only"/],
[{ items: [item()], requestedBy: "t", storedUrl: true }, /"storedUrl" must be one of/],
+ [{ items: [item()], requestedBy: "t", minGapSeconds: 10 }, /"minGapSeconds" must be seconds from 30 to 3600/],
+ [{ items: [item()], requestedBy: "t", minGapSeconds: "60" }, /"minGapSeconds" must be seconds/],
+ [{ siteId: "demo-site", minGapSeconds: 60 }, /"minGapSeconds" goes with "items"/],
];
for (const [body, re] of cases) {
const r = await post(body);
diff --git a/editor/app/api/ops/fetch-windows/route.ts b/editor/app/api/ops/fetch-windows/route.ts
@@ -11,7 +11,10 @@ import {
isStoredUrlMode,
type StoredUrlMode,
} from "yt-dlp-transcript-common/lib/storedMediaUrl";
-import type { FetchWindowsItem } from "yt-dlp-transcript-common/controller/fetchWindows";
+import {
+ CLIP_WINDOW_MIN_GAP_SECONDS,
+ type FetchWindowsItem,
+} from "yt-dlp-transcript-common/controller/fetchWindows";
import {
fetchMissingEvidenceAction,
fetchWindowsAction,
@@ -32,7 +35,7 @@ export const dynamic = "force-dynamic";
// POST { siteId, maxHeight?, storedUrl?, dryRun? }
// | { items: [{ slug, id, from, to, clipId?, reason?, pad?, webpageUrl?, force? }, …],
-// requestedBy, manifest?, maxHeight?, storedUrl?, dryRun? }
+// requestedBy, manifest?, maxHeight?, storedUrl?, minGapSeconds?, dryRun? }
// dryRun -> { ok, dryRun: true, groups: [{ platform, queueKey, items }],
// cached, inFlight, unresolved[, onDisk, unfetchable] }
// else -> { ok, dryRun: false, jobs: [{ platform, queueKey, jobId, items }],
@@ -60,6 +63,11 @@ export const dynamic = "force-dynamic";
// or cooling platform's group still runs its windows that have one; the rest are
// refused. The dry run's group says how many have one (`storedUrlItems`).
//
+// `minGapSeconds` (items only): this run's pause between two fetches, in place
+// of the platform's floor (Rumble 120 s); at least CLIP_WINDOW_MIN_GAP_SECONDS,
+// still jittered up to half again. Shorter than the default risks Rumble's
+// IP-wide Cloudflare challenge — the operator's call, per run.
+//
// 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", "force"];
@@ -141,6 +149,17 @@ function optStoredUrl(body: OpsBody): StoredUrlMode | undefined {
return v;
}
+function optMinGapSeconds(body: OpsBody): number | undefined {
+ const v = body.minGapSeconds;
+ if (v === undefined || v === null) return undefined;
+ if (typeof v !== "number" || !Number.isFinite(v) || v < CLIP_WINDOW_MIN_GAP_SECONDS || v > 3600) {
+ throw new OpsInputError(
+ `"minGapSeconds" must be seconds from ${CLIP_WINDOW_MIN_GAP_SECONDS} to 3600`,
+ );
+ }
+ return v;
+}
+
function optMaxHeight(body: OpsBody): number | undefined {
const v = body.maxHeight;
if (v === undefined || v === null) return undefined;
@@ -156,18 +175,19 @@ function optMaxHeight(body: OpsBody): number | undefined {
export async function POST(request: Request) {
return ops(
request,
- ["siteId", "items", "requestedBy", "manifest", "maxHeight", "storedUrl", "dryRun"],
+ ["siteId", "items", "requestedBy", "manifest", "maxHeight", "storedUrl", "minGapSeconds", "dryRun"],
async (body) => {
const maxHeight = optMaxHeight(body);
const storedUrl = optStoredUrl(body);
const dryRun = optBool(body, "dryRun");
+ const minGapSeconds = optMinGapSeconds(body);
if (body.siteId !== undefined && body.items !== undefined) {
throw new OpsInputError('send either "siteId" or "items", not both');
}
let result: Awaited<ReturnType<typeof fetchWindowsAction>>;
if (body.siteId !== undefined) {
// A site's windows say who asked themselves (the reports, by site).
- for (const k of ["requestedBy", "manifest"]) {
+ for (const k of ["requestedBy", "manifest", "minGapSeconds"]) {
if (body[k] !== undefined) {
throw new OpsInputError(`"${k}" goes with "items"; a site's windows name the site`);
}
@@ -191,6 +211,7 @@ export async function POST(request: Request) {
maxHeight,
storedUrl,
dryRun,
+ ...(minGapSeconds !== undefined ? { minGapSeconds } : {}),
});
} else {
throw new OpsInputError('"siteId" (a site\'s missing evidence) or "items" (a list of windows) is required');
diff --git a/editor/app/channels/[slug]/videos/fetchWindowsAction.ts b/editor/app/channels/[slug]/videos/fetchWindowsAction.ts
@@ -106,6 +106,8 @@ export type FetchWindowsRequest = {
queueKey?: string;
// Cut from the stored media URL: "never" (default) | "fallback" | "only".
storedUrl?: StoredUrlMode;
+ // The run's gap floor in seconds, in place of the platform's (controller).
+ minGapSeconds?: number;
};
export type FetchWindowsUnresolved = { item: FetchWindowsItem; error: string };
@@ -325,6 +327,7 @@ export async function fetchWindowsJobAction(req: {
maxHeight?: number;
queueKey: string;
storedUrl?: StoredUrlMode;
+ minGapSeconds?: number;
}): Promise<StreamActionResult> {
if (req.items.length === 0) return { ok: false, error: "No windows to fetch." };
if (req.maxHeight !== undefined && !isFetchMaxHeight(req.maxHeight)) {
@@ -361,6 +364,7 @@ export async function fetchWindowsJobAction(req: {
...(req.maxHeight !== undefined ? { maxHeight: req.maxHeight } : {}),
// A Retry keeps the mode it was asked with.
...(req.storedUrl && req.storedUrl !== "never" ? { storedUrl: req.storedUrl } : {}),
+ ...(req.minGapSeconds !== undefined ? { minGapSeconds: req.minGapSeconds } : {}),
},
},
fn: async (onLog, signal, setProgress, ctx) => {
@@ -374,6 +378,7 @@ export async function fetchWindowsJobAction(req: {
},
maxHeight: req.maxHeight,
storedUrl: req.storedUrl,
+ minGapSeconds: req.minGapSeconds,
onLog,
signal,
drainSignal: ctx.drainSignal,
@@ -467,6 +472,7 @@ export async function fetchWindowsAction(
maxHeight: req.maxHeight,
queueKey: g.queueKey,
storedUrl: storedMode,
+ ...(req.minGapSeconds !== undefined ? { minGapSeconds: req.minGapSeconds } : {}),
});
} catch (e) {
refused.push({ platform: g.platform, error: (e as Error).message, items: door.run.length });
diff --git a/editor/app/jobs/jobReplayRegistry.ts b/editor/app/jobs/jobReplayRegistry.ts
@@ -212,6 +212,7 @@ export const JOB_REPLAY_HANDLERS: Record<string, ReplayHandler> = {
queueKey,
maxHeight: num(p.maxHeight),
...(isStoredUrlMode(p.storedUrl) ? { storedUrl: p.storedUrl } : {}),
+ ...(num(p.minGapSeconds) !== undefined ? { minGapSeconds: num(p.minGapSeconds) } : {}),
});
},
// A batch of windows. Replay re-runs the same list on the same queue; the
diff --git a/scripts/archilyzer-ops.mjs b/scripts/archilyzer-ops.mjs
@@ -1404,6 +1404,10 @@ export function usage() {
' ("only"). A held or cooling platform still runs its windows that have',
' one; the rest are refused or left for a later run. Same queue, same gaps;',
' the window\'s provenance says source "stored-media-url".',
+ ' "minGapSeconds" (items only, 30–3600) sets this run\'s pause between two',
+ " fetches in place of the platform's floor (Rumble's 120 s); still jittered",
+ " up to half again. Shorter than the default risks Rumble's IP-wide",
+ " Cloudflare challenge; a Retry keeps it.",
"",
'"preview": "<branch>" on deploy-site or build-deploy makes it a Cloudflare',
" Pages PREVIEW instead of production: the same bundle goes to a branch",