"use server"; // "Audit audio" on the channel's Download stage (release 32): the // `audio-audit` job for this channel, through the same door as // `pnpm ops audio-audit` (controller/audioAudit.ts). Its refusals — a bad // body, the channel's media unreachable — come back as the button's error. // // NOTHING BUT FUNCTIONS IS DECLARED HERE (a "use server" file). import { getPaths } from "yt-dlp-transcript-common/lib/paths"; import { enqueueAudioAudit } from "yt-dlp-transcript-common/controller/audioAudit"; import type { StreamActionResult } from "yt-dlp-transcript-common/jobs/streamCommand"; export async function audioAuditAction( slug: string, opts: { scope: "untranscribed" | "all"; max?: number; force?: boolean }, ): Promise { let out; try { out = await enqueueAudioAudit( { slug, scope: opts.scope, ...(opts.max !== undefined ? { max: opts.max } : {}), ...(opts.force ? { force: true } : {}) }, { paths: getPaths() }, ); } catch (e) { return { ok: false, error: (e as Error).message }; } const started = out.started[0]; if (started) return started.result; return { ok: false, error: out.refused.map((r) => r.error).join("; ") || "No audit started" }; }