Archilyzer · Source

archilyzer

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

commit 158b0603e7e563bbcc745397b21e70b735289fe1
parent 39fa1d9fb9c629411f4eea0bc03e88921b57b61d
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Mon, 28 Sep 2026 02:20:06 -0400

common: sourceFetchFailure judges a media-pass last attempt by its exit code first

O3 review low 1. A no-subs fallback that fetched and persisted the source
and whose inline whisper then failed ends the download failed; reading the
status first called that source "not downloaded" (archiveSourceVideo threw,
the poll named no file). When the last attempt is the media pass, its exit
code alone answers. forceMedia.test.ts: the table gains that row.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Diffstat:
Mcommon/ytdlp/downloadOneManaged.ts | 14+++++++++++---
Mcommon/ytdlp/forceMedia.test.ts | 10++++++++++
2 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/common/ytdlp/downloadOneManaged.ts b/common/ytdlp/downloadOneManaged.ts @@ -525,15 +525,23 @@ function attemptSucceeded(exitCode: number | null): boolean { // which leaves the status as the subtitle pass made it, so only the last // attempt (the n: 3 media pass) says so. Reading the status alone ended those // jobs `done` with no file. +// +// WHEN THE LAST ATTEMPT IS THE MEDIA PASS, IT ALONE ANSWERS (review low 1). That +// pass IS the source fetch; a later step's status is not about the source. A +// fallback whose container came down and was persisted, and whose inline +// whisper then failed, ends the download `failed` — and reading the status +// first called that source "not downloaded". export function sourceFetchFailure(record: DownloadOutcomeRecord): string | null { const last = record.attempts.at(-1); const reason = (fallback: string) => last?.error?.trim() || fallback; + if (last?.kind === "no-subs-fallback") { + return attemptSucceeded(last.ytdlpExitCode) + ? null + : reason(`yt-dlp exited ${last.ytdlpExitCode ?? "without a code"}`); + } if (record.status === "failed" || record.status === "failed-corrupt-source") { return reason(`the download ended ${record.status}`); } - if (last?.kind === "no-subs-fallback" && !attemptSucceeded(last.ytdlpExitCode)) { - return reason(`yt-dlp exited ${last.ytdlpExitCode ?? "without a code"}`); - } return null; } diff --git a/common/ytdlp/forceMedia.test.ts b/common/ytdlp/forceMedia.test.ts @@ -400,4 +400,14 @@ test("sourceFetchFailure: a failed download, a failed forced pass, and the clean sourceFetchFailure({ ...base, status: "ok-with-cookies", attempts: [attempt("auth-retry", 0)] }), null, ); + // The fallback fetched and persisted the source, then inline whisper failed + // and ended the download `failed`: the SOURCE is there (review low 1). + assert.equal( + sourceFetchFailure({ + ...base, + status: "failed", + attempts: [attempt("primary", 0), attempt("no-subs-fallback", 0)], + }), + null, + ); });