// lane/local-media: a site's evidence read lists a cited local recording, and // every window of a local media library channel, as UNFETCHABLE ("local-media", // lib/localMedia.ts's sentence) — not missing, which a fetch would try to fill. // Synthetic ids; nothing is fetched or cut. // // Run with: pnpm --filter yt-dlp-transcript-common exec tsx --test publish/reportMediaLocal.test.ts import { after, test } from "node:test"; import assert from "node:assert/strict"; import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs"; import { tmpdir } from "node:os"; import path from "node:path"; const ROOT = mkdtempSync(path.join(tmpdir(), "report-media-local-")); Object.assign(process.env, { TRANSCRIPTS_DIR: path.join(ROOT, "transcripts"), SAVED_VIDEOS_DIR: path.join(ROOT, "saved-videos"), SITES_DIR: path.join(ROOT, "transcripts", "sites"), SETTINGS_FILE: path.join(ROOT, "settings.json"), EXPORT_PUBLIC_DIR: path.join(ROOT, "public"), EXPORT_INDEX_DIR: path.join(ROOT, ".export-index"), EXPORT_BUILDS_DIR: path.join(ROOT, ".export-builds"), ARCHILYZER_CONFIG_DIR: path.join(ROOT, "config"), }); after(() => rmSync(ROOT, { recursive: true, force: true })); const { getPaths } = await import("../lib/paths"); const { missingEvidenceWindows } = await import("./reportMedia"); const paths = getPaths(); const SITE = "demo-site"; const LIB = "library"; const ONLINE = "online"; const LOCAL_ID = "local-" + "e".repeat(32); const writeJson = (file: string, value: unknown) => { mkdirSync(path.dirname(file), { recursive: true }); writeFileSync(file, JSON.stringify(value, null, 2)); }; writeJson(path.join(paths.channelsDir, LIB, "config.json"), { handling: "youtube", name: "Library", localMedia: { sourceId: "library-1", directory: "/mnt/library" }, }); writeJson(path.join(paths.channelsDir, ONLINE, "config.json"), { handling: "youtube", name: "Online", url: "https://www.youtube.com/@online", }); for (const [ch, id] of [[LIB, LOCAL_ID], [LIB, "aaaaaaaaaaa"], [ONLINE, "bbbbbbbbbbb"]]) { writeJson(path.join(paths.channelsDir, ch, "data", id, "metadata.info.json"), { id, duration: 600 }); } writeJson(path.join(paths.sitesDir, SITE, "site.json"), { title: "Demo", channels: [{ slug: LIB }, { slug: ONLINE }], search: false, reports: ["r1"], }); writeJson(path.join(paths.sitesDir, SITE, "reports", "r1", "report.json"), { format: "archilyzer-report", version: 1, id: "r1", kind: "sweep", title: "Report r1", citations: { c01: { kind: "video", channel: LIB, id: LOCAL_ID, start: 10, end: 12, quote: "one" }, c02: { kind: "video", channel: LIB, id: "aaaaaaaaaaa", start: 10, end: 12, quote: "two" }, c03: { kind: "video", channel: ONLINE, id: "bbbbbbbbbbb", start: 10, end: 12, quote: "three" }, }, sections: [{ id: "s1", title: "One", body: "[c01](cite:c01) [c02](cite:c02) [c03](cite:c03)" }], }); test("a local recording and a local library channel's windows are unfetchable, the online one missing", async () => { const r = await missingEvidenceWindows(paths, SITE); assert.deepEqual(r.problems, []); assert.deepEqual(r.unfetchable.map((w) => [w.id, w.why]).sort(), [["aaaaaaaaaaa", "local-media"], [LOCAL_ID, "local-media"]]); for (const w of r.unfetchable) assert.match(w.message, /no online source, so no clip can be fetched for it\./); assert.deepEqual(r.missing.map((w) => w.id), ["bbbbbbbbbbb"]); });