Archilyzer · Source

archilyzer

Archilyzer
git clone https://archilyzer.pages.dev/source/archilyzer.git
Log | Files | Refs | README | LICENSE

commit 5ac698ad1decf2eb62960a3de477a12a263d7ad5
parent 5917853f536b3d443f722f0f9427068d7e6dba29
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Fri, 16 Oct 2026 23:51:07 -0400

editor: storedUrl on transcribe-one, retry-bucket and download-missing (ops bodies checked at the door, kept on Retry); a held platform's download-missing or retry with a stored-URL mode runs as only; the video page's download and Transcribe take the mode (Transcribe downloads through the managed path when one is set); ops help, COMMANDS.md

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Diffstat:
MCOMMANDS.md | 6+++---
Aeditor/app/api/ops/_storedUrl.ts | 17+++++++++++++++++
Meditor/app/api/ops/download-missing/route.ts | 14++++++++++++--
Meditor/app/api/ops/retry-bucket/route.test.ts | 19+++++++++++++++++++
Meditor/app/api/ops/retry-bucket/route.ts | 11++++++++++-
Meditor/app/api/ops/transcribe-one/route.ts | 13+++++++++++--
Meditor/app/channels/[slug]/pipelineActions.ts | 34+++++++++++++++++++++++++++++++++-
Meditor/app/channels/[slug]/videos/[id]/videoActions.ts | 95+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------
Meditor/app/jobs/jobReplayRegistry.ts | 3+++
Mscripts/archilyzer-ops.mjs | 10++++++++++
10 files changed, 201 insertions(+), 21 deletions(-)

diff --git a/COMMANDS.md b/COMMANDS.md @@ -117,8 +117,8 @@ Drives a running editor over HTTP (`/api/ops/*`, the same actions its pages run) | `feed-metadata` | feed-metadata completes a podcast channel's records from its RSS feed: one fetch of the channel's url, then title, date, description and duration into each record that lacks them: {"slug"}. "dryRun": true counts matched, unmatched and already complete, and writes nothing. | `pnpm ops feed-metadata --json '{"slug":"demo-podcast","dryRun":true}' --wait` | | `refresh-report` | refresh-report regenerates a channel's report (the buckets and counts its page shows) on the one serial report queue: {"slug"} answers the job queued, or the one already waiting ("started": false); {"all": true} queues every channel and answers {queued, jobIds, skipped}. | `pnpm ops refresh-report --json '{"all":true}'` | | `sync` | sync lists a channel and downloads what is new, as its Sync button does: {"slug"}. "full": true runs the periodic whole-listing sweep now (else the configured cadence decides); "queueKey" picks another queue. On the channel's platform queue, paced like its downloads. | `pnpm ops sync --json '{"slug":"the-quartering"}' --wait` | -| `download-missing` | download-missing downloads every listed video the channel does not hold: {"slug"}. "ignoreArchive": true drops the download archive so listed videos it names are fetched again (recovery from a stale archive); "abortOnError": false carries on past a failure (default: stop at the first that is not one video's own). Paced on the platform's queue. | | -| `retry-bucket` | retry-bucket runs one bucket of a channel's report as one job, past any lane hold: {"slug", "bucket"}. "ids": \[...\] runs only those videos, and every one must be in the bucket (a stray id is refused, named); a job run with ids is not replayable, as a checkbox selection in the UI is not. "corruptFullSource" downloads again: the kept file is set aside, and comes back if the download fails; malformed again, the longer decode stays. "corruptHeldAudio" (held audio the audio audit found damaged) is refetched the same way, with the audio check on; the new file is audited again. | `pnpm ops retry-bucket --json '{"slug":"demo-odysee","bucket":"corruptHeldAudio"}' --wait` | +| `download-missing` | download-missing downloads every listed video the channel does not hold: {"slug"}. "ignoreArchive": true drops the download archive so listed videos it names are fetched again (recovery from a stale archive); "abortOnError": false carries on past a failure (default: stop at the first that is not one video's own). Paced on the platform's queue. "storedUrl": "fallback" \| "only" reads each video from the media URL its record stores when the page is rate-limited (or always), one file per 20 min; with one, a held platform's run goes ahead as "only". | | +| `retry-bucket` | retry-bucket runs one bucket of a channel's report as one job, past any lane hold: {"slug", "bucket"}. "ids": \[...\] runs only those videos, and every one must be in the bucket (a stray id is refused, named); a job run with ids is not replayable, as a checkbox selection in the UI is not. "corruptFullSource" downloads again: the kept file is set aside, and comes back if the download fails; malformed again, the longer decode stays. "storedUrl": "fallback" \| "only" reads each from the media URL its record stores, as on download-missing (a held platform's retry runs as "only"). "corruptHeldAudio" (held audio the audio audit found damaged) is refetched the same way, with the audio check on; the new file is audited again. | `pnpm ops retry-bucket --json '{"slug":"demo-odysee","bucket":"corruptHeldAudio"}' --wait` | | `transcribe-bucket` | transcribe-bucket transcribes a channel's "downloaded, not transcribed" bucket on the transcription queue, as the channel page's Transcribe button does: {"slug"}. "ids": \[...\] narrows it the same way as on retry-bucket. | | | `fetch-posts` | fetch-posts fetches a social channel's new posts: {"slug"}. "full": true re-walks the whole timeline; "older": true walks back from the oldest archived post through search (X; needs a login), saving its place for the next run, down to "floor": "YYYY-MM-DD" when given; "from": "YYYY-MM-DD" starts the walk afresh there, replacing its saved place (and a "complete") — for a gap above one surviving old post. "limit": N caps the posts one run reads; "pages": N caps the pages (a forum thread: its latest N pages). "full" and "older" together are refused. An older walk over an account that shows no posts (nothing archived, and the last timeline fetch read none) is refused unless "force": true. A drained fetch stops at its next resume point and the next run resumes. | | | `capture-posts` | capture-posts captures archived posts of a social channel (X, forum, Bluesky): a screenshot of each through the connected X profile (a forum thread: its host's forum profile; Bluesky: a headless browser with no login on bsky.app, the shot cropped to the post), and its attached media through gallery-dl (a forum thread: the same profile; Bluesky: its images from the CDN), into the channel's posts-media/&lt;id&gt;/: {"slug", "ids": \[...\]}. Every id must be in the channel's posts archive. "shots": false or "media": false skips that half; posts already captured are skipped unless "force": true. A post that links to an X Article also gets the article (article.json, .md, .png and its images) unless "articles": false; both halves off with "articles": true reads only the articles. Paced like a post fetch, on its queue. | | @@ -144,7 +144,7 @@ Drives a running editor over HTTP (`/api/ops/*`, the same actions its pages run) | `settings` | settings patches settings.json through the editor's one writer: {"patch": {"&lt;top-level key&gt;": value, …}} (SETTINGS.md). A block's keys merge one level; an array, a scalar or an object nested in a block replaces. Refused before anything is written: an unknown key; a key another writer owns (channelPriority, autoQueue, workers, storage — the refusal names it); a value the schema would not keep as sent (clamped, dropped), named with what would be saved. Answers the saved values. | `pnpm ops settings --json '{"patch":{"minFreeDiskGB":20}}'` | | `clear-platform-hold` | clear-platform-hold clears a platform's rate-limit hold, backoff and raised pace, as the lane strip's Clear hold: {"platform"}. Answers the sentence. | | | `workers` | workers switches transcription workers as /workers does: {"op": "enable" \| "disable" \| "drain", "ids": \[...\]} — the live pool; a restart restores the launch default. An unknown id is named; the others still apply. | `pnpm ops workers --json '{"op":"disable","ids":["parakeet-cpu"]}'` | -| `transcribe-one` | transcribe-one transcribes one video: {"slug", "id", "file"?}. With "file" (an audio file in its dir) that file; without, the video page's Transcribe — the audio on disk, or downloaded first through the channel's managed path. A job; --wait follows it. "salvage": true decodes a damaged file with error tolerance and transcribes what decodes, on the recording's clock, its gaps recorded (the transcript is listed as salvaged); a corrupt-full-source video is salvaged unless "salvage": false. | | +| `transcribe-one` | transcribe-one transcribes one video: {"slug", "id", "file"?}. With "file" (an audio file in its dir) that file; without, the video page's Transcribe — the audio on disk, or downloaded first through the channel's managed path. A job; --wait follows it. "salvage": true decodes a damaged file with error tolerance and transcribes what decodes, on the recording's clock, its gaps recorded (the transcript is listed as salvaged); a corrupt-full-source video is salvaged unless "salvage": false. "storedUrl": "only" \| "fallback" \| "never" downloads missing audio from the media URL the record stores (Odysee's CDN), read in ranges as its player reads it — no page request with "only", the page first with "fallback" — through the audio check; one new file per platform per 20 min. Absent = the channel's storedUrlDownloads. | | | `delete-file` | delete-file deletes one file of one video, as its Files list does: {"slug", "id", "file"}. A tiered media file goes with its bytes on the media drive (never a bare link); refused while that drive is not answering. No undo. | | | `do-not-clean` | do-not-clean sets one video's "Do not clean" marker: {"slug", "id", "keep"?: true}; "keep": false removes it. (keep-videos is the bulk form.) | | | `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` | diff --git a/editor/app/api/ops/_storedUrl.ts b/editor/app/api/ops/_storedUrl.ts @@ -0,0 +1,17 @@ +import { + isStoredUrlMode, + STORED_URL_MODES, + type StoredUrlMode, +} from "yt-dlp-transcript-common/lib/storedMediaUrl"; +import { OpsInputError, type OpsBody } from "./_lib"; + +// `storedUrl` on a download body (release 32 R7): "never" | "fallback" | +// "only", checked at the door. Absent = the channel's `storedUrlDownloads`. +export function optStoredUrlMode(body: OpsBody, key = "storedUrl"): StoredUrlMode | undefined { + const v = body[key]; + if (v === undefined || v === null) return undefined; + if (!isStoredUrlMode(v)) { + throw new OpsInputError(`"${key}" must be one of ${STORED_URL_MODES.map((m) => `"${m}"`).join(", ")}`); + } + return v; +} diff --git a/editor/app/api/ops/download-missing/route.ts b/editor/app/api/ops/download-missing/route.ts @@ -1,13 +1,17 @@ import { downloadMissingAction } from "../../../channels/[slug]/pipelineActions"; import { jobResponse, ops, optBool, optString, reqSlug } from "../_lib"; +import { optStoredUrlMode } from "../_storedUrl"; export const dynamic = "force-dynamic"; -// POST { slug, queueKey?, ignoreArchive?, abortOnError? } -> { ok: true, jobId } +// POST { slug, queueKey?, ignoreArchive?, abortOnError?, storedUrl? } -> { ok: true, jobId } +// "storedUrl" (release 32 R7): "never" | "fallback" | "only" for every download +// in the run (absent = the channel's `storedUrlDownloads`); with one, a held +// platform's run goes ahead as "only". export async function POST(request: Request) { return ops( request, - ["slug", "queueKey", "ignoreArchive", "abortOnError"], + ["slug", "queueKey", "ignoreArchive", "abortOnError", "storedUrl"], async (body) => jobResponse( await downloadMissingAction( @@ -15,6 +19,12 @@ export async function POST(request: Request) { optString(body, "queueKey"), optBool(body, "ignoreArchive"), optBool(body, "abortOnError"), + undefined, + undefined, + undefined, + undefined, + undefined, + optStoredUrlMode(body), ), ), ); diff --git a/editor/app/api/ops/retry-bucket/route.test.ts b/editor/app/api/ops/retry-bucket/route.test.ts @@ -43,3 +43,22 @@ test("retry-bucket and transcribe-bucket ids must be in the bucket: a stray is r assert.equal(empty.status, 400); assert.deepEqual(await corpus.listJobIds(), []); }); + +// Release 32 R7: "storedUrl" is checked at the door on all three download routes. +test("storedUrl must be never|fallback|only on retry-bucket, download-missing and transcribe-one; nothing runs", async () => { + const dm = (await import("../download-missing/route")).POST; + const t1 = (await import("../transcribe-one/route")).POST; + const a = await callPost(retry, { slug: SLUG, bucket: "downloadedNoTranscript", storedUrl: "always" }); + assert.equal(a.status, 400); + assert.match(String(a.body.error), /"storedUrl" must be one of "never", "fallback", "only"/); + const b = await callPost(dm, { slug: SLUG, storedUrl: true }); + assert.equal(b.status, 400); + assert.match(String(b.body.error), /"storedUrl" must be one of/); + const c = await callPost(t1, { slug: SLUG, id: "in-bucket-1", storedUrl: "sometimes" }); + assert.equal(c.status, 400); + // With "file" nothing is downloaded, so a stored-URL mode is refused too. + const d = await callPost(t1, { slug: SLUG, id: "in-bucket-1", file: "audio.mp3", storedUrl: "only" }); + assert.equal(d.status, 400); + assert.match(String(d.body.error), /"storedUrl" is for a download/); + assert.deepEqual(await corpus.listJobIds(), []); +}); diff --git a/editor/app/api/ops/retry-bucket/route.ts b/editor/app/api/ops/retry-bucket/route.ts @@ -12,11 +12,17 @@ import { reqSlug, reqString, } from "../_lib"; +import { optStoredUrlMode } from "../_storedUrl"; export const dynamic = "force-dynamic"; // POST { slug, bucket, ids?, queueKey?, abortOnError?, handlingOverride?, -// forceCookies?, replaceAutoSubs? } -> { ok: true, jobId } +// forceCookies?, replaceAutoSubs?, storedUrl? } -> { ok: true, jobId } +// +// "storedUrl" (release 32 R7): "never" | "fallback" | "only" — each download +// reads the media URL its record stores, the way the platform's player does +// (absent = the channel's `storedUrlDownloads`); with one, a held platform's +// retry goes ahead as "only". // // THE BUCKET IS RESOLVED FROM THE SNAPSHOT HERE, and that is not new logic: the // bucket controls in the UI pass `snapshot.buckets[key]` to the same action, and @@ -41,10 +47,12 @@ export async function POST(request: Request) { "handlingOverride", "forceCookies", "replaceAutoSubs", + "storedUrl", ], async (body) => { const slug = reqSlug(body, "slug"); const bucket = reqString(body, "bucket"); + const storedUrl = optStoredUrlMode(body); const snapshot = await readChannelSnapshot(getPaths(), slug); if (!snapshot) { throw new OpsInputError( @@ -78,6 +86,7 @@ export async function POST(request: Request) { !subset && isReplayBucket(bucket) ? bucket : undefined, optBool(body, "forceCookies"), optBool(body, "replaceAutoSubs"), + storedUrl, ), ); }, diff --git a/editor/app/api/ops/transcribe-one/route.ts b/editor/app/api/ops/transcribe-one/route.ts @@ -3,6 +3,7 @@ import { whisperVideoAction, } from "../../../channels/[slug]/videos/[id]/videoActions"; import { jobResponse, ops, opsFail, optBool, optString, reqSlug, reqVideoId } from "../_lib"; +import { optStoredUrlMode } from "../_storedUrl"; export const dynamic = "force-dynamic"; @@ -21,12 +22,20 @@ export const dynamic = "force-dynamic"; // and transcribes what decodes, its gaps recorded (transcribeOne's salvage); // false forbids it; absent, a corrupt-full-source video is salvaged and any // other is not. +// "storedUrl" (release 32 R7): "never" | "fallback" | "only" — with no audio on +// disk, the download reads the media URL the record stores, the way the +// platform's player does (the managed path: the audio check, the outcome +// sidecar). Absent = the channel's `storedUrlDownloads`. Not with "file". export async function POST(request: Request) { - return ops(request, ["slug", "id", "file", "salvage"], async (body) => { + return ops(request, ["slug", "id", "file", "salvage", "storedUrl"], async (body) => { const slug = reqSlug(body, "slug"); const id = reqVideoId(body, "id"); const file = optString(body, "file"); const salvage = optBool(body, "salvage"); + const storedUrl = optStoredUrlMode(body); + if (storedUrl !== undefined && file !== undefined) { + return opsFail(`"storedUrl" is for a download; with "file" nothing is downloaded`); + } // One path segment, checked at the door as reqVideoId checks an id: the // name is joined under the video's directory. if (file !== undefined && (file === "" || /[/\\\0]/.test(file) || file.startsWith("."))) { @@ -35,7 +44,7 @@ export async function POST(request: Request) { return jobResponse( file !== undefined ? await transcribeOneAction(slug, id, file, undefined, salvage) - : await whisperVideoAction(slug, id, undefined, salvage), + : await whisperVideoAction(slug, id, undefined, salvage, storedUrl), ); }); } diff --git a/editor/app/channels/[slug]/pipelineActions.ts b/editor/app/channels/[slug]/pipelineActions.ts @@ -73,6 +73,10 @@ import { import type { JobSpec, ReplayBucket } from "yt-dlp-transcript-common/jobs/jobSpec"; import { makeTaskTracker } from "yt-dlp-transcript-common/jobs/taskHooks"; import type { Paths } from "yt-dlp-transcript-common/lib/paths"; +import { + resolveStoredUrlMode, + type StoredUrlMode, +} from "yt-dlp-transcript-common/lib/storedMediaUrl"; // Preflight disk-space gate: keep a download job from even starting when free // space is already below the configured floor. Returns an error result to @@ -134,6 +138,10 @@ async function runPipelineAction( // sync only: force the full sweep (whole-listing re-read) regardless of the // configured cadence. Undefined leaves the decision to the cadence gate. forceFullSweep?: boolean; + // download-missing / retry-bucket (release 32 R7): read the record's stored + // media URL (downloadOneManaged's `storedUrl`). Absent = the channel's + // `storedUrlDownloads`. + storedUrl?: StoredUrlMode; // Replay descriptor, forwarded onto the job record so it can be replayed (Retry). spec?: JobSpec; }, @@ -167,13 +175,24 @@ async function runPipelineAction( // clean one lifts the hold (onPlatformClean below). The sentence names the // hold and the next probe. store-playlist stays allowed, as it is under the // downloads pause. + // A HELD PLATFORM WITH A STORED-URL MODE (release 32 R7): a download-missing + // or a retry runs anyway, as `only` — no page request, each video read from + // the media URL its record stores (one new file per rest), a video without + // one failing without asking. The clip-window fetch's door answers the same. + let storedUrlHeld = false; + const storedMode = resolveStoredUrlMode(options?.storedUrl, channelConfig.storedUrlDownloads); if (mode !== "store-playlist") { const held = await heldPlatformRefusal( platform, mode === "sync" ? "Sync" : "This download", paths, ); - if (held) return { ok: false, info: true, error: held }; + if (held) { + const storedOk = + (mode === "download-missing" || mode === "retry-bucket") && storedMode !== "never"; + if (!storedOk) return { ok: false, info: true, error: held }; + storedUrlHeld = true; + } } // A manually clicked Sync RESPECTS the per-platform rate-limit cooldown: if // auto-download (or a prior sync) hit a 429, refuse rather than re-storm the @@ -257,6 +276,11 @@ async function runPipelineAction( keepSourceVideoOverride: options?.keepSourceVideoOverride, extractImmediately: options?.extractImmediately, audioFormatOverride: options?.audioFormatOverride, + ...(storedUrlHeld + ? { storedUrl: "only" as const, storedUrlHeld: true } + : options?.storedUrl + ? { storedUrl: options.storedUrl } + : {}), setProgress, progressBaseline, // On a 429/network failure, record the shared per-platform cooldown so @@ -325,6 +349,8 @@ export async function downloadMissingAction( keepSourceVideoOverride?: boolean, extractImmediately?: boolean, audioFormatOverride?: AudioFormat, + // Release 32 R7: the stored-media-URL mode for every download in the run. + storedUrl?: StoredUrlMode, ): Promise<StreamActionResult> { return runPipelineAction( slug, @@ -339,6 +365,7 @@ export async function downloadMissingAction( keepSourceVideoOverride, extractImmediately, audioFormatOverride, + storedUrl, spec: { kind: "download-missing", slug, @@ -351,6 +378,7 @@ export async function downloadMissingAction( keepSourceVideoOverride, extractImmediately, audioFormatOverride, + ...(storedUrl ? { storedUrl } : {}), }, }, }, @@ -468,6 +496,8 @@ export async function retryBucketAction( // Always paired with handlingOverride "transcribe" (a youtube-handling run // would re-fetch subs instead of audio). replaceAutoSubs?: boolean, + // Release 32 R7: the stored-media-URL mode for every download in the run. + storedUrl?: StoredUrlMode, ): Promise<StreamActionResult> { if (!Array.isArray(bucketIds) || bucketIds.length === 0) { return { ok: false, error: "No video IDs supplied for retry." }; @@ -493,6 +523,7 @@ export async function retryBucketAction( handlingOverride, forceCookies, replaceAutoSubs, + ...(storedUrl ? { storedUrl } : {}), }, } : undefined; @@ -507,6 +538,7 @@ export async function retryBucketAction( abortOnError, forceCookies, replaceAutoSubs, + storedUrl, spec, }, ); diff --git a/editor/app/channels/[slug]/videos/[id]/videoActions.ts b/editor/app/channels/[slug]/videos/[id]/videoActions.ts @@ -106,6 +106,15 @@ import { sourceFetchFailure, } from "yt-dlp-transcript-common/ytdlp/downloadOneManaged"; import { runYtdlp } from "yt-dlp-transcript-common/ytdlp/runYtdlp"; +import { + isStoredUrlMode, + resolveStoredUrlMode, + type StoredUrlMode, +} from "yt-dlp-transcript-common/lib/storedMediaUrl"; +import { + storedUrlAttemptOf, + type DownloadOutcomeRecord, +} from "yt-dlp-transcript-common/lib/downloadOutcome"; import { runRefreshMetadataJob } from "yt-dlp-transcript-common/controller/refreshVideoMetadataJob"; import { runManagedFunction, @@ -221,6 +230,10 @@ export async function downloadVideoPipelineAction( videoId: string, queueKey?: string, downloadFormat?: string, + // Release 32 R7: read the record's stored media URL ("never" | "fallback" | + // "only"); anything else, or nothing, inherits the channel's + // `storedUrlDownloads`. + storedUrl?: string, ): Promise<StreamActionResult> { const r = await loadConfigOrError(slug); if (!r.ok) return r; @@ -255,7 +268,7 @@ export async function downloadVideoPipelineAction( kind: "download", }); try { - await downloadOneManaged({ + const record = await downloadOneManaged({ channelSlug: slug, channelConfig: r.config, paths, @@ -271,7 +284,9 @@ export async function downloadVideoPipelineAction( global: settings.downloadFormat, }), appendArchive: true, + ...(isStoredUrlMode(storedUrl) ? { storedUrl } : {}), }); + await recordStoredUrlBackoff(record, url, paths); safeRevalidate([ `/channels/${slug}/videos/${videoId}`, `/channels/${slug}`, @@ -283,6 +298,27 @@ export async function downloadVideoPipelineAction( }); } +// A single-video download that read the stored media URL (release 32 R7) +// backs the platform off on a refusal — its CDN's, or the page lookup's before +// it — as a batch does. Best-effort. +async function recordStoredUrlBackoff( + record: DownloadOutcomeRecord, + url: string, + paths: Paths, +): Promise<void> { + const st = storedUrlAttemptOf(record); + if (!st) return; + const refused = + record.failureClass === "rate_limit" || + (st.why === "rate-limited" && record.status.startsWith("ok")); + if (!refused) return; + try { + await recordDownloadBackoff(detectPlatform(url) ?? "unknown", paths, "rate_limit"); + } catch { + /* shared-state write is best-effort */ + } +} + // "Refresh metadata": re-read this one video's metadata.info.json from its // source — no subtitles, no media — for a source that changed after the first // fetch (a livestream VOD gaining its processed formats and captions). The job @@ -454,6 +490,12 @@ export async function whisperVideoAction( queueKey?: string, // See transcribeOneAction's `salvage`. salvage?: boolean, + // Release 32 R7: how the audio is downloaded when there is none. Anything + // but "never" (this, else the channel's `storedUrlDownloads`) downloads + // through the managed path with that stored-URL mode — the audio check, the + // outcome sidecar, the corrupt-source refetch — instead of the plain + // one-video download. + storedUrl?: StoredUrlMode, ): Promise<StreamActionResult> { const r = await loadConfigOrError(slug); if (!r.ok) return r; @@ -509,17 +551,46 @@ export async function whisperVideoAction( "Could not determine the video URL: no metadata.info.json and the playlist does not contain a matching entry.", ); } - onLog(`No audio on disk for ${videoId}; downloading…`); - await runYtdlp({ - channelSlug: slug, - mode: "download-one-audio", - channelConfig: r.config, - paths, - onLog, - signal, - singleVideoUrl: url, - audioFormatOverride: audioFormat, - }); + const storedMode = resolveStoredUrlMode(storedUrl, r.config.storedUrlDownloads); + if (storedMode !== "never") { + onLog(`No audio on disk for ${videoId}; downloading (stored media URL: ${storedMode})…`); + const settings = getSettings(); + const record = await downloadOneManaged({ + channelSlug: slug, + channelConfig: r.config, + paths, + videoUrl: url, + onLog, + signal, + cookiePolicy: resolveCookiePolicy(settings, r.config), + globalSkipLiveDownloads: settings.skipLiveDownloads, + audioFormatOverride: audioFormat, + appendArchive: true, + storedUrl: storedMode, + }); + await recordStoredUrlBackoff(record, url, paths); + if (!record.status.startsWith("ok")) { + const why = record.attempts.at(-1)?.error?.trim(); + throw new Error( + `The download of ${videoId} ended ${record.status}` + + (record.failureClass ? ` (${record.failureClass})` : "") + + (why ? `: ${why}` : "") + + "; nothing to transcribe.", + ); + } + } else { + onLog(`No audio on disk for ${videoId}; downloading…`); + await runYtdlp({ + channelSlug: slug, + mode: "download-one-audio", + channelConfig: r.config, + paths, + onLog, + signal, + singleVideoUrl: url, + audioFormatOverride: audioFormat, + }); + } } else { onLog(`Audio already on disk for ${videoId}; skipping download.`); } diff --git a/editor/app/jobs/jobReplayRegistry.ts b/editor/app/jobs/jobReplayRegistry.ts @@ -318,6 +318,8 @@ export const JOB_REPLAY_HANDLERS: Record<string, ReplayHandler> = { spec.bucket, Boolean(p.forceCookies), Boolean(p.replaceAutoSubs), + // Release 32 R7: a replay keeps the stored-URL mode it was asked with. + isStoredUrlMode(p.storedUrl) ? p.storedUrl : undefined, ); }, "download-from-playlist": (spec) => { @@ -336,6 +338,7 @@ export const JOB_REPLAY_HANDLERS: Record<string, ReplayHandler> = { bool(p.keepSourceVideoOverride), bool(p.extractImmediately), str(p.audioFormatOverride) as AudioFormat | undefined, + isStoredUrlMode(p.storedUrl) ? p.storedUrl : undefined, ); }, sync: (spec) => { diff --git a/scripts/archilyzer-ops.mjs b/scripts/archilyzer-ops.mjs @@ -954,6 +954,11 @@ export function usage() { ' file with error tolerance and transcribes what decodes, on the', ' recording\'s clock, its gaps recorded (the transcript is listed as', ' salvaged); a corrupt-full-source video is salvaged unless "salvage": false.', + ' "storedUrl": "only" | "fallback" | "never" downloads missing audio from the', + ' media URL the record stores (Odysee\'s CDN), read in ranges as its player', + ' reads it — no page request with "only", the page first with "fallback" —', + ' through the audio check; one new file per platform per 20 min. Absent =', + ' the channel\'s storedUrlDownloads.', "", 'delete-file deletes one file of one video, as its Files list does:', ' {"slug", "id", "file"}. A tiered media file goes with its bytes on the', @@ -991,6 +996,9 @@ export function usage() { ' videos it names are fetched again (recovery from a stale archive);', ' "abortOnError": false carries on past a failure (default: stop at the', ' first that is not one video\'s own). Paced on the platform\'s queue.', + ' "storedUrl": "fallback" | "only" reads each video from the media URL its', + ' record stores when the page is rate-limited (or always), one file per 20', + ' min; with one, a held platform\'s run goes ahead as "only".', "", 'metadata-scan reads every listed video\'s title, date and description', ' into the channel\'s scan file, fetching no media: {"slug"}. Not held by', @@ -1124,6 +1132,8 @@ export function usage() { " with ids is not replayable, as a checkbox selection in the UI is not.", ' "corruptFullSource" downloads again: the kept file is set aside, and comes', " back if the download fails; malformed again, the longer decode stays.", + ' "storedUrl": "fallback" | "only" reads each from the media URL its record', + ' stores, as on download-missing (a held platform\'s retry runs as "only").', ' "corruptHeldAudio" (held audio the audio audit found damaged) is refetched', " the same way, with the audio check on; the new file is audited again.", "",