#!/usr/bin/env node // E2E fake ffprobe. The duration guard invokes: // ffprobe -v error -show_entries format=duration -of default=...:nokey=1 // We report a duration read from a marker the fake-ytdlp embeds in the audio // file (`__DUR=__`). A file with no marker reports a large duration so // the guard never falsely trips on it (matches a full-length download). import { readFile } from "node:fs/promises"; import { installFixtureWatchdog } from "./_watchdog.mjs"; // Never outlive the run that spawned us — see _watchdog.mjs. installFixtureWatchdog(); const argv = process.argv.slice(2); // The input file is the only non-flag argument (and not a value of -show_entries // / -of). It's the last positional in the guard's invocation. const file = argv[argv.length - 1]; async function main() { if (!file || file.startsWith("-")) { process.stderr.write("[fake-ffprobe] missing input file\n"); process.exit(1); } let buf; try { buf = await readFile(file, "utf8"); } catch { process.stderr.write(`[fake-ffprobe] cannot read ${file}\n`); process.exit(1); } const m = buf.match(/__DUR=([0-9]+(?:\.[0-9]+)?)__/); // No marker -> report a long duration so isShortAudio() stays false. const seconds = m ? m[1] : "100000"; process.stdout.write(`${seconds}\n`); } main();