import { transcriptAround } from "@/lib/phrase-finder/server"; export const dynamic = "force-dynamic"; // GET ?channel&video&at -> the cues around that second of the video's // transcript, the hit's cue lit: where the phrase was said, read in place. export async function GET(request: Request) { const sp = new URL(request.url).searchParams; const at = Number(sp.get("at")); if (!Number.isFinite(at)) return Response.json({ error: "at is a second" }, { status: 400 }); try { const t = await transcriptAround(String(sp.get("channel") ?? ""), String(sp.get("video") ?? ""), at); if (!t) return Response.json({ error: "no transcript" }, { status: 404 }); return Response.json(t, { headers: { "cache-control": "no-store" } }); } catch (e) { return Response.json({ error: e instanceof Error ? e.message : String(e) }, { status: 400 }); } }