commit e8b4412de936787d67c04f4612cf68b970de9554 parent 45d252dc75b4ed49fefff098b991719d324d3bdf Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st> Date: Thu, 29 Oct 2026 13:44:54 -0400 Merge lane/manual-downloads: a channel's downloadMode "manual" -- only videos asked for are downloaded Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Diffstat:
30 files changed, 680 insertions(+), 8 deletions(-)
diff --git a/CHANNEL.md b/CHANNEL.md @@ -43,6 +43,7 @@ Regenerate this file with `pnpm --filter yt-dlp-transcript-common exec tsx bin/f | `syncIntervalMinutes` | config | Auto-sync cadence: the scheduler syncs this channel when `now - lastSyncedAt >= syncIntervalMinutes`. Absent = inherit the global default; 0 = auto-sync off (still manually syncable); positives clamp to [1, 44640] (~31 days). A missing `url`, or a `sync` tier of paused in the channel-priority document, also disables auto-sync. | | `fullSweepIntervalMinutes` | config | Full-sweep cadence: a sync upgrades itself to a full sweep when `now - lastFullSweepAt >= fullSweepIntervalMinutes`. Absent = inherit `syncScheduler.fullSweepIntervalMinutes`; 0 = never sweep (every sync is a paged walk); positives clamp to [1, 44640]. | | `skipLiveDownloads` | config | Per-channel override for the global `skipLiveDownloads`. Absent = inherit; false = allow downloading currently-live / upcoming videos. | +| `downloadMode` | config | `"auto"` (default) or `"manual"`. Manual: nothing is downloaded unasked — the download lane skips the channel, a sync or full sweep reads the listing (roster, `playlist`, maybe-missing) but downloads none of the new uploads it finds, and the batch downloads (Download from playlist, Download videos / `download-missing`, a bucket retry) refuse. What someone asks for still downloads: `import-video`, the video page's download and persist buttons, `persist-videos`, clip windows (`fetch-windows`), a whole-recording fetch; videos on disk are still transcribed by the lanes. The listed videos it never downloaded are reported as not requested (`manualNotRequestedIds` in its report), never as undownloaded work or as never-fetched losses. A Configure field (`downloadMode`). | | `downloadFilter` | config | Per-channel title/description download filter, matched against the per-video metadata prefetch. A declined video is SETTLED by a terminal download-outcome keyed on the filter's signature, not by an archive line, so changing either pattern re-evaluates every settled video on the next run. An object with no real rule is dropped (the filter is inert). See [`downloadFilter`](#downloadfilter). | | `cookiesFromBrowser` | config | Per-channel override of the global cookies-from-browser spec (a browser spec, or `file:<path>` for a cookies.txt). Trimmed; blank = inherit. | | `cookieMode` | config | Per-channel override of the global cookie mode. Absent = inherit. | diff --git a/COMMANDS.md b/COMMANDS.md @@ -104,7 +104,7 @@ Drives a running editor over HTTP (`/api/ops/*`, the same actions its pages run) | action | what it does | example | |---|---|---| | `channel-priority` | channel-priority sets channels' priority, as the /channels deck's tier control does: {"slugs", "tier": "normal" \| "low" \| "paused"} sets the base tier; with "operation" (sync, transcription, download, digest, backfill) it pins that operation's tier, "tier": null clearing it back to the base; "preset": "sync-only" \| "clear" is the deck's two shortcuts and takes no tier. A manual change clears an automatic pause. {"focus": {"kind": "site", "siteId"} \| {"kind": "channels", "slugs"} \| {"kind": "none"}} alone is the deck's focus bar: those channels lead every lane (a site focus follows its membership); "none" ends it. | `pnpm ops channel-priority --json '{"slugs":["x"],"operation":"download","tier":"paused"}'`<br>`pnpm ops channel-priority --json '{"focus":{"kind":"site","siteId":"x"}}'` | -| `channel-config` | channel-config changes a channel as its Configure form does: {"slug"} and any of "patch" (form field names; "" clears one), "sites" (the WHOLE membership set: \[{"siteId", "groupId"? \| "newGroupName"?}\], \[\] = on no site; an unknown site id is refused), "excludeFromBuild" and "excludeFromCleanup" (set to the value given, not toggled). A VOD mirror's recorded date: "patch": {"recordedDateTitlePattern": "<regex with named groups year, month, day>"} (CHANNEL.md, recordedDate). A mirror's creator channels: "patch": {"mirrorOf": "<slug>, <slug>"} (CHANNEL.md, mirror; then mirror-scan). Caption languages and the live chat: "patch": {"subLangs": "en.\*", "chat": "with-download" \| "later" \| "never"} (CHANNEL.md, subLangs and chat). | `pnpm ops channel-config --json '{"slug":"demo-yt","patch":{"chat":"later","subLangs":"en.*"}}'`<br>`pnpm ops channel-config --json '{"slug":"x","patch":{"downloadFilterExclude":"rerun"}}'`<br>`pnpm ops channel-config --json '{"slug":"x","sites":[{"siteId":"anilyzer"}]}'`<br>`pnpm ops channel-config --json '{"slug":"x","sites":[],"excludeFromBuild":true}'` | +| `channel-config` | channel-config changes a channel as its Configure form does: {"slug"} and any of "patch" (form field names; "" clears one), "sites" (the WHOLE membership set: \[{"siteId", "groupId"? \| "newGroupName"?}\], \[\] = on no site; an unknown site id is refused), "excludeFromBuild" and "excludeFromCleanup" (set to the value given, not toggled). A VOD mirror's recorded date: "patch": {"recordedDateTitlePattern": "<regex with named groups year, month, day>"} (CHANNEL.md, recordedDate). A mirror's creator channels: "patch": {"mirrorOf": "<slug>, <slug>"} (CHANNEL.md, mirror; then mirror-scan). Caption languages and the live chat: "patch": {"subLangs": "en.\*", "chat": "with-download" \| "later" \| "never"} (CHANNEL.md, subLangs and chat). Manual downloads: "patch": {"downloadMode": "manual"} — only videos you add (import-video, the video page) are downloaded; the download lane, a sync's new uploads and download-missing leave the channel alone; "" (or "auto") is automatic (CHANNEL.md, downloadMode). | `pnpm ops channel-config --json '{"slug":"demo-yt","patch":{"chat":"later","subLangs":"en.*"}}'`<br>`pnpm ops channel-config --json '{"slug":"x","patch":{"downloadFilterExclude":"rerun"}}'`<br>`pnpm ops channel-config --json '{"slug":"x","patch":{"downloadMode":"manual"}}'`<br>`pnpm ops channel-config --json '{"slug":"x","sites":[{"siteId":"anilyzer"}]}'`<br>`pnpm ops channel-config --json '{"slug":"x","sites":[],"excludeFromBuild":true}'` | | `site-config` | site-config sets two keys of a site as its form does: {"siteId"} and any of "citedChannels" (the WHOLE cited scope, channel slugs: what the site's reports may cite without publishing the channel; \[\] clears it; a slug the pool holds is dropped) and "publishAuto" ("off" \| "build" \| "preview" \| "production", the publish lane's policy; a deploying one needs a Pages project, a private site is clamped to "build"). Only those two keys; an unknown site or channel is refused before anything is written. Answers the saved values. | `pnpm ops site-config --json '{"siteId":"anilyzer","citedChannels":["critic-channel"]}'`<br>`pnpm ops site-config --json '{"siteId":"anilyzer","publishAuto":"build"}'` | | `articles-config` | articles-config sets an article's audience and its place in the published list (transcripts/reports/index.json), through the article registry: {"id"} and any of "audience" ("public" \| "private"; absent in report.json = private), "published" (true = listed, false = a draft) and "position" (its place in the list, 0 = first; publishing with none keeps a listed article where it is, else puts it last). Refused before anything is written: an unknown article, a position on a draft or out of range, publishing an article whose report.json has problems (listed). Answers the article as saved. | `pnpm ops articles-config --json '{"id":"demo-article","published":true}'`<br>`pnpm ops articles-config --json '{"id":"demo-article","audience":"public","position":0}'` | | `delete-article` | delete-article deletes an article, as `archilyzer reports delete <id>` does: {"id"}, "dryRun"? (answer the plan — every path with its size, what is kept and why — and write nothing), "force"? (unpublish it, and drop a site page naming it with no report of its own, first). It removes the article's directory (report, video, history, notes, iterations), each iteration's video project under settings.generation.projectsRoot and its staged exports. Refused with the plan (409): a published article or such a site page without "force"; a queued or running iteration, force or not. | `pnpm ops delete-article --json '{"id":"demo-article","dryRun":true}'`<br>`pnpm ops delete-article --json '{"id":"demo-article","force":true}'` | diff --git a/OPERATING.md b/OPERATING.md @@ -51,6 +51,13 @@ pnpm ops get channel example ([RUNNING_IN_DOCKER.md](RUNNING_IN_DOCKER.md), "Driving the editor without a browser"). Every `config.json` key: [CHANNEL.md](CHANNEL.md). - `sites` is the whole membership set; absent or `[]` keeps the channel on no site. +- **Download only what you ask for:** `pnpm ops channel-config --json '{"slug":"example","patch":{"downloadMode":"manual"}}'` + (Configure → Advanced → **Downloads**; `""` is Automatic again). Syncs still read the listing and the videos on disk + still transcribe, but the download lane, a sync's new uploads, `download-missing` and the bucket retries leave the + channel alone; `import-video` and the video page still download, through the channel's download filter. To drop a + filter on such a channel, set manual FIRST: removing a filter re-evaluates every video it had settled, and on an + automatic channel the next lane run downloads all of them. Neither older switch says this — `syncIntervalMinutes: 0` + stops the listing but not the backlog, and a `paused` tier stops every lane, transcription too. - `"fetchPlaylist": true` on `create-channel` stores the playlist at once (the form's "Fetch playlist now"); a social channel's is `"fetchPostsNow": true`. - Rename or delete: `pnpm ops rename-channel --json '{"slug":"old","newSlug":"new"}'`, `pnpm ops delete-channel --json '{"slug":"x","confirm":"x"}'` — both refused while the channel is busy. diff --git a/common/controller/autoRunner.test.ts b/common/controller/autoRunner.test.ts @@ -878,3 +878,51 @@ test("release 17: an unmounted media drive holds transcription/download/backfill backfill: true, }); }); + + +// --- Manual downloads: off the download lane, on every other --------------- +// +// 2026-10-29 (lib/manualDownloads.ts). A `downloadMode: "manual"` channel is +// not on the download lane's list (listChannelMeta), so its listing's backlog +// is no lane's work; the transcription lane still draws its videos on disk, +// and an automatic channel beside it is still the download lane's work. + +test("a manual-downloads channel projects no download work but keeps its transcription work; an automatic one keeps both", async () => { + const paths = pendingFixture(); + const downloadOp = bucketLaneOperationId("download"); + const transcribeOp = bucketLaneOperationId("transcription"); + const channel = (slug: string, extra: Record<string, unknown>) => { + const channelDir = path.join(paths.channelsDir, slug); + mkdirSync(path.join(channelDir, "data", `${slug}-on-disk`), { recursive: true }); + const config = { url: `https://www.youtube.com/@${slug}`, handling: "transcribe", ...extra }; + writeFileSync(path.join(channelDir, "config.json"), JSON.stringify(config)); + // A report written BEFORE the mode was set: it still lists the backlog, + // and the lane must not take it from there either. + writeFileSync( + path.join(channelDir, "snapshot.json"), + JSON.stringify({ + generatedAt: new Date().toISOString(), + totals: { videos: 1, downloaded: 1, transcribed: 0 }, + buckets: { downloadedNoTranscript: [`${slug}-on-disk`] }, + undownloadedIds: [`${slug}-listed`], + backfill: { + ...(downloadOp ? { [downloadOp]: { ids: [`${slug}-listed`] } } : {}), + ...(transcribeOp ? { [transcribeOp]: { ids: [`${slug}-on-disk`] } } : {}), + }, + }), + ); + forgetChannelMedia(slug); + return { slug, config: config as never }; + }; + const manual = channel("manual", { downloadMode: "manual" }); + const auto = channel("auto", {}); + + assert.equal(await laneTotal("download", paths, [manual]), 0, "the download lane skips a manual channel"); + assert.ok((await laneTotal("transcription", paths, [manual])) > 0, "its videos on disk still transcribe"); + assert.ok((await laneTotal("download", paths, [auto])) > 0, "an automatic channel is still download work"); + assert.equal( + await laneTotal("download", paths, [manual, auto]), + await laneTotal("download", paths, [auto]), + "side by side, only the automatic channel's backlog counts", + ); +}); diff --git a/common/controller/autoRunner.ts b/common/controller/autoRunner.ts @@ -132,6 +132,7 @@ import { } from "./channels"; import { transcribeOneFromQueue } from "./transcribeOneFromQueue"; import { findVideoSourceUrl } from "./undownloadedVideos"; +import { channelDownloadsAreManual } from "../lib/manualDownloads"; import { downloadOneManaged } from "../ytdlp/downloadOneManaged"; import { makeStoredUrlLaneMemo, storedUrlLaneMode, storedUrlRescue } from "./laneStoredUrl"; import { storedUrlGapRemainingMs } from "../jobs/storedUrlPace"; @@ -373,6 +374,9 @@ const SNAPSHOT_READ_CONCURRENCY = 64; // and one with `{tier:"paused"}` or `overrides:{download:"paused"}` is not. // Re-evaluated on CHANNEL_LIST_TTL_MS, which is the clock for this decision. // +// MANUAL DOWNLOADS ARE A SECOND FILTER, on the download lane only +// (`channelDownloadsAreManual`), on the same TTL. +// // It returns the PRE-FILTER slug list beside the filtered meta, off the one // read. `known` is an EXISTENCE filter for the focus resolver (a site whose // membership has outrun the corpus, or a hand-edited settings.json), and the @@ -393,6 +397,14 @@ async function listChannelMeta( return { meta: configs .filter(({ slug }) => !isChannelPaused(priority, slug, kind)) + // A MANUAL-DOWNLOADS CHANNEL is not on the download lane's list at all + // (lib/manualDownloads.ts): its listing's backlog, its retries, its + // metadata scan and its chat backlog are all things nobody asked for. + // Every other lane still draws it — its videos on disk transcribe. + .filter( + ({ config }) => + kind !== "download" || !channelDownloadsAreManual(config), + ) .map(({ slug, config }) => ({ slug, platform: detectPlatform(config.url), diff --git a/common/controller/channelSnapshot.test.ts b/common/controller/channelSnapshot.test.ts @@ -421,6 +421,8 @@ type FilterFixture = { roster?: string[]; // Ids the scan failed on, by class — what it writes for a members-only video. scanErrors?: Record<string, string>; + // Other config.json keys (e.g. `downloadMode`). + config?: Record<string, unknown>; }; async function filteredChannel( @@ -440,6 +442,7 @@ async function filteredChannel( handling: "youtube", url: "https://www.youtube.com/@alpha/videos", ...(fixture.filter ? { downloadFilter: fixture.filter } : {}), + ...fixture.config, }), ); await writeFile( @@ -966,3 +969,30 @@ test("fullAudio: a stored-URL channel's corrupt full sources, their attempts, th await rm(dir, { recursive: true, force: true }); } }); + +// MANUAL DOWNLOADS (2026-10-29, lib/manualDownloads.ts): what a manual channel +// lists and lacks is not work — undownloadedIds is empty, so no lane, count or +// station reports it — and it is kept as manualNotRequestedIds for the channel +// page. A video that left the listing unfetched is not a loss either. +test("a manual-downloads channel has no undownloaded work and no never-fetched alarm", async () => { + const fixture = { + listed: ["aaaa0000001", "bbbb0000002"], + roster: ["aaaa0000001", "bbbb0000002", "cccc0000003"], + }; + const manual = await filteredChannel({ ...fixture, config: { downloadMode: "manual" } }); + const auto = await filteredChannel(fixture); + try { + const snap = await generateChannelSnapshot(manual.paths, "alpha"); + assert.deepEqual(snap.undownloadedIds, []); + assert.deepEqual(snap.manualNotRequestedIds, ["aaaa0000001", "bbbb0000002"]); + assert.deepEqual(snap.missingNeverFetched ?? [], []); + // The control: the same channel, automatic, is unchanged. + const control = await generateChannelSnapshot(auto.paths, "alpha"); + assert.deepEqual(control.undownloadedIds, ["aaaa0000001", "bbbb0000002"]); + assert.equal("manualNotRequestedIds" in control, false); + assert.deepEqual((control.missingNeverFetched ?? []).map((m) => m.id), ["cccc0000003"]); + } finally { + await rm(manual.dir, { recursive: true, force: true }); + await rm(auto.dir, { recursive: true, force: true }); + } +}); diff --git a/common/controller/channelSnapshot.ts b/common/controller/channelSnapshot.ts @@ -90,6 +90,7 @@ import { resolveCaptionsProvenance } from "../lib/subtitleProvenance"; import { isIncompleteTranscript } from "../lib/transcriptCoverage"; import { storedMediaUrl } from "../lib/storedMediaUrl-server"; import { FULL_AUDIO_ATTEMPTS, fullAudioAttemptsOf } from "../lib/fullAudioFirst"; +import { channelDownloadsAreManual } from "../lib/manualDownloads"; // THE PER-OPERATION WORK LISTS, keyed by operation id. // @@ -362,6 +363,13 @@ export type ChannelSnapshot = { digestWarnings?: string[]; }; undownloadedIds: string[]; + // MANUAL-DOWNLOADS CHANNELS ONLY (ChannelConfig.downloadMode "manual", + // lib/manualDownloads.ts): the listed videos with nothing on disk that would + // otherwise be undownloadedIds — in playlist order, without the settled and + // the permanently unavailable. Nothing downloads them unasked, so they are + // not work: undownloadedIds is empty on such a channel and every count of + // download work reads 0. Absent on every other channel. + manualNotRequestedIds?: string[]; excludedFromDownload?: ExcludedFromDownload; // Count of videos in the channel's keep-latest window (ChannelConfig.keepLatest). // These are protected from the Clean-audio sweep (folded into the cleanup- @@ -1666,6 +1674,8 @@ export async function generateChannelSnapshot( const listedIdSet = new Set(sets.listed); const undownloadedIds: string[] = []; + const manual = channelDownloadsAreManual(config); + const manualNotRequestedIds: string[] = []; const needsCookies: string[] = []; // The metadata scan's backlog, counted in the same walk: a listed video with // nothing on disk that the scan has not read and has not recently failed on. @@ -1712,6 +1722,13 @@ export async function generateChannelSnapshot( // auto-download runner's work queue, and it is derived from artifacts, so an // archive line alone would not have kept the id out of it. if (settledIds.has(dirId)) continue; + // A MANUAL-DOWNLOADS CHANNEL has no download work: what it lists and lacks + // is waiting for someone to ask, not for a lane (lib/manualDownloads.ts). + // Kept apart so the channel page can still show it. + if (manual) { + if (!excludedById.has(dirId)) manualNotRequestedIds.push(dirId); + continue; + } const effective = effectiveById.get(dirId); if (effective && AUTH_RETRY_CLASSES.has(effective)) { needsCookies.push(dirId); @@ -1846,13 +1863,16 @@ export async function generateChannelSnapshot( : {}), backfill: { ...backfillCounts, ...bucketLaneEntries }, undownloadedIds, + ...(manual ? { manualNotRequestedIds } : {}), excludedFromDownload, keptCount: keptIds.size, availability, ...(maybeMissing ? { maybeMissing } : {}), // Newest-first by when we first heard of them: the most recent loss is the // one still worth chasing. - missingNeverFetched: sets.missingNeverFetched + // A manual-downloads channel never fetched them because nobody asked: not + // a loss, so not the loudest alarm this report raises. + missingNeverFetched: (manual ? [] : sets.missingNeverFetched) .map((id) => ({ id, url: roster.entries[id]?.url ?? "", diff --git a/common/controller/manualDownloadsConfig.test.ts b/common/controller/manualDownloadsConfig.test.ts @@ -0,0 +1,38 @@ +import { test } from "node:test"; +import assert from "node:assert/strict"; +import { mkdtemp, mkdir, readFile, writeFile } from "node:fs/promises"; +import { tmpdir } from "node:os"; +import path from "node:path"; +import type { Paths } from "../lib/paths"; +import { patchChannelConfig, readChannelConfig } from "./channels"; + +// Run with: +// pnpm --filter yt-dlp-transcript-common exec tsx --test controller/manualDownloadsConfig.test.ts +// +// `downloadMode` (2026-10-29, lib/manualDownloads.ts) through the one config +// writer, in a temp corpus. + +test("patchChannelConfig sets it, keeps it across another patch, and unsets it", async () => { + const dir = await mkdtemp(path.join(tmpdir(), "manual-dl-")); + const paths = { channelsDir: path.join(dir, "channels") } as Paths; + const slug = "harmful"; + await mkdir(path.join(paths.channelsDir, slug), { recursive: true }); + const file = path.join(paths.channelsDir, slug, "config.json"); + await writeFile( + file, + JSON.stringify({ handling: "transcribe", url: "https://www.youtube.com/@h", downloadFilter: { include: "guest" } }), + ); + + await patchChannelConfig(paths, slug, { downloadMode: "manual" }); + assert.equal((await readChannelConfig(paths, slug))?.downloadMode, "manual"); + assert.equal(JSON.parse(await readFile(file, "utf8")).downloadMode, "manual"); + + // The operator's second step: the filter goes, the mode stays. + await patchChannelConfig(paths, slug, {}, { unset: ["downloadFilter"] }); + const after = await readChannelConfig(paths, slug); + assert.equal(after?.downloadMode, "manual"); + assert.equal(after && "downloadFilter" in after, false); + + await patchChannelConfig(paths, slug, {}, { unset: ["downloadMode"] }); + assert.equal("downloadMode" in JSON.parse(await readFile(file, "utf8")), false); +}); diff --git a/common/lib/channelConfig.ts b/common/lib/channelConfig.ts @@ -126,6 +126,21 @@ export function isChatMode(v: unknown): v is ChatMode { return v === "with-download" || v === "later" || v === "never"; } +// WHAT THE CHANNEL DOWNLOADS UNASKED (2026-10-29). Absent = "auto" (every +// channel before the field, byte for byte): the download lane works the +// listing's backlog and a sync downloads the new uploads it finds. "manual": +// the listing is still read (a sync records it, a sweep refreshes `playlist`), +// but nothing is downloaded unless someone asks for that video — an import, +// the video page's buttons, a clip window. Videos that are on disk are still +// transcribed. lib/manualDownloads.ts holds the one predicate every lane and +// controller asks. +export type DownloadMode = "auto" | "manual"; +export const DOWNLOAD_MODES: readonly DownloadMode[] = ["auto", "manual"]; + +export function isDownloadMode(v: unknown): v is DownloadMode { + return v === "auto" || v === "manual"; +} + // yt-dlp's `--sub-langs` when the channel names none. export const DEFAULT_SUB_LANGS = "en.*,live_chat"; @@ -195,6 +210,7 @@ export type ChannelConfig = { syncIntervalMinutes?: number; fullSweepIntervalMinutes?: number; skipLiveDownloads?: boolean; + downloadMode?: DownloadMode; downloadFilter?: DownloadFilterConfig; cookiesFromBrowser?: string; cookieMode?: CookieMode; @@ -266,6 +282,8 @@ export const CHANNEL_CONFIG_FIELD_DOCS: FieldDocs<ChannelConfig> = { "Full-sweep cadence: a sync upgrades itself to a full sweep when `now - lastFullSweepAt >= fullSweepIntervalMinutes`. Absent = inherit `syncScheduler.fullSweepIntervalMinutes`; 0 = never sweep (every sync is a paged walk); positives clamp to [1, 44640].", skipLiveDownloads: "Per-channel override for the global `skipLiveDownloads`. Absent = inherit; false = allow downloading currently-live / upcoming videos.", + downloadMode: + '`"auto"` (default) or `"manual"`. Manual: nothing is downloaded unasked — the download lane skips the channel, a sync or full sweep reads the listing (roster, `playlist`, maybe-missing) but downloads none of the new uploads it finds, and the batch downloads (Download from playlist, Download videos / `download-missing`, a bucket retry) refuse. What someone asks for still downloads: `import-video`, the video page\'s download and persist buttons, `persist-videos`, clip windows (`fetch-windows`), a whole-recording fetch; videos on disk are still transcribed by the lanes. The listed videos it never downloaded are reported as not requested (`manualNotRequestedIds` in its report), never as undownloaded work or as never-fetched losses. A Configure field (`downloadMode`).', downloadFilter: "Per-channel title/description download filter, matched against the per-video metadata prefetch. A declined video is SETTLED by a terminal download-outcome keyed on the filter's signature, not by an archive line, so changing either pattern re-evaluates every settled video on the next run. An object with no real rule is dropped (the filter is inert).", cookiesFromBrowser: @@ -484,6 +502,7 @@ export const CHANNEL_CONFIG_COERCIONS: { SYNC_INTERVAL_MAX_MINUTES, ), skipLiveDownloads: bool, + downloadMode: (v) => (isDownloadMode(v) ? v : undefined), downloadFilter: coerceDownloadFilter, cookiesFromBrowser: trimmedNonBlank, cookieMode: (v) => (isCookieMode(v) ? v : undefined), diff --git a/common/lib/channelConfigSchema.test.ts b/common/lib/channelConfigSchema.test.ts @@ -39,7 +39,7 @@ test("one key list: docs = coercions = schema shape, sync-state keys inside it", assert.deepEqual(Object.keys(CHANNEL_CONFIG_COERCIONS), [...CHANNEL_CONFIG_KEYS]); assert.deepEqual(Object.keys(channelConfigObjectSchema.shape), [...CHANNEL_CONFIG_KEYS]); assert.deepEqual(Object.keys(CHANNEL_CONFIG_FIELD_DOCS), [...CHANNEL_CONFIG_KEYS]); - assert.equal(CHANNEL_CONFIG_KEYS.length, 40); // 2026-10-27: `postCaptureThread` + assert.equal(CHANNEL_CONFIG_KEYS.length, 41); // 2026-10-29: `downloadMode` assert.equal(sameKeys, true); assert.equal(fits, true); for (const k of CHANNEL_SYNC_STATE_KEYS) assert.ok(CHANNEL_CONFIG_KEYS.includes(k), k); diff --git a/common/lib/channelConfigSchema.ts b/common/lib/channelConfigSchema.ts @@ -72,6 +72,7 @@ export const channelConfigObjectSchema = z.object({ syncIntervalMinutes: field("syncIntervalMinutes"), fullSweepIntervalMinutes: field("fullSweepIntervalMinutes"), skipLiveDownloads: field("skipLiveDownloads"), + downloadMode: field("downloadMode"), downloadFilter: field("downloadFilter"), cookiesFromBrowser: field("cookiesFromBrowser"), cookieMode: field("cookieMode"), diff --git a/common/lib/manualDownloads.test.ts b/common/lib/manualDownloads.test.ts @@ -0,0 +1,61 @@ +import { test } from "node:test"; +import assert from "node:assert/strict"; +import { parseChannelConfig } from "./channelConfig"; +import { channelConfigSchema } from "./channelConfigSchema"; +import { + BATCH_DOWNLOAD_MODES, + channelDownloadsAreManual, + manualDownloadsRefusal, +} from "./manualDownloads"; + +// Run with: +// pnpm --filter yt-dlp-transcript-common exec tsx --test lib/manualDownloads.test.ts +// +// A channel that downloads only what it is asked for (2026-10-29). The one +// predicate every lane and controller asks, the refusal the batch downloads +// give, and the key's coercion (controller/manualDownloadsConfig.test.ts +// writes it through patchChannelConfig). + +test("the predicate: only an explicit manual is manual", () => { + assert.equal(channelDownloadsAreManual({ downloadMode: "manual" }), true); + assert.equal(channelDownloadsAreManual({ downloadMode: "auto" }), false); + assert.equal(channelDownloadsAreManual({}), false); + assert.equal(channelDownloadsAreManual(null), false); + assert.equal(channelDownloadsAreManual(undefined), false); +}); + +test("the batch downloads refuse on a manual channel; a single video, a sync and an automatic channel do not", () => { + for (const mode of BATCH_DOWNLOAD_MODES) { + const refusal = manualDownloadsRefusal("harmful", { downloadMode: "manual" }, mode); + assert.ok(refusal, mode); + assert.match(refusal!, /manual downloads/); + assert.match(refusal!, new RegExp(mode)); + assert.equal(manualDownloadsRefusal("harmful", {}, mode), null, `${mode} on an automatic channel`); + } + for (const mode of ["sync", "store-playlist", "download-one-audio", "download-missing-subs", "import-one"]) { + assert.equal( + manualDownloadsRefusal("harmful", { downloadMode: "manual" }, mode), + null, + `${mode} runs on a manual channel`, + ); + } +}); + +test("config.json: manual and auto are kept, anything else is dropped, by both readers", () => { + for (const [raw, want] of [ + ["manual", "manual"], + ["auto", "auto"], + ["Manual", undefined], + [true, undefined], + ] as const) { + const file = { handling: "youtube", downloadMode: raw }; + assert.equal(parseChannelConfig(file)?.downloadMode, want, String(raw)); + assert.equal(channelConfigSchema.parse(file)?.downloadMode, want, String(raw)); + if (want === undefined) { + assert.equal("downloadMode" in parseChannelConfig(file)!, false); + assert.equal("downloadMode" in channelConfigSchema.parse(file)!, false); + } + } + // Absent stays absent: an automatic channel's file is byte for byte as before. + assert.equal("downloadMode" in parseChannelConfig({ handling: "youtube" })!, false); +}); diff --git a/common/lib/manualDownloads.ts b/common/lib/manualDownloads.ts @@ -0,0 +1,68 @@ +// A CHANNEL THAT DOWNLOADS ONLY WHAT IT IS ASKED FOR (2026-10-29). +// +// `ChannelConfig.downloadMode: "manual"` (lib/channelConfig.ts). Neither of +// the two older switches says it: `syncIntervalMinutes: 0` stops the listing +// being read but leaves the download lane working the backlog it already has, +// and a `paused` tier takes the channel off EVERY lane — transcription too. +// Manual keeps the listing and the transcription and turns off only the paths +// that turn "a video the channel lists but lacks" into a download: +// +// the download lane controller/autoRunner.ts, listChannelMeta +// a sync's / sweep's new-upload walk ytdlp/runYtdlp.ts, syncPaged / syncFullSweep +// the batch downloads download-from-playlist, download-missing, +// retry-bucket (runYtdlp, and the editor's +// runPipelineAction before it queues a job) +// the report's work list controller/channelSnapshot.ts: undownloadedIds +// is empty, the listed-but-absent ids are +// `manualNotRequestedIds` +// the Download station views/channelGroupSections.ts +// +// What a person asks for, one video at a time, is not gated: import-video, the +// video page's download / persist buttons, persist-videos, clip windows, a +// whole-recording fetch, transcribe-one. +// +// Client-safe: the Configure form and the rack read the sentence below. + +import type { ChannelConfig } from "./channelConfig"; + +// THE ONE PREDICATE. Absent (and "auto") is today's behaviour. +export function channelDownloadsAreManual( + config: Pick<ChannelConfig, "downloadMode"> | null | undefined, +): boolean { + return config?.downloadMode === "manual"; +} + +// What the channel page, the rack and the form say, so a manual channel with a +// long listing is not read as a stalled one. +export const MANUAL_DOWNLOADS_TEXT = + "Manual downloads — only videos you add are downloaded"; + +// The runYtdlp modes that download a channel's listed-but-absent videos as a +// batch. A manual channel refuses them; `sync` is not here because a sync +// still reads the listing — it only skips the download half. +export const BATCH_DOWNLOAD_MODES = [ + "download-from-playlist", + "download-missing", + "retry-bucket", +] as const; + +export function isBatchDownloadMode(mode: string): boolean { + return (BATCH_DOWNLOAD_MODES as readonly string[]).includes(mode); +} + +// The refusal a batch download gets on a manual channel, or null when it may +// run. One sentence for the editor's notice, the job log and the ops answer. +export function manualDownloadsRefusal( + slug: string, + config: Pick<ChannelConfig, "downloadMode"> | null | undefined, + mode: string, +): string | null { + if (!channelDownloadsAreManual(config) || !isBatchDownloadMode(mode)) { + return null; + } + return ( + `"${slug}" is set to manual downloads: only videos you add are downloaded, ` + + `so ${mode} does not run. Import a video (import-video, or the channel ` + + `page's Import) to download it, or set Downloads to Automatic in Configure.` + ); +} diff --git a/common/views/channelGroupSections.test.ts b/common/views/channelGroupSections.test.ts @@ -227,6 +227,20 @@ test("download excludes members-only/deleted/private ids", () => { assert.equal(sections[0].download.total, 1); }); +test("a manual-downloads channel is not download-eligible, even on a report that predates the mode", () => { + const snap = snapshotOf({ undownloadedIds: ["listed"] }); + const manual = channel("m", { downloadMode: "manual" }, snap); + assert.deepEqual(stationWorkFor("download", manual.brief, LANE_ON), { + eligible: false, + work: 0, + reason: "manual downloads", + }); + assert.deepEqual(stationWorkFor("download", channel("a", {}, snap).brief, LANE_ON), { + eligible: true, + work: 1, + }); +}); + test("a youtube-handling channel IS transcribe-eligible: missing auto-subs is whisper work", () => { const sections = build( siteOf({ channels: [{ slug: "yt" }, { slug: "whisper" }] }), diff --git a/common/views/channelGroupSections.ts b/common/views/channelGroupSections.ts @@ -1,3 +1,4 @@ +import { channelDownloadsAreManual } from "../lib/manualDownloads"; import type { ChannelBrief, ChannelStat } from "../controller/channels"; import { isSocialChannel } from "../lib/channelConfig"; import { @@ -175,6 +176,11 @@ export function stationWorkFor( if (station === "download") { if (!config.url) return { eligible: false, work: 0, reason: "no url" }; + // The group's Download runs download-missing, which a manual-downloads + // channel refuses (lib/manualDownloads.ts). + if (channelDownloadsAreManual(config)) { + return { eligible: false, work: 0, reason: "manual downloads" }; + } if (!snapshot) return { eligible: true, work: null }; const excluded = excludedDownloadIdSet(snapshot); return { diff --git a/common/views/channelRow.ts b/common/views/channelRow.ts @@ -1,3 +1,4 @@ +import { channelDownloadsAreManual } from "../lib/manualDownloads"; import type { ChannelConfig } from "../lib/channelConfig"; import type { ChannelSnapshot } from "../controller/channelSnapshot"; import type { ChannelMediaLocation } from "../lib/channelMedia"; @@ -112,6 +113,10 @@ export type ChannelRowView = { // the lanes read the channel. The rack draws it beside the tier, because it // is the reason the lanes are skipping the row (release 16 slice RM). mediaHold: string | null; + // `downloadMode: "manual"` (lib/manualDownloads.ts): the download lane skips + // the channel by design and its `work.undownloaded` is 0 — the rack says so, + // so a long, mostly undownloaded listing is not read as a stalled channel. + manualDownloads: boolean; // WHICH VOLUME THE MEDIA IS ON, as an id a filter can name: a location id, // "internal" for the corpus volume, or "" for a mediaDir under a root nobody // named. (The text is on the corpus volume whatever this says.) @@ -222,6 +227,7 @@ export function buildChannelRowView(i: ChannelRowInput): ChannelRowView { } : null, mediaHold: i.media ? mediaHoldText(i.media.status) : null, + manualDownloads: channelDownloadsAreManual(i.config), volumeId: i.volume.id, volumeLabel: i.volume.label, mediaBytes: snap?.totalMediaBytes ?? null, diff --git a/common/ytdlp/manualDownloads.test.ts b/common/ytdlp/manualDownloads.test.ts @@ -0,0 +1,138 @@ +import { test } from "node:test"; +import assert from "node:assert/strict"; +import { + chmodSync, + existsSync, + mkdirSync, + mkdtempSync, + readFileSync, + writeFileSync, +} from "node:fs"; +import os from "node:os"; +import path from "node:path"; + +// Run with: +// pnpm --filter yt-dlp-transcript-common exec tsx --test ytdlp/manualDownloads.test.ts +// +// A MANUAL-DOWNLOADS CHANNEL IN runYtdlp (2026-10-29, lib/manualDownloads.ts): +// the batch downloads refuse, a sync and a full sweep read the listing and +// download nothing, and a single video still downloads. Against a fake yt-dlp +// that lists two videos and records every call. getPaths() memoizes, so the +// env is set before anything imports it. +const ROOT = mkdtempSync(path.join(os.tmpdir(), "manual-downloads-")); +process.env.TRANSCRIPTS_DIR = ROOT; +process.env.SETTINGS_FILE = path.join(ROOT, "settings.json"); +writeFileSync( + process.env.SETTINGS_FILE, + JSON.stringify({ minFreeDiskGB: 0, sleepBetweenDownloadsSeconds: 0 }) + "\n", +); +const CALLS = path.join(ROOT, "calls.log"); +const BIN = path.join(ROOT, "fake-ytdlp.sh"); +writeFileSync( + BIN, + [ + "#!/bin/sh", + `echo "$*" >> "${CALLS}"`, + 'case "$*" in', + " *--flat-playlist*)", + " echo https://www.youtube.com/watch?v=aaaaaaaaaaa", + " echo https://www.youtube.com/watch?v=bbbbbbbbbbb", + " ;;", + "esac", + "exit 0", + "", + ].join("\n"), +); +chmodSync(BIN, 0o755); +process.env.YTDLP_BIN = BIN; + +const MANUAL = { handling: "transcribe", url: "https://www.youtube.com/@manual/videos", downloadMode: "manual" } as const; +const AUTO = { handling: "transcribe", url: "https://www.youtube.com/@auto/videos" } as const; +for (const [slug, config] of [["manual", MANUAL], ["auto", AUTO]] as const) { + mkdirSync(path.join(ROOT, "channels", slug, "data"), { recursive: true }); + writeFileSync(path.join(ROOT, "channels", slug, "config.json"), JSON.stringify(config)); + // An empty saved playlist: an automatic download-missing has nothing to fetch. + writeFileSync(path.join(ROOT, "channels", slug, "playlist"), ""); +} + +const { runYtdlp } = await import("./runYtdlp"); +const { getPaths } = await import("../lib/paths"); + +function calls(): string[] { + if (!existsSync(CALLS)) return []; + return readFileSync(CALLS, "utf8").split("\n").filter(Boolean); +} + +function resetCalls(): void { + writeFileSync(CALLS, ""); +} + +function run( + slug: "manual" | "auto", + mode: Parameters<typeof runYtdlp>[0]["mode"], + extra: Partial<Parameters<typeof runYtdlp>[0]> = {}, +): Promise<void> { + return runYtdlp({ + channelSlug: slug, + mode, + channelConfig: (slug === "manual" ? MANUAL : AUTO) as never, + paths: getPaths(), + onLog: () => {}, + signal: new AbortController().signal, + ...extra, + }); +} + +test("the batch downloads refuse on a manual channel, before asking the source anything", async () => { + resetCalls(); + for (const mode of ["download-missing", "download-from-playlist", "retry-bucket"] as const) { + await assert.rejects( + run("manual", mode, { bucketIds: ["aaaaaaaaaaa"] }), + /manual downloads: only videos you add are downloaded/, + mode, + ); + } + assert.deepEqual(calls(), []); +}); + +test("an automatic channel's download-missing still runs", async () => { + await run("auto", "download-missing"); +}); + +test("a manual channel's sync records the newest page and downloads nothing", async () => { + resetCalls(); + await run("manual", "sync", { forceFullSweep: false }); + const made = calls(); + assert.equal(made.length, 1, "one listing page, nothing else"); + assert.match(made[0], /--flat-playlist/); + // The page is recorded: the roster knows both listed videos. + const roster = readFileSync(path.join(ROOT, "channels", "manual", "roster.json"), "utf8"); + assert.match(roster, /aaaaaaaaaaa/); + assert.match(roster, /bbbbbbbbbbb/); + // And the sync is a sync: its stamp is written. + const cfg = JSON.parse(readFileSync(path.join(ROOT, "channels", "manual", "config.json"), "utf8")); + assert.ok(cfg.lastSyncedAt); + assert.equal(cfg.downloadMode, "manual"); +}); + +test("a manual channel's full sweep refreshes the playlist and downloads nothing", async () => { + resetCalls(); + await run("manual", "sync", { forceFullSweep: true }); + const made = calls(); + assert.ok(made.length >= 1); + for (const c of made) assert.match(c, /--flat-playlist/, `only listings: ${c}`); + const playlist = readFileSync(path.join(ROOT, "channels", "manual", "playlist"), "utf8"); + assert.match(playlist, /aaaaaaaaaaa/); + assert.match(playlist, /bbbbbbbbbbb/); +}); + +test("a single video still downloads on a manual channel", async () => { + resetCalls(); + await run("manual", "download-one-audio", { + singleVideoUrl: "https://www.youtube.com/watch?v=aaaaaaaaaaa", + }); + assert.ok( + calls().some((c) => !c.includes("--flat-playlist") && c.includes("aaaaaaaaaaa")), + "the one video was asked for", + ); +}); diff --git a/common/ytdlp/runYtdlp.ts b/common/ytdlp/runYtdlp.ts @@ -102,6 +102,10 @@ import type { TaskTracker } from "../jobs/taskHooks"; import type { JobProgress } from "../jobs/registry"; import { heldAudioDamage } from "../lib/audioIntegrity-server"; import { jitterYtdlpSleeps } from "../lib/jitter"; +import { + channelDownloadsAreManual, + manualDownloadsRefusal, +} from "../lib/manualDownloads"; export type YtdlpMode = | "store-playlist" @@ -235,6 +239,13 @@ export async function runYtdlp(opts: RunYtdlpOpts): Promise<void> { if (!opts.channelConfig.url) { throw new Error("Channel has no `url` configured"); } + // A MANUAL-DOWNLOADS CHANNEL refuses a batch download of its listing + // (lib/manualDownloads.ts). The editor's actions refuse first with a notice; + // this is the floor under every other caller (a replay, a resumed job). + const manual = opts.saveShardOnly + ? null + : manualDownloadsRefusal(opts.channelSlug, opts.channelConfig, opts.mode); + if (manual) throw new Error(manual); // A shard save computes a slice and writes it; it downloads nothing. if (!MEDIA_WRITING_MODES.has(opts.mode) || opts.saveShardOnly) { return runYtdlpMode(opts); @@ -1801,6 +1812,17 @@ export async function destinationExists( // the first page that contains an already-archived entry. const SYNC_PAGE_SIZE = 50; +// The line a manual-downloads channel's sync logs in place of its downloads. +function manualSyncLine(newCount: number | null): string { + return ( + `Manual downloads: ` + + (newCount === null + ? "the listing is recorded" + : `${newCount} new on the newest page recorded`) + + ` and nothing is downloaded — import a video to fetch it.\n` + ); +} + // A sync is one of two passes over the same channel listing: // // syncPaged the cheap default. Walks newest-first one 50-entry @@ -1945,6 +1967,7 @@ async function syncPaged(opts: RunYtdlpOpts): Promise<void> { opts.channelSlug, opts.channelConfig, ); + const manual = channelDownloadsAreManual(opts.channelConfig); for ( let page = 0; @@ -1983,6 +2006,14 @@ async function syncPaged(opts: RunYtdlpOpts): Promise<void> { : "") + `.\n`, ); + // MANUAL DOWNLOADS: the page is recorded (the roster merge above) and + // nothing on it is fetched. One page is the whole walk — the stop signal is + // an archived entry, and a channel that downloads only what it is asked for + // may have none for a thousand pages; the full sweep reads the rest. + if (manual) { + opts.onLog(manualSyncLine(newUrls.length)); + break; + } if (deferredAuthCount > 0) { opts.onLog( `Cookie mode is "defer": needs_auth deferred=${deferredAuthCount} — run the "Needs cookies" bucket to download them with cookies.\n`, @@ -2140,7 +2171,10 @@ async function syncFullSweep(opts: RunYtdlpOpts): Promise<void> { opts.onLog( `Full sweep: ${onDiskIds.size} known, ${listedIds.size} in fresh listing, ${maybeMissing.length} maybe-missing.\n`, ); - if (sets.missingNeverFetched.length > 0) { + if ( + sets.missingNeverFetched.length > 0 && + !channelDownloadsAreManual(opts.channelConfig) + ) { opts.onLog( `Full sweep: ${sets.missingNeverFetched.length} video(s) were listed but never downloaded and have now left the listing — see "Never fetched, now gone" on the channel page to attempt a direct-link recovery.\n`, ); @@ -2148,7 +2182,10 @@ async function syncFullSweep(opts: RunYtdlpOpts): Promise<void> { } // 4. Walk the same listing in newest-first windows, applying the paged walk's - // filter and stopping rule to slices instead of spawns. + // filter and stopping rule to slices instead of spawns. NOT on a + // manual-downloads channel (lib/manualDownloads.ts): the sweep's product + // there is what it KNOWS — the playlist and the missing sets above. + const manual = channelDownloadsAreManual(opts.channelConfig); let archive = await readArchive(archivePath); let totalNew = 0; let totalFailed = 0; @@ -2168,6 +2205,10 @@ async function syncFullSweep(opts: RunYtdlpOpts): Promise<void> { !opts.signal.aborted && !opts.drainSignal?.aborted; page++ ) { + if (manual) { + opts.onLog(manualSyncLine(null)); + break; + } const pageUrls = urls.slice( page * SYNC_PAGE_SIZE, (page + 1) * SYNC_PAGE_SIZE, diff --git a/editor/CHANGELOG.md b/editor/CHANGELOG.md @@ -1,6 +1,7 @@ # Changelog ## [Unreleased] +- **A channel can download only the videos you add.** The operator wanted Harmful Opinions downloaded by hand, with its title filter gone, and nothing said that: `syncIntervalMinutes: 0` stops the listing but the download lane still works the backlog it has — and dropping a filter re-decides every video it had settled, so the whole channel would come down — while a `paused` tier stops every lane, transcription too. Configure → Advanced → **Downloads**: Manual (`downloadMode: "manual"` in config.json; `pnpm ops channel-config --json '{"slug":"<slug>","patch":{"downloadMode":"manual"}}'`, `""` sets it back to Automatic). On a manual channel the download lane skips the channel (its backlog, retries, metadata scan and chat backlog); a sync reads only the newest page of the listing and a full sweep still refreshes the playlist and the maybe-missing set, and neither downloads the new uploads it finds; Download from playlist, Download videos (`download-missing`) and the bucket retries refuse with a notice. What you ask for still downloads — Import, `import-video`, the video page's download and persist buttons, `persist-videos`, clip windows, a whole-recording fetch — and the videos on disk are still transcribed. The channel's report keeps the listed videos it lacks as **Listed, not requested** (`manualNotRequestedIds`) rather than undownloaded work, so no lane, rack figure, dashboard count or group Download button counts them, and a video that leaves the listing unfetched is not raised as never fetched; the channel page says "Manual downloads — only videos you add are downloaded" at the top and the rack row carries a **manual dl** chip. An import still passes the channel's download filter, so set the mode first and then clear the filter. Needs a restart of the editor. - **A report-video take can be walked clip by clip before it is rendered, and made the cut.** Until now the clip bench walked only a project's own cut, and a take's clips could only be watched as a render. Now a take — a tight version's 27 sub-windows, say — opens on the bench at `/projects/<project>/takes/<take>/walk` (**Walk this take** on its card, or **walk a take** on the Cut tab): its clips in walk order with their verdicts, each played from the windows already fetched, with nothing fetched again for a clip inside one. Everything the walk changes — a verdict, a trim, a note, a clip removed or moved (**← earlier**, **later →**, **Remove from take**) — goes into the take's own patch in `takes/<take>/take.json`, never the project's manifest, and **Undo take edit** takes back the newest one. **walk every clip** keeps the clips that already carry a verdict on the walk. `umtool take <project> --id <take> --patch F --draft` records a take without rendering it (the Takes page shows it as **draft — walk / render**), and `umtool take <project> --id <take> --full` or **Render full** renders it later from its walked patch. **Make this the cut** (`umtool take <project> --id <take> --promote`) puts the take over the project's manifest with one undo point, so the Cut tab's **Undo last edit** takes it back; it waits for **Make it the cut anyway** when the take's timeline would replace a cut that changed since the take was made. From a terminal: `umtool walk <project> --take <take>`, `umtool window <project> <clip> --take <take> …` and `umtool timeline <project> --take <take> move|remove|undo`. A windowed render of a take whose timeline has none of the project's clips is now timed over the take's own clips instead of being refused. Needs a restart of umtool for the pages; the CLI has it at once. - **A live stream can be transcribed and clipped while it is still recording.** Until now a recording was transcribed only once the stream ended and the file landed, so on a long stream nothing could be found or shared until hours later. `pnpm ops record-live` takes `"preclip": true` (or `{"everyMinutes": 10, "maxChunkMinutes": 20, "overlapSeconds": 15, "scan": true, "mine": true, "project": "<slug>"}`, defaults in `settings.livePreclip`). `pnpm ops live-preclip {"slug", "id"}` starts the same thing on a recording already running, and the video page's **Live pre-clip** panel has a Start button. Every few minutes a tick transcribes only what was recorded since the last one. It reads the growing file in place and never copies it or touches the recorder, whatever the recording is: one MPEG-TS, YouTube's separate video and audio, or Kick's polled VOD. The new span is transcribed on the transcription worker, with word timings, and added to `data/<id>/live-transcript.json`, marked provisional, on the clock the landed video will have. The clip finder then grows a umtool project for the stream (`<id>-live`), so its windows can be walked in the clip editor while the stream goes on. A busy worker never piles ticks up: the next tick takes everything since, and a tick that is far behind is followed by the next one at once. A tick is skipped, and the log says why, when there is under 30 s new, when the machine is under the 6 GB memory floor (checked again every minute), or when the store's disk has under 2 GB free. A recorder that restarts or falls back (Rumble) is followed. If its audio matches, the transcript goes on; if not, it starts again on the new recording and the project's windows are flagged. When the stream lands, the landed video is checked against what was transcribed live, and the windows stay where they are when it matches (flagged when it does not). Once the final transcript is there it replaces the live one, and the project reads the corpus from then on. `"action": "stop"`, `"status"` and `"finalize"` stop it (the recording goes on), print its state, and finish that hand-over by hand. **A clip of a stream still live can be shared at once:** `pnpm ops live-clip {"slug", "id", "start", "end"}`, the panel's **Share this clip**, or the clip editor's **Share now (live)** cuts the window from what is recorded so far and makes the clip's short with the live captions. A share is at most 2:20 and 512 MiB, for X, and nothing is fetched from the network. Needs a restart of the editor and umtool. - **A reply can be captured with the post it answers above it.** `capture-posts` with `"thread": true` (X; or a channel's new `postCaptureThread`, or the Thread shot box under Capture posts on an X channel's page) also writes `shot-thread.png` beside the post's `shot.png`: the post it replies to over the reply, in the same page load — only the immediate parent, a longer chain cut to it. The parent is the post the archive says it answers; with no archive word, the post directly above it on the page; a post the archive says is no reply is not opened for it, and a post shot before gets only its thread shot. **The replied-to author is blurred** — avatar, name and handle, and any link to them in the reply — unless they carry an organisation's gold or a government's grey check, or are the reply's own author. X Premium's blue check is bought, so a blue-checked person is blurred like anyone else (the first live proof's parent was one). `"threadRedact": false` (or `{"<id>": false}`) takes it unblurred; a parent whose name cannot be found to blur gets no thread shot. capture.json records the parent, its badge and every blurred box. Proved on TheQuartering's reply 2114214000653414579. Needs a restart of the editor. diff --git a/editor/app/channels/[slug]/components/stages/DownloadStage.tsx b/editor/app/channels/[slug]/components/stages/DownloadStage.tsx @@ -22,6 +22,7 @@ import { import { RetryBucketControl } from "../RetryBucketControl"; import { fetchChatBacklogAction } from "../../chatBacklogActions"; import { VideoIdList } from "../VideoIdList"; +import { MANUAL_DOWNLOADS_TEXT } from "yt-dlp-transcript-common/lib/manualDownloads"; type Props = { slug: string; @@ -29,6 +30,9 @@ type Props = { defaultQueueKey: string; existingQueues: string[]; undownloadedIds: string[]; + // A manual-downloads channel's listed videos nobody asked for (the + // snapshot's manualNotRequestedIds); null on an automatic channel. + manualNotRequestedIds?: string[] | null; excludedFromDownload: ExcludedFromDownload; noTranscriptIds: string[]; partialDownloadIds: string[]; @@ -51,6 +55,7 @@ export function DownloadStage({ defaultQueueKey, existingQueues, undownloadedIds, + manualNotRequestedIds = null, excludedFromDownload, noTranscriptIds, partialDownloadIds, @@ -84,7 +89,11 @@ export function DownloadStage({ } return ( <div className="flex flex-col gap-6"> - <UndownloadedList slug={slug} ids={undownloadedIds} /> + {manualNotRequestedIds ? ( + <NotRequestedList slug={slug} ids={manualNotRequestedIds} /> + ) : ( + <UndownloadedList slug={slug} ids={undownloadedIds} /> + )} <ExcludedFromDownloadCard slug={slug} excluded={excludedFromDownload} @@ -458,6 +467,30 @@ function UndownloadedList({ slug, ids }: { slug: string; ids: string[] }) { ); } +// A MANUAL-DOWNLOADS CHANNEL's listing: not work, so not "undownloaded" +// (lib/manualDownloads.ts). Each video's page has its download button. +function NotRequestedList({ slug, ids }: { slug: string; ids: string[] }) { + return ( + <div className="flex flex-col gap-2"> + <h3 className="text-base font-semibold"> + Listed, not requested ({ids.length}) + </h3> + <p className="text-xs text-muted-foreground"> + {MANUAL_DOWNLOADS_TEXT}. Import a video, or open it and download it, + to fetch it; the batch downloads below refuse on this channel. + </p> + <VideoIdList + slug={slug} + ids={ids} + ariaLabel="not requested videos list" + emptyAriaLabel="not requested videos empty" + emptyMessage="Every listed video is downloaded." + itemAriaLabel={(id) => `not requested video ${id}`} + /> + </div> + ); +} + function NoTranscriptList({ slug, ids, diff --git a/editor/app/channels/[slug]/page.tsx b/editor/app/channels/[slug]/page.tsx @@ -43,6 +43,10 @@ import { pageCaptureView } from "yt-dlp-transcript-common/lib/waybackPages/view" import { postsMediaDir, readPostCapture } from "yt-dlp-transcript-common/social/postCapture"; import { listPostFetchersFor } from "./socialActions"; import { NoReportYet } from "./components/NoReportYet"; +import { + MANUAL_DOWNLOADS_TEXT, + channelDownloadsAreManual, +} from "yt-dlp-transcript-common/lib/manualDownloads"; import type { ChannelSnapshot } from "yt-dlp-transcript-common/controller/channelSnapshot"; import { digestWorkOf, @@ -602,6 +606,9 @@ export default async function ChannelDetailPage({ defaultQueueKey={platformDefaultQueueKey} existingQueues={existingQueues} undownloadedIds={undownloadedIds} + manualNotRequestedIds={ + channelDownloadsAreManual(config) ? (snapshot.manualNotRequestedIds ?? []) : null + } excludedFromDownload={excludedFromDownload} noTranscriptIds={actionableNoTranscriptIds} partialDownloadIds={buckets.partialDownloads} @@ -915,6 +922,24 @@ export default async function ChannelDetailPage({ <div className="flex flex-col gap-6"> {!existing && <NoReportYet slug={slug} />} + {/* MANUAL DOWNLOADS (lib/manualDownloads.ts): said at the top, so a + channel whose listing is mostly undownloaded is not read as stalled. */} + {channelDownloadsAreManual(config) && ( + <p + role="note" + aria-label="manual downloads" + className="rounded border border-border bg-muted px-3 py-2 text-sm" + > + <span className="font-medium">{MANUAL_DOWNLOADS_TEXT}.</span>{" "} + <span className="text-muted-foreground"> + {(snapshot.manualNotRequestedIds ?? []).length} listed video + {(snapshot.manualNotRequestedIds ?? []).length === 1 ? "" : "s"} not + requested. Syncs read the listing; the download lane and the batch + downloads leave this channel alone. Change it under Configure → Advanced → Downloads. + </span> + </p> + )} + <ChannelLine flow={flow} slug={slug} /> {/* The shortcut exists so you do not have to dig into a stage to start the diff --git a/editor/app/channels/[slug]/pipelineActions.ts b/editor/app/channels/[slug]/pipelineActions.ts @@ -1,5 +1,6 @@ "use server"; +import { manualDownloadsRefusal } from "yt-dlp-transcript-common/lib/manualDownloads"; import path from "node:path"; import { safeRevalidate } from "../../lib/safeRevalidate"; import { @@ -154,6 +155,10 @@ async function runPipelineAction( if (!channelConfig.url) { return { ok: false, error: "Channel has no `url` configured" }; } + // A MANUAL-DOWNLOADS CHANNEL refuses a batch download of its listing, as a + // notice (lib/manualDownloads.ts); a sync still runs and only reads. + const manual = manualDownloadsRefusal(slug, channelConfig, mode); + if (manual) return { ok: false, info: true, error: manual }; // Global downloads pause: every mode that writes media is blocked with a // friendly notice (info, not an error). store-playlist only enumerates the // video list — no media is written — so it stays allowed even while paused. diff --git a/editor/app/channels/components/ChannelForm.tsx b/editor/app/channels/components/ChannelForm.tsx @@ -40,6 +40,7 @@ import { waybackTargetFromUrl, waybackTargetHost } from "yt-dlp-transcript-commo import { WaybackTargetsField } from "./WaybackTargetsField"; import { XSearchFields } from "./XSearchFields"; import { isXSearchUrl, xSearchFromUrl } from "yt-dlp-transcript-common/lib/xSearch/config"; +import { MANUAL_DOWNLOADS_TEXT } from "yt-dlp-transcript-common/lib/manualDownloads"; import { probeChannelUrlAction } from "../actions"; import { Field, @@ -958,6 +959,29 @@ export function ChannelForm({ className="rounded border border-border bg-card px-2 py-1 text-sm font-mono" /> </label> + <label className="flex flex-col gap-1 text-sm"> + <span className="font-medium">Downloads</span> + <SeededSelect + state={state} + name="downloadMode" + initial={c?.downloadMode === "manual" ? "manual" : ""} + aria-label="downloads" + className="rounded border border-border bg-card px-2 py-1 text-sm" + > + <option value=""> + Automatic — the download lane and syncs fetch new and missing videos + </option> + <option value="manual">{MANUAL_DOWNLOADS_TEXT}</option> + </SeededSelect> + <span className="text-xs text-muted-foreground"> + Manual: syncs still read the listing and videos on disk are still + transcribed, but nothing is downloaded until you import it (or use a + video's download, persist or clip buttons); Download from + playlist, Download videos and the bucket retries refuse. An import + still passes the download filter below — clear it to let any video + you add download. + </span> + </label> <Field label="Download filter: include (regex)" name="downloadFilterInclude" diff --git a/editor/app/channels/components/ChannelTierSelect.tsx b/editor/app/channels/components/ChannelTierSelect.tsx @@ -25,6 +25,7 @@ // or the page's auto-refresh can never leave this select disagreeing with // settings.json, which a `useState` seeded from props would. +import { MANUAL_DOWNLOADS_TEXT } from "yt-dlp-transcript-common/lib/manualDownloads"; import { useOptimistic, useState, useTransition } from "react"; import { PRIORITY_OPERATIONS, @@ -63,6 +64,9 @@ export type ChannelTierSelectProps = { // whatever its tier and whatever the focus, until the move completes or its // marker is cleared (release 16 slice RM). mediaHold?: string | null; + // A manual-downloads channel (lib/manualDownloads.ts): the download lane + // skips it by design, so its rack row says so rather than looking stalled. + manualDownloads?: boolean; disabled?: boolean; }; @@ -93,6 +97,7 @@ export default function ChannelTierSelect({ heldReason = null, autoPausedReason = null, mediaHold = null, + manualDownloads = false, disabled = false, }: ChannelTierSelectProps): React.ReactNode { const [pending, startTransition] = useTransition(); @@ -208,6 +213,17 @@ export default function ChannelTierSelect({ <span className="sr-only"> — {mediaHold}</span> </span> )} + {manualDownloads && ( + <span + role="note" + aria-label={`manual downloads for ${slug}`} + title={MANUAL_DOWNLOADS_TEXT} + className="rounded-full border border-border px-1.5 text-[10px] uppercase tracking-wide text-muted-foreground" + > + manual dl + <span className="sr-only"> — {MANUAL_DOWNLOADS_TEXT}</span> + </span> + )} {error && ( <span role="alert" diff --git a/editor/app/channels/components/channelColumns.tsx b/editor/app/channels/components/channelColumns.tsx @@ -179,6 +179,7 @@ export const CHANNEL_COLUMNS: Record< heldReason={c.priority.heldReason} autoPausedReason={c.priority.autoPausedReason} mediaHold={c.mediaHold} + manualDownloads={c.manualDownloads} /> ), }), diff --git a/editor/app/channels/components/channelConfigToForm.ts b/editor/app/channels/components/channelConfigToForm.ts @@ -56,6 +56,8 @@ export const CHANNEL_FORM_VALUES = [ // Caption languages and when the live chat is fetched (2026-10-26). "subLangs", "chat", + // "manual" or "auto"/"" (2026-10-29, lib/manualDownloads.ts). + "downloadMode", "downloadFilterInclude", "downloadFilterExclude", "downloadFilterRejectedLivestreams", @@ -127,6 +129,7 @@ export function channelConfigToFormData(config: ChannelConfig): FormData { if (config.browserLookup) fd.set("browserLookup", "on"); put(fd, "subLangs", config.subLangs); put(fd, "chat", config.chat); + put(fd, "downloadMode", config.downloadMode); put(fd, "downloadFilterInclude", config.downloadFilter?.include); put(fd, "downloadFilterExclude", config.downloadFilter?.exclude); if (config.downloadFilter?.includeLivestreams) { diff --git a/editor/app/channels/components/parseChannelForm.test.ts b/editor/app/channels/components/parseChannelForm.test.ts @@ -332,3 +332,33 @@ test("subLangs and chat: parsed, refused when unknown, round-tripped through the assert.equal("subLangs" in cleared, false); assert.equal("chat" in cleared, false); }); + +// 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 +// patch. +test("downloadMode: manual is stored, automatic clears it, refused when unknown; the ops patch sets it and survives clearing the filter", () => { + assert.equal(parseChannelForm(form({ downloadMode: "manual" })).config.downloadMode, "manual"); + assert.equal("downloadMode" in parseChannelForm(form({ downloadMode: "" })).config, false); + assert.equal("downloadMode" in parseChannelForm(form({ downloadMode: "auto" })).config, false); + assert.throws(() => parseChannelForm(form({ downloadMode: "sometimes" })), /Downloads must be one of: auto, manual/); + assert.ok((CHANNEL_FORM_FIELDS as readonly string[]).includes("downloadMode")); + + const filtered = { handling: "youtube" as const, name: "Example VODs", downloadFilter: { include: "guest" } }; + const fd = channelConfigToFormData(filtered); + validateChannelFormPatch({ downloadMode: "manual" }); + applyChannelFormPatch(fd, { downloadMode: "manual" }); + const manual = parseChannelForm(fd).config; + assert.equal(manual.downloadMode, "manual"); + assert.deepEqual(manual.downloadFilter, { include: "guest" }, "a patch that does not name the filter keeps it"); + + const second = channelConfigToFormData(manual); + applyChannelFormPatch(second, { downloadFilterInclude: "" }); + const unfiltered = parseChannelForm(second).config; + assert.equal(unfiltered.downloadMode, "manual", "clearing the filter keeps the mode"); + assert.equal("downloadFilter" in unfiltered, false); + + const back = channelConfigToFormData(unfiltered); + applyChannelFormPatch(back, { downloadMode: "" }); + assert.equal("downloadMode" in parseChannelForm(back).config, false); +}); diff --git a/editor/app/channels/components/parseChannelForm.ts b/editor/app/channels/components/parseChannelForm.ts @@ -46,7 +46,13 @@ import { import { downloadFilterPatternProblem } from "yt-dlp-transcript-common/lib/downloadFilters"; import { recordedDatePatternProblem } from "yt-dlp-transcript-common/lib/recordedDate"; import { mirrorSlugs } from "yt-dlp-transcript-common/lib/mirrors/config"; -import { CHAT_MODES, isChatMode, isRejectedLivestreamMode } from "yt-dlp-transcript-common/lib/channelConfig"; +import { + CHAT_MODES, + DOWNLOAD_MODES, + isChatMode, + isDownloadMode, + isRejectedLivestreamMode, +} from "yt-dlp-transcript-common/lib/channelConfig"; import { AUDIO_CHECK_PLATFORMS } from "yt-dlp-transcript-common/lib/audioCheckPolicy"; export type ParsedChannelForm = { @@ -85,6 +91,8 @@ export const CHANNEL_FORM_FIELDS = [ // offline before, with patchChannelConfig). "subLangs", "chat", + // 2026-10-29: manual downloads (lib/manualDownloads.ts). + "downloadMode", "downloadFilter", "recordedDate", "mirror", @@ -288,6 +296,14 @@ export function parseChannelForm(formData: FormData): ParsedChannelForm { } const chat = isChatMode(chatRaw) && chatRaw !== "with-download" ? chatRaw : undefined; + // Downloads: "" or "auto" = automatic, the default — omitted, so choosing it + // clears a stored mode; "manual" = only what someone asks for. + const downloadModeRaw = String(formData.get("downloadMode") ?? "").trim(); + if (downloadModeRaw && !isDownloadMode(downloadModeRaw)) { + throw new Error(`Downloads must be one of: ${DOWNLOAD_MODES.join(", ")}`); + } + const downloadMode = downloadModeRaw === "manual" ? downloadModeRaw : undefined; + // Download filter. Both patterns are regex SOURCES compiled with "i" at // download time, so the form is the place that refuses an unparseable one: // a bad pattern saved here would make the filter silently inert on every @@ -471,6 +487,7 @@ export function parseChannelForm(formData: FormData): ParsedChannelForm { if (browserLookup) config.browserLookup = true; if (subLangs) config.subLangs = subLangs; if (chat) config.chat = chat; + if (downloadMode) config.downloadMode = downloadMode; if (downloadFilter) config.downloadFilter = downloadFilter; if (recordedDateTitlePattern) { config.recordedDate = { titlePattern: recordedDateTitlePattern }; diff --git a/editor/e2e/forms-keep-input.spec.ts b/editor/e2e/forms-keep-input.spec.ts @@ -270,6 +270,7 @@ test("ChannelForm create: a refused slug keeps every field", async ({ await named(form, "savedVideosDir").fill("/tmp/typed-dir"); await form.getByText("Advanced", { exact: true }).click(); await named(form, "ytdlpExtraArgs").fill("--typed\n--args"); + await named(form, "downloadMode").selectOption("manual"); await named(form, "downloadFilterInclude").fill("typed-include"); await named(form, "downloadFilterIncludeLivestreams").check(); await named(form, "downloadFilterRejectedLivestreams").selectOption( @@ -303,6 +304,7 @@ test("ChannelForm create: a refused slug keeps every field", async ({ await expect(named(form, "extractionMode")).toHaveValue("app"); await expect(named(form, "savedVideosDir")).toHaveValue("/tmp/typed-dir"); await expect(named(form, "ytdlpExtraArgs")).toHaveValue("--typed\n--args"); + await expect(named(form, "downloadMode")).toHaveValue("manual"); await expect(named(form, "downloadFilterInclude")).toHaveValue( "typed-include", ); diff --git a/scripts/archilyzer-ops.mjs b/scripts/archilyzer-ops.mjs @@ -67,6 +67,7 @@ // pnpm ops build-cues --json '{"slug":"demo-yt","ids":["<videoId>"]}' --wait // pnpm ops get transcript <videoId> --slug demo-yt // pnpm ops channel-config --json '{"slug":"x","patch":{"downloadFilterExclude":"rerun"}}' +// pnpm ops channel-config --json '{"slug":"x","patch":{"downloadMode":"manual"}}' // pnpm ops channel-config --json '{"slug":"x","sites":[{"siteId":"anilyzer"}]}' // pnpm ops channel-config --json '{"slug":"x","sites":[],"excludeFromBuild":true}' // pnpm ops site-config --json '{"siteId":"anilyzer","citedChannels":["critic-channel"]}' @@ -1312,7 +1313,11 @@ export function usage() { ' creator channels: "patch": {"mirrorOf": "<slug>, <slug>"} (CHANNEL.md,', ' mirror; then mirror-scan). Caption languages and the live chat:', ' "patch": {"subLangs": "en.*", "chat": "with-download" | "later" |', - ' "never"} (CHANNEL.md, subLangs and chat).', + ' "never"} (CHANNEL.md, subLangs and chat). Manual downloads: "patch":', + ' {"downloadMode": "manual"} — only videos you add (import-video, the', + ' video page) are downloaded; the download lane, a sync\'s new uploads and', + ' download-missing leave the channel alone; "" (or "auto") is automatic', + ' (CHANNEL.md, downloadMode).', "", 'site-config sets two keys of a site as its form does: {"siteId"} and any of', ' "citedChannels" (the WHOLE cited scope, channel slugs: what the site\'s',