Archilyzer · Source

archilyzer

Archilyzer
git clone https://archilyzer.pages.dev/source/archilyzer.git
Log | Files | Refs | README | LICENSE

commit 6cfc7f34858376399c14f5fc7b786a25e6cc4d3e
parent 75783ecfe2d3a7e1256d413b227ffffa091922cc
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Fri, 13 Nov 2026 22:21:54 -0500

review fixes (A-D): the promo ends only a whole last clip, tiered out/ kept, one look per format, rebuilds that reproduce

MEDIUM
- The channel promo ends a build only when its LAST entry/piece is a whole clip (build-video
  promoFor; buildShort passes --no-promo and notes why otherwise); a reel's outro card is
  then not added after it (a note).
- buildShort makes the take's out/ through ensureWriteDir before linkSharedOut (a tiered
  project's out/ stays the media-root link), and links the landscape build's own out too;
  drawPromoCards' out/promo likewise.
- Each batch format takes only the knobs it reads (shortsBatch knobsForFormat: landscape
  none, said; the vertical/desktop validation skipped for landscape): `--formats
  desktop,landscape --qr-corner br` builds every row.
- The promo card's work dir is per call (two draws at once no longer share one); its
  meta is renamed into place.

LOW
- batch.json rows keep the look they were built with (verticalCli LOOK_SNAPSHOT_KEYS);
  --again hands it back (buildShort `look`), so a rebuild reproduces.
- --replace puts the old file back when the rebuild fails; names read back from
  batch.json are used only when they are plain file names of the folder.
- linkSharedOut replaces an EMPTY real directory (a failed build's) with the link.
- The promo portrait is grabbed from the tallest window that holds the second when the
  project fetches taller ones (stillGrab preferTall).
- The promo code's plate is white whatever the palette, with a four-module quiet zone.
- The expiring-VOD note fires for a citeUrl that is itself a Kick/Twitch VOD; the lint
  lists no vertical code for a stacked-deck cut.

Co-Authored-By: Claude <noreply@anthropic.com>

Diffstat:
Mumtool/docs/cli.md | 11++++++++---
Mumtool/docs/knobs.md | 7+++++--
Mumtool/lib/report/promoCli.mjs | 7+++++--
Mumtool/lib/report/shortsBatch.mjs | 13++++++++++++-
Mumtool/lib/report/shortsBatch.test.mjs | 76++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----
Mumtool/lib/report/shortsCli.mjs | 17+++++++++++++----
Mumtool/lib/report/stillGrab.mjs | 30++++++++++++++++++++++++------
Mumtool/lib/report/takeMaker.mjs | 9+++++++--
Mumtool/lib/report/verticalCli.mjs | 46++++++++++++++++++++++++++++++++++++----------
Mumtool/report-to-video/build-video.mjs | 6++++--
Mumtool/report-to-video/clip-kit.test.mjs | 8+++++++-
Mumtool/report-to-video/lint.mjs | 6++++--
Mumtool/report-to-video/promo-card.mjs | 19+++++++++++++------
Mumtool/report-to-video/promo-card.test.mjs | 2+-
14 files changed, 211 insertions(+), 46 deletions(-)

diff --git a/umtool/docs/cli.md b/umtool/docs/cli.md @@ -589,10 +589,15 @@ $U shorts my-clips --take kit --again # the folder's batch.json - **Names.** `<name>.<format>.mp4`, each with its record (`.json`): the clip's `name` when it pins one, else its title's slug, else its id. A name another clip of the folder holds gets `-<clip id>` (two clips of one cut often share a title). Once a clip has a name in `batch.json` it keeps it, whatever its title becomes. -- **A file there is kept** unless `--replace`, which sets the old one aside as `<name>.<format>.<stamp>.mp4`. +- **A file there is kept** unless `--replace`, which sets the old one aside as `<name>.<format>.<stamp>.mp4` -- and + puts it back when the rebuild fails. +- **Each format takes only the knobs it reads:** `landscape` (the take's own look) none of them (said in its notes); a + short keeps its code at the top when a bottom corner is asked for the desktop clips. - **`batch.json`** names each clip's files, lengths, notes and errors, the knobs it was last built with and its - **snapshot** (its framing, `vertical` and `side`, as read). `--again` builds every clip of the folder again with its - own formats, knobs and snapshot, so a later edit of the project does not silently change a rebuild. + **snapshot** (its own keys as read: framing, side post, code, promo, zooms, cold open) and the **look** it was built + with (the palette, `render.promo`, `render.qr`, the vertical and desktop knobs, …). `--again` builds every clip of + the folder again from those, so a later edit of the project or its look does not silently change a rebuild. A name + read back from `batch.json` is used only when it is a plain file name of the folder. - **Length.** A vertical over 180 s (`--max-vertical`, Shorts' 3 minutes) or a desktop or landscape clip over 140 s (`--max-desktop`, `--max-landscape`, X's 2:20) is said so in the record: a note, never a refusal. - Each build runs in the heavy slot as `umtool vertical`'s does (another job may run between two clips). A clip that diff --git a/umtool/docs/knobs.md b/umtool/docs/knobs.md @@ -433,8 +433,11 @@ where, one template draws it 9:16 and 16:9. - **The faces** are the repository's (Archivo for the name, IBM Plex Sans for the rest), so a fresh clone or the container draws the same card. The card is drawn by a browser (as a post card is), once per key, into the build's `cards/`. -- Only the LAST clip of a per-clip build ends on it; the stacked vertical deck's end card and a reel's outro are other - things. A take's 16:9 look (`--landscape`) draws none. +- Only a build whose LAST piece is a whole clip ends on it (a short ending on a post item, or on a clip cut short of + its end, ends without it, said); a reel's outro card is then not added after it (one ending, said). The stacked + vertical deck's end card is another thing; a take's 16:9 look (`--landscape`) draws none. +- **The code** stands on a WHITE plate (whatever the palette; `palette.plate` changes it) with a quiet zone of four + modules, as the QR standard asks. | Knob | Values (default) | What it does | |---|---|---| diff --git a/umtool/lib/report/promoCli.mjs b/umtool/lib/report/promoCli.mjs @@ -11,6 +11,7 @@ import { kindMakesTakes } from "../projects/kinds.mjs"; import { readManifest } from "../projects/report.mjs"; import { manifestToken, updateRender } from "./manifest.mjs"; import { StillRefused, grabStill } from "./stillGrab.mjs"; +import { ensureWriteDir } from "./storage.mjs"; export const PROMO_USAGE = [ "usage: umtool promo <project> [--portrait-from <clip>@<second>] [--box x,y,w,h] [--draw] [--take <t>] [--json]", @@ -54,7 +55,8 @@ export async function setPromoPortrait(project, { clip, at, box = null }) { if (!isObj(promo)) throw new CliError(`${project.id} sets no channel promo yet: umtool look ${project.id} promo='{"name":"…","url":"https://…"}' first`); let still; try { - still = await grabStill(project, manifest, clip, at); + // The tallest window that holds the second, when the project fetches taller ones (render.tallWindows). + still = await grabStill(project, manifest, clip, at, { preferTall: manifest.render?.tallWindows === true }); } catch (e) { if (e instanceof StillRefused) throw new CliError(e.message); throw e; @@ -78,7 +80,8 @@ export async function drawPromoCards(project, { take = null } = {}) { const { promoErrors, renderPromoCard } = await import("umtool-report-to-video/promo-card"); const errors = promoErrors(promo); if (errors.length) throw new CliError(errors.join("; ")); - const dir = path.join(/* turbopackIgnore: true */ project.dir, "out", "promo"); + // Through ensureWriteDir: a tiered project's out/ stays the link to the media root. + const dir = await ensureWriteDir(path.join(/* turbopackIgnore: true */ project.dir, "out", "promo")); const out = []; for (const [width, height] of [[1080, 1920], [1920, 1080]]) { const r = await renderPromoCard({ promo: { ...promo, captions: promo.captions !== false }, render: manifest.render, width, height, dir, manifestDir: project.dir }); diff --git a/umtool/lib/report/shortsBatch.mjs b/umtool/lib/report/shortsBatch.mjs @@ -30,6 +30,11 @@ export const BATCH_FORMATS = Object.freeze({ * the desktop clips is the short's default corner. Returns `{knobs, note}`. */ export function knobsForFormat(knobs, format) { + // The take's own 16:9 look reads none of the per-clip builder's knobs (its look is the take's): none handed on. + if (format === "landscape") { + const asked = Object.keys(knobs ?? {}).filter((k) => !["maxSeconds"].includes(k)); + return { knobs: {}, note: asked.length ? `the take's own 16:9 look: ${asked.join(", ")} ${asked.length > 1 ? "are" : "is"} not its (left out)` : null }; + } const qr = knobs?.qr; if (format === "vertical" && qr && typeof qr === "object" && !["tr", "tl"].includes(qr.corner)) { return { knobs: { ...knobs, qr: true }, note: `its code at the top right (a short's captions run along its foot; ${qr.corner} is a desktop clip's corner)` }; @@ -87,6 +92,9 @@ export function assignNames(entries, prior = {}) { return names; } +/** A name read back from a record: a file name of the folder, nothing else (no separator, no dot path). */ +export const safeName = (n) => typeof n === "string" && /^[a-z0-9][a-z0-9-]{0,80}$/.test(n); + /** `--formats a,b` read: known names, each once, in the order given. Throws naming an unknown one. */ export function parseFormats(text) { const list = String(text ?? "vertical").split(",").map((s) => s.trim()).filter(Boolean); @@ -124,6 +132,7 @@ export function againOf(record) { formats: FORMAT_NAMES.filter((f) => (isObj(c.files) && c.files[f]) || (isObj(c.errors) && c.errors[f])), knobs: isObj(c.knobs) ? c.knobs : {}, snapshot: isObj(c.snapshot) ? c.snapshot : null, + look: isObj(c.look) ? c.look : null, })) .filter((c) => c.formats.length); } @@ -135,7 +144,7 @@ export function againOf(record) { * * @param {Record<string, any> | null} prior * @param {{ id: string, name: string, title: string | null, format: string, knobs: Record<string, any>, snapshot: Record<string, any>, - * file?: string, seconds?: number | null, notes?: string[], error?: string, exists?: boolean }} r + * file?: string, seconds?: number | null, notes?: string[], error?: string, exists?: boolean, look?: Record<string, any> | null }} r */ export function rowAfter(prior, r) { const row = { id: r.id, name: r.name, title: r.title, knobs: {}, snapshot: null, files: {}, seconds: {}, notes: {}, errors: {}, ...(isObj(prior) ? prior : {}) }; @@ -160,6 +169,8 @@ export function rowAfter(prior, r) { row.notes[r.format] = r.notes ?? []; row.knobs = r.knobs; row.snapshot = r.snapshot; + // The look it was built with (verticalCli.mjs LOOK_SNAPSHOT_KEYS): what `--again` builds from. + if (isObj(r.look)) row.look = r.look; return row; } diff --git a/umtool/lib/report/shortsBatch.test.mjs b/umtool/lib/report/shortsBatch.test.mjs @@ -51,7 +51,7 @@ test("formats, items and the record's again", () => { { id: "a", knobs: { clip: "framed" }, snapshot: { vertical: null, side: null }, files: { landscape: "a.landscape.mp4" }, errors: { vertical: "failed" } }, { id: "b", files: {}, errors: {} }, ] }); - assert.deepEqual(again, [{ id: "a", formats: ["vertical", "landscape"], knobs: { clip: "framed" }, snapshot: { vertical: null, side: null } }]); + assert.deepEqual(again, [{ id: "a", formats: ["vertical", "landscape"], knobs: { clip: "framed" }, snapshot: { vertical: null, side: null }, look: null }]); // A row: a success records the file, the knobs and the snapshot; a failure keeps a file still there, drops one gone. const ok = rowAfter(null, { id: "a", name: "n", title: "T", format: "vertical", knobs: { clip: "framed" }, snapshot: { vertical: null, side: null }, file: "n.vertical.mp4", seconds: 9, notes: ["x"] }); assert.deepEqual(ok, { id: "a", name: "n", title: "T", knobs: { clip: "framed" }, snapshot: { vertical: null, side: null }, files: { vertical: "n.vertical.mp4" }, seconds: { vertical: 9 }, notes: { vertical: ["x"] }, errors: {} }); @@ -117,13 +117,14 @@ test("umtool shorts: each clip in each format into shorts-<take>/, named, record const files = (await readdir(folder)).sort(); assert.deepEqual(files, ["batch.json", "toms-toast-w01.landscape.mp4", "toms-toast-w01.vertical.mp4", "toms-toast.landscape.mp4", "toms-toast.vertical.mp4"]); // The builder was asked one clip at a time, with the flags' knobs and each format's cap. - assert.deepEqual(calls.map((c) => [c.items[0], c.landscape, c.knobs.maxSeconds, c.knobs.clip]), [["m01", false, 180, "framed"], ["m01", true, 140, "framed"], ["w01", false, 180, "framed"], ["w01", true, 140, "framed"]]); + // The take's own 16:9 look takes none of the per-clip builder's knobs (each format only the knobs it reads). + assert.deepEqual(calls.map((c) => [c.items[0], c.landscape, c.knobs.maxSeconds, c.knobs.clip]), [["m01", false, 180, "framed"], ["m01", true, 140, undefined], ["w01", false, 180, "framed"], ["w01", true, 140, undefined]]); assert.deepEqual(calls[2].overrides, { w01: { vertical: { crop: [0.6, 0, 0.3164, 1] }, side: null, qr: null, promo: null, zooms: null, coldOpen: null } }); const rec = JSON.parse(await readFile(path.join(folder, "batch.json"), "utf8")); assert.equal(rec.kind, "shorts-batch"); assert.deepEqual(rec.last.argv, ["shorts", "proj", "--take", "kit", "--items", "m01,w01", "--formats", "vertical,landscape"]); assert.deepEqual(rec.clips.map((c) => [c.id, c.name, c.files.vertical, c.knobs.clip]), [["m01", "toms-toast", "toms-toast.vertical.mp4", "framed"], ["w01", "toms-toast-w01", "toms-toast-w01.vertical.mp4", "framed"]]); - assert.deepEqual(rec.clips[0].notes, { vertical: [], landscape: ["this short runs 150.0 s, over its 140 s"] }); + assert.deepEqual(rec.clips[0].notes, { vertical: [], landscape: ["the take's own 16:9 look: clip, hook are not its (left out)", "this short runs 150.0 s, over its 140 s"] }); // Again without --replace: refused per file, recorded, exit 1; the files are untouched. const o2 = sink(); @@ -139,7 +140,7 @@ test("umtool shorts: each clip in each format into shorts-<take>/, named, record const calls3 = []; const o3 = sink(); assert.equal(await shortsCommand(["proj", "--take", "kit", "--again"], { reportsRoot: w.reportsRoot, log: o3.log, err: o3.err, build: standIn(calls3) }), 0, o3.errs.join("\n")); - assert.deepEqual(calls3.map((c) => [c.items[0], c.landscape, c.knobs.clip]), [["m01", false, "framed"], ["m01", true, "framed"], ["w01", false, "framed"], ["w01", true, "framed"]]); + assert.deepEqual(calls3.map((c) => [c.items[0], c.landscape, c.knobs.clip]), [["m01", false, "framed"], ["m01", true, undefined], ["w01", false, "framed"], ["w01", true, undefined]]); assert.deepEqual(calls3[2].overrides.w01.vertical, { crop: [0.6, 0, 0.3164, 1] }, "the snapshot, not the project's new crop"); const after = await readdir(folder); assert.ok(after.includes("toms-toast.vertical.mp4"), "the name kept though the title changed"); @@ -181,3 +182,70 @@ test("umtool shorts: a failing clip is recorded and the rest go on; --dry-run wr await rm(w.root, { recursive: true, force: true }); } }); + +test("umtool shorts: --again builds from the look it recorded; a failed rebuild puts the old file back; a hand-edited name is not trusted", async () => { + const w = await world(); + try { + const look = { palette: { bg: "#101010" }, promo: { name: "Example Channel", url: "https://example.org/c" } }; + const withLook = (calls, o2 = {}) => async (o) => { + calls.push(o); + if (o2.fail) throw new Error("the build failed"); + await mkdir(path.dirname(o.out), { recursive: true }); + await writeFile(o.out, `mp4 of ${o.items[0]} ${calls.length}`); + return { record: { seconds: 9, notes: [], out: o.out, look } }; + }; + const o = sink(); + assert.equal(await shortsCommand(["proj", "--take", "kit", "--items", "w01", "--formats", "vertical,landscape", "--qr-corner", "br"], { reportsRoot: w.reportsRoot, log: o.log, err: o.err, build: withLook([]) }), 0, o.errs.join("\n")); + const folder = path.join(w.dir, "shorts-kit"); + const rec = JSON.parse(await readFile(path.join(folder, "batch.json"), "utf8")); + assert.deepEqual(rec.clips[0].look, look); + assert.match(rec.clips[0].notes.vertical[0], /code at the top right/); + // --again: the recorded look handed to the builder. + const calls = []; + assert.equal(await shortsCommand(["proj", "--take", "kit", "--again"], { reportsRoot: w.reportsRoot, log: o.log, err: o.err, build: withLook(calls) }), 0); + assert.deepEqual(calls.map((c) => c.look), [look, look]); + // A rebuild that fails: the file it replaced is back, its contents as they were. + const file = path.join(folder, "toms-toast.vertical.mp4"); + const before = await readFile(file, "utf8"); + assert.equal(await shortsCommand(["proj", "--take", "kit", "--items", "w01", "--replace"], { reportsRoot: w.reportsRoot, log: o.log, err: o.err, build: withLook([], { fail: true }) }), 1); + assert.equal(await readFile(file, "utf8"), before); + // A name in the record that is not a plain file name of the folder is not used. + const hacked = JSON.parse(await readFile(path.join(folder, "batch.json"), "utf8")); + hacked.clips[0].name = "../../escape"; + await writeFile(path.join(folder, "batch.json"), JSON.stringify(hacked)); + const d = sink(); + assert.equal(await shortsCommand(["proj", "--take", "kit", "--items", "w01", "--dry-run", "--json"], { reportsRoot: w.reportsRoot, log: d.log, err: d.err, build: withLook([]) }), 0); + assert.deepEqual(JSON.parse(d.logs.join("\n")).clips[0].files, { vertical: "toms-toast.vertical.mp4" }); + } finally { + await rm(w.root, { recursive: true, force: true }); + } +}); + +import { buildShort } from "./verticalCli.mjs"; +import { linkSharedOut } from "./takeMaker.mjs"; +import { lstat, readlink } from "node:fs/promises"; + +test("the promo ends a short only on a whole clip, and a reel's outro is not added after it; a take's empty clips-raw becomes the link", async () => { + const w = await world(); + try { + const m = JSON.parse(await readFile(path.join(w.dir, "video.manifest.json"), "utf8")); + m.render.promo = { name: "Example Channel", url: "https://example.org/c" }; + m.timeline.push({ type: "post", id: "p1", post: "x/1", platform: "x", author: "A", handle: "a", date: "2026-01-01T00:00:00Z", text: "a post" }); + await writeFile(path.join(w.dir, "video.manifest.json"), JSON.stringify(m)); + const ends = await buildShort({ project: "proj", take: "kit", items: ["m01", "w01"], dryRun: true }, { reportsRoot: w.reportsRoot }); + assert.equal(ends.dryRun.promo, true); + const post = await buildShort({ project: "proj", take: "kit", items: ["w01", "p1"], dryRun: true }, { reportsRoot: w.reportsRoot }); + assert.equal(post.dryRun.promo, false); + assert.match(post.dryRun.notes.join(), /ends on p1, a post: no channel promo/); + // An empty real out/clips-raw (a failed build's) is replaced by the link to the project's. + await mkdir(path.join(w.dir, "out", "clips-raw"), { recursive: true }); + await writeFile(path.join(w.dir, "out", "clips-raw", "v_0.00-9.00.mp4"), "x"); + const takeOut = path.join(w.dir, "takes", "kit", "out"); + await mkdir(path.join(takeOut, "clips-raw"), { recursive: true }); + await linkSharedOut(w.dir, takeOut); + assert.ok((await lstat(path.join(takeOut, "clips-raw"))).isSymbolicLink()); + assert.equal(await readlink(path.join(takeOut, "clips-raw")), path.join(w.dir, "out", "clips-raw")); + } finally { + await rm(w.root, { recursive: true, force: true }); + } +}); diff --git a/umtool/lib/report/shortsCli.mjs b/umtool/lib/report/shortsCli.mjs @@ -16,7 +16,7 @@ import path from "node:path"; import { REPORTS_ROOT, resolveProject } from "../projects/core.mjs"; import { kindMakesTakes } from "../projects/kinds.mjs"; import { deliverableDir } from "./storage.mjs"; -import { BATCH_FILE, BATCH_FORMATS, FORMAT_NAMES, againOf, asideName, assignNames, batchDirName, batchItems, knobsForFormat, parseFormats, rowAfter, snapshotOf } from "./shortsBatch.mjs"; +import { BATCH_FILE, BATCH_FORMATS, FORMAT_NAMES, againOf, asideName, assignNames, batchDirName, batchItems, knobsForFormat, parseFormats, rowAfter, safeName, snapshotOf } from "./shortsBatch.mjs"; import { CliError, buildShort, isRefusal, knobsOfFlags, promoOptionsOf, takeManifestOf } from "./verticalCli.mjs"; export const SHORTS_USAGE = [ @@ -124,7 +124,8 @@ export async function shortsCommand(args, { reportsRoot = REPORTS_ROOT, log = co const projectManifest = await readJson(path.join(dir, "video.manifest.json")); const projectById = new Map((projectManifest?.timeline ?? []).filter((e) => typeof e?.id === "string").map((e) => [e.id, e])); const priorRows = new Map((Array.isArray(prior?.clips) ? prior.clips : []).filter((c) => isObj(c) && typeof c.id === "string").map((c) => [c.id, c])); - const priorNames = Object.fromEntries([...priorRows.values()].filter((c) => typeof c.name === "string").map((c) => [c.id, c.name])); + // A name read back is kept only when it is a plain file name of this folder (a record edited by hand is not trusted). + const priorNames = Object.fromEntries([...priorRows.values()].filter((c) => safeName(c.name)).map((c) => [c.id, c.name])); // A clip's name reads its PROJECT entry (a pinned `name`, a title set after the take), over the take's. const names = assignNames(entries.map((e) => ({ ...e, ...(projectById.get(e.id) ?? {}) })), priorNames); const caps = { @@ -143,6 +144,7 @@ export async function shortsCommand(args, { reportsRoot = REPORTS_ROOT, log = co id: e.id, name: names[e.id], title: projectById.get(e.id)?.title ?? e.title ?? null, knobs: ag ? ag.knobs : knobs, snapshot: ag?.snapshot ?? snapshotOf(projectById.get(e.id) ?? e, PROJECT_KEYS), + look: ag?.look ?? null, files: Object.fromEntries(fs.map((f) => [f, `${names[e.id]}.${f}.mp4`])), }; }); @@ -170,10 +172,11 @@ export async function shortsCommand(args, { reportsRoot = REPORTS_ROOT, log = co const file = path.join(outDir, c.files[f]); const base = { id: c.id, name: c.name, title: c.title, format: f, knobs: c.knobs, snapshot: c.snapshot }; let row; + let aside = null; try { if (existsSync(file)) { if (!replace) throw new CliError(`${c.files[f]} is there — --replace to make it again (the old one set aside)`); - const aside = asideName(file); + aside = asideName(file); await rename(file, aside); await rename(file.replace(/\.mp4$/, ".json"), aside.replace(/\.mp4$/, ".json")).catch(() => {}); } @@ -185,13 +188,19 @@ export async function shortsCommand(args, { reportsRoot = REPORTS_ROOT, log = co project: r.project.id, take, items: [c.id], knobs: { ...fk.knobs, maxSeconds: caps[f] }, name: "shorts", out: file, landscape: BATCH_FORMATS[f].landscape, desktop: BATCH_FORMATS[f].desktop, overrides: { [c.id]: c.snapshot }, ...(promoKnob === false ? { promo: false } : promoKnob && typeof promoKnob === "object" ? { promoKnobs: promoKnob } : {}), ...(coldKnob === false ? { coldOpen: false } : {}), + ...(c.look ? { look: c.look } : {}), }, { reportsRoot, say }, ); const rec = "record" in done ? done.record : null; - row = rowAfter(record.clips.find((x) => x.id === c.id) ?? null, { ...base, file: c.files[f], seconds: rec?.seconds ?? null, notes: [...(fk.note ? [fk.note] : []), ...(rec?.notes ?? [])] }); + row = rowAfter(record.clips.find((x) => x.id === c.id) ?? null, { ...base, file: c.files[f], seconds: rec?.seconds ?? null, notes: [...(fk.note ? [fk.note] : []), ...(rec?.notes ?? [])], look: rec?.look ?? null }); } catch (e) { if (!(e instanceof Error)) throw e; + // A rebuild that failed puts the old file back where it was (and its record). + if (aside && !existsSync(file) && existsSync(aside)) { + await rename(aside, file).catch(() => {}); + await rename(aside.replace(/\.mp4$/, ".json"), file.replace(/\.mp4$/, ".json")).catch(() => {}); + } failed += 1; err(`shorts: ${c.id} ${f}: ${e.message}`); row = rowAfter(record.clips.find((x) => x.id === c.id) ?? null, { ...base, error: e.message, exists: existsSync(file) }); diff --git a/umtool/lib/report/stillGrab.mjs b/umtool/lib/report/stillGrab.mjs @@ -12,7 +12,7 @@ import { execFile } from "node:child_process"; import { mkdir, readdir, rename, rm, stat } from "node:fs/promises"; import path from "node:path"; import { promisify } from "node:util"; -import { FFMPEG_BIN } from "umtool-report-to-video/build-video"; +import { FFMPEG_BIN, FFPROBE_BIN } from "umtool-report-to-video/build-video"; import { resolveInRoots } from "../paths.mjs"; import { clipsOf } from "../projects/report.mjs"; import { windowsFor } from "./serve.mjs"; @@ -43,8 +43,9 @@ export const stillNameOf = (clip, seconds) => `still-${String(clip).replace(/[^A * @param {Record<string, any>} clip * @param {number} at */ -export async function stillSourceOf(project, clip, at) { +export async function stillSourceOf(project, clip, at, { preferTall = false, ffprobe = null } = {}) { const windows = await windowsFor(project, clip); + const found = []; for (const w of windows) { if (w.piecesOf) continue; const src = w.excerptOf ? { path: w.excerptOf.path, from: w.excerptOf.from } : { path: w.path, from: w.from }; @@ -53,9 +54,26 @@ export async function stillSourceOf(project, clip, at) { const abs = resolveInRoots(src.path); if (!abs) continue; if (!(await stat(abs).catch(() => null))?.isFile()) continue; - return { file: abs, offset: Math.max(0, at - src.from) }; + const hit = { file: abs, offset: Math.max(0, at - src.from) }; + if (!preferTall) return hit; + found.push(hit); } - return null; + if (!found.length) return null; + // The tallest picture of those that hold the second (a project fetching taller windows: render.tallWindows). + const heightOf = async (f) => { + const { stdout } = await execFileP(ffprobe ?? FFPROBE_BIN, ["-v", "error", "-select_streams", "v:0", "-show_entries", "stream=height", "-of", "csv=p=0", f]).catch(() => ({ stdout: "0" })); + return Number(String(stdout).trim()) || 0; + }; + let best = found[0]; + let bestH = await heightOf(best.file); + for (const f of found.slice(1)) { + const h = await heightOf(f.file); + if (h > bestH) { + best = f; + bestH = h; + } + } + return best; } /** @@ -69,12 +87,12 @@ export async function stillSourceOf(project, clip, at) { * @param {number} at a source second * @param {{ ffmpeg?: string, name?: string | null }} [opts] */ -export async function grabStill(project, manifest, clipId, at, { ffmpeg = FFMPEG_BIN, name = null } = {}) { +export async function grabStill(project, manifest, clipId, at, { ffmpeg = FFMPEG_BIN, name = null, preferTall = false } = {}) { const clip = clipsOf(manifest).find((e) => e.id === clipId); if (!clip) throw new StillRefused(`no clip ${clipId} in ${project.id}`, 404); const t = Number(at); if (!Number.isFinite(t) || t < 0) throw new StillRefused("at is a source second, 0 or more"); - const src = await stillSourceOf(project, clip, t); + const src = await stillSourceOf(project, clip, t, { preferTall }); if (!src) throw new StillRefused(`no fetched window of ${clip.video} holds ${t.toFixed(2)} s -- fetch ${clipId} first (umtool fetch ${project.id} --clips ${clipId})`, 409); const file = name ?? stillNameOf(clipId, t); if (!/^[A-Za-z0-9_.-]{1,120}\.png$/.test(file)) throw new StillRefused(`a still's name is letters, digits, . _ - and .png (got ${file})`); diff --git a/umtool/lib/report/takeMaker.mjs b/umtool/lib/report/takeMaker.mjs @@ -44,7 +44,7 @@ // pages import the parts they show (the styles, the staleness check). import { resolvePresetLayers } from "umtool-report-to-video/presets"; import { createHash } from "node:crypto"; -import { link, lstat, mkdir, readFile, rename, rm, stat, symlink, unlink, writeFile } from "node:fs/promises"; +import { link, lstat, mkdir, readFile, readdir, rename, rm, rmdir, stat, symlink, unlink, writeFile } from "node:fs/promises"; import path from "node:path"; import { pathToFileURL } from "node:url"; import { mergePatch } from "umtool-report-to-video/montage-styles"; @@ -504,7 +504,12 @@ export async function linkSharedOut(projectDir, takeOut) { const src = path.join(projectDir, "out", name); const dst = path.join(takeOut, name); if (!(await stat(src).then((s) => s.isDirectory(), () => false))) continue; - if (await exists(dst)) continue; + if (await exists(dst)) { + // An EMPTY real directory (a build that failed before its first fetch made it) holds nothing: the link replaces it. + const empty = await lstat(dst).then((st) => st.isDirectory() && !st.isSymbolicLink(), () => false) && (await readdir(dst).catch(() => [null])).length === 0; + if (!empty) continue; + await rmdir(dst); + } await symlink(src, dst); linked.push(name); } diff --git a/umtool/lib/report/verticalCli.mjs b/umtool/lib/report/verticalCli.mjs @@ -22,6 +22,14 @@ import { takesDirOf } from "./takes.mjs"; import { readTrailerBeats, reelFileOf } from "./trailerBeats.mjs"; import { resolveOutro } from "umtool-report-to-video/outro"; import { PIPELINE_DIR, UMTOOL_DIR } from "./driver.mjs"; +import { ensureWriteDir } from "./storage.mjs"; + +/** + * The look keys a short is built from that a batch's record keeps (lib/report/shortsBatch.mjs `--again`): what the + * render draws a per-clip build with, as the take resolved them then. + */ +export const LOOK_SNAPSHOT_KEYS = Object.freeze(["palette", "fontRegular", "fontBold", "fps", "captions", "loudness", "qr", "vertical", "desktop", "promo", "zooms", "tallWindows", "maxHeightSource", "blur", "transition", "transitionStyle", "headerHeight", "footerHeight"]); +export const lookSnapshotOf = (render) => Object.fromEntries(LOOK_SNAPSHOT_KEYS.filter((k) => render?.[k] !== undefined).map((k) => [k, render[k]])); export const VERTICAL_USAGE = [ "usage: umtool vertical <project> --take <t> (--reel <r> | --beats FILE | --items <id>,<id>…)", @@ -218,7 +226,8 @@ export function shortOptionsOf(p) { * * @param {{ project: string, take?: string | null, reel?: string | null, beats?: string | null, items?: string[] | null, * knobs?: Record<string, any>, name?: string | null, out?: string | null, reframe?: boolean, landscape?: boolean, - * dryRun?: boolean, intro?: boolean, noIntro?: boolean, noOutro?: boolean, overrides?: Record<string, Record<string, any>> | null }} o + * dryRun?: boolean, intro?: boolean, noIntro?: boolean, noOutro?: boolean, overrides?: Record<string, Record<string, any>> | null, + * desktop?: boolean, promo?: boolean, promoKnobs?: Record<string, number>, coldOpen?: boolean, look?: Record<string, any> | null }} o * @param {{ reportsRoot?: string, say?: (s: string) => void }} [ctx] * @returns {Promise<{ dryRun: Record<string, any> } | { record: Record<string, any> }>} */ @@ -251,14 +260,16 @@ export async function buildShort(o, { reportsRoot = REPORTS_ROOT, say = () => {} if (!take) throw new CliError("--take <t>: the take whose items the short is cut from"); if (!/^[a-z0-9][a-z0-9-]*$/.test(take)) throw new CliError(`--take ${take}: a take id`); const takeDir = path.join(takesDirOf(dir), take); - const takeManifest = await takeManifestOf(dir, take); + const takeManifest0 = await takeManifestOf(dir, take); + // A rebuild from a batch's record (`o.look`, LOOK_SNAPSHOT_KEYS) lays the look it was built with over the take's. + const takeManifest = isObj(o.look) ? { ...takeManifest0, render: { ...(takeManifest0.render ?? {}), ...o.look } } : takeManifest0; const projectManifest = await readJson(path.join(dir, "video.manifest.json")); const outDir = path.join(takeDir, "out"); const sourced = path.join(outDir, "sourced"); const schedule = await readJson(path.join(sourced, "schedule.json")); const knobs = o.knobs ?? {}; // A desktop build reads its own knobs (render.desktop: a corner a short does not have is one it does). - const errors = o.desktop ? [] : V.validateVerticalRender({ render: { format: "vertical", vertical: { ...(takeManifest.render?.vertical ?? {}), ...knobs } } }); + const errors = o.desktop || o.landscape ? [] : V.validateVerticalRender({ render: { format: "vertical", vertical: { ...(takeManifest.render?.vertical ?? {}), ...knobs } } }); if (errors.length) throw new CliError(errors.join("; ")); const name = P.shortName({ reel, name: o.name ?? null }); const reframe = !!o.reframe; @@ -277,7 +288,7 @@ export async function buildShort(o, { reportsRoot = REPORTS_ROOT, say = () => {} if ((o.promo === true || o.promoKnobs) && !takeManifest.render?.promo) { throw new CliError(`--promo: the take sets no channel promo -- umtool look ${r.project.id} promo='{"name":"…","url":"https://…"}' (or a take's patch)`); } - const promoArgs = o.promo === false ? ["--no-promo"] : o.promoKnobs ? ["--promo-knobs", JSON.stringify(o.promoKnobs)] : []; + const promoArgs0 = o.promo === false ? ["--no-promo"] : o.promoKnobs ? ["--promo-knobs", JSON.stringify(o.promoKnobs)] : []; const slug = takeManifest.slug ?? r.project.id.split("/").pop(); const outFile = o.out ? path.resolve(o.out) : path.join(outDir, `${slug}.${name}.${tag}${landscape || desktop ? "" : ".vertical"}.mp4`); const cuts = new Map(); @@ -302,15 +313,29 @@ export async function buildShort(o, { reportsRoot = REPORTS_ROOT, say = () => {} const stacked = !desktop && !landscape && !reframe && V.stackedDeckWanted({ ...(takeManifest.render ?? {}), format: "vertical", vertical: { ...(takeManifest.render?.vertical ?? {}), ...knobs } }); const coldOpens = o.coldOpen !== false && !landscape && !reframe && !stacked; const plan = P.planVerticalCut({ timeline: takeManifest.timeline ?? [], beats, items, schedule, cuts, project, coldOpens }); + // The channel promo ends the short only when its last piece is a whole clip (promo-card.mjs): then a reel's outro + // card is not added after it (one ending, said). + const notes = []; + const lastPiece = plan.pieces.at(-1); + const lastEntry = lastPiece ? plan.timeline.find((e) => e.id === lastPiece.id) : null; + const promoEnds = !landscape && !reframe && !stacked && o.promo !== false && !!takeManifest.render?.promo && lastEntry?.type === "clip" && lastEntry.promo !== false && lastPiece.to === null && !lastPiece.from; + const promoArgs2 = !landscape && !reframe && !stacked && o.promo !== false && takeManifest.render?.promo && !promoEnds ? ["--no-promo"] : []; + if (!promoEnds && promoArgs2.length && lastEntry) notes.push(`the short ends on ${lastEntry.id}${lastEntry.type === "clip" ? " cut short of its end" : `, a ${lastEntry.type}`}: no channel promo (it ends a whole clip)`); + if (promoEnds && outro) { + notes.push(`the channel promo ends the short: the reel's outro card is not added after it`); + outro = null; + } if (o.dryRun) { - return { dryRun: { project: r.project.id, take, name, layout: tag, wouldWrite: outFile, intro: introSpec ? (introSpec === true ? "the take's render.intro, else the default" : introSpec) : null, outro: outro ? { title: outro.title, text: outro.text, image: outro.image, seconds: outro.seconds } : null, pieces: plan.pieces, items: plan.timeline.map((e) => ({ id: e.id, type: e.type, start: e.start, end: e.end })) } }; + return { dryRun: { project: r.project.id, take, name, layout: tag, wouldWrite: outFile, intro: introSpec ? (introSpec === true ? "the take's render.intro, else the default" : introSpec) : null, outro: outro ? { title: outro.title, text: outro.text, image: outro.image, seconds: outro.seconds } : null, pieces: plan.pieces, items: plan.timeline.map((e) => ({ id: e.id, type: e.type, start: e.start, end: e.end })), promo: promoEnds, notes } }; } const started = Date.now(); // The project's fetched windows (and narration) are the take's too, as a made take's are (takeMaker.mjs // linkSharedOut): a draft take that was never rendered has no out/clips-raw of its own to cut from. if (!reframe) { - await mkdir(outDir, { recursive: true }); - await (await import("./takeMaker.mjs")).linkSharedOut(dir, outDir); + // Through ensureWriteDir: a tiered project's out/ is a link to the media root, never replaced by a directory. + const { linkSharedOut } = await import("./takeMaker.mjs"); + await linkSharedOut(dir, await ensureWriteDir(outDir)); + if (landscape) await linkSharedOut(dir, await ensureWriteDir(path.join(takeDir, `out-landscape-${name}`))); } let made; if (reframe) { @@ -337,7 +362,7 @@ export async function buildShort(o, { reportsRoot = REPORTS_ROOT, say = () => {} const sections = V.sectionTitlesOf(takeManifest); const argv = [ process.execPath, path.join(PIPELINE_DIR, "build-video.mjs"), renderPath, "--out", outDir, - "--skip-fetch", "--no-chapters", "--desktop", "--desktop-knobs", JSON.stringify(dknobs), "--vertical-work", work, "--vertical-out", built, ...promoArgs, + "--skip-fetch", "--no-chapters", "--desktop", "--desktop-knobs", JSON.stringify(dknobs), "--vertical-work", work, "--vertical-out", built, ...(promoArgs2.length ? promoArgs2 : promoArgs0), "--vertical-sections", JSON.stringify(Object.fromEntries(plan.timeline.map((e) => [e.id, sections.get(e.id.replace(/~(?:\d+|co)$/, "")) ?? null]))), ]; say(`vertical --desktop: building ${plan.timeline.length} item(s) 16:9 in the heavy slot …`); @@ -359,7 +384,7 @@ export async function buildShort(o, { reportsRoot = REPORTS_ROOT, say = () => {} const built = path.join(outDir, `${slug}.${name}.${tag}.vertical-build.mp4`); const argv = [ process.execPath, path.join(PIPELINE_DIR, "build-video.mjs"), renderPath, "--out", outDir, - "--skip-fetch", "--no-chapters", "--vertical", "--vertical-knobs", JSON.stringify(knobs), "--vertical-work", work, "--vertical-out", built, ...promoArgs, + "--skip-fetch", "--no-chapters", "--vertical", "--vertical-knobs", JSON.stringify(knobs), "--vertical-work", work, "--vertical-out", built, ...(promoArgs2.length ? promoArgs2 : promoArgs0), // The hook "section" names a clip's section in the WHOLE take (each planned entry under its source's id). "--vertical-sections", JSON.stringify(Object.fromEntries(plan.timeline.map((e) => [e.id, sections.get(e.id.replace(/~(?:\d+|co)$/, "")) ?? null]))), ]; @@ -396,7 +421,8 @@ export async function buildShort(o, { reportsRoot = REPORTS_ROOT, say = () => {} const record = { version: 1, kind: "vertical-short", project: r.project.id, take, name, layout: tag, reframe, knobs, ...(o.promo === false ? { promo: false } : o.promoKnobs ? { promo: o.promoKnobs } : {}), ...(o.coldOpen === false ? { coldOpen: false } : {}), pieces: plan.pieces, ...(wrapped.intro ? { intro: wrapped.intro } : {}), ...(wrapped.outro ? { outro: wrapped.outro } : {}), seconds: made.seconds, loudness: made.loudness ?? null, - notes: V.verticalNotes({ format: "vertical", vertical: desktop ? { maxSeconds: V.desktopKnobs({ desktop: { ...(takeManifest.render?.desktop ?? {}), ...dknobs } }).maxSeconds } : knobs }, made.seconds), out: outFile, + look: lookSnapshotOf(takeManifest.render), + notes: [...notes, ...V.verticalNotes({ format: "vertical", vertical: desktop ? { maxSeconds: V.desktopKnobs({ desktop: { ...(takeManifest.render?.desktop ?? {}), ...dknobs } }).maxSeconds } : knobs }, made.seconds)], out: outFile, madeAt: new Date().toISOString(), buildSeconds: Math.round((Date.now() - started) / 1000), }; await writeFile(outFile.replace(/\.mp4$/, ".json"), JSON.stringify(record, null, 2) + "\n", "utf8"); diff --git a/umtool/report-to-video/build-video.mjs b/umtool/report-to-video/build-video.mjs @@ -7080,8 +7080,10 @@ export async function buildVideo({ manifestPath, opts = {}, out, only, fetchOnly if (errors.length) throw new Error(`promo: ${errors.join("; ")}`); } if (dirs.vertical && !dirs.vertical.stacked && render.promo) { - const clips = (manifest.timeline ?? []).filter((e) => e?.type === "clip"); - dirs.vertical.promoFor = clips.length ? clips[clips.length - 1].id : null; + // The card ends the build: only when its LAST entry is a clip (a post item last would put the card mid-short). + const last = (manifest.timeline ?? []).at(-1); + dirs.vertical.promoFor = last?.type === "clip" ? last.id : null; + if (last && last.type !== "clip") EMIT("note", { message: `the build ends on ${last.id}, a ${last.type ?? "non-clip"}: the channel promo ends a clip, so it is left out` }); dirs.vertical.manifestDir = manifestDir; } diff --git a/umtool/report-to-video/clip-kit.test.mjs b/umtool/report-to-video/clip-kit.test.mjs @@ -106,8 +106,14 @@ test("a moment code to a Kick or Twitch VOD is a NOTE naming the expiry; a chann const moment = lintManifest({ ...base, render: { ...base.render, qr: { links: "moment" } }, timeline: [clip({ citeUrl: KICK })] }, { validators: false }); assert.ok(moment.warnings.some((w) => /Kick deletes VODs/.test(w)), moment.warnings.join("\n")); assert.equal(moment.errors.length, 0, moment.errors.join("\n")); + // A citeUrl that is itself a Kick VOD is noted too (review); an archive link is not. const cite = lintManifest({ ...base, timeline: [clip({ citeUrl: KICK })] }, { validators: false }); - assert.ok(!cite.warnings.some((w) => /deletes VODs/.test(w))); + assert.ok(cite.warnings.some((w) => /Kick deletes VODs/.test(w)), cite.warnings.join("\n")); + const archive = lintManifest({ ...base, provenance: { siteOrigin: "https://archive.example", channelSlug: "chan" }, timeline: [clip({ channel: "chan" })] }, { validators: false }); + assert.ok(!archive.warnings.some((w) => /deletes VODs/.test(w))); + // A stacked-deck 9:16 cut draws no vertical code: none is listed. + const stacked = { ...base, render: { width: 1080, height: 1920, format: "vertical", vertical: { qr: true, deck: "stacked" }, chrome: { engine: "hyperframes", layout: "deck", deck: { qr: { show: false } } } }, timeline: [clip({ citeUrl: KICK })] }; + assert.ok(!qrsOf(stacked).some((q) => /\(its QR\)/.test(q.where))); // A short's code is measured and noted too. const short = lintManifest({ ...base, render: { width: 1080, height: 1920, format: "vertical", qr: false, vertical: { qr: true } }, timeline: [clip({ citeUrl: KICK })] }, { validators: false }); assert.ok(short.warnings.some((w) => /timeline w01 \(its QR\): its QR links a Kick VOD/.test(w)), short.warnings.join("\n")); diff --git a/umtool/report-to-video/lint.mjs b/umtool/report-to-video/lint.mjs @@ -223,7 +223,7 @@ export function qrsOf(manifest, { only = null, metaOf = null } = {}) { return out; } // A 9:16 short's code (clip-kit.mjs, render.vertical.qr): each clip's, at the top of the safe area. - if (verticalOn(render)) { + if (verticalOn(render) && !stackedOn(render)) { for (const e of timeline) { const vq = e.type === "clip" ? verticalQrOf(e, render) : null; if (!vq || (e.src != null && !e.citeUrl)) continue; @@ -558,7 +558,9 @@ export function lintManifest(manifest, { `${q.where}: ${per.toFixed(2)} px per module at 720p ` + `(${q.px === null ? `scale ${q.perModule}` : `${q.px} px`} on a ${height}p frame, a version-${version} code, ${modules} modules)`; // A code that links a stream's VOD at its second, on a platform that deletes VODs: a note (clip-kit.mjs). - if (q.links === "moment") { + // A code whose link is a Kick or Twitch VOD -- the moment, or a citeUrl that is one -- stops opening once the VOD + // is deleted: a note (clip-kit.mjs expiringLinkNote). + if (q.source === "entry") { const n = expiringLinkNote(q.url, q.where); if (n) warnings.push(n); } diff --git a/umtool/report-to-video/promo-card.mjs b/umtool/report-to-video/promo-card.mjs @@ -30,7 +30,7 @@ // The card is drawn by a browser (Playwright's chromium, as a post card is) from promoCardHtml, once per key, into the // build's cards dir. PURE above renderPromoCard. import { execFile } from "node:child_process"; -import { createHash } from "node:crypto"; +import { createHash, randomBytes } from "node:crypto"; import { access, mkdir, readFile, rename, rm, writeFile } from "node:fs/promises"; import path from "node:path"; import { pathToFileURL } from "node:url"; @@ -55,6 +55,8 @@ export const PROMO_NAME_LINE_MAX = 24; export const PROMO_KICKER_MAX = 40; /** The clip's sound fades out over its last this-many seconds, before the card's silence. */ export const PROMO_SOUND_OUT = 0.15; +/** The code's quiet zone, in modules (the QR standard's four). */ +export const PROMO_QR_QUIET = 4; /** A platform's own colour, for the url's host (the operator's card: Kick's green). */ export const PROMO_LINK_COLOURS = Object.freeze({ "kick.com": "#53fc18", "twitch.tv": "#a970ff", "youtube.com": "#ff4e45", "rumble.com": "#85c742" }); const IMAGE = /\.(png|jpe?g|webp)$/i; @@ -191,7 +193,8 @@ export function promoPalette(render, promo) { const own = isObj(promo?.palette) ? promo.palette : {}; const out = { ...base, ...Object.fromEntries(Object.entries(own).filter(([, c]) => ok(c))) }; out.link = ok(own.link) ?? linkColourOf(promo?.url) ?? out.accent; - out.plate = ok(own.plate) ?? out.ink; + // The code's plate: WHITE whatever the palette (a scanner wants black on white), unless the promo names one. + out.plate = ok(own.plate) ?? "#ffffff"; out.lift = mixHex(out.ground, out.accent, 0.12); return out; } @@ -267,7 +270,7 @@ h1 .u { color: ${palette.accent}; } .v .row { flex-direction: column; gap: ${px(4)}; } .url { font-size: ${px(sz.u)}; font-weight: 600; white-space: nowrap; } .url b { color: ${palette.link}; font-weight: 700; } -.qr { background: ${palette.plate}; padding: ${px(1.6)}; border-radius: ${px(1.6)}; width: ${px(sz.q)}; height: ${px(sz.q)}; flex: none; } +.qr { background: ${palette.plate}; padding: 0; border-radius: ${px(1.2)}; width: ${px(sz.q)}; height: ${px(sz.q)}; flex: none; overflow: hidden; } .qr img { width: 100%; height: 100%; display: block; image-rendering: pixelated; } </style></head> <body data-promo-ready="0"> @@ -352,13 +355,15 @@ export async function renderPromoCard({ promo, render, width, height, dir, manif const file = path.join(/* turbopackIgnore: true */ dir, `promo-${key}.png`); const meta = `${file}.json`; if ((await exists(file)) && (await exists(meta))) return { file, key, cached: true, ...JSON.parse(await readFile(/* turbopackIgnore: true */ meta, "utf8")) }; - const work = path.join(/* turbopackIgnore: true */ dir, `.promo-${key}-${process.pid}`); + // Its own work dir per call (two draws of one card at once -- the page asks for both shapes together -- never share one). + const work = path.join(/* turbopackIgnore: true */ dir, `.promo-${key}-${process.pid}-${randomBytes(4).toString("hex")}`); await mkdir(/* turbopackIgnore: true */ work, { recursive: true }); try { let qrUrl = null; if (qrText) { const qrPng = path.join(/* turbopackIgnore: true */ work, "qr.png"); - await execFileP(process.env.QRENCODE_BIN ?? "qrencode", ["-o", qrPng, "-s", "10", "-m", "0", "-l", "M", "--", qrText]); + // A real quiet zone: four modules of white inside the plate (the code's own margin), the plate's corners round. + await execFileP(process.env.QRENCODE_BIN ?? "qrencode", ["-o", qrPng, "-s", "10", "-m", String(PROMO_QR_QUIET), "-l", "M", "--", qrText]); qrUrl = pathToFileURL(qrPng).href; } let portraitUrl = null; @@ -386,7 +391,9 @@ export async function renderPromoCard({ promo, render, width, height, dir, manif } finally { await browser.close(); } - await writeFile(/* turbopackIgnore: true */ meta, JSON.stringify({ scale }) + "\n"); + const metaTmp = path.join(/* turbopackIgnore: true */ work, "meta.json"); + await writeFile(/* turbopackIgnore: true */ metaTmp, JSON.stringify({ scale }) + "\n"); + await rename(/* turbopackIgnore: true */ metaTmp, meta); return { file, key, cached: false, scale }; } finally { await rm(/* turbopackIgnore: true */ work, { recursive: true, force: true }); diff --git a/umtool/report-to-video/promo-card.test.mjs b/umtool/report-to-video/promo-card.test.mjs @@ -47,7 +47,7 @@ test("a clip's promo: the cut's with its own timing over it; none for `promo: fa test("the colours: the cut's palette, the promo's over it, the url's host in its platform's colour", () => { const pal = promoPalette({ palette: { bg: "#12100c", fg: "#f6f1e6", accent: "#c8752a", amber: "#ffc860" } }, PROMO); - assert.deepEqual([pal.ground, pal.ink, pal.accent, pal.link, pal.plate], ["#12100c", "#f6f1e6", "#ffc860", "#53fc18", "#f6f1e6"]); + assert.deepEqual([pal.ground, pal.ink, pal.accent, pal.link, pal.plate], ["#12100c", "#f6f1e6", "#ffc860", "#53fc18", "#ffffff"], "the code's plate white whatever the palette"); // A streamer's own colours, for the card alone. const own = promoPalette({ palette: { bg: "#12100c", fg: "#f6f1e6", accent: "#c8752a" } }, { ...PROMO, url: "https://example.org/me", palette: { ground: "#001122", accent: "#ff00aa" } }); assert.deepEqual([own.ground, own.accent, own.link], ["#001122", "#ff00aa", "#ff00aa"]);