"use server"; // The Pool's corpus-wide jobs that are not publish stages: normalize and the // downloadable archives. Build index, the stats dataset, a site's build and // deploy, "Build all sites" and the hub's and the homepage's buttons are // publish stages now (release 18): sites/lib/publishActions.ts. import { normalizeAllTranscripts } from "yt-dlp-transcript-common/controller/normalizeAll"; import { normalizeAllLiveChat } from "yt-dlp-transcript-common/controller/normalizeAllLiveChat"; import { archiveTranscripts, archiveCombinedTranscripts, type ArchiveBuildOptions, } from "yt-dlp-transcript-common/controller/archiveTranscripts"; import { archiveLiveChat, archiveCombinedLiveChat, } from "yt-dlp-transcript-common/controller/archiveLiveChat"; import { getPaths } from "yt-dlp-transcript-common/lib/paths"; import { runManagedFunction, type StreamActionResult, } from "yt-dlp-transcript-common/jobs/streamCommand"; const DEFAULT_BUILD_QUEUE = "build"; export async function normalizeTranscriptsAction( queueKey?: string, ): Promise { const paths = getPaths(); return runManagedFunction({ kind: "normalize-transcripts", queueKey: queueKey === undefined ? DEFAULT_BUILD_QUEUE : queueKey.trim(), paths, fn: async (onLog, signal) => { await normalizeAllTranscripts({ paths, onLog, signal }); }, }); } export async function archiveTranscriptsAction( build: Partial, queueKey?: string, ): Promise { const paths = getPaths(); return runManagedFunction({ kind: "archive-transcripts", queueKey: queueKey === undefined ? DEFAULT_BUILD_QUEUE : queueKey.trim(), paths, fn: async (onLog, signal) => { await archiveTranscripts({ paths, onLog, signal, build }); }, }); } export async function archiveCombinedTranscriptsAction( build: Partial, queueKey?: string, ): Promise { const paths = getPaths(); return runManagedFunction({ kind: "archive-combined-transcripts", queueKey: queueKey === undefined ? DEFAULT_BUILD_QUEUE : queueKey.trim(), paths, fn: async (onLog, signal) => { await archiveCombinedTranscripts({ paths, onLog, signal, build }); }, }); } export async function normalizeLiveChatAction( queueKey?: string, ): Promise { const paths = getPaths(); return runManagedFunction({ kind: "normalize-live-chat", queueKey: queueKey === undefined ? DEFAULT_BUILD_QUEUE : queueKey.trim(), paths, fn: async (onLog, signal) => { await normalizeAllLiveChat({ paths, onLog, signal }); }, }); } export async function archiveLiveChatAction( build: Partial, queueKey?: string, ): Promise { const paths = getPaths(); return runManagedFunction({ kind: "archive-live-chat", queueKey: queueKey === undefined ? DEFAULT_BUILD_QUEUE : queueKey.trim(), paths, fn: async (onLog, signal) => { await archiveLiveChat({ paths, onLog, signal, build }); }, }); } export async function archiveCombinedLiveChatAction( build: Partial, queueKey?: string, ): Promise { const paths = getPaths(); return runManagedFunction({ kind: "archive-combined-live-chat", queueKey: queueKey === undefined ? DEFAULT_BUILD_QUEUE : queueKey.trim(), paths, fn: async (onLog, signal) => { await archiveCombinedLiveChat({ paths, onLog, signal, build }); }, }); }