"use server"; // The video page's Live pre-clip panel: the same jobs as `pnpm ops // live-preclip` and `pnpm ops live-clip` (controller/livePreclip.ts, // controller/liveClip.ts). NOTHING BUT FUNCTIONS IS DECLARED HERE (a "use // server" file). import { getPaths } from "yt-dlp-transcript-common/lib/paths"; import { readChannelConfig } from "yt-dlp-transcript-common/controller/channels"; import { preclipDefaults, startLivePreclipJob, stopLivePreclip } from "yt-dlp-transcript-common/controller/livePreclip"; import { parseLiveClipBody, runLiveClipJob } from "yt-dlp-transcript-common/controller/liveClip"; import type { StreamActionResult } from "yt-dlp-transcript-common/jobs/streamCommand"; import { safeRevalidate } from "../../../../lib/safeRevalidate"; export async function startLivePreclipAction(slug: string, videoId: string, everyMinutes?: number): Promise { const paths = getPaths(); const config = await readChannelConfig(paths, slug); if (!config) return { ok: false, error: `Channel "${slug}" not found` }; const options = { ...preclipDefaults(), ...(everyMinutes && everyMinutes >= 1 && everyMinutes <= 120 ? { everyMinutes: Math.round(everyMinutes) } : {}) }; const r = await startLivePreclipJob({ paths, slug, id: videoId, channelConfig: config, options }); safeRevalidate([`/channels/${slug}/videos/${videoId}`]); return r; } export async function stopLivePreclipAction(slug: string, videoId: string): Promise<{ ok: boolean; error?: string }> { const r = stopLivePreclip(slug, videoId); safeRevalidate([`/channels/${slug}/videos/${videoId}`]); return r.ok ? { ok: true } : { ok: false, error: r.error }; } export async function shareLiveClipAction(slug: string, videoId: string, start: number, end: number): Promise { const parsed = parseLiveClipBody({ slug, id: videoId, start, end }); if (!parsed.ok) return parsed; return runLiveClipJob({ paths: getPaths(), request: parsed.value }); }