Archilyzer · Source

archilyzer

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

commit af80ae1efde681097533f9e5ad1dc641dfbb04d3
parent c628d37babb3c44be7a0b42f5a66a35b32082114
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Sun, 17 May 2026 12:15:42 -0400

Fix filename issue

Diffstat:
Mcommon/ytdlp/audioCheckedDownload.ts | 11+++++++++++
Meditor/e2e/audio-check-scenarios.spec.ts | 33+++++++++++++++++++++++++++++++++
Meditor/e2e/fixtures/bin/fake-ytdlp.mjs | 8++++++--
3 files changed, 50 insertions(+), 2 deletions(-)

diff --git a/common/ytdlp/audioCheckedDownload.ts b/common/ytdlp/audioCheckedDownload.ts @@ -455,6 +455,17 @@ export async function runAudioCheckedYtdlp( const audioFmt: AudioFormat = opts.channelConfig.audioFormat ?? "mp3"; const finalBasename = path.basename(finalFile); const videoDir = path.dirname(finalFile); + const targetBasename = `audio.${audioFmt}`; + if (finalBasename === targetBasename) { + // yt-dlp's bestaudio selector picked a stream already in the target + // format (e.g. Odysee serving a native mp3 audio track). The file is + // the final output; no transcode and no source-cleanup needed. + opts.onLog( + `File already in target format (${targetBasename}); skipping transcode.\n`, + ); + await rm(goodPath(partPathFor(finalFile)), { force: true }); + return buildOutcome("ok"); + } try { await transcodeAudio({ paths: opts.paths, diff --git a/editor/e2e/audio-check-scenarios.spec.ts b/editor/e2e/audio-check-scenarios.spec.ts @@ -17,6 +17,7 @@ type FakeSidecar = { totalChunks?: number; chunkDelayMs?: number; corruptAfterChunk?: number; + partExtension?: string; }; async function writeFakeConfig(sidecar: FakeSidecar) { @@ -96,6 +97,38 @@ test.describe("audio-checked download scenarios", () => { ).toBe(false); }); + test("download already in target format skips transcode", async ({ page }) => { + // Regression: bestaudio sometimes serves a stream already in the target + // format (Odysee mp3). The orchestrator must skip the transcode step + // instead of calling ffmpeg with src === out (which previously threw + // "Source and target are the same file" and rolled the download back). + await resetData("audio-check-channel"); + await writeFakeConfig({ + mode: "happy", + partExtension: "mp3", + totalChunks: 6, + chunkDelayMs: 150, + }); + await triggerDownload(page); + + const log = page.getByLabel("Download videos output"); + await expect(log).toContainText("skipping transcode", { timeout: 30_000 }); + + const outcome = await waitForOutcome( + (o) => o.status === "ok-audio-checked", + "same-format outcome", + ); + expect(outcome.attempts[0].audioCheck?.rollbacks).toBe(0); + + expect(await pathExists(`${CHANNEL_ROOT}/data/${VIDEO_ID}/audio.mp3`)).toBe(true); + expect( + await pathExists(`${CHANNEL_ROOT}/data/${VIDEO_ID}/audio.mp3.part.good`), + ).toBe(false); + expect( + await pathExists(`${CHANNEL_ROOT}/data/${VIDEO_ID}/audio.mp3.part.testing`), + ).toBe(false); + }); + test("mid-stream corruption rolls back to last good snapshot and recovers", async ({ page, }) => { diff --git a/editor/e2e/fixtures/bin/fake-ytdlp.mjs b/editor/e2e/fixtures/bin/fake-ytdlp.mjs @@ -180,6 +180,10 @@ async function modeAudioCheckOneUrl(url) { ), 10, ); + // Extension yt-dlp would pick for the downloaded stream. Defaults to mp4 + // (Odysee "original" video). Tests can set this to "mp3" to simulate the + // bestaudio-already-in-target-format case. + const partExtension = String(sidecar.partExtension ?? "mp4"); const id = urlIdYouTube(url) ?? "ackid"; const videoDir = path.join("data", id); @@ -188,8 +192,8 @@ async function modeAudioCheckOneUrl(url) { if (!existsSync(path.join(videoDir, "metadata.info.json"))) { await writeMetadata(videoDir, id); } - const partFile = path.join(videoDir, "audio.mp4.part"); - const finalFile = path.join(videoDir, "audio.mp4"); + const partFile = path.join(videoDir, `audio.${partExtension}.part`); + const finalFile = path.join(videoDir, `audio.${partExtension}`); const isResume = existsSync(partFile); // Count prior audio-check invocations so the fake can simulate "transient // CDN hiccups" — first run emits the marker, subsequent runs don't even