import { reportsPrepareAction } from "../../../sites/lib/reportsPrepareAction"; import { jobResponse, OpsInputError, ops, reqString } from "../_lib"; import { isValidSiteId } from "yt-dlp-transcript-common/lib/site"; export const dynamic = "force-dynamic"; // POST { siteId: string } -> { ok: true, jobId } // // An adapter: one call to the action the site's Reports tab posts. Cuts every // clip and copies every post capture the site's published reports cite into // its report-media cache, as one `reports-prepare` job on its own queue. The // job fails, naming each citation, when any lacks its media. export async function POST(request: Request) { return ops(request, ["siteId"], async (body) => { const siteId = reqString(body, "siteId"); if (!isValidSiteId(siteId)) { throw new OpsInputError( `"${siteId}" is not a valid site id (lowercase letters, digits and "-"; must start with a letter or digit)`, ); } return jobResponse(await reportsPrepareAction(siteId)); }); }