commit 2c182f63b89088e45907b2636db30bf3e3981d75
parent f2e4c7f7337b0068d37178b53363105ee02b6281
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Mon, 9 Nov 2026 19:13:17 -0500
transcribe-one: refuse a video that is live, scheduled or still processing its VOD
A one-video download of a live stream reads the HLS at 1x and holds the
platform's queue for the stream's length (4 Nov). whisperVideoAction (the
video page's Transcribe, pnpm ops transcribe-one) now refuses, before anything
is queued, a video whose metadata.info.json says is_live / is_upcoming /
post_live, with the sentence naming record-live, the VOD and refresh-metadata
(common/lib/liveNow.ts). The job checks again before its download. Audio or a
container already on disk owes no download and still transcribes.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
8 files changed, 224 insertions(+), 15 deletions(-)
diff --git a/COMMANDS.md b/COMMANDS.md
@@ -184,7 +184,7 @@ Drives a running editor over HTTP (`/api/ops/*`, the same actions its pages run)
| `dismiss-service` | — | |
| `rerun-service-jobs` | — | |
| `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. Only a download waits on the platform's queue: the transcription runs as a transcribe-one job on the video's own queue (transcribe-one:<slug>:<id>), at once when nothing is downloaded, else handed off by the whisper-video once the audio is down. A job; --wait follows it through the hand-off to the end of the transcription. "queueKey" names another queue. A youtube-handling video with no audio whose metadata lists English captions has those fetched instead ({"instead": "captions", "message"}, the job the caption download), one with an English caption track on disk is refused; "asr": true transcribes it anyway (no "file"). "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 — once its full audio was tried: when its record stores an Odysee media URL, that URL is downloaded first, up to 2 times (20 min apart), and the salvage follows only if neither download is clean. "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. "whilePaused": true runs this one transcription during a pause-all on a worker the pause alone switched off; the pause stays on (the video page's "Transcribe now (workers paused)"). | |
+| `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. Only a download waits on the platform's queue: the transcription runs as a transcribe-one job on the video's own queue (transcribe-one:<slug>:<id>), at once when nothing is downloaded, else handed off by the whisper-video once the audio is down. A job; --wait follows it through the hand-off to the end of the transcription. "queueKey" names another queue. A youtube-handling video with no audio whose metadata lists English captions has those fetched instead ({"instead": "captions", "message"}, the job the caption download), one with an English caption track on disk is refused; "asr": true transcribes it anyway (no "file"). "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 — once its full audio was tried: when its record stores an Odysee media URL, that URL is downloaded first, up to 2 times (20 min apart), and the salvage follows only if neither download is clean. "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. "whilePaused": true runs this one transcription during a pause-all on a worker the pause alone switched off; the pause stays on (the video page's "Transcribe now (workers paused)"). A video its record says is live, scheduled or still processing its VOD (live\_status is\_live, is\_upcoming, post\_live) is refused before anything is queued — a download would read the stream at 1x and hold the platform queue: record it with record-live, or wait for the VOD (refresh-metadata re-reads the record once it has ended). With its audio on disk it transcribes. | |
| `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.) | |
| `drop-saved-alternate` | drop-saved-alternate deletes one saved alternate of one video, as its "Drop this alternate" button does: {"slug", "id", "file", "dryRun"?}. "file" is a name `get saved-alternates` lists under "alternates"; the active copy, an unlisted name and any path are refused, and so is a store being moved. The file goes from the store and its entry from saved-video.json (the rest of the pointer is untouched); one already gone is cleaned from the pointer ("existed": false). "dryRun": true answers the same and changes nothing. No undo. | |
diff --git a/common/lib/liveNow-server.ts b/common/lib/liveNow-server.ts
@@ -0,0 +1,25 @@
+import path from "node:path";
+import { readFile } from "node:fs/promises";
+import { liveDownloadRefusal, liveNowState, type LiveNowState } from "./liveNow";
+
+// The live state a video's metadata.info.json records (lib/liveNow.ts), null
+// when it records none — or there is no readable record, which says nothing
+// either way: a download is not refused on a guess.
+export async function readLiveNowState(videoDir: string): Promise<LiveNowState | null> {
+ try {
+ const meta = JSON.parse(await readFile(path.join(videoDir, "metadata.info.json"), "utf8")) as unknown;
+ return liveNowState(meta as Parameters<typeof liveNowState>[0]);
+ } catch {
+ return null;
+ }
+}
+
+// The refusal for a download of this video, or null when its record says it
+// is not a stream in progress.
+export async function liveDownloadRefusalFor(
+ videoDir: string,
+ ids: { slug: string; videoId: string },
+): Promise<string | null> {
+ const state = await readLiveNowState(videoDir);
+ return state ? liveDownloadRefusal(state, ids) : null;
+}
diff --git a/common/lib/liveNow.test.ts b/common/lib/liveNow.test.ts
@@ -0,0 +1,53 @@
+import test from "node:test";
+import assert from "node:assert/strict";
+import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises";
+import os from "node:os";
+import path from "node:path";
+import { liveDownloadRefusal, liveNowState } from "./liveNow";
+import { liveDownloadRefusalFor, readLiveNowState } from "./liveNow-server";
+
+test("liveNowState: is_live, is_upcoming and post_live are streams in progress; was_live and not_live are not", () => {
+ assert.equal(liveNowState({ live_status: "is_live" }), "is_live");
+ assert.equal(liveNowState({ live_status: "is_upcoming" }), "is_upcoming");
+ assert.equal(liveNowState({ live_status: "post_live" }), "post_live");
+ assert.equal(liveNowState({ live_status: "was_live" }), null, "a finished VOD downloads normally");
+ assert.equal(liveNowState({ live_status: "not_live" }), null);
+ assert.equal(liveNowState({}), null);
+ assert.equal(liveNowState(null), null);
+ // The boolean alone (an older record), and a status that overrules it.
+ assert.equal(liveNowState({ is_live: true }), "is_live");
+ assert.equal(liveNowState({ is_live: true, live_status: "was_live" }), null, "the newer field wins");
+ assert.equal(liveNowState({ is_live: "yes" }), null, "only a real true");
+});
+
+test("liveDownloadRefusal names record-live and refresh-metadata with runnable bodies", () => {
+ const ids = { slug: "demo-yt", videoId: "abcdefghijk" };
+ const live = liveDownloadRefusal("is_live", ids);
+ assert.match(live, /^abcdefghijk is live now \(live_status is_live\)/);
+ assert.match(live, /at 1x/);
+ assert.ok(live.includes(`pnpm ops record-live --json '{"slug":"demo-yt","id":"abcdefghijk"}'`), live);
+ assert.ok(live.includes(`pnpm ops refresh-metadata --json '{"slug":"demo-yt","id":"abcdefghijk"}'`), live);
+ assert.match(live, /wait for the VOD/);
+ assert.match(liveDownloadRefusal("is_upcoming", ids), /scheduled stream that has not started/);
+ const post = liveDownloadRefusal("post_live", ids);
+ assert.match(post, /VOD is still being processed/);
+ assert.equal(post.includes("record-live"), false, "an ended stream is not recorded");
+});
+
+test("readLiveNowState reads metadata.info.json; no record (or junk) is no answer", async () => {
+ const root = await mkdtemp(path.join(os.tmpdir(), "live-now-"));
+ try {
+ const dir = path.join(root, "v1");
+ await mkdir(dir);
+ assert.equal(await readLiveNowState(dir), null);
+ await writeFile(path.join(dir, "metadata.info.json"), "{not json");
+ assert.equal(await readLiveNowState(dir), null);
+ await writeFile(path.join(dir, "metadata.info.json"), JSON.stringify({ id: "v1", live_status: "is_live" }));
+ assert.equal(await readLiveNowState(dir), "is_live");
+ assert.match((await liveDownloadRefusalFor(dir, { slug: "s", videoId: "v1" })) ?? "", /v1 is live now/);
+ await writeFile(path.join(dir, "metadata.info.json"), JSON.stringify({ id: "v1", live_status: "was_live" }));
+ assert.equal(await liveDownloadRefusalFor(dir, { slug: "s", videoId: "v1" }), null);
+ } finally {
+ await rm(root, { recursive: true, force: true });
+ }
+});
diff --git a/common/lib/liveNow.ts b/common/lib/liveNow.ts
@@ -0,0 +1,65 @@
+// IS THIS VIDEO A STREAM THAT HAS NOT FINISHED? — and the sentence a
+// download-for-transcription says when it is.
+//
+// A one-video download of a video that is live reads the HLS at 1x: yt-dlp
+// follows the stream until it ends, and the platform's queue is held for the
+// stream's whole length (4 Nov: a transcribe-one on a live YouTube video sat
+// on platform:youtube for hours). Such a video is recorded by record-live, or
+// transcribed once its VOD exists — never downloaded as a finished video.
+//
+// What a download already knows is the video's metadata.info.json (yt-dlp's
+// `is_live` / `live_status`, the same fields skip-live and record-live read).
+// It is a snapshot: a stream that has ended since still says `is_live` until
+// the record is re-read, which is why the sentence names refresh-metadata.
+//
+// The three states are record-live's LIVE_STATES: `is_live`, `is_upcoming`
+// (scheduled, not started) and `post_live` (ended; its VOD is still being
+// processed and a download of it now is the stream's fragments, or an
+// incomplete file). `was_live` is a finished VOD and downloads normally.
+
+export type LiveNowState = "is_live" | "is_upcoming" | "post_live";
+
+export type LiveFields = {
+ is_live?: unknown;
+ live_status?: unknown;
+};
+
+export function liveNowState(meta: LiveFields | null | undefined): LiveNowState | null {
+ if (!meta || typeof meta !== "object") return null;
+ const status = typeof meta.live_status === "string" ? meta.live_status : "";
+ if (status === "is_live" || status === "is_upcoming" || status === "post_live") return status;
+ // An extractor that sets only the boolean (older records, some platforms).
+ // A `live_status` that says otherwise wins: it is the newer field.
+ if (meta.is_live === true && (status === "" || status === "is_live")) return "is_live";
+ return null;
+}
+
+// The refusal. `slug` and `videoId` make the two commands it names runnable
+// as they stand.
+export function liveDownloadRefusal(
+ state: LiveNowState,
+ { slug, videoId }: { slug: string; videoId: string },
+): string {
+ const body = JSON.stringify({ slug, id: videoId });
+ const record = `pnpm ops record-live --json '${body}'`;
+ const refresh = `pnpm ops refresh-metadata --json '${body}'`;
+ if (state === "is_upcoming") {
+ return (
+ `${videoId} is a scheduled stream that has not started (live_status is_upcoming): there is nothing to ` +
+ `transcribe yet. Record it from its start with record-live (${record}), or wait for the VOD; once it has ` +
+ `aired, ${refresh} re-reads its record.`
+ );
+ }
+ if (state === "post_live") {
+ return (
+ `${videoId}'s stream has ended but its VOD is still being processed (live_status post_live): a download now ` +
+ `reads the stream's fragments, not the finished video. Wait for the VOD; ${refresh} re-reads its record ` +
+ `once it is ready.`
+ );
+ }
+ return (
+ `${videoId} is live now (live_status is_live): a download would read the stream at 1x and hold the ` +
+ `platform's queue for as long as it runs. Record it with record-live (${record}), or wait for the VOD; ` +
+ `once it has ended, ${refresh} re-reads its record.`
+ );
+}
diff --git a/editor/CHANGELOG.md b/editor/CHANGELOG.md
@@ -1,6 +1,7 @@
# Changelog
## [Unreleased]
+- **Transcribe refuses a video that is live.** On 4 Nov a transcribe-one on a live YouTube video downloaded the stream at 1x and held `platform:youtube` for the stream's whole length. Now the video page's Transcribe and `pnpm ops transcribe-one` refuse a video whose `metadata.info.json` says it is live (`is_live`), scheduled (`is_upcoming`) or still processing its VOD (`post_live`), before anything is queued. The refusal names `pnpm ops record-live` for the stream (not for `post_live`), says to wait for the VOD otherwise, and names `refresh-metadata` to re-read the record once the stream has ended. The job checks again just before its download, in case the record was re-read while it waited. A video whose audio or container is already on disk still transcribes, since nothing is downloaded. A finished stream (`was_live`) downloads as before (`common/lib/liveNow.ts`).
- **The X run console: several X channels' posts fetched as one job that stops when the cookies go stale.** On 8 and 9 Nov an agent ran X fetch-posts by hand, one channel after another, watching the cookie jar age and putting off the rest once it went stale. `/review`'s new **X run** section lists the X posts channels in priority order (focus, tier, rank; paused ones unticked), with a tick and up/down buttons for each, and **Start X run** queues ONE `x-run` job on X's queue. The job fetches each channel in turn (new posts only, at most 200 each), waits X's queue gap (`pacing.jobGapSeconds.twitter`) between two channels, and checks the cookie jar again before EACH one. Once the jar is past `social.x.maxCookieAgeMinutes`, or the X alert is up, the run stops and the rest are **deferred until the next refresh**. It never refreshes cookies itself. The console shows each channel's state (queued, running, done with its new posts, deferred, failed), "N done, M deferred until the next refresh", the jar's age counted down to the limit, and the wait before the next channel. **Resume** runs the deferred channels after the operator presses Refresh cookies on /settings. A Retry of the job, and "Re-run stopped jobs", do the same. A restart does not resume a run: an interrupted run ends deferred. `pnpm ops x-run {"channels": [...]}` / `{"resume": "<run id>"}` and `pnpm ops get x-run` do the same from a terminal.
- **Account activity on a posts channel's page: posts per day, with the long silences marked.** A compact bar strip shows posts per UTC day over the archive's range. Long silences are shaded and listed: a gap of at least 3× the account's median gap AND 48 h, each linked to the post before it and the post after. An open-ended silence since the last post is listed too, when the last fetch came that long after it. Only the account's own posts count (a with-replies timeline also archives the posts it answers). The silence is the archive's ("no archived post"), and a stretch no fetch reached looks the same. Mr Obvious's 5–8 Nov gap reads 4 Nov 10:54 → 8 Nov 19:00 UTC on ObviousRises-x.
- **umtool: each character has a voice, auditioned on a page, the same in every project.** The operator wanted to "pick different voices for different characters, and in UI alone be able to try rendering different ones to compare … and try to maintain consistent voices for different repeating characters" -- tonight TheQuartering's reads were re-voiced by hand after scoring five voices against his real one. `/projects/<p>/voices` (from the Cut tab's Reads and voices) lists every character a project's reads use, the voice each reads in now and where it comes from (the cast, the project, the narrator's, the default), its reads in another voice, and its real voice. **Audition** reads one line (its own words here, a stock line, or typed) in 2-6 stock voices -- a job: the editor's tts, then each one's closeness to the real voice (speakers.json, TitaNet, local) -- played side by side at one loudness beside the real voice, a reference never a target. **Use for this project** or **Use everywhere** (the cast, `<reports>/.umtool/cast.json`), then the items to re-read, queued. A recording of an item can be made a character's read: kept, cleaned, converted to its stock voice. Every read -- a single post's and each piece of a thread read -- asks the same order (the read's own, the project's map, the cast, the narrator's, the default), and a cast voice of another engine is synthesized by it. `umtool cast ls|add|set|rm|undo|project|audition|use|reread`, `posts narrate … --recording`, and `umtool lint` warns when a cast character is read in another voice.
diff --git a/editor/app/api/ops/transcribe-one/route.test.ts b/editor/app/api/ops/transcribe-one/route.test.ts
@@ -214,3 +214,47 @@ test("English captions listed and no audio: the captions are fetched instead; as
assert.equal(bad.status, 400);
assert.match(String(bad.body.error), /"asr" must be a boolean/);
});
+
+// 4 Nov: a transcribe-one on a video that was LIVE downloaded the HLS at 1x and
+// held platform:youtube for the stream's length. Its record says so, and the
+// door refuses it with the commands that do the right thing — nothing queued.
+// The audio, or a container, already here owes no download and is transcribed.
+test("a live, scheduled or processing stream is refused before anything is queued; with its audio here it transcribes", async () => {
+ const before = (await corpus.listJobIds()).length;
+ await video("liveHHHHHHH", { live_status: "is_live", is_live: true });
+ const live = await callPost(POST, { slug: SLUG, id: "liveHHHHHHH", asr: true });
+ assert.equal(live.status, 400, JSON.stringify(live.body));
+ assert.match(String(live.body.error), /^liveHHHHHHH is live now \(live_status is_live\): a download would read the stream at 1x/);
+ assert.ok(
+ String(live.body.error).includes(`pnpm ops record-live --json '{"slug":"${SLUG}","id":"liveHHHHHHH"}'`),
+ String(live.body.error),
+ );
+ // Without "asr" too: the live check comes before the captions route.
+ const plain = await callPost(POST, { slug: SLUG, id: "liveHHHHHHH" });
+ assert.equal(plain.status, 400);
+ assert.match(String(plain.body.error), /is live now/);
+
+ await video("upcomingIII", { live_status: "is_upcoming" });
+ const upcoming = await callPost(POST, { slug: SLUG, id: "upcomingIII" });
+ assert.equal(upcoming.status, 400);
+ assert.match(String(upcoming.body.error), /scheduled stream that has not started/);
+
+ await video("postliveJJJ", { live_status: "post_live" });
+ const post = await callPost(POST, { slug: SLUG, id: "postliveJJJ" });
+ assert.equal(post.status, 400);
+ assert.match(String(post.body.error), /VOD is still being processed/);
+ assert.equal((await corpus.listJobIds()).length, before, "nothing was queued");
+
+ // A finished stream (was_live) downloads as any video does.
+ await video("wasliveKKKK", { live_status: "was_live" });
+ const vod = await callPost(POST, { slug: SLUG, id: "wasliveKKKK", asr: true });
+ assert.equal(vod.status, 200, JSON.stringify(vod.body));
+ await until("the VOD's audio download", () => ended(String(vod.body.jobId)));
+
+ // Audio already on disk: nothing to download, so nothing to refuse.
+ await video("liveaudioLL", { live_status: "is_live" }, { "audio.mp3": "fake audio\n" });
+ const here = await callPost(POST, { slug: SLUG, id: "liveaudioLL" });
+ assert.equal(here.status, 200, JSON.stringify(here.body));
+ assert.equal(job(String(here.body.jobId)).kind, "transcribe-one");
+ await until("the on-disk transcription", () => ended(String(here.body.jobId)));
+});
diff --git a/editor/app/channels/[slug]/videos/[id]/videoActions.ts b/editor/app/channels/[slug]/videos/[id]/videoActions.ts
@@ -31,6 +31,7 @@ import {
isEnglishCaptionTrack,
readListedCaptionTracks,
} from "yt-dlp-transcript-common/lib/listedCaptions-server";
+import { liveDownloadRefusalFor } from "yt-dlp-transcript-common/lib/liveNow-server";
import {
clipWindowQueueKey,
downloadQueueKey,
@@ -729,6 +730,19 @@ export async function whisperVideoAction(
};
const firstEntries = await readdir(videoDir).catch(() => [] as string[]);
const audioOnDisk = firstEntries.some(isRealAudioFile);
+ const firstHeld = audioOnDisk
+ ? null
+ : await transcriptionContainer({ paths, slug, videoDir, entries: firstEntries });
+
+ // A STREAM IN PROGRESS IS NEVER DOWNLOADED FOR A TRANSCRIPTION (4 Nov): the
+ // one-video download would read the HLS at 1x and hold the platform's queue
+ // for the stream's length. Refused while its record says it is live,
+ // scheduled or still processing — unless nothing has to be downloaded (the
+ // audio, or a container, is already here). lib/liveNow.ts.
+ if (!audioOnDisk && firstHeld?.kind !== "container") {
+ const live = await liveDownloadRefusalFor(videoDir, { slug, videoId });
+ if (live) return { ok: false, error: live };
+ }
if (!audioOnDisk && asr !== true && r.config.handling === "youtube") {
const onDisk = englishVttsByPreference(firstEntries);
@@ -772,20 +786,17 @@ export async function whisperVideoAction(
prelude: [`Audio already on disk for ${videoId}; skipping download.`],
});
}
- } else {
- const held = await transcriptionContainer({ paths, slug, videoDir, entries: firstEntries });
- if (held?.kind === "container") {
- return queueTranscribeOne({
- slug,
- videoId,
- config: r.config,
- audioFilename,
- queueKey: transcribeQueue,
- fullAudioFirst: false,
- ...opts,
- prelude: [containerLine(videoId, held)],
- });
- }
+ } else if (firstHeld?.kind === "container") {
+ return queueTranscribeOne({
+ slug,
+ videoId,
+ config: r.config,
+ audioFilename,
+ queueKey: transcribeQueue,
+ fullAudioFirst: false,
+ ...opts,
+ prelude: [containerLine(videoId, firstHeld)],
+ });
}
const platformQueue = videoQueueKey(r.config, queueKey);
@@ -816,6 +827,10 @@ export async function whisperVideoAction(
if (held?.kind === "no-audio") {
onLog(`The container ${held.file} has no sound; downloading the audio instead.`);
}
+ // The door's live check again, at the moment of the download: the
+ // record may have been re-read while this job waited for its queue.
+ const live = await liveDownloadRefusalFor(videoDir, { slug, videoId });
+ if (live) throw new Error(live);
// Only this branch writes bytes. Transcribing audio that is already on
// disk produces a transcript.json measured in kilobytes, so a low disk
// is no reason to refuse it — the gate belongs on the fetch, not on the
diff --git a/scripts/archilyzer-ops.mjs b/scripts/archilyzer-ops.mjs
@@ -1270,6 +1270,12 @@ export function usage() {
' "whilePaused": true runs this one transcription during a pause-all on a',
' worker the pause alone switched off; the pause stays on (the video page\'s',
' "Transcribe now (workers paused)").',
+ ' A video its record says is live, scheduled or still processing its VOD',
+ ' (live_status is_live, is_upcoming, post_live) is refused before anything',
+ ' is queued — a download would read the stream at 1x and hold the platform',
+ ' queue: record it with record-live, or wait for the VOD (refresh-metadata',
+ ' re-reads the record once it has ended). With its audio on disk it',
+ ' transcribes.',
"",
'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',