Archilyzer · Source

archilyzer

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

commit 7dbef189b7838126822a20b2017ab65013004cb2
parent acd7f2b18d2853b79c0d83a43ced9f1572a25f44
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Wed, 11 Nov 2026 04:53:39 -0500

cleanup: no availability check is asked while the channel's platform has an open cookie/service alert (the store `get services` reads) -- the video is held "awaiting an availability check (service alert open: <evidence>)" and nothing is requested

An open alert is the platform answering with a challenge or a login wall; a
listing then would only add to it. requestAvailabilityCheck asks
raisedServiceAlert(paths, platform) after the platform hold and before
marking or starting anything. Tests: an injected alert holds and requests
nothing (not even marked); the real .service-cookies.json store with a raised
youtube alert answers service-alert.

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

Diffstat:
Mcommon/controller/availabilityVerdict.ts | 16++++++++++++++++
Mcommon/controller/cleanAfterCapture.test.ts | 47++++++++++++++++++++++++++++++++++++++++++++++-
Mcommon/controller/cleanAudioFromTranscribed.ts | 4++++
3 files changed, 66 insertions(+), 1 deletion(-)

diff --git a/common/controller/availabilityVerdict.ts b/common/controller/availabilityVerdict.ts @@ -21,6 +21,7 @@ import type { Paths } from "../lib/paths"; import { readJsonFile, withJsonFileLock, writeJsonAtomic } from "../lib/jsonFile-server"; import { runManagedFunction, type StreamActionResult } from "../jobs/streamCommand"; import { heldPlatformRefusal } from "../jobs/downloadBackoff"; +import { raisedServiceAlert } from "../lib/serviceCookies-server"; import { detectPlatform, platformQueueKey, queueKeyForUrl } from "../lib/platform"; import { resolveQueueKey } from "../lib/queueKeys"; import { readChannelConfig } from "./channels"; @@ -158,6 +159,9 @@ export async function startQuickAvailabilityCheckJob(opts: { export type CheckRequestDeps = { start?: (paths: Paths, slug: string) => Promise<StreamActionResult>; platformRefusal?: (platform: string) => Promise<string | null>; + // The platform's open cookie/service alert (the store `get services` + // reads), as its evidence line, or null. + serviceAlert?: (platform: string) => Promise<string | null>; now?: () => number; }; @@ -165,6 +169,7 @@ export type CheckRequest = | { status: "requested"; jobId?: string } | { status: "already-requested"; at: string } | { status: "platform-held"; why: string } + | { status: "service-alert"; why: string } | { status: "refused"; why: string } | { status: "no-url" }; @@ -182,6 +187,17 @@ export async function requestAvailabilityCheck( const platform = config.platform ?? detectPlatform(config.url) ?? "unknown"; const held = await (deps.platformRefusal ?? ((p: string) => heldPlatformRefusal(p, "An availability check", paths)))(platform); if (held) return { status: "platform-held", why: held }; + // An open cookie alert is the platform answering with a challenge or a + // login wall: a listing now would only add to it. Asked nothing until the + // operator's Recheck or Dismiss clears it. + const alert = await ( + deps.serviceAlert ?? + (async (p: string) => { + const e = await raisedServiceAlert(paths, p); + return e ? (e.evidence?.line ?? "alert raised") : null; + }) + )(platform); + if (alert) return { status: "service-alert", why: alert }; const record = await readAvailabilityVerdict(paths, slug); if (!mayRequestCheck(record, maxAgeHours, now)) { return { status: "already-requested", at: record!.requestedAt! }; diff --git a/common/controller/cleanAfterCapture.test.ts b/common/controller/cleanAfterCapture.test.ts @@ -8,7 +8,7 @@ import type { Operation } from "../lib/operations"; import { cleanAudioForVideo, cleanAudioFromTranscribed } from "./cleanAudioFromTranscribed"; import { runOperationUnit, type OperationRun } from "./operationBatch"; import { readSpeakersLedger } from "../lib/speakersLedger-server"; -import { readAvailabilityVerdict, writeAvailabilityVerdict, type CheckRequestDeps } from "./availabilityVerdict"; +import { readAvailabilityVerdict, requestAvailabilityCheck, writeAvailabilityVerdict, type CheckRequestDeps } from "./availabilityVerdict"; // Any test that reaches the request path without saying otherwise fails loudly. const NO_NETWORK: CheckRequestDeps = { @@ -16,6 +16,7 @@ const NO_NETWORK: CheckRequestDeps = { throw new Error("a test asked for a real availability check"); }, platformRefusal: async () => null, + serviceAlert: async () => null, }; import { defaultSiteSettings, getSettings } from "../lib/settings"; @@ -383,6 +384,50 @@ test("the automatic clean requires the verdict even with verifyAvailabilityBefor assert.equal(r.cleanedDirs, 1); }); +test("an open service alert for the platform: held \"awaiting an availability check (service alert open)\", nothing requested", async () => { + await settings({}); + const { paths, video } = await corpus(); + const v = await video("v1", { diarization: "voiceprints", listed: false }); + let started = 0; + const logs: string[] = []; + const out = await cleanAudioForVideo({ + channelSlug: "ch", + paths, + videoId: "v1", + onLog: (m) => logs.push(m), + checkDeps: { + start: async () => { + started++; + return { ok: true, jobId: "x" } as never; + }, + platformRefusal: async () => null, + serviceAlert: async (platform) => (platform === "youtube" ? "Sign in to confirm you're not a bot" : null), + }, + }); + assert.equal(out.gate, "awaiting-availability"); + assert.equal(started, 0); + assert.equal((await readAvailabilityVerdict(paths, "ch"))?.requestedAt, undefined); + assert.equal(await exists(path.join(v, "audio.mp3")), true); + assert.ok(logs.some((l) => l.includes("awaiting an availability check (service alert open: Sign in to confirm")), logs.join("\n")); +}); + +test("the real alert store: a raised yt-dlp service alert for the channel's platform is read", async () => { + await settings({}); + const { paths, video } = await corpus(); + await video("v1", { diarization: "voiceprints", listed: false }); + await writeFile( + path.join(paths.transcriptsDir, ".service-cookies.json"), + JSON.stringify({ version: 1, services: { youtube: { since: new Date().toISOString(), raisedAt: new Date().toISOString(), kind: "challenge", evidence: { line: "bot check", at: new Date().toISOString() }, signals: 3 } } }), + ); + const asked = await requestAvailabilityCheck(paths, "ch", 24, { + start: async () => { + throw new Error("must not start"); + }, + platformRefusal: async () => null, + }); + assert.equal(asked.status, "service-alert"); +}); + test.after(() => rm(ROOT, { recursive: true, force: true })); test("concurrency stays 1: one diarization at a time, one backfill unit at a time", () => { diff --git a/common/controller/cleanAudioFromTranscribed.ts b/common/controller/cleanAudioFromTranscribed.ts @@ -408,6 +408,10 @@ export async function cleanAudioForVideo({ } if (verdict !== "listed") { const asked = await requestAvailabilityCheck(paths, channelSlug, maxAge, checkDeps); + if (asked.status === "service-alert") { + log(`Kept ${videoId}'s audio: awaiting an availability check (service alert open: ${asked.why}).`); + return held("awaiting-availability"); + } const why = asked.status === "requested" ? "a quick availability check of the channel is queued"