import { NextResponse } from "next/server"; import { getPaths } from "yt-dlp-transcript-common/lib/paths"; import { readSubtitleDeferrals } from "yt-dlp-transcript-common/jobs/downloadBackoff"; export const dynamic = "force-dynamic"; // GET → { count, lastAt, until } | null — the video's SUBTITLE deferral // (release 17, slice RL): how many times its subtitle fetch answered 429, when // last, and until when Download missing subs leaves it alone. Read by the video // page's one-line note. // // A ROUTE, NOT A SERVER ACTION: the note asks on mount, and Next runs a page's // server actions one at a time — a mount-time action would sit in front of the // operator's first click (Mark untranscribable, Download, …) while it ran. export async function GET( _req: Request, ctx: { params: Promise<{ slug: string; id: string }> }, ): Promise { const { slug, id } = await ctx.params; const all = await readSubtitleDeferrals(getPaths()).catch(() => ({})); const d = (all as Record)[id]; return NextResponse.json( d && d.channelSlug === slug ? { count: d.count, lastAt: d.lastAt, until: d.until } : null, { headers: { "cache-control": "no-store" } }, ); }