import { isValidChannelSlug } from "yt-dlp-transcript-common/controller/channels"; import { keptOriginalsList } from "../../../saved-videos/compactActions"; import { readRoute } from "../_read"; import { opsFail } from "../_lib"; export const dynamic = "force-dynamic"; // GET [?slug=] // -> { ok, count, videos: [{ slug, id, active, compacted, kept: [{ file, // keptAs: "original" | "former-original", sha256?, bytes }], // pendingDrops: [{ file, keptAs?, at }] }], notAnswering } // // Every saved video that keeps an ORIGINAL or a FORMER ORIGINAL beside its // active copy, or has a drop in flight (a file the pointer no longer lists, // still on disk: drop it again by name to finish). An editor built from // before compaction does not know those labels and would treat such a copy // as an ordinary droppable alternate: while this list is not empty, do not // roll the editor back past that release (OPERATING.md, "Compact saved // videos"). Pointers only — no container is opened. export async function GET(request: Request) { return readRoute(request, ["slug"], async (q) => { const slug = q.get("slug")?.trim() || undefined; if (slug && !isValidChannelSlug(slug)) return opsFail(`"${slug}" is not a valid channel slug`); const { rows, notAnswering } = await keptOriginalsList(slug ? { slug } : {}); return { count: rows.length, videos: rows, notAnswering }; }); }