import { fetchChatAction } from "../../../channels/[slug]/videos/[id]/mediaToolsActions"; import { jobResponse, ops, optBool, optString, reqSlug, reqVideoId } from "../_lib"; export const dynamic = "force-dynamic"; // POST { slug, id, queueKey?, renormalize? } -> { ok: true, jobId } // // ONE video's live chat replay, and nothing else (release 36, lane A; // controller/fetchLiveChat.ts): the chat-only yt-dlp pass the managed download // runs for a chat-only channel — the channel's cookies and the platform's live // pace — on the platform's download queue, then live_chat.cues.json. The video // page's Media tools → "Fetch live chat", and the find-clips job's chat step. // // Answered without a job, `info: true` (a skip, not an error): a video on a // platform with no chat fetcher ("no chat fetcher for twitch"), a chat already // here and fresh, a video that was never live, a held platform or one in a // rate-limit cooldown. Refused: an id with no data//, a channel whose text // cannot be read. A pass that finds no replay ends `done` and says so. // // `renormalize: true` parses the raw chat already on disk again (fresh or // not) onto the recording's clock, with no network: refused when no raw is // here — it never fetches. // // `replace: true` is the DELIBERATE RE-FETCH over a chat stored compressed // (`transcript.live_chat.json.zst`): the stored capture is first KEPT as // `chat-capture-kept..json.zst` (no reader of the chat sees it; it // is never removed automatically), then the replay is fetched. A replay with // messages becomes the chat; an empty one is kept too and, like no replay at // all, leaves the stored capture the chat. The job log gives both captures' // bytes, message counts and first/last message times. Refused over a plain // chat (delete it on the files card first) and with `renormalize`. export async function POST(request: Request) { return ops(request, ["slug", "id", "queueKey", "renormalize", "replace"], async (body) => jobResponse( await fetchChatAction(reqSlug(body, "slug"), reqVideoId(body, "id"), optString(body, "queueKey"), { renormalize: optBool(body, "renormalize") === true, replace: optBool(body, "replace") === true, }), ), ); }