commit 36387cf2ce84e782680aa354317f472fb52f492f
parent 2c182f63b89088e45907b2636db30bf3e3981d75
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Mon, 9 Nov 2026 19:17:19 -0500
channels: Configure's caption languages (subLangs) are checked at the save
A subLangs value yt-dlp's --sub-langs cannot use (an empty entry, a space
inside an entry, a bare '-', a bad regex, over 200 characters) failed every
caption download on the channel when it ran. parseChannelForm now refuses it
in the field's words — the Configure form and the channel-config ops patch
alike — and drops spaces around entries (common/lib/channelConfig.ts
subLangsProblem, normalizeSubLangs).
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
5 files changed, 86 insertions(+), 1 deletion(-)
diff --git a/common/lib/channelConfig.ts b/common/lib/channelConfig.ts
@@ -144,6 +144,44 @@ export function isDownloadMode(v: unknown): v is DownloadMode {
// yt-dlp's `--sub-langs` when the channel names none.
export const DEFAULT_SUB_LANGS = "en.*,live_chat";
+// THE FORM'S CHECK OF A `subLangs` VALUE. yt-dlp splits `--sub-langs` on
+// commas and matches each entry — a regex, or `all` — against a track's
+// language; a leading `-` excludes. A value it cannot use fails every caption
+// download on the channel at the moment it runs, so Configure and
+// `channel-config` refuse it at the save instead: an empty entry (two commas,
+// or one at an end), a space inside an entry, an entry that is not a regular
+// expression, a value over 200 characters. Spaces AROUND an entry are not a
+// problem: `normalizeSubLangs` drops them.
+export const SUB_LANGS_MAX_LENGTH = 200;
+
+export function normalizeSubLangs(value: string): string {
+ return value
+ .split(",")
+ .map((x) => x.trim())
+ .join(",");
+}
+
+export function subLangsProblem(value: string): string | null {
+ const v = normalizeSubLangs(value.trim());
+ if (!v) return null;
+ if (v.length > SUB_LANGS_MAX_LENGTH) {
+ return `is ${v.length} characters; at most ${SUB_LANGS_MAX_LENGTH}`;
+ }
+ for (const entry of v.split(",")) {
+ if (!entry) return `has an empty entry (two commas, or one at an end)`;
+ if (/\s/.test(entry)) return `entry "${entry}" has a space in it — entries are separated by commas`;
+ const pattern = entry.startsWith("-") ? entry.slice(1) : entry;
+ if (!pattern) return `entry "-" excludes nothing — a "-" goes before a language, e.g. -live_chat`;
+ if (pattern === "all") continue;
+ try {
+ new RegExp(`^(?:${pattern})$`);
+ } catch (e) {
+ return `entry "${entry}" is not a valid regular expression: ${(e as Error).message}`;
+ }
+ }
+ return null;
+}
+
// The `--sub-langs` a caption download passes: the channel's (or the
// default), WITHOUT the live chat unless `chat` fetches it with the download.
// An entry that is `live_chat` itself is dropped; one that would still match
diff --git a/common/lib/subLangs.test.ts b/common/lib/subLangs.test.ts
@@ -0,0 +1,22 @@
+import test from "node:test";
+import assert from "node:assert/strict";
+import { normalizeSubLangs, SUB_LANGS_MAX_LENGTH, subLangsProblem } from "./channelConfig";
+
+// Configure's caption languages (subLangs): what yt-dlp's --sub-langs can use
+// is saved; what would fail every caption download is refused at the save.
+test("subLangsProblem accepts yt-dlp's forms: regexes, all, exclusions, spaces around entries", () => {
+ for (const ok of ["en.*", "en.*,live_chat", "all,-live_chat", "en,es,fr", "en-US", "en(-GB)?", " en.* , es ", ""]) {
+ assert.equal(subLangsProblem(ok), null, ok);
+ }
+ assert.equal(normalizeSubLangs(" en.* , es "), "en.*,es");
+});
+
+test("subLangsProblem refuses an empty entry, a space inside an entry, a bare dash, a bad regex, an over-long value", () => {
+ assert.match(subLangsProblem("en,,es") ?? "", /has an empty entry/);
+ assert.match(subLangsProblem("en,") ?? "", /has an empty entry/);
+ assert.match(subLangsProblem("en us") ?? "", /entry "en us" has a space in it/);
+ assert.match(subLangsProblem("en,-") ?? "", /entry "-" excludes nothing/);
+ assert.match(subLangsProblem("en(") ?? "", /entry "en\(" is not a valid regular expression/);
+ assert.match(subLangsProblem("-[") ?? "", /entry "-\[" is not a valid regular expression/);
+ assert.match(subLangsProblem("e".repeat(SUB_LANGS_MAX_LENGTH + 1)) ?? "", /at most 200/);
+});
diff --git a/editor/CHANGELOG.md b/editor/CHANGELOG.md
@@ -1,6 +1,7 @@
# Changelog
## [Unreleased]
+- **Configure's Caption languages field (`subLangs`) is checked when you save.** Before, any text was saved, and a value yt-dlp's `--sub-langs` cannot use failed every caption download on the channel at the moment it ran. Configure and `pnpm ops channel-config` (`patch.subLangs`) now refuse it, in the field's words, with what you typed kept. Refused: an empty entry (two commas, or one at an end), a space inside an entry, a bare `-`, an entry that is not a regular expression, or a value over 200 characters. Spaces around an entry are dropped (`en.* , es` saves as `en.*,es`). `all` and `-<lang>` exclusions are accepted as before (`common/lib/channelConfig.ts` `subLangsProblem`).
- **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.
diff --git a/editor/app/channels/components/parseChannelForm.test.ts b/editor/app/channels/components/parseChannelForm.test.ts
@@ -358,6 +358,23 @@ test("subLangs and chat: parsed, refused when unknown, round-tripped through the
assert.equal("chat" in cleared, false);
});
+// Caption languages are checked at the save (lane editor-gaps): a value
+// yt-dlp's --sub-langs cannot use is refused in the field's words, on the form
+// and through the ops patch alike; spaces around an entry are dropped.
+test("subLangs: a value --sub-langs cannot use is refused; spaces around entries are dropped", () => {
+ assert.equal(parseChannelForm(form({ subLangs: "en.* , es" })).config.subLangs, "en.*,es");
+ assert.equal(parseChannelForm(form({ subLangs: "all,-live_chat" })).config.subLangs, "all,-live_chat");
+ assert.throws(() => parseChannelForm(form({ subLangs: "en,,es" })), /^Error: Caption languages has an empty entry/);
+ assert.throws(() => parseChannelForm(form({ subLangs: "en us" })), /Caption languages entry "en us" has a space in it/);
+ assert.throws(
+ () => parseChannelForm(form({ subLangs: "en(" })),
+ /Caption languages entry "en\(" is not a valid regular expression/,
+ );
+ const fd = channelConfigToFormData({ handling: "youtube", name: "Example VODs" });
+ applyChannelFormPatch(fd, { subLangs: "en,(" });
+ assert.throws(() => parseChannelForm(fd), /Caption languages entry "\(" is not a valid regular expression/);
+});
+
// 2026-10-29: manual downloads (lib/manualDownloads.ts) are a Configure field
// and a `channel-config` patch key — and the operator's two-step recipe (set
// manual, THEN clear the download filter) must keep the mode across the second
diff --git a/editor/app/channels/components/parseChannelForm.ts b/editor/app/channels/components/parseChannelForm.ts
@@ -10,6 +10,8 @@ import {
KEEP_LATEST_MAX,
SYNC_INTERVAL_MAX_MINUTES,
SYNC_INTERVAL_MIN_MINUTES,
+ normalizeSubLangs,
+ subLangsProblem,
type AudioCheckConfig,
type ExtractionMode,
} from "yt-dlp-transcript-common/lib/channelConfig";
@@ -291,7 +293,12 @@ export function parseChannelForm(formData: FormData): ParsedChannelForm {
// Caption languages and the live chat (2026-10-26). Blank = the default
// (`en.*,live_chat`), omitted; "with-download" is the default chat mode,
// omitted too, so choosing it clears a stored mode.
- const subLangs = stringOrUndef(formData, "subLangs");
+ const subLangsRaw = stringOrUndef(formData, "subLangs");
+ if (subLangsRaw) {
+ const problem = subLangsProblem(subLangsRaw);
+ if (problem) throw new Error(`Caption languages ${problem}`);
+ }
+ const subLangs = subLangsRaw ? normalizeSubLangs(subLangsRaw) : undefined;
const chatRaw = String(formData.get("chat") ?? "").trim();
if (chatRaw && !isChatMode(chatRaw)) {
throw new Error(`Live chat must be one of: ${CHAT_MODES.join(", ")}`);