// THE PUBLISHED EMBED ID, found on this disk (umtool redesign L6, the Links panel's "use the published embed id"; // owed 4 and 8 Nov: `umtool links` showed 15/15 DEAD on quartering-midterms, a QR naming the Rumble URL-slug folder // the corpus keeps a recording under while the archive serves its EMBED id). // // `embedIdRows` lists every clip of the cut that cites a folder id the archive does not serve -- the id // shareLine.mjs siteVideoFor (L1's one mapping) reads from the folder's metadata.info.json -- with the QR it draws // now, the QR it would draw with `siteVideo`, and what the last link check (out/links.json) said of it. No network: // the check is the `links` command's; this is the fix, which needs only the corpus. `embedIdFixes` is what // setSiteVideos (inspectorEdits.mjs) writes for the rows asked: `siteVideo`, and a citeUrl that named the folder id // moved to the embed id (linkCheck.mjs withArchiveId). // // Plain ESM: the CLI (`umtool links

--embed-ids`) runs it under bare node. import { archiveLinkOf, linksOf, withArchiveId } from "./linkCheck.mjs"; import { siteVideoFor } from "./shareLine.mjs"; /** * @typedef {{ clip: string, channel: string | null, video: string, siteVideo: string, url: string | null, fixedUrl: string | null, * citeUrl: string | null, state: "dead" | "ok" | "unverified" | "direct" | "unchecked" }} EmbedRow */ /** * The clips whose folder id is not the archive's, read from the project's channels trees (its shadow, then the * corpus behind it). A clip that pins `siteVideo` already is never looked up. * * @param {string} dir the project's directory * @param {Record} manifest * @param {{ doc?: { links?: Array<{ clip: string, url: string, state: string }> } | null, layers?: string[] | null }} [opts] * @returns {Promise} */ export async function embedIdRows(dir, manifest, { doc = null, layers = null } = {}) { let trees = layers; if (!trees) { const { channelsLayersFor, hasShadowChannels } = await import("../projects/report.mjs"); trees = channelsLayersFor(dir, manifest, { shadowExists: await hasShadowChannels(dir) }); } const qr = new Map(linksOf(manifest).map((l) => [l.clip, l.url])); const checked = new Map((doc?.links ?? []).map((l) => [`${l.clip}\u0000${l.url}`, l.state])); /** @type {EmbedRow[]} */ const rows = []; for (const e of manifest?.timeline ?? []) { if (e?.type !== "clip" || e.siteVideo || e.video == null) continue; const slug = e.channel ?? manifest?.provenance?.channelSlug ?? null; const video = String(e.video); let embed = null; for (const d of trees) { embed = await siteVideoFor({ channelsDir: d, slug, video }).catch(() => null); if (embed) break; } if (!embed) continue; const url = qr.get(e.id) ?? null; const cite = typeof e.citeUrl === "string" && e.citeUrl ? e.citeUrl : null; const citeNamesFolder = cite ? archiveLinkOf(cite)?.id === video : false; // The QR after the fix: a citeUrl naming the folder moves to the embed id; a QR built from the moment follows // `siteVideo` by itself (site-links.mjs archiveMomentUrl). const fixedUrl = url && archiveLinkOf(url)?.id === video ? withArchiveId(url, video, embed) : url; rows.push({ clip: String(e.id), channel: slug, video, siteVideo: embed, url, fixedUrl, citeUrl: citeNamesFolder ? withArchiveId(cite, video, embed) : null, state: /** @type {EmbedRow["state"]} */ (url ? checked.get(`${e.id}\u0000${url}`) ?? "unchecked" : "unchecked"), }); } return rows; } /** * The writes for `clips` (null: every row), as setSiteVideos takes them. A clip named that is not a row is refused. * @param {EmbedRow[]} rows * @param {string[] | null} clips */ export function embedIdFixes(rows, clips = null) { const by = new Map(rows.map((r) => [r.clip, r])); const want = clips ?? rows.map((r) => r.clip); const missing = want.filter((c) => !by.has(c)); if (missing.length) throw new Error(`${missing.join(", ")}: no published embed id to use (not a Rumble folder id, or siteVideo is set already)`); return want.map((c) => { const r = /** @type {EmbedRow} */ (by.get(c)); return { clip: r.clip, siteVideo: r.siteVideo, ...(r.citeUrl ? { citeUrl: r.citeUrl } : {}) }; }); }