Archilyzer · Source

archilyzer

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

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

common: a Rumble 403 on a channel missing cookiesFromBrowser, cookieMode or --impersonate says which in the job's log (rumbleMissingConfigLine), not a bare exit code

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

Diffstat:
Mcommon/lib/serviceCookies-server.test.ts | 36+++++++++++++++++++++++++++++++++++-
Mcommon/lib/serviceCookies-server.ts | 27++++++++++++++++++++++++++-
Mcommon/lib/serviceCookies.test.ts | 19+++++++++++++++++++
Mcommon/lib/serviceCookies.ts | 22++++++++++++++++++++++
4 files changed, 102 insertions(+), 2 deletions(-)

diff --git a/common/lib/serviceCookies-server.test.ts b/common/lib/serviceCookies-server.test.ts @@ -7,7 +7,7 @@ import test from "node:test"; import assert from "node:assert/strict"; -import { mkdtemp, readFile, rm, writeFile } from "node:fs/promises"; +import { mkdir, mkdtemp, readFile, rm, writeFile } from "node:fs/promises"; import os from "node:os"; import path from "node:path"; import { readFileSync } from "node:fs"; @@ -193,3 +193,37 @@ test("dismiss and re-run marks", async () => { await rm(paths.transcriptsDir, { recursive: true, force: true }); } }); + +test("a Rumble listing 403 on a channel with no cookie config names the missing keys in the job's log; a configured one says nothing extra", async () => { + const paths = await tmpPaths(); + try { + const dir = path.join(paths.channelsDir, "bare-rumble"); + await mkdir(dir, { recursive: true }); + await writeFile(path.join(dir, "config.json"), JSON.stringify({ name: "Bare", url: "https://rumble.com/c/bare", platform: "rumble", handling: "youtube" })); + const okDir = path.join(paths.channelsDir, "ok-rumble"); + await mkdir(okDir, { recursive: true }); + await writeFile( + path.join(okDir, "config.json"), + JSON.stringify({ + name: "Ok", + url: "https://rumble.com/c/ok", + platform: "rumble", + handling: "youtube", + cookiesFromBrowser: "firefox", + cookieMode: "always", + ytdlpExtraArgs: ["--impersonate", "firefox"], + }), + ); + const stderr = "ERROR: [RumbleChannel] bare: Unable to download webpage: HTTP Error 403: Forbidden"; + const ctx = jobCtx("JOB2", "sync"); + await runInJobContext(ctx, async () => { + await observeYtdlpServiceOutcome(paths, { url: "https://rumble.com/c/bare", channel: "bare-rumble", exitCode: 1, stderrTail: stderr }); + await observeYtdlpServiceOutcome(paths, { url: "https://rumble.com/c/ok", channel: "ok-rumble", exitCode: 1, stderrTail: stderr }); + }); + assert.equal(ctx.lines.length, 1, ctx.lines.join("")); + assert.match(ctx.lines[0], /bare-rumble has no cookiesFromBrowser, no cookieMode, no --impersonate in ytdlpExtraArgs/); + assert.match(ctx.lines[0], /Rumble needs cookies from firefox, cookieMode always and --impersonate firefox/); + } finally { + await rm(paths.transcriptsDir, { recursive: true, force: true }); + } +}); diff --git a/common/lib/serviceCookies-server.ts b/common/lib/serviceCookies-server.ts @@ -12,6 +12,7 @@ import path from "node:path"; import type { Paths } from "./paths"; +import type { ChannelConfig } from "./channelConfig"; import { readJsonFile, withJsonFileLock, writeJsonAtomic } from "./jsonFile-server"; import { currentJobContext } from "./jobContext"; import { getSettings } from "./settings"; @@ -28,6 +29,7 @@ import { isYtdlpCookieService, noteLastGood, pruneServiceCookieState, + rumbleMissingConfigLine, serviceCookieSignalFromStderr, serviceLabel, serviceStoppedLine, @@ -177,6 +179,26 @@ async function cleanWouldChange( // THE yt-dlp HOOK (ytdlp/runOneYtdlp.ts): one invocation's outcome for the // service its URL is on. A non-zero exit whose stderr carries a cookie signal // records it; a zero exit is a clean request. Never throws. +// A Rumble 403 on a channel whose config lacks what Rumble needs: the job's +// log names the missing keys (rumbleMissingConfigLine) instead of a bare exit +// code. Reads the channel's config.json beside the transcripts; never throws. +async function logRumbleConfigProblem( + paths: Pick<Paths, "transcriptsDir">, + stderr: string, + platform: string | null | undefined, + channel: string | undefined, +): Promise<void> { + if (platform !== "rumble" || !channel) return; + try { + const read = await readJsonFile(path.join(paths.transcriptsDir, "channels", channel, "config.json")); + if (!read.ok || typeof read.value !== "object" || read.value === null) return; + const line = rumbleMissingConfigLine(stderr, channel, read.value as ChannelConfig); + if (line) currentJobContext()?.onLog(line); + } catch { + // bookkeeping only + } +} + export async function observeYtdlpServiceOutcome( paths: Pick<Paths, "transcriptsDir">, run: { url: string; channel?: string; exitCode: number | null; stderrTail: string; aborted?: boolean }, @@ -192,6 +214,7 @@ export async function observeYtdlpServiceOutcome( if (line) currentJobContext()?.onLog(line); return; } + await logRumbleConfigProblem(paths, run.stderrTail, platform, run.channel); const signal = serviceCookieSignalFromStderr(run.stderrTail, platform); if (!signal) return; await noteServiceCookieSignal(paths, signal, { @@ -210,7 +233,9 @@ export async function observeStderrServiceSignal( stderr: string, ctx: { url?: string; channel?: string; platform?: string | null } = {}, ): Promise<void> { - const signal = serviceCookieSignalFromStderr(stderr, ctx.platform ?? (ctx.url ? detectPlatform(ctx.url) : null)); + const platform = ctx.platform ?? (ctx.url ? detectPlatform(ctx.url) : null); + await logRumbleConfigProblem(paths, stderr, platform, ctx.channel); + const signal = serviceCookieSignalFromStderr(stderr, platform); if (!signal) return; await noteServiceCookieSignal(paths, signal, { ...(ctx.url ? { url: ctx.url } : {}), diff --git a/common/lib/serviceCookies.test.ts b/common/lib/serviceCookies.test.ts @@ -23,6 +23,7 @@ import { isServiceKey, noteLastGood, pruneServiceCookieState, + rumbleMissingConfigLine, serviceCookieSignalFromStderr, serviceFamily, serviceFixText, @@ -264,3 +265,21 @@ test("X is a cookie-alert service: key, label, family, fix; one challenge raises assert.equal(view.alerts[0]?.canRecheck, true); assert.match(view.alerts[0]?.headline ?? "", /^X needs fresh cookies: /); }); + +test("rumbleMissingConfigLine: names what the channel's config lacks on any Rumble 403, and nothing otherwise", () => { + const err = "ERROR: [RumbleChannel] x: Unable to download webpage: HTTP Error 403: Forbidden"; + assert.match( + rumbleMissingConfigLine(err, "rekietalaw-rumble", {}) ?? "", + /^Rumble refused \(HTTP 403\): rekietalaw-rumble has no cookiesFromBrowser, no cookieMode, no --impersonate in ytdlpExtraArgs; Rumble needs cookies from firefox/, + ); + // Only the missing part; a wrong mode is named with its value. + const partial = rumbleMissingConfigLine(err, "c", { cookiesFromBrowser: "firefox", cookieMode: "defer", ytdlpExtraArgs: ["--impersonate=firefox"] }); + assert.match(partial ?? "", /c has cookieMode defer;/); + assert.equal(partial?.includes("cookiesFromBrowser"), false); + // Complete config, a non-Rumble line, a non-403, an unreadable config: no line. + const full = { cookiesFromBrowser: "firefox", cookieMode: "always" as const, ytdlpExtraArgs: ["--impersonate", "firefox"] }; + assert.equal(rumbleMissingConfigLine(err, "c", full), null); + assert.equal(rumbleMissingConfigLine("ERROR: [youtube] abc: HTTP Error 403", "c", {}), null); + assert.equal(rumbleMissingConfigLine("ERROR: [RumbleChannel] x: HTTP Error 429", "c", {}), null); + assert.equal(rumbleMissingConfigLine(err, "c", null), null); +}); diff --git a/common/lib/serviceCookies.ts b/common/lib/serviceCookies.ts @@ -21,6 +21,8 @@ // moment Rumble answers cleanly. import { isBotCheck } from "./availability"; +import type { ChannelConfig } from "./channelConfig"; +import { RUMBLE_NEEDS_TEXT, rumbleMissingKeys } from "./rumbleDefaults"; // "auth-failure": X's login refused or gone (gallery-dl's AuthRequired, a 401, // "Could not authenticate you" — social/xGalleryDlSignals.ts). "jar-age": X's @@ -193,6 +195,26 @@ export function serviceCookieSignalFromStderr( return null; } +// ── a Rumble channel missing the config Rumble needs ───────────────────── + +// Any Rumble extractor's 403 ([RumbleChannel] a listing, [RumbleEmbed] an embed, +// [Rumble] a page). A 403 alone is ambiguous (a removed video answers it too), +// so this never raises an alert: it only NAMES the channel's own missing config +// when there is some, in place of a bare exit code. The channel's config is the +// source of truth (rumbleMissingKeys). +const RUMBLE_ANY_403 = /\[Rumble(?:Channel|Embed)?\][^\n]*HTTP Error 403/; + +export function rumbleMissingConfigLine( + stderr: string, + slug: string, + config: Pick<ChannelConfig, "cookiesFromBrowser" | "cookieMode" | "ytdlpExtraArgs"> | null | undefined, +): string | null { + if (!stderr || !config || !RUMBLE_ANY_403.test(stderr)) return null; + const missing = rumbleMissingKeys(config); + if (missing.length === 0) return null; + return `Rumble refused (HTTP 403): ${slug} has ${missing.join(", ")}; ${RUMBLE_NEEDS_TEXT} (Configure → Cookies from browser, Cookie mode, Extra yt-dlp args).`; +} + // ── the state ───────────────────────────────────────────────────────────── export type ServiceCookieJobRef = { id: string; kind?: string };