// 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/` // 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 | 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/` 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 | 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 | null | undefined, urls: Iterable, idOf: (url: string) => string | null, ): Set { const out = new Set(); 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; }