"use server"; import { safeRevalidate } from "../../lib/safeRevalidate"; import { getPaths } from "yt-dlp-transcript-common/lib/paths"; import { getSettings } from "yt-dlp-transcript-common/lib/settings"; import { readChannelConfig } from "yt-dlp-transcript-common/controller/channels"; import { runBrowserLookupJob } from "yt-dlp-transcript-common/controller/browserLookupJob"; import type { StreamActionResult } from "yt-dlp-transcript-common/jobs/streamCommand"; // THE BROWSER LOOKUP (release 32 R9): an Odysee video's record, or the // channel's listing, read from its page in a headless browser when yt-dlp's // lookup is refused — the `browser-lookup` job, as the video page's "Read from // the page", the Playlist stage's "List from the page" and `pnpm ops // browser-lookup` (`/api/ops/browser-lookup`) ask for it. The work and its // refusals are common/controller/browserLookupJob.ts. export async function browserLookupAction( slug: string, req: { ids?: string[]; listing?: boolean; scrolls?: number; queueKey?: string }, ): Promise { const paths = getPaths(); const channelConfig = await readChannelConfig(paths, slug); if (!channelConfig) return { ok: false, error: `Channel "${slug}" not found` }; const ids = (req.ids ?? []).map((s) => s.trim()).filter(Boolean); return runBrowserLookupJob({ paths, slug, channelConfig, ...(ids.length ? { videoIds: ids } : {}), ...(req.listing ? { listing: true } : {}), ...(req.scrolls !== undefined ? { scrolls: req.scrolls } : {}), skipLiveDownloads: getSettings().skipLiveDownloads, ...(req.queueKey ? { queueKey: req.queueKey } : {}), requestedBy: "editor", afterRun: () => { safeRevalidate([ `/channels/${slug}`, ...ids.map((id) => `/channels/${slug}/videos/${id}`), ]); }, }); }