commit 7388bdaef38a6bc17abf4386bd63fe37c239fc08 parent f72e3355a9f7c99b8842ff72702959fd0b2135f7 Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st> Date: Fri, 30 Oct 2026 12:39:59 -0400 Channel config skipShorts: a listed YouTube Short is not wanted `skipShorts: true` on a channel's config.json (a Configure checkbox beside the download filter, and `pnpm ops channel-config {"slug","patch":{"skipShorts":true}}`) treats every `youtube.com/shorts/<id>` listing entry with nothing on disk as not wanted, decided from the URL alone (lib/skipShorts.ts): - a sync's paged walk and a full sweep's walk skip it (neither new nor an archived hit, so it never stops a walk; the log line counts it); - Download from playlist, Download videos and the bucket retries skip it (partitionDownloadBatch, `shortsSkippedCount`); - the snapshot keeps it out of undownloadedIds (so out of the download lane) and lists it as a new top-level `skippedShortsIds`; a delisted unfetched Short is not in missingNeverFetched; - the metadata scan does not read it (metadataScanTargets and the snapshot's `metadataScan.unscanned` agree). Importing a Shorts URL still downloads it; a Short already on disk stays an ordinary video. Absent = byte-identical behaviour (no new snapshot key). CHANNEL.md regenerated. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Diffstat:
17 files changed, 472 insertions(+), 38 deletions(-)
diff --git a/CHANNEL.md b/CHANNEL.md @@ -45,6 +45,7 @@ Regenerate this file with `pnpm --filter yt-dlp-transcript-common exec tsx bin/f | `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). | +| `skipShorts` | config | `true`: the channel's YouTube Shorts — the listing entries whose URL is `youtube.com/shorts/<id>` — are not wanted. Decided from the listing URL alone (no metadata): a sync or full sweep does not download them, Download from playlist, Download videos and the bucket retries skip them, the metadata scan does not read them, and the report lists the ones with nothing on disk as `skippedShortsIds` instead of as undownloaded work (or, once delisted, as never-fetched losses). Importing a Shorts URL still downloads it, and a Short already on disk stays an ordinary video. Absent = Shorts are downloaded like any upload. A Configure field (`skipShorts`). | | `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. | | `sleepBetweenDownloadsSeconds` | config | Per-channel override for the global pause between downloads. Absent = inherit; 0 = no sleep; floored and capped at 600. | diff --git a/common/controller/channelSnapshot.test.ts b/common/controller/channelSnapshot.test.ts @@ -996,3 +996,69 @@ test("a manual-downloads channel has no undownloaded work and no never-fetched a await rm(auto.dir, { recursive: true, force: true }); } }); + +// SKIP SHORTS (2026-10-30, lib/skipShorts.ts): a listed `/shorts/` entry with +// nothing on disk is not work — out of undownloadedIds (the download lane's +// queue) and out of the metadata scan's backlog, kept as skippedShortsIds for +// the channel page — and a Short that left the listing unfetched is not a loss. +// A Short already on disk stays an ordinary video. Off, the same channel is +// unchanged and carries no new key. +test("a skip-Shorts channel keeps its listed Shorts out of the work list and the never-fetched alarm", async () => { + const shortUrl = (id: string) => `https://www.youtube.com/shorts/${id}`; + const watchUrl = (id: string) => `https://www.youtube.com/watch?v=${id}`; + async function seed(config: Record<string, unknown>) { + const ch = await filteredChannel({ listed: [], config }); + await writeFile( + path.join(ch.channelDir, "playlist"), + [watchUrl("aaaa0000001"), shortUrl("shrt0000002"), shortUrl("shrt0000003")].join("\n"), + ); + const roster: Record<string, { url: string; firstSeenAt: string }> = {}; + for (const [id, url] of [ + ["aaaa0000001", watchUrl("aaaa0000001")], + ["shrt0000002", shortUrl("shrt0000002")], + ["shrt0000003", shortUrl("shrt0000003")], + ["gone0000004", shortUrl("gone0000004")], + ["gone0000005", watchUrl("gone0000005")], + ]) { + roster[id] = { url, firstSeenAt: "2026-01-01T00:00:00.000Z" }; + } + await writeFile( + path.join(ch.channelDir, "roster.json"), + JSON.stringify({ version: 1, entries: roster }), + ); + // shrt0000003 is on disk: an ordinary, transcribed video. + const v = path.join(ch.channelDir, "data", "shrt0000003"); + await mkdir(v, { recursive: true }); + await writeFile( + path.join(v, "metadata.info.json"), + JSON.stringify({ id: "shrt0000003", title: "A short" }), + ); + await writeFile( + path.join(v, "transcript.en.vtt"), + "WEBVTT\n\n00:00:00.000 --> 00:00:01.000\nhi\n", + ); + return ch; + } + const skipping = await seed({ skipShorts: true }); + const keeping = await seed({}); + try { + const snap = await generateChannelSnapshot(skipping.paths, "alpha"); + assert.deepEqual(snap.undownloadedIds, ["aaaa0000001"]); + assert.deepEqual(snap.skippedShortsIds, ["shrt0000002"]); + assert.deepEqual((snap.missingNeverFetched ?? []).map((m) => m.id), ["gone0000005"]); + assert.equal(snap.metadataScan?.unscanned, 1, "the scan does not read a skipped Short"); + assert.equal(snap.totals.videos, 1, "the Short on disk is a video of the channel"); + // The control: the same channel without the key is unchanged. + const control = await generateChannelSnapshot(keeping.paths, "alpha"); + assert.deepEqual(control.undownloadedIds, ["aaaa0000001", "shrt0000002"]); + assert.equal("skippedShortsIds" in control, false); + assert.deepEqual( + (control.missingNeverFetched ?? []).map((m) => m.id).sort(), + ["gone0000004", "gone0000005"], + ); + assert.equal(control.metadataScan?.unscanned, 2); + } finally { + await rm(skipping.dir, { recursive: true, force: true }); + await rm(keeping.dir, { recursive: true, force: true }); + } +}); diff --git a/common/controller/channelSnapshot.ts b/common/controller/channelSnapshot.ts @@ -91,6 +91,11 @@ import { isIncompleteTranscript } from "../lib/transcriptCoverage"; import { storedMediaUrl } from "../lib/storedMediaUrl-server"; import { FULL_AUDIO_ATTEMPTS, fullAudioAttemptsOf } from "../lib/fullAudioFirst"; import { channelDownloadsAreManual } from "../lib/manualDownloads"; +import { + channelSkipsShorts, + isShortsUrl, + skippedShortIds, +} from "../lib/skipShorts"; // THE PER-OPERATION WORK LISTS, keyed by operation id. // @@ -370,6 +375,14 @@ export type ChannelSnapshot = { // not work: undownloadedIds is empty on such a channel and every count of // download work reads 0. Absent on every other channel. manualNotRequestedIds?: string[]; + // SKIP-SHORTS CHANNELS ONLY (ChannelConfig.skipShorts, lib/skipShorts.ts): + // the listed YouTube Shorts with nothing on disk, in playlist order — what + // undownloadedIds would otherwise carry. Not work: the download lane, the + // syncs and the batch downloads all pass them over, and the metadata scan + // does not read them (so they are not in `metadataScan.unscanned` either). + // Taken out of the walk before the settled and manual checks, so a Short is + // never in manualNotRequestedIds. Absent on every other channel. + skippedShortsIds?: 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- @@ -1658,6 +1671,14 @@ export async function generateChannelSnapshot( // can't mean two things in two files. `listed` is the stored playlist's // canonical ids; `missingNeverFetched` is the category that used to be // inexpressible — in the roster, never downloaded, and no longer listed. + // A skip-Shorts channel's Shorts, from the listing and — for one that has + // left it — the roster's stored URL. Empty on every other channel. + const skipShorts = channelSkipsShorts(config); + const shortIds = skippedShortIds( + config, + [...urls, ...Object.values(roster.entries).map((e) => e.url)], + extractVideoId, + ); const sets = deriveChannelSets({ roster, listedIds: new Set( @@ -1668,14 +1689,16 @@ export async function generateChannelSnapshot( // a directory, and a settled video has none since a rejection stopped // leaving its prefetch dir behind. Without this, `missingNeverFetched` — // the loudest alarm this report raises — would fire for videos the operator - // asked us not to fetch. - settledIds, + // asked us not to fetch. A skipped Short is the same: no directory, by the + // operator's choice. + settledIds: shortIds.size ? new Set([...settledIds, ...shortIds]) : settledIds, }); const listedIdSet = new Set(sets.listed); const undownloadedIds: string[] = []; const manual = channelDownloadsAreManual(config); const manualNotRequestedIds: string[] = []; + const skippedShortsIds: 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. @@ -1693,6 +1716,13 @@ export async function generateChannelSnapshot( if (!dirId || !listedIdSet.has(dirId)) continue; const f = filesById.get(dirId); if (f && videoHasAnyArtifact(f)) continue; + // A SKIPPED SHORT (lib/skipShorts.ts) is not wanted and not read: out + // before the metadata-scan count, because metadataScanTargets leaves it + // out too. One on disk already returned above — it is an ordinary video. + if (skipShorts && isShortsUrl(url)) { + skippedShortsIds.push(dirId); + continue; + } // Never fetched and never read: work for the metadata scan. Counted before // the settlement check, because a settled video HAS been read — it is the // scan's output, not its input. @@ -1864,6 +1894,7 @@ export async function generateChannelSnapshot( backfill: { ...backfillCounts, ...bucketLaneEntries }, undownloadedIds, ...(manual ? { manualNotRequestedIds } : {}), + ...(skipShorts ? { skippedShortsIds } : {}), excludedFromDownload, keptCount: keptIds.size, availability, diff --git a/common/lib/channelConfig.ts b/common/lib/channelConfig.ts @@ -212,6 +212,8 @@ export type ChannelConfig = { skipLiveDownloads?: boolean; downloadMode?: DownloadMode; downloadFilter?: DownloadFilterConfig; + // 2026-10-30: listed YouTube Shorts are not wanted (lib/skipShorts.ts). + skipShorts?: boolean; cookiesFromBrowser?: string; cookieMode?: CookieMode; sleepBetweenDownloadsSeconds?: number; @@ -286,6 +288,8 @@ export const CHANNEL_CONFIG_FIELD_DOCS: FieldDocs<ChannelConfig> = { '`"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).", + skipShorts: + "`true`: the channel's YouTube Shorts — the listing entries whose URL is `youtube.com/shorts/<id>` — are not wanted. Decided from the listing URL alone (no metadata): a sync or full sweep does not download them, Download from playlist, Download videos and the bucket retries skip them, the metadata scan does not read them, and the report lists the ones with nothing on disk as `skippedShortsIds` instead of as undownloaded work (or, once delisted, as never-fetched losses). Importing a Shorts URL still downloads it, and a Short already on disk stays an ordinary video. Absent = Shorts are downloaded like any upload. A Configure field (`skipShorts`).", cookiesFromBrowser: "Per-channel override of the global cookies-from-browser spec (a browser spec, or `file:<path>` for a cookies.txt). Trimmed; blank = inherit.", cookieMode: "Per-channel override of the global cookie mode. Absent = inherit.", @@ -504,6 +508,7 @@ export const CHANNEL_CONFIG_COERCIONS: { skipLiveDownloads: bool, downloadMode: (v) => (isDownloadMode(v) ? v : undefined), downloadFilter: coerceDownloadFilter, + skipShorts: (v) => (v === true ? true : undefined), cookiesFromBrowser: trimmedNonBlank, cookieMode: (v) => (isCookieMode(v) ? v : undefined), sleepBetweenDownloadsSeconds: (v) => 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, 41); // 2026-10-29: `downloadMode` + assert.equal(CHANNEL_CONFIG_KEYS.length, 42); // 2026-10-30: `skipShorts` 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 @@ -74,6 +74,7 @@ export const channelConfigObjectSchema = z.object({ skipLiveDownloads: field("skipLiveDownloads"), downloadMode: field("downloadMode"), downloadFilter: field("downloadFilter"), + skipShorts: field("skipShorts"), cookiesFromBrowser: field("cookiesFromBrowser"), cookieMode: field("cookieMode"), sleepBetweenDownloadsSeconds: field("sleepBetweenDownloadsSeconds"), diff --git a/common/lib/skipShorts.test.ts b/common/lib/skipShorts.test.ts @@ -0,0 +1,67 @@ +import { test } from "node:test"; +import assert from "node:assert/strict"; +import { + channelSkipsShorts, + isShortsUrl, + skippedShortIds, + skipsAsShort, +} from "./skipShorts"; +import { extractVideoId } from "./videoId"; +import { parseChannelConfig } from "./channelConfig"; +import { channelConfigSchema } from "./channelConfigSchema"; + +// Run with: node_modules/.bin/tsx --test common/lib/skipShorts.test.ts + +test("isShortsUrl: a youtube.com /shorts/<id> path, as the listing spells it", () => { + for (const u of [ + "https://www.youtube.com/shorts/EZNHvnapR_s", + "https://youtube.com/shorts/EZNHvnapR_s", + "https://m.youtube.com/shorts/EZNHvnapR_s?feature=share", + "https://www.youtube.com/Shorts/EZNHvnapR_s", + ]) { + assert.equal(isShortsUrl(u), true, u); + } + for (const u of [ + "https://www.youtube.com/watch?v=EZNHvnapR_s", + "https://www.youtube.com/shorts", + "https://www.youtube.com/@x/shorts", + "https://youtu.be/EZNHvnapR_s", + "https://rumble.com/shorts/v123-x.html", + "https://notyoutube.com/shorts/EZNHvnapR_s", + "not a url", + "", + ]) { + assert.equal(isShortsUrl(u), false, u); + } +}); + +test("only `skipShorts: true` skips; absent, false or junk keep today's behaviour", () => { + const short = "https://www.youtube.com/shorts/EZNHvnapR_s"; + assert.equal(channelSkipsShorts({ skipShorts: true }), true); + assert.equal(skipsAsShort({ skipShorts: true }, short), true); + assert.equal(skipsAsShort({ skipShorts: true }, "https://www.youtube.com/watch?v=EZNHvnapR_s"), false); + for (const c of [null, undefined, {}, { skipShorts: false }]) { + assert.equal(channelSkipsShorts(c), false); + assert.equal(skipsAsShort(c, short), false); + } +}); + +test("skippedShortIds: the Shorts' ids, and none on a channel that keeps them", () => { + const urls = [ + "https://www.youtube.com/watch?v=aaaaaaaaaaa", + "https://www.youtube.com/shorts/bbbbbbbbbbb", + "", + ]; + assert.deepEqual([...skippedShortIds({ skipShorts: true }, urls, extractVideoId)], ["bbbbbbbbbbb"]); + assert.equal(skippedShortIds({}, urls, extractVideoId).size, 0); +}); + +test("the config key: true is kept, anything else is dropped (both compositions)", () => { + const base = { handling: "youtube", url: "https://www.youtube.com/@x" }; + assert.equal(parseChannelConfig({ ...base, skipShorts: true })?.skipShorts, true); + assert.equal(channelConfigSchema.parse({ ...base, skipShorts: true })?.skipShorts, true); + for (const v of [false, "true", 1, null]) { + assert.equal("skipShorts" in (parseChannelConfig({ ...base, skipShorts: v }) ?? {}), false, String(v)); + assert.equal("skipShorts" in (channelConfigSchema.parse({ ...base, skipShorts: v }) ?? {}), false, String(v)); + } +}); diff --git a/common/lib/skipShorts.ts b/common/lib/skipShorts.ts @@ -0,0 +1,91 @@ +// A CHANNEL THAT SKIPS ITS YOUTUBE SHORTS (2026-10-30). +// +// `ChannelConfig.skipShorts: true` (lib/channelConfig.ts). A YouTube channel's +// listing — the `playlist` file a sync writes from `yt-dlp --flat-playlist +// --print url` — carries its Shorts as `https://www.youtube.com/shorts/<id>` +// lines, and nothing else said "not those": `downloadFilter` reads titles and +// descriptions, and a Short's title is no different from an upload's. The +// listing URL is the one place a Short says what it is, so this is decided from +// the URL alone — no metadata, no request. +// +// With it on, a listed Short that has nothing on disk is NOT WANTED by every +// path that turns "listed but absent" into a download: +// +// a sync's / sweep's new-upload walk ytdlp/runYtdlp.ts, selectDownloadableUrls +// (counted like a filter-settled entry) +// the batch downloads download-from-playlist, download-missing, +// retry-bucket (partitionDownloadBatch) +// the report's work list controller/channelSnapshot.ts: +// out of undownloadedIds (and so out of +// the download lane), listed instead as +// `skippedShortsIds`; never in +// missingNeverFetched +// the metadata scan ytdlp/metadataScan.ts, metadataScanTargets +// +// What a person asks for is not gated: importing a Shorts URL (import-video, +// the channel page's Import), the video page's buttons, clip windows. A Short +// already on disk is an ordinary video of the channel. +// +// Absent (the default) is the behaviour before the key existed, byte for byte: +// every predicate below answers false and the snapshot carries no new key. +// +// Client-safe and import-free: the Configure form reads the sentence below. + +import type { ChannelConfig } from "./channelConfig"; + +// THE ONE PREDICATE over the config. +export function channelSkipsShorts( + config: Pick<ChannelConfig, "skipShorts"> | null | undefined, +): boolean { + return config?.skipShorts === true; +} + +// Is this listing URL a YouTube Short? Path-based, as the listing spells it: +// youtube.com (any subdomain) with `/shorts/<id>` as its path. A watch URL of +// the same video is NOT a Short by this test — the listing decides, and a +// listing that names a video by its watch URL listed it as an upload. +export function isShortsUrl(url: string): boolean { + let u: URL; + try { + u = new URL(url); + } catch { + return false; + } + const host = u.hostname.toLowerCase(); + if (host !== "youtube.com" && !host.endsWith(".youtube.com")) return false; + const seg = u.pathname.split("/").filter(Boolean); + return seg.length >= 2 && seg[0].toLowerCase() === "shorts"; +} + +// Should a batch or a sync skip this listing URL? The question every download +// path asks, in one place. +export function skipsAsShort( + config: Pick<ChannelConfig, "skipShorts"> | null | undefined, + url: string, +): boolean { + return channelSkipsShorts(config) && isShortsUrl(url); +} + +// What the form and the channel page say. +export const SKIP_SHORTS_TEXT = "Skip YouTube Shorts"; + +// The ids of the Shorts among `urls` a skipShorts channel does not want — +// empty for every other channel. `idOf` is lib/videoId's extractVideoId, +// passed in so this module stays import-free for the form. Used where a set +// is defined by the ABSENCE of a directory (controller/channelSets.ts's +// undownloaded and missingNeverFetched): a skipped Short has none, and must not +// read as work, or as a loss once it leaves the listing. +export function skippedShortIds( + config: Pick<ChannelConfig, "skipShorts"> | null | undefined, + urls: Iterable<string>, + idOf: (url: string) => string | null, +): Set<string> { + const out = new Set<string>(); + if (!channelSkipsShorts(config)) return out; + for (const url of urls) { + if (!isShortsUrl(url)) continue; + const id = idOf(url); + if (id) out.add(id); + } + return out; +} diff --git a/common/ytdlp/metadataScan.ts b/common/ytdlp/metadataScan.ts @@ -37,6 +37,7 @@ import { noteServiceCookieClean, observeStderrServiceSignal } from "../lib/servi import type { Paths } from "../lib/paths"; import { getSettings } from "../lib/settings"; import { extractVideoId } from "../lib/videoId"; +import { channelSkipsShorts, isShortsUrl } from "../lib/skipShorts"; import { isVideoFetched, readVideoFiles } from "../lib/videoStatus"; import type { JobProgress } from "../jobs/registry"; import { @@ -152,7 +153,12 @@ export type RunMetadataScanOpts = { maxTargets?: number; }; -async function readPlaylistIds(channelDir: string): Promise<string[]> { +// `skipShorts`: leave a YouTube Short's listing line out (lib/skipShorts.ts) — +// a skip-Shorts channel never downloads one, so its title settles nothing. +async function readPlaylistIds( + channelDir: string, + skipShorts = false, +): Promise<string[]> { const raw = await readFile(path.join(channelDir, "playlist"), "utf8").catch( () => "", ); @@ -161,6 +167,7 @@ async function readPlaylistIds(channelDir: string): Promise<string[]> { for (const line of raw.split("\n")) { const url = line.trim(); if (!url) continue; + if (skipShorts && isShortsUrl(url)) continue; const id = extractVideoId(url); if (id && !seen.has(id)) { seen.add(id); @@ -201,15 +208,19 @@ async function fetchedIds(dataDir: string): Promise<Set<string>> { // What this run will fetch: listed, not already fetched, not already scanned. // Deliberately NOT filtered by the download filter — the scan exists to find out -// what the filter should say, so it cannot use the answer as its input. +// what the filter should say, so it cannot use the answer as its input. A +// skip-Shorts channel's Shorts ARE left out: that decision is the URL's, made +// before any title, and the snapshot's `metadataScan.unscanned` leaves them +// out the same way. export async function metadataScanTargets( paths: Paths, slug: string, now: number = Date.now(), + opts: { skipShorts?: boolean } = {}, ): Promise<string[]> { const channelDir = path.join(paths.channelsDir, slug); const [listed, fetched, scan] = await Promise.all([ - readPlaylistIds(channelDir), + readPlaylistIds(channelDir, opts.skipShorts === true), fetchedIds(path.join(channelDir, "data")), loadMetadataScan(paths, slug), ]); @@ -254,7 +265,9 @@ export async function runMetadataScan( const channelDir = path.join(paths.channelsDir, slug); const startedAt = new Date().toISOString(); - const backlog = await metadataScanTargets(paths, slug); + const backlog = await metadataScanTargets(paths, slug, Date.now(), { + skipShorts: channelSkipsShorts(channelConfig), + }); const targetIds = opts.maxTargets && opts.maxTargets > 0 ? backlog.slice(0, opts.maxTargets) diff --git a/common/ytdlp/partitionDownloadBatch.test.ts b/common/ytdlp/partitionDownloadBatch.test.ts @@ -139,3 +139,30 @@ test("the download filter's settled set is checked first; needs_auth defers only }); assert.deepEqual(always.fetch, [url("episodeJJJJ"), url("needsAuthHH")]); }); + +// SKIP SHORTS (lib/skipShorts.ts): a `/shorts/` listing line is out of every +// batch on a skipShorts channel — counted, never fetched — and only there. +test("a skipShorts channel's batch leaves its /shorts/ entries out; any other channel fetches them", async () => { + const short = (id: string) => `https://www.youtube.com/shorts/${id}`; + const urls = [url("uploadKKKKK"), short("shortLLLLLL"), short("shortMMMMMM")]; + const skipping = await partitionDownloadBatch({ + urls, + dataDir: DATA, + scan: scanWith({}), + config: { skipShorts: true }, + deferNeedsAuth: false, + }); + assert.deepEqual(skipping.fetch, [url("uploadKKKKK")]); + assert.equal(skipping.shortsSkippedCount, 2); + for (const config of [null, {}, { skipShorts: false }] as const) { + const keeping = await partitionDownloadBatch({ + urls, + dataDir: DATA, + scan: scanWith({}), + config: config as never, + deferNeedsAuth: false, + }); + assert.deepEqual(keeping.fetch, urls); + assert.equal(keeping.shortsSkippedCount, 0); + } +}); diff --git a/common/ytdlp/runYtdlp.ts b/common/ytdlp/runYtdlp.ts @@ -106,6 +106,12 @@ import { channelDownloadsAreManual, manualDownloadsRefusal, } from "../lib/manualDownloads"; +import { + channelSkipsShorts, + isShortsUrl, + skippedShortIds, + skipsAsShort, +} from "../lib/skipShorts"; export type YtdlpMode = | "store-playlist" @@ -786,11 +792,14 @@ type PrefilterMode = "archive" | "destination-exists"; // yt-dlp runs on each of the 277 members-only videos the scan had found // that night, and landed nothing. // 3. needs_auth under cookie mode "defer". +// +// Before all three, a listed YouTube Short on a `skipShorts` channel +// (lib/skipShorts.ts): decided from the URL alone, so it costs no read at all. export async function partitionDownloadBatch(args: { urls: ReadonlyArray<string>; dataDir: string; scan: MetadataScan; - config: Pick<ChannelConfig, "downloadFilter"> | null | undefined; + config: Pick<ChannelConfig, "downloadFilter" | "skipShorts"> | null | undefined; deferNeedsAuth: boolean; }): Promise<{ fetch: string[]; @@ -799,6 +808,7 @@ export async function partitionDownloadBatch(args: { excludedByScan: number; deferredAuthCount: number; settledByFilterCount: number; + shortsSkippedCount: number; }> { const settledByFilter = settledIdsFrom(args.scan, args.config); const scanExcluded = scanExclusionsFrom(args.scan); @@ -806,8 +816,13 @@ export async function partitionDownloadBatch(args: { let excludedByScan = 0; let deferredAuthCount = 0; let settledByFilterCount = 0; + let shortsSkippedCount = 0; const fetch: string[] = []; for (const url of args.urls) { + if (skipsAsShort(args.config, url)) { + shortsSkippedCount++; + continue; + } const dirId = extractVideoId(url); if (dirId) { if (settledByFilter.has(dirId)) { @@ -843,6 +858,7 @@ export async function partitionDownloadBatch(args: { excludedByScan, deferredAuthCount, settledByFilterCount, + shortsSkippedCount, }; } @@ -1000,6 +1016,7 @@ async function downloadPlaylistManaged( excludedByScan, deferredAuthCount, settledByFilterCount, + shortsSkippedCount, } = batch; const totalExcluded = excludedCounts.members_only + @@ -1017,6 +1034,11 @@ async function downloadPlaylistManaged( `Settled by this channel's download filter: ${settledByFilterCount} skipped (already decided). Change the include/exclude patterns in Configure to re-evaluate them.\n`, ); } + if (shortsSkippedCount > 0) { + opts.onLog( + `Skipped ${shortsSkippedCount} YouTube Short(s): this channel skips Shorts (Configure). Import one to download it anyway.\n`, + ); + } if (deferredAuthCount > 0) { opts.onLog( `Cookie mode is "defer": needs_auth deferred=${deferredAuthCount} — run the "Needs cookies" bucket to download them with cookies.\n`, @@ -1883,28 +1905,42 @@ export async function fullSweepDue( // `settled` is a SET, resolved once per run by the caller. It used to be a // per-video sidecar read; the whole point of deriving settlement from the // channel-level metadata-scan store is that this loop does no I/O for it. +// +// A SKIPPED SHORT (`skipShorts`, lib/skipShorts.ts) IS NEITHER NEW NOR A HIT. +// It is not downloaded, and it does not stop the walk: a YouTube listing puts +// its Shorts in one block at the END (every one of the 47 corpus listings that +// carries Shorts, 2026-10-30), so a caught-up walk has stopped on archived +// uploads long before it reaches them, and counting a Short as "content we +// already have" could only ever stop a walk short of an upload. async function selectDownloadableUrls( pageUrls: ReadonlyArray<string>, archive: Awaited<ReturnType<typeof readArchive>>, dataDir: string, runCookiePolicy: ResolvedCookiePolicy, settled: ReadonlySet<string>, + skipShorts = false, ): Promise<{ newUrls: string[]; archivedHits: number; deferredAuthCount: number; settledCount: number; + shortsCount: number; }> { const newUrls: string[] = []; let archivedHits = 0; let deferredAuthCount = 0; let settledCount = 0; + let shortsCount = 0; for (const url of pageUrls) { const archiveId = await archiveIdForUrl(url, dataDir); if (archiveId && archive.ids.has(archiveId)) { archivedHits++; continue; } + if (skipShorts && isShortsUrl(url)) { + shortsCount++; + continue; + } const dirId = extractVideoId(url); // Settled by the channel's download filter: counted as a hit (see above), // and reported separately so the log doesn't claim they were archived. @@ -1924,7 +1960,28 @@ async function selectDownloadableUrls( } newUrls.push(url); } - return { newUrls, archivedHits, deferredAuthCount, settledCount }; + return { newUrls, archivedHits, deferredAuthCount, settledCount, shortsCount }; +} + +// The sync page's log line, one spelling for both passes. +function syncPageLine( + page: number, + entries: number, + sel: { + newUrls: string[]; + archivedHits: number; + settledCount: number; + shortsCount: number; + }, +): string { + return ( + `Sync page ${page + 1}: ${entries} entries, ${sel.newUrls.length} new, ${sel.archivedHits} already archived` + + (sel.settledCount + ? ` (${sel.settledCount} settled by the download filter)` + : "") + + (sel.shortsCount ? `, ${sel.shortsCount} Shorts skipped` : "") + + `.\n` + ); } async function syncPaged(opts: RunYtdlpOpts): Promise<void> { @@ -1991,21 +2048,16 @@ async function syncPaged(opts: RunYtdlpOpts): Promise<void> { "listing", ); - const { newUrls, archivedHits, deferredAuthCount, settledCount } = - await selectDownloadableUrls( - pageUrls, - archive, - dataDir, - runCookiePolicy, - settledIds, - ); - opts.onLog( - `Sync page ${page + 1}: ${pageUrls.length} entries, ${newUrls.length} new, ${archivedHits} already archived` + - (settledCount - ? ` (${settledCount} settled by the download filter)` - : "") + - `.\n`, + const selection = await selectDownloadableUrls( + pageUrls, + archive, + dataDir, + runCookiePolicy, + settledIds, + channelSkipsShorts(opts.channelConfig), ); + const { newUrls, archivedHits, deferredAuthCount } = selection; + opts.onLog(syncPageLine(page, pageUrls.length, selection)); // 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 @@ -2156,11 +2208,21 @@ async function syncFullSweep(opts: RunYtdlpOpts): Promise<void> { opts.channelSlug, opts.channelConfig, ); + // A skipped Short (lib/skipShorts.ts) is subtracted for the same reason: + // nothing on disk, by the operator's choice. Its URL is the roster's when + // it has left the listing. + const skippedShorts = skippedShortIds( + opts.channelConfig, + [...urls, ...Object.values(roster.entries).map((e) => e.url)], + extractVideoId, + ); const sets = deriveChannelSets({ roster, listedIds, onDiskIds, - settledIds: sweepSettledIds, + settledIds: skippedShorts.size + ? new Set([...sweepSettledIds, ...skippedShorts]) + : sweepSettledIds, }); maybeMissing = sets.missingDownloaded; await writeMaybeMissing(opts.paths, opts.channelSlug, { @@ -2215,21 +2277,16 @@ async function syncFullSweep(opts: RunYtdlpOpts): Promise<void> { ); if (pageUrls.length === 0) break; - const { newUrls, archivedHits, deferredAuthCount, settledCount } = - await selectDownloadableUrls( - pageUrls, - archive, - dataDir, - runCookiePolicy, - settledIds, - ); - opts.onLog( - `Sync page ${page + 1}: ${pageUrls.length} entries, ${newUrls.length} new, ${archivedHits} already archived` + - (settledCount - ? ` (${settledCount} settled by the download filter)` - : "") + - `.\n`, + const selection = await selectDownloadableUrls( + pageUrls, + archive, + dataDir, + runCookiePolicy, + settledIds, + channelSkipsShorts(opts.channelConfig), ); + const { newUrls, archivedHits, deferredAuthCount } = selection; + opts.onLog(syncPageLine(page, pageUrls.length, selection)); if (deferredAuthCount > 0) { opts.onLog( `Cookie mode is "defer": needs_auth deferred=${deferredAuthCount} — run the "Needs cookies" bucket to download them with cookies.\n`, diff --git a/editor/app/channels/[slug]/components/stages/DownloadStage.tsx b/editor/app/channels/[slug]/components/stages/DownloadStage.tsx @@ -23,6 +23,7 @@ import { RetryBucketControl } from "../RetryBucketControl"; import { fetchChatBacklogAction } from "../../chatBacklogActions"; import { VideoIdList } from "../VideoIdList"; import { MANUAL_DOWNLOADS_TEXT } from "yt-dlp-transcript-common/lib/manualDownloads"; +import { SKIP_SHORTS_TEXT } from "yt-dlp-transcript-common/lib/skipShorts"; type Props = { slug: string; @@ -33,6 +34,9 @@ type Props = { // A manual-downloads channel's listed videos nobody asked for (the // snapshot's manualNotRequestedIds); null on an automatic channel. manualNotRequestedIds?: string[] | null; + // A skip-Shorts channel's listed Shorts with nothing on disk (the snapshot's + // skippedShortsIds, lib/skipShorts.ts); null when the channel keeps Shorts. + skippedShortsIds?: string[] | null; excludedFromDownload: ExcludedFromDownload; noTranscriptIds: string[]; partialDownloadIds: string[]; @@ -56,6 +60,7 @@ export function DownloadStage({ existingQueues, undownloadedIds, manualNotRequestedIds = null, + skippedShortsIds = null, excludedFromDownload, noTranscriptIds, partialDownloadIds, @@ -94,6 +99,18 @@ export function DownloadStage({ ) : ( <UndownloadedList slug={slug} ids={undownloadedIds} /> )} + {skippedShortsIds ? ( + <p + role="note" + aria-label="skipped shorts" + className="text-sm text-muted-foreground" + > + {SKIP_SHORTS_TEXT}: {skippedShortsIds.length} listed Short + {skippedShortsIds.length === 1 ? "" : "s"} not downloaded and not + counted above. Import one to download it, or untick the setting in + Configure. + </p> + ) : null} <ExcludedFromDownloadCard slug={slug} excluded={excludedFromDownload} diff --git a/editor/app/channels/[slug]/page.tsx b/editor/app/channels/[slug]/page.tsx @@ -47,6 +47,7 @@ import { MANUAL_DOWNLOADS_TEXT, channelDownloadsAreManual, } from "yt-dlp-transcript-common/lib/manualDownloads"; +import { channelSkipsShorts } from "yt-dlp-transcript-common/lib/skipShorts"; import type { ChannelSnapshot } from "yt-dlp-transcript-common/controller/channelSnapshot"; import { digestWorkOf, @@ -609,6 +610,9 @@ export default async function ChannelDetailPage({ manualNotRequestedIds={ channelDownloadsAreManual(config) ? (snapshot.manualNotRequestedIds ?? []) : null } + skippedShortsIds={ + channelSkipsShorts(config) ? (snapshot.skippedShortsIds ?? []) : null + } excludedFromDownload={excludedFromDownload} noTranscriptIds={actionableNoTranscriptIds} partialDownloadIds={buckets.partialDownloads} diff --git a/editor/app/channels/components/ChannelForm.tsx b/editor/app/channels/components/ChannelForm.tsx @@ -41,6 +41,7 @@ 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 { SKIP_SHORTS_TEXT } from "yt-dlp-transcript-common/lib/skipShorts"; import { probeChannelUrlAction } from "../actions"; import { Field, @@ -1041,6 +1042,25 @@ export function ChannelForm({ captions; they are never downloaded and never transcribed. </span> </label> + <label className="flex items-start gap-2 text-sm"> + <input + type="checkbox" + name="skipShorts" + aria-label="skip YouTube Shorts" + defaultChecked={seedChecked(state, "skipShorts", c?.skipShorts === true)} + className="mt-1" + /> + <span className="flex flex-col gap-0.5"> + <span className="font-medium">{SKIP_SHORTS_TEXT}</span> + <span className="text-xs text-muted-foreground"> + Listing entries at youtube.com/shorts/… are not downloaded by + syncs, Download from playlist, Download videos or the download + lane, and are not counted as undownloaded. Decided from the + listing URL, so no title is read. Importing a Shorts URL still + downloads it, and Shorts already on disk stay. + </span> + </span> + </label> <Field label="Recorded date from the title (regex)" name="recordedDateTitlePattern" diff --git a/editor/app/channels/components/channelConfigToForm.ts b/editor/app/channels/components/channelConfigToForm.ts @@ -25,6 +25,8 @@ export const CHANNEL_FORM_FLAGS = [ "keepSourceVideo", "browserLookup", "downloadFilterIncludeLivestreams", + // A listed YouTube Short is not wanted (2026-10-30, lib/skipShorts.ts). + "skipShorts", "audioCheckEnabled", "audioCheckResumeDuringProbe", // A Wayback pages channel's `wayback.auto` (release 37 S2). @@ -135,6 +137,7 @@ export function channelConfigToFormData(config: ChannelConfig): FormData { if (config.downloadFilter?.includeLivestreams) { fd.set("downloadFilterIncludeLivestreams", "on"); } + if (config.skipShorts) fd.set("skipShorts", "on"); // Omitted when it is "skip" — the parser reads an absent field as "skip", so // emitting it would be a value with no effect, and a patch clearing it ("") // has to land on the same default the form's own select does. diff --git a/editor/app/channels/components/parseChannelForm.test.ts b/editor/app/channels/components/parseChannelForm.test.ts @@ -153,6 +153,31 @@ test("the form writes browserLookup from its checkbox; unchecked clears it; the assert.equal("browserLookup" in parseChannelForm(back).config, false); }); +// Skip YouTube Shorts (2026-10-30, lib/skipShorts.ts): the same checkbox shape, +// and the ops patch (`pnpm ops channel-config {"slug","patch":{"skipShorts":true}}`) +// round-trips it without touching the download filter beside it. +test("the form writes skipShorts from its checkbox; unchecked clears it; the ops patch round-trips", () => { + assert.equal(parseChannelForm(form({ skipShorts: "on" })).config.skipShorts, true); + assert.equal("skipShorts" in parseChannelForm(form({})).config, false); + assert.ok((CHANNEL_FORM_FIELDS as readonly string[]).includes("skipShorts")); + const fd = channelConfigToFormData({ + handling: "youtube", + name: "Synth", + url: "https://www.youtube.com/@synth", + downloadFilter: { include: "guest" }, + }); + applyChannelFormPatch(fd, { skipShorts: true }); + const set = parseChannelForm(fd).config; + assert.equal(set.skipShorts, true); + assert.deepEqual(set.downloadFilter, { include: "guest" }); + const back = channelConfigToFormData(set); + assert.equal(back.get("skipShorts"), "on"); + applyChannelFormPatch(back, { skipShorts: false }); + const cleared = parseChannelForm(back).config; + assert.equal("skipShorts" in cleared, false); + assert.deepEqual(cleared.downloadFilter, { include: "guest" }); +}); + // A Wayback pages channel (release 37 S1): a non-video Wayback URL makes one — // platform "webpage", social, its target derived from the URL and its handle // the target's host; the form's target rows win over the URL; a row that is diff --git a/editor/app/channels/components/parseChannelForm.ts b/editor/app/channels/components/parseChannelForm.ts @@ -94,6 +94,8 @@ export const CHANNEL_FORM_FIELDS = [ // 2026-10-29: manual downloads (lib/manualDownloads.ts). "downloadMode", "downloadFilter", + // 2026-10-30: skip the listing's YouTube Shorts (lib/skipShorts.ts). + "skipShorts", "recordedDate", "mirror", "wayback", @@ -303,6 +305,9 @@ export function parseChannelForm(formData: FormData): ParsedChannelForm { throw new Error(`Downloads must be one of: ${DOWNLOAD_MODES.join(", ")}`); } const downloadMode = downloadModeRaw === "manual" ? downloadModeRaw : undefined; + // Skip the listing's YouTube Shorts (lib/skipShorts.ts): a checkbox; + // unchecked = omitted, which is "download them like any upload". + const skipShorts = formData.get("skipShorts") != null; // Download filter. Both patterns are regex SOURCES compiled with "i" at // download time, so the form is the place that refuses an unparseable one: @@ -489,6 +494,7 @@ export function parseChannelForm(formData: FormData): ParsedChannelForm { if (chat) config.chat = chat; if (downloadMode) config.downloadMode = downloadMode; if (downloadFilter) config.downloadFilter = downloadFilter; + if (skipShorts) config.skipShorts = true; if (recordedDateTitlePattern) { config.recordedDate = { titlePattern: recordedDateTitlePattern }; }