commit 8d0b1e068df8d0902f2ce58ef9b90678bd484fa9
parent b1c52521f92ebd1230a0af86866c13daca7f8a06
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Wed, 18 Nov 2026 15:41:33 -0500
review 1 S11: yt-dlp is never started on an instagram.com URL
The pass every yt-dlp argv takes before a spawn refuses one, import-video says
so before a job exists, and the live recorder asks too.
Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat:
5 files changed, 77 insertions(+), 0 deletions(-)
diff --git a/common/controller/recordLive.ts b/common/controller/recordLive.ts
@@ -102,6 +102,7 @@ import {
import { refreshVideoMetadata, type RefreshRunner } from "./refreshVideoMetadata";
import { findVideoSourceUrl } from "./undownloadedVideos";
import { jitterYtdlpSleeps } from "../lib/jitter";
+import { refuseInstagramYtdlp } from "../lib/instagram/ytdlp";
import { parsePreclipKnob, type PreclipOptions } from "../lib/livePreclip";
import { jitterMs } from "../lib/jitter";
import "../lib/childKillGuard";
@@ -894,6 +895,8 @@ export async function recordLiveRun(
`ffmpeg_i:${mode !== "now" ? "-live_start_index 0 " : ""}-m3u8_hold_counters 180 -seg_max_retry 10`,
],
});
+ // The recorder's argv does not pass jitterYtdlpSleeps: asked here.
+ refuseInstagramYtdlp(args);
const o = await runRecorder({ bin: paths.ytdlpBin, args, cwd: channelDir, onLog, signal, label: tag });
finish(part, `${extraNote}yt-dlp exit ${o.exitCode ?? "null"}${o.signalled ? " (stopped)" : ""}`);
await save();
diff --git a/common/lib/instagram/ytdlp.test.ts b/common/lib/instagram/ytdlp.test.ts
@@ -0,0 +1,40 @@
+// yt-dlp is never started on an instagram.com URL (review 1, S11): the pass
+// every yt-dlp argv takes before a spawn throws, so no process starts.
+import { test } from "node:test";
+import assert from "node:assert/strict";
+import { readFile, readdir } from "node:fs/promises";
+import path from "node:path";
+import { fileURLToPath } from "node:url";
+import { jitterYtdlpSleeps } from "../jitter";
+import { INSTAGRAM_YTDLP_REFUSAL, instagramUrlInArgs, refuseInstagramYtdlp } from "./ytdlp";
+
+test("an argv naming an instagram.com URL is refused, wherever the URL sits; any other is passed on", () => {
+ const reel = "https://www.instagram.com/reel/CabcDEF1234/";
+ assert.equal(instagramUrlInArgs(["--skip-download", "--", reel]), reel);
+ assert.equal(instagramUrlInArgs(["-J", "https://instagram.com/example.account/"]), "https://instagram.com/example.account/");
+ assert.equal(instagramUrlInArgs(["--referer", "x", "https://www.youtube.com/watch?v=aaaaaaaaaaa"]), null);
+ // A word that merely mentions it is not a URL on it.
+ assert.equal(instagramUrlInArgs(["--match-filter", "title~=instagram.com", "https://example.com/instagram.com"]), null);
+ assert.throws(() => refuseInstagramYtdlp(["--", reel]), new Error(INSTAGRAM_YTDLP_REFUSAL));
+ assert.throws(() => jitterYtdlpSleeps(["--sleep-requests", "2", "--", reel]), new Error(INSTAGRAM_YTDLP_REFUSAL));
+ assert.deepEqual(jitterYtdlpSleeps(["-J", "--", "https://www.youtube.com/watch?v=aaaaaaaaaaa"]), ["-J", "--", "https://www.youtube.com/watch?v=aaaaaaaaaaa"]);
+ assert.match(INSTAGRAM_YTDLP_REFUSAL, /Instagram is read as a posts channel; a single reel import comes with a later slice/);
+});
+
+test("every module of common/ that spawns yt-dlp passes its argv through that refusal", async () => {
+ const root = path.join(path.dirname(fileURLToPath(import.meta.url)), "..", "..");
+ const offenders: string[] = [];
+ for (const dir of ["controller", "ytdlp", "jobs", "lib", "social", "publish", "bin"]) {
+ for (const name of await readdir(path.join(root, dir))) {
+ if (!name.endsWith(".ts") || name.endsWith(".test.ts") || name.endsWith(".fixture.ts")) continue;
+ // The doctor asks yt-dlp for its --version: no URL is ever in that argv.
+ if (dir === "bin" && name === "doctor.ts") continue;
+ const src = await readFile(path.join(root, dir, name), "utf8");
+ // A module that spawns the yt-dlp binary itself…
+ if (!/(execa|spawn|runRecorder)\(\s*(?:[\w.]*\.)?ytdlpBin\b|bin:\s*paths\.ytdlpBin/.test(src)) continue;
+ // …passes the argv through one of the two.
+ if (!/jitterYtdlpSleeps\(|refuseInstagramYtdlp\(/.test(src)) offenders.push(`${dir}/${name}`);
+ }
+ }
+ assert.deepEqual(offenders, []);
+});
diff --git a/common/lib/instagram/ytdlp.ts b/common/lib/instagram/ytdlp.ts
@@ -0,0 +1,24 @@
+// yt-dlp IS NEVER STARTED ON AN instagram.com URL (lane instagram, review 1
+// S11). Instagram is read as a posts channel, by its own fetcher, on its own
+// queue, behind its own guard; a yt-dlp run on a reel or an account would be
+// a second, unguarded path to the same site. A single reel's import comes
+// with a later slice. Pure and client-safe.
+
+import { isInstagramUrl } from "./ids";
+
+export const INSTAGRAM_YTDLP_REFUSAL =
+ "Instagram is read as a posts channel; a single reel import comes with a later slice. " +
+ "No yt-dlp process was started for this instagram.com URL.";
+
+// The first argument that is an instagram.com URL, or null.
+export function instagramUrlInArgs(args: readonly string[]): string | null {
+ for (const a of args) {
+ if (/^https?:\/\//i.test(a) && isInstagramUrl(a)) return a;
+ }
+ return null;
+}
+
+// Throws the refusal when the argv names an instagram.com URL.
+export function refuseInstagramYtdlp(args: readonly string[]): void {
+ if (instagramUrlInArgs(args)) throw new Error(INSTAGRAM_YTDLP_REFUSAL);
+}
diff --git a/common/lib/jitter.ts b/common/lib/jitter.ts
@@ -1,6 +1,7 @@
// The operator's jitter (settings.json `pacing.jitter`) over ./jitter.mjs — see
// there for why every request-pacing wait is stretched, and only stretched.
+import { refuseInstagramYtdlp } from "./instagram/ytdlp";
import { getSettings } from "./settings";
import {
clampSpread,
@@ -45,9 +46,15 @@ export function jitterMsStable(ms: number, seed: string): number {
// yt-dlp args with their fixed waits (`--sleep-requests`, `--sleep-subtitles`)
// stretched — once per spawn, since yt-dlp itself waits exactly what it is told.
+//
+// EVERY yt-dlp ARGV PASSES HERE ON ITS WAY TO A SPAWN, which is why the one
+// refusal that holds for all of them is asked here too: an instagram.com URL
+// is never handed to yt-dlp (lib/instagram/ytdlp.ts) — it throws, and no
+// process starts.
export function jitterYtdlpSleeps(
args: readonly string[],
rand: () => number = Math.random,
): string[] {
+ refuseInstagramYtdlp(args);
return jitterSleepArgs(args, pacingJitter(), rand);
}
diff --git a/editor/app/channels/[slug]/pipelineActions.ts b/editor/app/channels/[slug]/pipelineActions.ts
@@ -1,5 +1,6 @@
"use server";
+import { INSTAGRAM_YTDLP_REFUSAL } from "yt-dlp-transcript-common/lib/instagram/ytdlp";
import { localMediaMetadataRefusal } from "yt-dlp-transcript-common/lib/localMedia";
import { manualDownloadsRefusal } from "yt-dlp-transcript-common/lib/manualDownloads";
import { isSocialChannel, remoteOnlyRefusal } from "yt-dlp-transcript-common/lib/channelConfig";
@@ -606,6 +607,8 @@ export async function importVideoAction(
// (controller/archiveOrgDownload.ts) — and a file already on disk is not
// fetched again.
const urlPlatform = detectPlatform(videoUrl);
+ // An instagram.com URL is never handed to yt-dlp (lane instagram).
+ if (urlPlatform === "instagram") return { ok: false, error: INSTAGRAM_YTDLP_REFUSAL };
const archiveOrg = urlPlatform === "archiveorg";
// A BitChute URL likewise (controller/bitchuteImport.ts): canonicalized, run
// on BitChute's own queue with BitChute's args whatever the channel's