Archilyzer · Source

archilyzer

Archilyzer
git clone https://archilyzer.pages.dev/source/archilyzer.git
Log | Files | Refs | README | LICENSE

commit 819edaea4631e139c421cb0bda9cbbcd13403457
parent a24777f3764cbf1a12f6a3590829a0b45d0073f4
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Sun,  1 Nov 2026 22:34:22 -0500

channels: a new Rumble channel is born with Firefox cookies, cookieMode always and --impersonate firefox (lib/rumbleDefaults.ts; the create action and the New channel form's prefill; a key sent blank stands)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

Diffstat:
Acommon/lib/rumbleDefaults.test.ts | 43+++++++++++++++++++++++++++++++++++++++++++
Acommon/lib/rumbleDefaults.ts | 54++++++++++++++++++++++++++++++++++++++++++++++++++++++
Meditor/app/api/ops/create-channel/route.ts | 11+++++++++++
Meditor/app/channels/actions.ts | 12+++++++++++-
Meditor/app/channels/components/ChannelForm.tsx | 23+++++++++++++++++++----
Meditor/app/channels/components/parseChannelForm.test.ts | 22++++++++++++++++++++++
6 files changed, 160 insertions(+), 5 deletions(-)

diff --git a/common/lib/rumbleDefaults.test.ts b/common/lib/rumbleDefaults.test.ts @@ -0,0 +1,43 @@ +// A new Rumble channel's defaults (lib/rumbleDefaults.ts). +// Run with: pnpm --filter yt-dlp-transcript-common exec tsx --test lib/rumbleDefaults.test.ts + +import test from "node:test"; +import assert from "node:assert/strict"; +import type { ChannelConfig } from "./channelConfig"; +import { rumbleMissingKeys, withRumbleDefaults } from "./rumbleDefaults"; + +const base: ChannelConfig = { name: "R", url: "https://rumble.com/c/r", platform: "rumble", handling: "youtube" } as ChannelConfig; + +test("a Rumble channel gets the three keys", () => { + const c = withRumbleDefaults(base); + assert.equal(c.cookiesFromBrowser, "firefox"); + assert.equal(c.cookieMode, "always"); + assert.deepEqual(c.ytdlpExtraArgs, ["--impersonate", "firefox"]); + assert.deepEqual(rumbleMissingKeys(c), []); +}); + +test("another platform is left alone", () => { + const yt = { ...base, platform: "youtube" } as ChannelConfig; + assert.deepEqual(withRumbleDefaults(yt), yt); +}); + +test("explicit values win; --impersonate is appended to given args and never duplicated", () => { + const c = withRumbleDefaults({ ...base, cookiesFromBrowser: "chrome", cookieMode: "when-required", ytdlpExtraArgs: ["--sleep-requests", "2"] }); + assert.equal(c.cookiesFromBrowser, "chrome"); + assert.equal(c.cookieMode, "when-required"); + assert.deepEqual(c.ytdlpExtraArgs, ["--sleep-requests", "2", "--impersonate", "firefox"]); + const again = withRumbleDefaults(c); + assert.deepEqual(again.ytdlpExtraArgs, c.ytdlpExtraArgs); + const own = withRumbleDefaults({ ...base, ytdlpExtraArgs: ["--impersonate", "chrome"] }); + assert.deepEqual(own.ytdlpExtraArgs, ["--impersonate", "chrome"]); +}); + +test("a key the request sent blank is none, not a default", () => { + const c = withRumbleDefaults(base, { cookiesFromBrowser: true, cookieMode: true, ytdlpExtraArgs: true }); + assert.equal(c.cookiesFromBrowser, undefined); + assert.equal(c.cookieMode, undefined); + assert.equal(c.ytdlpExtraArgs, undefined); + // Extra args sent non-blank still gain the impersonation. + const g = withRumbleDefaults({ ...base, ytdlpExtraArgs: ["-v"] }, { ytdlpExtraArgs: true }); + assert.deepEqual(g.ytdlpExtraArgs, ["-v", "--impersonate", "firefox"]); +}); diff --git a/common/lib/rumbleDefaults.ts b/common/lib/rumbleDefaults.ts @@ -0,0 +1,54 @@ +// WHAT A RUMBLE CHANNEL IS CREATED WITH. Rumble refuses yt-dlp without the +// Firefox cookie jar and Firefox impersonation, and every working Rumble channel +// carries the same three keys. They are the DEFAULT for a new Rumble channel +// (2026-11-02), so a channel made from a bare Rumble URL works on its first +// fetch instead of ending in a 403 nobody can explain. +// +// A default, never an override: a key the request SETS (a value, or "" meaning +// none) is left alone. Only `--impersonate firefox` joins extra args that were +// given — appended, never duplicated. +import type { ChannelConfig } from "./channelConfig"; + +export const RUMBLE_COOKIES_FROM_BROWSER = "firefox"; +export const RUMBLE_COOKIE_MODE = "always"; +export const RUMBLE_IMPERSONATE_ARGS: ReadonlyArray<string> = ["--impersonate", "firefox"]; + +// The prose a missing key is reported with (serviceCookies' Rumble 403 line). +export const RUMBLE_NEEDS_TEXT = + "Rumble needs cookies from firefox, cookieMode always and --impersonate firefox"; + +// What of the three keys a Rumble channel's config lacks, as short phrases. The config is the +// source of truth: a channel with cookiesFromBrowser "chrome" is not missing it. +export function rumbleMissingKeys( + config: Pick<ChannelConfig, "cookiesFromBrowser" | "cookieMode" | "ytdlpExtraArgs">, +): string[] { + const missing: string[] = []; + if (!config.cookiesFromBrowser?.trim()) missing.push("no cookiesFromBrowser"); + if (config.cookieMode !== "always") missing.push(config.cookieMode ? `cookieMode ${config.cookieMode}` : "no cookieMode"); + if (!hasImpersonate(config.ytdlpExtraArgs)) missing.push("no --impersonate in ytdlpExtraArgs"); + return missing; +} + +export function hasImpersonate(args: ReadonlyArray<string> | undefined): boolean { + return (args ?? []).some((a) => a === "--impersonate" || a.startsWith("--impersonate=")); +} + +// `explicit` names the keys the request set on purpose (present, even blank). +// The default fills the others. +export function withRumbleDefaults( + config: ChannelConfig, + explicit: { cookiesFromBrowser?: boolean; cookieMode?: boolean; ytdlpExtraArgs?: boolean } = {}, +): ChannelConfig { + if (config.platform !== "rumble") return config; + const next: ChannelConfig = { ...config }; + if (!explicit.cookiesFromBrowser && !next.cookiesFromBrowser) { + next.cookiesFromBrowser = RUMBLE_COOKIES_FROM_BROWSER; + } + if (!explicit.cookieMode && !next.cookieMode) next.cookieMode = RUMBLE_COOKIE_MODE; + if (!explicit.ytdlpExtraArgs || (next.ytdlpExtraArgs?.length ?? 0) > 0) { + if (!hasImpersonate(next.ytdlpExtraArgs)) { + next.ytdlpExtraArgs = [...(next.ytdlpExtraArgs ?? []), ...RUMBLE_IMPERSONATE_ARGS]; + } + } + return next; +} diff --git a/editor/app/api/ops/create-channel/route.ts b/editor/app/api/ops/create-channel/route.ts @@ -30,6 +30,11 @@ export const dynamic = "force-dynamic"; // refuses: no name, a handling that is not "youtube" or "transcribe", a social // URL with no derivable handle, a bad filter regex. // +// A Rumble channel (platform given or detected from the URL) gets Rumble's +// defaults for cookiesFromBrowser ("firefox"), cookieMode ("always") and +// ytdlpExtraArgs (--impersonate firefox) unless `fields` sets them; "" or [] +// means none. +// // The three start-something options are OFF unless asked for. The form ticks // "Fetch playlist now" by default because a person creating a channel usually // wants it; a script creating one says so. Any job they start comes back in @@ -50,6 +55,12 @@ export async function POST(request: Request) { } const fd = new FormData(); applyChannelFormPatch(fd, fields as Record<string, unknown>); + // A blank cookie/extra-args value is an explicit "none": applyChannelFormPatch + // drops it, which would let a Rumble channel's defaults fill it back in. + for (const key of ["cookiesFromBrowser", "cookieMode", "ytdlpExtraArgs"]) { + const v = (fields as Record<string, unknown>)[key]; + if (v === "" || (Array.isArray(v) && v.length === 0)) fd.set(key, ""); + } if (body.slug !== undefined) { if (typeof body.slug !== "string") { throw new OpsInputError('"slug" must be a string'); diff --git a/editor/app/channels/actions.ts b/editor/app/channels/actions.ts @@ -1,5 +1,6 @@ "use server"; +import { withRumbleDefaults } from "yt-dlp-transcript-common/lib/rumbleDefaults"; import { revalidatePath } from "next/cache"; import { redirect } from "next/navigation"; import slugify from "@sindresorhus/slugify"; @@ -238,7 +239,16 @@ export async function createChannelFromForm( } catch (e) { return fail((e as Error).message); } - const { name, config } = parsed; + const { name } = parsed; + // A Rumble channel is born with the cookie and impersonation keys it needs + // (lib/rumbleDefaults.ts). A key the form or request SENT, even blank, is + // the operator's word and stands; the web form posts all three, prefilled + // for a Rumble URL, so only a request that omits one is defaulted here. + const config = withRumbleDefaults(parsed.config, { + cookiesFromBrowser: formData.has("cookiesFromBrowser"), + cookieMode: formData.has("cookieMode"), + ytdlpExtraArgs: formData.has("ytdlpExtraArgs"), + }); const slug = parsed.slug || slugify(name); if (!slug) { return fail("Could not derive a slug from the name"); diff --git a/editor/app/channels/components/ChannelForm.tsx b/editor/app/channels/components/ChannelForm.tsx @@ -1,6 +1,11 @@ "use client"; -import { useEffect, useState } from "react"; +import { Fragment, useEffect, useState } from "react"; +import { + RUMBLE_COOKIES_FROM_BROWSER, + RUMBLE_COOKIE_MODE, + RUMBLE_IMPERSONATE_ARGS, +} from "yt-dlp-transcript-common/lib/rumbleDefaults"; import slugify from "@sindresorhus/slugify"; import type { ChannelConfig } from "yt-dlp-transcript-common/lib/channelConfig"; import { AUDIO_CHECK_PLATFORMS } from "yt-dlp-transcript-common/lib/audioCheckPolicy"; @@ -224,6 +229,12 @@ export function ChannelForm({ // A Wayback pages channel (release 37): captures of pages, no fetcher; its // scope is its targets. const isWaybackPages = isEdit ? c?.platform === "webpage" : platform === "webpage"; + // A new Rumble channel shows Rumble's cookie and impersonation defaults + // (lib/rumbleDefaults.ts) pre-filled; the fields below are remounted when + // this flips so the box shows what it would save. Edit mode shows the stored + // config as it is. + const isRumbleNew = !isEdit && (platform === "rumble" || (platform === "" && detectPlatform(url) === "rumble")); + const rumbleKey = isRumbleNew ? "rumble-defaults" : "plain"; const waybackHandle = (() => { const t = waybackTargetFromUrl(url); return t ? waybackTargetHost(t) : ""; @@ -944,6 +955,7 @@ export function ChannelForm({ </> )} <CollapsibleSection title="Advanced"> + <Fragment key={rumbleKey}> <label className="flex flex-col gap-1 text-sm"> <span className="font-medium"> Extra yt-dlp args @@ -954,12 +966,13 @@ export function ChannelForm({ defaultValue={seedValue( state, "ytdlpExtraArgs", - (c?.ytdlpExtraArgs ?? []).join("\n"), + (c?.ytdlpExtraArgs ?? (isRumbleNew ? RUMBLE_IMPERSONATE_ARGS : [])).join("\n"), )} rows={4} className="rounded border border-border bg-card px-2 py-1 text-sm font-mono" /> </label> + </Fragment> <label className="flex flex-col gap-1 text-sm"> <span className="font-medium">Downloads</span> <SeededSelect @@ -1077,11 +1090,12 @@ export function ChannelForm({ placeholder="(not a mirror)" hint="For a channel that copies another creator's streams: the creator's channels here, by slug, separated by commas. The channel page then has a Mirror stage, where a scan pairs each video with the creator's and says which are the only copy left." /> + <Fragment key={rumbleKey}> <Field label="Cookies from browser" name="cookiesFromBrowser" state={state} - defaultValue={c?.cookiesFromBrowser ?? ""} + defaultValue={c?.cookiesFromBrowser ?? (isRumbleNew ? RUMBLE_COOKIES_FROM_BROWSER : "")} placeholder="(inherit global)" hint="Per-channel override of the global yt-dlp --cookies-from-browser browser spec (e.g. firefox, chrome:Default). Blank inherits the global value from /settings." /> @@ -1090,7 +1104,7 @@ export function ChannelForm({ <SeededSelect state={state} name="cookieMode" - initial={c?.cookieMode ?? ""} + initial={c?.cookieMode ?? (isRumbleNew ? RUMBLE_COOKIE_MODE : "")} aria-label="cookie mode" className="rounded border border-border bg-card px-2 py-1 text-sm" > @@ -1112,6 +1126,7 @@ export function ChannelForm({ &ldquo;Needs cookies&rdquo; bucket on the Download stage. </span> </label> + </Fragment> <label className="flex flex-col gap-1 text-sm"> <span className="font-medium"> Sleep between managed downloads diff --git a/editor/app/channels/components/parseChannelForm.test.ts b/editor/app/channels/components/parseChannelForm.test.ts @@ -387,3 +387,25 @@ test("downloadMode: manual is stored, automatic clears it, refused when unknown; applyChannelFormPatch(back, { downloadMode: "" }); assert.equal("downloadMode" in parseChannelForm(back).config, false); }); + +// A Rumble URL with the platform on Auto is a rumble channel; the create action +// then defaults the cookie and impersonation keys (lib/rumbleDefaults.ts), and a +// key the form SENT, even blank, stands. +test("a Rumble URL parses to platform rumble, and the create defaults fill what the form omitted", async () => { + const { withRumbleDefaults } = await import("yt-dlp-transcript-common/lib/rumbleDefaults"); + const fd = form({ name: "Rekieta Law", handling: "youtube", url: "https://rumble.com/c/RekietaLaw" }); + const parsed = parseChannelForm(fd); + assert.equal(parsed.config.platform, "rumble"); + const made = withRumbleDefaults(parsed.config, { + cookiesFromBrowser: fd.has("cookiesFromBrowser"), + cookieMode: fd.has("cookieMode"), + ytdlpExtraArgs: fd.has("ytdlpExtraArgs"), + }); + assert.equal(made.cookiesFromBrowser, "firefox"); + assert.equal(made.cookieMode, "always"); + assert.deepEqual(made.ytdlpExtraArgs, ["--impersonate", "firefox"]); + const blank = form({ name: "Rekieta Law", handling: "youtube", url: "https://rumble.com/c/RekietaLaw", cookiesFromBrowser: "", cookieMode: "", ytdlpExtraArgs: "" }); + const none = withRumbleDefaults(parseChannelForm(blank).config, { cookiesFromBrowser: true, cookieMode: true, ytdlpExtraArgs: true }); + assert.equal(none.cookiesFromBrowser, undefined); + assert.equal(none.ytdlpExtraArgs, undefined); +});