import { NextResponse } from "next/server"; import { LIVE_PRECLIP_BODY_KEYS } from "yt-dlp-transcript-common/controller/livePreclip"; import { livePreclipAction } from "../../../channels/[slug]/liveMediaActions"; import { opsFail, ops, reqSlug } from "../_lib"; export const dynamic = "force-dynamic"; // POST { slug, id, action?: "start" (default) | "stop" | "status" | "finalize", // everyMinutes?, maxChunkMinutes?, overlapSeconds?, scan?, mine?, // project? } // start -> { ok: true, jobId } the live-preclip job for a recording in // progress (record-live's `preclip` starts // it by itself) // stop -> { ok: true, jobId } that job cancelled; the recording goes on // status -> { ok: true, status } live-preclip.json, the live transcript's // summary and last cues, the job // finalize -> { ok: true, project } the supersede by hand, once the final // transcript is here // // LIVE PRE-CLIP (controller/livePreclip.ts; plans/live-preclip.md): every few // minutes the new span of the growing recording is transcribed on a worker // lease and spliced into data//live-transcript.json, and umtool's clip // finder grows the stream's project — no network request. export async function POST(request: Request) { return ops(request, LIVE_PRECLIP_BODY_KEYS, async (body) => { reqSlug(body, "slug"); const r = await livePreclipAction(body); if (!r.ok) return opsFail(r.error, 400, r.info ? { info: true } : undefined); return NextResponse.json(r); }); }