commit f7a246f3d49074335591ab99363bcf46356bcfc4
parent b5e33d680f2684753ba1d1b3afb7ae98216027f7
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Mon, 26 Oct 2026 07:21:55 -0400
Downloads: a successful download (and the missing-subs pass) writes transcript.cues.json, so a fresh caption download is build-ready (writeCuesAfterDownload)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
5 files changed, 120 insertions(+), 0 deletions(-)
diff --git a/common/controller/normalizeTranscript.ts b/common/controller/normalizeTranscript.ts
@@ -106,6 +106,42 @@ export async function normalizeTranscript(
return { status: "wrote", cuesPath };
}
+// THE CUES OF A DOWNLOAD THAT JUST LANDED (2026-10-26). A youtube-handling
+// download fetches captions with --skip-download and never reaches
+// transcribeOne — the one automatic caller of normalizeTranscript before this —
+// so a fresh caption download had transcript.en(-orig).vtt and no
+// transcript.cues.json until someone ran the normalize pass (`pnpm ops
+// build-cues`, the digest card's Normalize, or the corpus-wide pass on /sites:
+// that is where every older video got its file). umtool's build refused such a
+// video ("clip-no-cues"). The managed download's end and the caption-only pass
+// call this, so a new download is build-ready the moment it lands.
+//
+// The same normalize the pass runs (a fresh cues.json is left alone, so a
+// transcription that already wrote one costs a readdir and a stat). Never
+// throws: the download succeeded, and a cues file that could not be written is
+// a line in its log, which the normalize pass can still mend.
+export async function writeCuesAfterDownload(opts: {
+ videoDir: string;
+ channelSlug: string;
+ configName?: string;
+ onLog: (line: string) => void;
+}): Promise<NormalizeOutcome | null> {
+ try {
+ return await normalizeTranscript({
+ videoDir: opts.videoDir,
+ channelSlug: opts.channelSlug,
+ ...(opts.configName ? { configName: opts.configName } : {}),
+ log: (m) => opts.onLog(`${m}\n`),
+ });
+ } catch (err) {
+ opts.onLog(
+ `Could not write ${CUES_JSON_FILENAME} for ${path.basename(opts.videoDir)}: ${(err as Error).message} ` +
+ `(the normalize pass — pnpm ops build-cues — can write it later)\n`,
+ );
+ return null;
+ }
+}
+
// WHAT normalizeTranscript WOULD WRITE, built in memory and not written: the
// summary from metadata.info.json and the cues of the transcript the index
// would pick (the caption-track rule for VTTs). Shared by normalize and by a
diff --git a/common/controller/writeCuesAfterDownload.test.ts b/common/controller/writeCuesAfterDownload.test.ts
@@ -0,0 +1,60 @@
+// A download that just landed gets its transcript.cues.json (2026-10-26): the
+// caption download never reached the normalize, so umtool refused the video
+// ("clip-no-cues") until `pnpm ops build-cues` ran by hand.
+//
+// Run with: node_modules/.bin/tsx --test common/controller/writeCuesAfterDownload.test.ts
+
+import { after, test } from "node:test";
+import assert from "node:assert/strict";
+import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
+import { tmpdir } from "node:os";
+import path from "node:path";
+import { isCuesJsonFresh, writeCuesAfterDownload } from "./normalizeTranscript";
+
+const ROOT = mkdtempSync(path.join(tmpdir(), "cues-after-download-"));
+after(() => rmSync(ROOT, { recursive: true, force: true }));
+
+const VTT = readFileSync(path.join(import.meta.dirname, "..", "lib", "__fixtures__", "vtt-cue-blocks.vtt"), "utf8");
+const META = {
+ id: "vid",
+ title: "A video",
+ upload_date: "20261024",
+ duration: 30,
+ webpage_url: "https://www.youtube.com/watch?v=vid",
+ extractor_key: "Youtube",
+};
+
+let n = 0;
+function videoDir(files: Record<string, string>): string {
+ const dir = path.join(ROOT, `c${n}`, "data", `vid${n++}`);
+ mkdirSync(dir, { recursive: true });
+ for (const [name, body] of Object.entries(files)) writeFileSync(path.join(dir, name), body);
+ return dir;
+}
+
+test("a caption download's VTT becomes a fresh transcript.cues.json, said in the log", async () => {
+ const dir = videoDir({ "metadata.info.json": JSON.stringify(META), "transcript.en-orig.vtt": VTT });
+ const lines: string[] = [];
+ const out = await writeCuesAfterDownload({ videoDir: dir, channelSlug: "c", onLog: (l) => lines.push(l) });
+ assert.equal(out?.status, "wrote");
+ assert.ok(existsSync(path.join(dir, "transcript.cues.json")));
+ assert.equal((await isCuesJsonFresh(dir)).fresh, true);
+ assert.match(lines.join(""), /Normalized c\/vid\d+ \(transcript\.en-orig\.vtt, \d+ cues\)/);
+ // Again: fresh, nothing rewritten.
+ assert.equal((await writeCuesAfterDownload({ videoDir: dir, channelSlug: "c", onLog: () => {} }))?.status, "fresh");
+});
+
+test("a download with no transcript (audio for transcription) is skipped, not an error", async () => {
+ const dir = videoDir({ "metadata.info.json": JSON.stringify(META), "audio.mp3": "x" });
+ const out = await writeCuesAfterDownload({ videoDir: dir, channelSlug: "c", onLog: () => {} });
+ assert.deepEqual(out, { status: "skipped", reason: "no-raw-transcript" });
+ assert.equal(existsSync(path.join(dir, "transcript.cues.json")), false);
+});
+
+test("a metadata file it cannot read is a log line and null — the download is not failed", async () => {
+ const dir = videoDir({ "metadata.info.json": "{not json", "transcript.en.vtt": VTT });
+ const lines: string[] = [];
+ const out = await writeCuesAfterDownload({ videoDir: dir, channelSlug: "c", onLog: (l) => lines.push(l) });
+ assert.equal(out, null);
+ assert.match(lines.join(""), /Could not write transcript\.cues\.json for vid\d+: .*pnpm ops build-cues/);
+});
diff --git a/common/ytdlp/downloadOneManaged.ts b/common/ytdlp/downloadOneManaged.ts
@@ -67,6 +67,7 @@ import {
} from "../lib/transcripts-server";
import { evaluateDownloadFilters } from "../lib/downloadFilters";
import { normalizeLiveChat } from "../controller/normalizeLiveChat";
+import { writeCuesAfterDownload } from "../controller/normalizeTranscript";
import { LIVE_CHAT_FILENAME } from "../lib/videoStatus";
import {
upsertMetadataScan,
@@ -2006,6 +2007,19 @@ async function writeOutcome(
);
}
+ // THE CUES SIDECAR, so a fresh download is build-ready (2026-10-26): a
+ // caption download (youtube handling) never reaches transcribeOne, the only
+ // other automatic writer of transcript.cues.json. Every success, any path —
+ // a transcription that already wrote it finds it fresh. Never throws.
+ if (status.startsWith("ok")) {
+ await writeCuesAfterDownload({
+ videoDir,
+ channelSlug: opts.channelSlug,
+ ...(opts.channelConfig.name ? { configName: opts.channelConfig.name } : {}),
+ onLog: opts.onLog,
+ });
+ }
+
// Capture an availability history entry when the last attempt observed a
// class (e.g. a public video the uploader just deleted). Never touch the
// top-level fields (updateTopLevel: false) so resolveEffectiveAvailability's
diff --git a/common/ytdlp/runYtdlp.ts b/common/ytdlp/runYtdlp.ts
@@ -88,6 +88,7 @@ import {
} from "../jobs/platformBackoff";
import { hasSubtitleRateLimit } from "../lib/availability";
import { computeKeepWindow, type KeepWindow } from "../controller/keptVideos";
+import { writeCuesAfterDownload } from "../controller/normalizeTranscript";
import { downloadOneManaged } from "./downloadOneManaged";
import { STDERR_TAIL_BYTES } from "./runOneYtdlp";
import { observeStderrServiceSignal } from "../lib/serviceCookies-server";
@@ -1648,6 +1649,14 @@ async function downloadMissingSubs(opts: RunYtdlpOpts): Promise<void> {
} else {
await clearSubtitleDeferral(id, opts.paths).catch(() => {});
}
+ // The cues the new tracks make (2026-10-26): what the normalize
+ // pass would write, written now. Never throws.
+ await writeCuesAfterDownload({
+ videoDir: path.join(dataDir, id),
+ channelSlug: opts.channelSlug,
+ ...(opts.channelConfig.name ? { configName: opts.channelConfig.name } : {}),
+ onLog: task?.onLog ?? opts.onLog,
+ });
}
} catch (err) {
failed++;
diff --git a/editor/CHANGELOG.md b/editor/CHANGELOG.md
@@ -1,6 +1,7 @@
# Changelog
## [Unreleased]
+- **A new caption download is ready for a umtool build the moment it lands.** A YouTube video whose captions were downloaded (the-quartering, 2026-10-23/24) had its `transcript.en-orig.vtt` but no `transcript.cues.json` — only a transcription wrote one, and every older video got its file from the normalize pass — so umtool refused it ("clip-no-cues") until `pnpm ops build-cues` was run by hand. Every successful download, and the Download missing subs pass, now writes the cues file the normalize pass would. Needs a restart of the editor.
- **An interrupted catch-up no longer sends a finished forum thread back through its whole history.** When an editor restart cut a thread's catch-up short, the next run saw the page the catch-up still owed as a hole in the history, marked the history unfinished and re-read every held page below it (on 2026-10-26 it re-read 150 pages of the Ethan Klein thread before it was stopped; left alone, every sync would have gone on doing it). The page an unfinished catch-up owes is now its own, and the history stays complete. Needs a restart of the editor.
- **A take of part of a cut (`--at`) now shows the clips its own changes add.** The window is timed against the project's cut so every take of a group covers the same clips, and a clip only the take adds (a montage line, an extra beat) was never in it: the Huck cut's pitch-count take rendered seven of its eight pitches. A clip the take adds right after one the window covers now renders with it. Needs a restart of umtool for takes made from the app (the `umtool take` command has it now).
- **An assistant can now change a report video's timeline, find a clip's scene cuts, and add a post from the archive, all from the command line.** `umtool timeline <project>` lists the cut (index, id, type, video, start–end, date and title) and does what the Cut tab's timeline does: `insert --after <id> <channel>/<video>@<start>-<end>` with `--title`, `--date`, `--quote` and `--cite`, `move <id> --to <index>`, `remove`, `duplicate`, `post`, `post-remove`, `teaser` and `undo`. It goes through the same writers as the page, so each change saves an undo point first, is refused when the build would refuse it, and leaves an edit note on a generated manifest. A bad `--date` is refused before anything is written. `umtool scenes <project> <clip>` prints where the picture cuts and where it goes black in the clip's fetched window, in the recording's own seconds, for setting a blur's from and to or a trim: the Huck dog clip is black 250.49–251.09 and cuts at 251.09. It fetches nothing. `umtool posts add <project> <channel>/<postId>` makes a post card from the posts archive (its words, date, link, handle and screenshot, with `--attach <clip>` and `--flag`) and copies the capture into the project's `posts-media/`. A post with no screenshot is refused, and the message names the `pnpm ops capture-posts` to run first.