import { getPaths } from "yt-dlp-transcript-common/lib/paths"; import { getSettings } from "yt-dlp-transcript-common/lib/settings"; import { computeLeafPending } from "yt-dlp-transcript-common/controller/autoRunner"; import { copiesReport } from "yt-dlp-transcript-common/controller/copiesScan"; import { COPY_LANES } from "yt-dlp-transcript-common/controller/copiesLane"; import { opsFail } from "../_lib"; import { readRoute } from "../_read"; export const dynamic = "force-dynamic"; // GET /api/ops/copies[?group=][&pairs=1] — `pnpm ops get copies []` // // THE COPIES REPORT (lane cross-source-dupes, slice 1), read only: each source // group (settings.sourceGroups) — its channels in order of preference, whether // the lanes act on it, its last scan (`transcripts/copies/.json`: when, // the totals), its pairs by link (confirmed by text, metadata only, partial, // inside one channel), what the fallback copies of confirmed recordings hold // (seconds, and audio bytes through tier links — null with the reason when a // channel's media cannot be read now), and the released videos. `pairs=1` // adds every pair with its evidence. `lanes` is what the transcription and // Speakers lanes skip and hold RIGHT NOW, each video with its reason: the // same computeLeafPending the console polls. Writes nothing. export async function GET(request: Request) { return readRoute(request, ["group", "pairs"], async (q) => { const settings = getSettings(); const group = q.get("group"); const pairs = q.get("pairs"); if (pairs !== null && pairs !== "1") return opsFail('"pairs" takes 1'); if (group !== null && !settings.sourceGroups.some((g) => g.id === group)) { return opsFail( `no source group "${group}" — settings.sourceGroups names ${settings.sourceGroups.map((g) => g.id).join(", ") || "none"}`, 404, ); } const paths = getPaths(); const groups = await copiesReport(paths, settings, { group, pairs: pairs === "1" }); const lanes: Record = {}; if (settings.sourceGroups.some((g) => g.lanes)) { for (const lane of COPY_LANES) { const r = await computeLeafPending(lane, paths); lanes[lane] = r.copies ?? { skipped: 0, held: 0, head: [] }; } } return { groups, lanes }; }); }