Archilyzer · Source

archilyzer

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

commit 2aaca270a98b3bda0abb24c86633996414aa0ebb
parent b08a6ca150b3d78710efa3bbef483b83bf9e1c66
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Sat, 21 Nov 2026 02:08:21 -0500

Merge lane/channel-title: a cut's own name for a channel

render.channelNames names a channel once for a whole cut (umtool look, Look panel); a clip's
channelTitle has a set key and a bench field. Order: clip, cut, record, sweep, slug.

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

Diffstat:
Acommon/lib/report/channelNames.d.mts | 11+++++++++++
Acommon/lib/report/channelNames.mjs | 109+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Acommon/lib/report/channelNames.test.ts | 70++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mcommon/lib/report/look.d.mts | 2+-
Mcommon/lib/report/look.mjs | 13+++++++++++--
Mcommon/lib/report/videoAssistOps.test.ts | 2+-
Mcommon/package.json | 1+
Meditor/CHANGELOG.md | 18++++++++++++++++++
Mumtool/app/api/report/clip/route.ts | 4++++
Mumtool/app/api/report/onscreen/route.ts | 2+-
Mumtool/app/api/report/render/route.ts | 11+++++++++--
Mumtool/app/api/report/window/route.ts | 2++
Mumtool/components/projects/ClipBench.tsx | 25+++++++++++++++++++------
Mumtool/components/projects/report/LookPanel.tsx | 61++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
Mumtool/docs/knobs.md | 45+++++++++++++++++++++++++++++++++++++++++++++
Mumtool/lib/projects/report.mjs | 43++++++++++++++++++++++++++++++++++++++++++-
Mumtool/lib/report/benchData.ts | 2++
Mumtool/lib/report/knobsCli.mjs | 40+++++++++++++++++++++++++++++++++++++---
Mumtool/lib/report/knobsCli.test.mjs | 48++++++++++++++++++++++++++++++++++++++++++++++++
Mumtool/lib/report/look.test.mjs | 2+-
Mumtool/lib/report/manifest.mjs | 19+++++++++++++++++--
Mumtool/lib/report/onscreen.mjs | 2+-
Mumtool/lib/report/verticalCli.mjs | 2+-
Mumtool/report-to-video/attribution.mjs | 41+++++++++++++++++++++++++++++++++++------
Mumtool/report-to-video/attribution.test.mjs | 40++++++++++++++++++++++++++++++++++++++++
Mumtool/report-to-video/build-video.mjs | 25+++++++++++++------------
Aumtool/report-to-video/channel-names.test.mjs | 86+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mumtool/report-to-video/deck.mjs | 21+++++++++++++--------
Mumtool/report-to-video/modules/analysis.mjs | 2+-
Mumtool/report-to-video/modules/panel.mjs | 4++--
Mumtool/report-to-video/outro.mjs | 11+++++++----
31 files changed, 706 insertions(+), 58 deletions(-)

diff --git a/common/lib/report/channelNames.d.mts b/common/lib/report/channelNames.d.mts @@ -0,0 +1,11 @@ +// Types for ./channelNames.mjs (lane channel-title): a cut's per-channel display name. + +type Render = Record<string, unknown> | null | undefined; + +export const CHANNEL_NAME_MAX: number; +export const CHANNEL_SLUG_RE: RegExp; +export function channelNameProblem(value: unknown): string | null; +export function channelNamesOf(render: Render): Record<string, unknown>; +export function validateChannelNames(manifest: unknown): string[]; +export function patchChannelNames(was: unknown, patch: unknown): Record<string, unknown> | null; +export function channelNamesWarnings(manifest: unknown): string[]; diff --git a/common/lib/report/channelNames.mjs b/common/lib/report/channelNames.mjs @@ -0,0 +1,109 @@ +// A CUT'S OWN NAME FOR A CHANNEL (lane channel-title): `render.channelNames`, +// `{ "<slug>": "<name>" }` -- what every clip of that channel is called on +// screen in this cut, whatever the record of each recording says. One +// channel's two recordings can carry two uploader names (an old one and the +// current one); this says once which to show, without touching a clip. +// +// The resolver is umtool's report-to-video/attribution.mjs `channelName`: +// a clip's own `channelTitle` > this > the record's uploader name > the +// sweep's display name > the slug. This module holds the rules every writer +// and reader checks (look.mjs applyLookPatch / validateLook, umtool's clip +// writer for a clip's `channelTitle`), so the editor's video assistant, the +// CLI, the Look panel and the build refuse the same names. +// +// PURE: no fs. Plain ESM with a .d.mts beside it. + +const isObj = (v) => !!v && typeof v === "object" && !Array.isArray(v); + +/** The longest name a channel is given on screen, in characters. */ +export const CHANNEL_NAME_MAX = 60; + +/** A channel slug as a clip's `channel` names it: no space, no slash, not empty. */ +export const CHANNEL_SLUG_RE = /^[^\s/]+$/; + +// C0 controls (newline and tab among them), DEL and the C1 controls. +// eslint-disable-next-line no-control-regex +const CONTROL_RE = /[\u0000-\u001f\u007f-\u009f]/; + +/** + * Why `value` cannot be a channel's name on screen, or null when it can: words + * (a string), not empty once trimmed, at most CHANNEL_NAME_MAX characters, no + * control character (a newline would break the one line the header is). + * @param {unknown} value + * @returns {string | null} + */ +export function channelNameProblem(value) { + if (typeof value !== "string") return `a channel's name is words, not ${JSON.stringify(value)}`; + const v = value.trim(); + if (!v) return "a channel's name is empty (clear it instead)"; + if (CONTROL_RE.test(value)) return "a channel's name has a control character (a newline, a tab …): one line of plain words"; + const n = [...v].length; + if (n > CHANNEL_NAME_MAX) return `a channel's name is ${n} characters (at most ${CHANNEL_NAME_MAX})`; + return null; +} + +/** `render.channelNames` as a plain map (an empty one when absent or malformed). */ +export function channelNamesOf(render) { + return isObj(render?.channelNames) ? render.channelNames : {}; +} + +/** + * `render.channelNames`: absent, or an object of slug → name, each name by + * channelNameProblem's rules. + * @returns {string[]} + */ +export function validateChannelNames(manifest) { + const v = manifest?.render?.channelNames; + if (v === undefined || v === null) return []; + if (!isObj(v)) return ['render.channelNames must be an object {"<channel slug>": "<name>"}']; + const errors = []; + for (const [slug, name] of Object.entries(v)) { + if (!CHANNEL_SLUG_RE.test(slug)) { + errors.push(`render.channelNames: ${JSON.stringify(slug)} is not a channel slug (no spaces, no slash)`); + continue; + } + const p = channelNameProblem(name); + if (p) errors.push(`render.channelNames.${slug}: ${p}`); + } + return errors; +} + +/** + * A patch of `render.channelNames` over what it holds: each key set (a string + * trimmed), a key null dropping one; `null` drops them all. Returns the new + * map, or null when none is left (written as no key). A value that is not a + * string is kept as given, for validateChannelNames to name. + * @param {unknown} was + * @param {unknown} patch + * @returns {Record<string, unknown> | null} + */ +export function patchChannelNames(was, patch) { + if (patch === null || patch === undefined) return null; + if (!isObj(patch)) return /** @type {any} */ (patch); + const next = { ...(isObj(was) ? was : {}) }; + for (const [k, v] of Object.entries(patch)) { + if (v === null || v === undefined) delete next[k]; + else next[k] = typeof v === "string" ? v.trim() : v; + } + return Object.keys(next).length ? next : null; +} + +/** + * The names given to a channel no clip of the cut is from -- a typo in the + * slug, or a clip since removed. Warned about, never refused: a name kept for + * a clip about to come back is harmless. + * @returns {string[]} + */ +export function channelNamesWarnings(manifest) { + const names = channelNamesOf(manifest?.render); + const keys = Object.keys(names); + if (!keys.length) return []; + const own = manifest?.provenance?.channelSlug ?? null; + const used = new Set( + (Array.isArray(manifest?.timeline) ? manifest.timeline : []) + .filter((e) => isObj(e) && e.type === "clip") + .map((e) => e.channel ?? own) + .filter(Boolean), + ); + return keys.filter((k) => !used.has(k)).map((k) => `render.channelNames.${k}: no clip of this cut is from "${k}" -- kept, but it names nothing (${[...used].join(", ") || "no clips"})`); +} diff --git a/common/lib/report/channelNames.test.ts b/common/lib/report/channelNames.test.ts @@ -0,0 +1,70 @@ +// channelNames.mjs (lane channel-title): a cut's per-channel display name +// (`render.channelNames`), its rules, its merge patch and its warnings. + +import { test } from "node:test"; +import assert from "node:assert/strict"; +import { + CHANNEL_NAME_MAX, + channelNameProblem, + channelNamesWarnings, + patchChannelNames, + validateChannelNames, +} from "./channelNames.mjs"; +import { LOOK_KEYS, applyLookPatch, lookOf } from "./look.mjs"; + +test("a name: a string, at most 60 characters, no control character, no newline", () => { + assert.equal(CHANNEL_NAME_MAX, 60); + assert.equal(channelNameProblem("Synth Channel"), null); + assert.equal(channelNameProblem("x".repeat(60)), null); + assert.match(String(channelNameProblem("x".repeat(61))), /at most 60/); + assert.match(String(channelNameProblem("Synth\nChannel")), /control character/); + assert.match(String(channelNameProblem("Synth\tChannel")), /control character/); + assert.match(String(channelNameProblem("Synth\u0007Channel")), /control character/); + assert.match(String(channelNameProblem(" ")), /empty/); + assert.match(String(channelNameProblem(42)), /words/); +}); + +test("validateChannelNames: absent is fine; a slug per key, a name per value", () => { + assert.deepEqual(validateChannelNames({ render: {} }), []); + assert.deepEqual(validateChannelNames({ render: { channelNames: { "synth-chan": "Synth Channel" } } }), []); + assert.match(validateChannelNames({ render: { channelNames: ["Synth Channel"] } }).join(), /an object/); + assert.match(validateChannelNames({ render: { channelNames: { "a b": "Synth" } } }).join(), /not a channel slug/); + assert.match(validateChannelNames({ render: { channelNames: { "synth-chan": "a\nb" } } }).join(), /render\.channelNames\.synth-chan.*control character/); +}); + +test("patchChannelNames: merged over what it holds, a key null drops one, null drops all, trimmed", () => { + assert.deepEqual(patchChannelNames(undefined, { a: " Synth A " }), { a: "Synth A" }); + assert.deepEqual(patchChannelNames({ a: "Synth A" }, { b: "Synth B" }), { a: "Synth A", b: "Synth B" }); + assert.equal(patchChannelNames({ a: "Synth A" }, { a: null }), null, "empty is no key"); + assert.equal(patchChannelNames({ a: "Synth A" }, null), null); + // A value that is not words is kept as given, for the validator to name. + assert.deepEqual(patchChannelNames({}, { a: 7 }), { a: 7 }); +}); + +test("the look writes it: a LOOK key, merged, checked", () => { + assert.ok(LOOK_KEYS.includes("channelNames")); + const m = { render: { fps: 30 }, timeline: [{ type: "clip", id: "c1", channel: "synth-chan", video: "v", start: 0, end: 1 }] }; + const a = applyLookPatch(m, { channelNames: { "synth-chan": "Synth Channel" } }); + assert.deepEqual(a.errors, []); + assert.deepEqual(lookOf(a.render).channelNames, { "synth-chan": "Synth Channel" }); + const b = applyLookPatch({ ...m, render: a.render }, { channelNames: { "synth-chan": null } }); + assert.deepEqual(b.errors, []); + assert.equal("channelNames" in b.render, false); + const bad = applyLookPatch(m, { channelNames: { "synth-chan": "Synth\u0000" } }); + assert.match(bad.errors.join(), /control character/); +}); + +test("channelNamesWarnings: a slug no clip of the cut uses is named, not refused", () => { + const m = { + provenance: { channelSlug: "own-chan" }, + render: { channelNames: { "synth-chan": "Synth Channel", "own-chan": "Own", "gone-chan": "Gone" } }, + timeline: [ + { type: "clip", id: "c1", channel: "synth-chan", video: "v", start: 0, end: 1 }, + { type: "clip", id: "c2", video: "w", start: 0, end: 1 }, + ], + }; + const w = channelNamesWarnings(m); + assert.equal(w.length, 1); + assert.match(w[0], /gone-chan/); + assert.deepEqual(channelNamesWarnings({ render: {} }), []); +}); diff --git a/common/lib/report/look.d.mts b/common/lib/report/look.d.mts @@ -4,7 +4,7 @@ type Manifest = { render?: Record<string, unknown> | null; timeline?: unknown[] } & Record<string, unknown>; type Render = Record<string, unknown> | null | undefined; -export type LookKey = "headerHeight" | "footerHeight" | "qr" | "transition" | "transitionStyle" | "loudness" | "captions" | "room" | "slide" | "blur" | "intro" | "format" | "vertical" | "mode" | "basic" | "tallWindows" | "desktop" | "promo" | "zooms" | "censor" | "gapCue"; +export type LookKey = "headerHeight" | "footerHeight" | "qr" | "transition" | "transitionStyle" | "loudness" | "captions" | "room" | "slide" | "blur" | "intro" | "format" | "vertical" | "mode" | "basic" | "tallWindows" | "desktop" | "promo" | "zooms" | "censor" | "gapCue" | "channelNames"; export const LOOK_KEYS: readonly LookKey[]; export const QR_CORNERS: readonly ["br", "bl", "tr", "tl"]; export const QR_LINK_VALUES: readonly ["cite", "moment", "channel"]; diff --git a/common/lib/report/look.mjs b/common/lib/report/look.mjs @@ -21,6 +21,8 @@ import { introPatchValue, validateIntro } from "./intro.mjs"; import { CLIP_OWN_LAYOUTS, validateVerticalFormat } from "./vertical.mjs"; // `gapCue` (lane gap-cue): the mark at a clip gap's join (./gapCue.mjs). import { patchGapCue, validateGapCue } from "./gapCue.mjs"; +// `channelNames` (lane channel-title): the cut's own name for a channel, by slug (./channelNames.mjs). +import { patchChannelNames, validateChannelNames } from "./channelNames.mjs"; const isObj = (v) => !!v && typeof v === "object" && !Array.isArray(v); const num = (v) => typeof v === "number" && Number.isFinite(v); @@ -31,7 +33,7 @@ const round2 = (n) => Number(Number(n).toFixed(2)); /** The corner code's corners and links (lane clip-kit; umtool report-to-video clip-kit.mjs draws them). */ export const QR_CORNERS = Object.freeze(["br", "bl", "tr", "tl"]); export const QR_LINK_VALUES = Object.freeze(["cite", "moment", "channel"]); -export const LOOK_KEYS = Object.freeze(["headerHeight", "footerHeight", "qr", "transition", "transitionStyle", "loudness", "captions", "room", "slide", "blur", "intro", "format", "vertical", "mode", "basic", "tallWindows", "desktop", "promo", "zooms", "censor", "gapCue"]); +export const LOOK_KEYS = Object.freeze(["headerHeight", "footerHeight", "qr", "transition", "transitionStyle", "loudness", "captions", "room", "slide", "blur", "intro", "format", "vertical", "mode", "basic", "tallWindows", "desktop", "promo", "zooms", "censor", "gapCue", "channelNames"]); /** `headerHeight` / `footerHeight`: whole pixels, 0 (off) to this. */ export const BAND_MAX = 240; @@ -386,7 +388,7 @@ export function validateLook(manifest) { // render.blur (the uncensored variant's switch) is part of the look too. return [ ...validateCaptions(manifest), ...validateLoudness(manifest), ...validateVertical(manifest), ...validateRoom(manifest), ...validateRenderBlur(manifest), ...validateIntro(manifest), - ...validateVerticalFormat(manifest), ...validateRenderMode(manifest), ...validateGapCue(manifest), + ...validateVerticalFormat(manifest), ...validateRenderMode(manifest), ...validateGapCue(manifest), ...validateChannelNames(manifest), ]; } @@ -495,6 +497,13 @@ export function applyLookPatch(manifest, patch) { else render.gapCue = next; break; } + case "channelNames": { + // Merged over what it holds (a slug null drops it, null drops all); validateChannelNames (lookErrors) says what is wrong. + const next = patchChannelNames(render.channelNames, v); + if (next === null) delete render.channelNames; + else render.channelNames = next; + break; + } case "format": // "landscape" is the default: written as no key at all. if (v === "landscape") delete render.format; diff --git a/common/lib/report/videoAssistOps.test.ts b/common/lib/report/videoAssistOps.test.ts @@ -26,7 +26,7 @@ test("the look's rules: one patch function — keys refused, null removes, qr on assert.deepEqual(bad.errors, validateTransitionStyle({ render: { slide: { blur: 9 } } })); assert.deepEqual(applyLookPatch(m, { loudness: { target: -40 } }).errors, validateLook({ render: { loudness: { target: -40 } } })); assert.deepEqual(lookErrors(m), []); - assert.equal(LOOK_KEYS.length, 21); + assert.equal(LOOK_KEYS.length, 22); }); test("render.mode and render.basic: deck is the default (no key), basic the footage alone; the fades checked", () => { diff --git a/common/package.json b/common/package.json @@ -63,6 +63,7 @@ "./lib/report/drafted.mjs": "./lib/report/drafted.mjs", "./lib/report/look.mjs": "./lib/report/look.mjs", "./lib/report/gapCue.mjs": "./lib/report/gapCue.mjs", + "./lib/report/channelNames.mjs": "./lib/report/channelNames.mjs", "./lib/report/vertical.mjs": "./lib/report/vertical.mjs", "./lib/report/intro.mjs": "./lib/report/intro.mjs", "./lib/report/fxParams.mjs": "./lib/report/fxParams.mjs", diff --git a/editor/CHANGELOG.md b/editor/CHANGELOG.md @@ -1,6 +1,24 @@ # Changelog ## [Unreleased] +- **umtool: name a channel once for a whole cut.** + - A cut made from two recordings of one channel showed two names for it, the older record's uploader name and + the current one. Before, the only fix was to hand-edit `channelTitle` on every clip. + - New `render.channelNames: {"<slug>": "<name>"}`. Every clip of that channel shows that name in the header, the + deck's source line, the stacked deck, a short's end card and source tag, the poster of an audio-only clip, the + chapter list and the analysis item's "HEARD:" line. The clip bench's preview and the walk show it too. + - Order: the clip's own `channelTitle`, then the cut's name, then the record's uploader name, then the sweep's + display name, then the slug. A cut without the key prints exactly what it printed before. + - Set it in Build → Look → **Channel names** (one field per channel, with the records' names as placeholder) or + with `umtool look <p> channelNames.<slug>='Synth Channel'`. `channelNames.<slug>=` clears one name and + `channelNames=` clears all of them. + - A clip's own name now has a verb and a field: `umtool set <p> <clip> channelTitle='…'` (`channelTitle=` clears + it), and the clip bench's **channel** field beside title and date. + - A name is at most 60 characters on one line. A control character or newline is refused. A name for a channel + no clip of the cut uses is written, with a warning. + - Under the deck, a `--chrome-only` take picks up the change. The exception is an audio-only clip, whose poster + is part of its segment. A no-deck build re-encodes only the clips of the renamed channel (docs/knobs.md, "A + channel's name in the cut"). - **umtool: the gap mark's border is the deck's accent colour.** - The operator picked variant B. The border is drawn in the deck's accent, the colour of the deck's accent rule and the dots in its source line, at full opacity. The box behind the text is near-black at 90 %, and the text diff --git a/umtool/app/api/report/clip/route.ts b/umtool/app/api/report/clip/route.ts @@ -61,6 +61,7 @@ export async function GET(request: Request) { title: clip.title ?? null, date: clip.date ?? null, citeUrl: clip.citeUrl ?? null, + channelTitle: clip.channelTitle ?? null, lock: !!clip.lock, lockStart: !!clip.lockStart, lockEnd: !!clip.lockEnd, @@ -111,6 +112,9 @@ export async function GET(request: Request) { // feeds it straight back into attributionLine's override slot, so the // preview and the renderer cannot disagree about who is speaking. sourceChannel: entry?.sourceChannel ?? null, + // Who it would name WITHOUT the clip's own channelTitle (the cut's render.channelNames, the record, …): + // the placeholder of the bench's channel field. + sourceChannelDefault: entry?.sourceChannelDefault ?? null, cues: cues?.cues ?? [], // The other clips cut from this same recording: is the context this clip // is missing already in the cut, or is it a hole? diff --git a/umtool/app/api/report/onscreen/route.ts b/umtool/app/api/report/onscreen/route.ts @@ -82,7 +82,7 @@ export async function GET(request: Request) { // An entry with marks (`claims`) shows its first here; the clip editor's Marks box edits them all. claim: e.claim ?? (Array.isArray(e.claims) ? (e.claims[0] ?? null) : null), ...(Array.isArray(e.claims) ? { marks: e.claims.length } : {}), - auto: deckText(bare, metas[i] ?? null, provenance, deck, multi), + auto: deckText(bare, metas[i] ?? null, provenance, deck, multi, "", (render as { channelNames?: Record<string, unknown> }).channelNames ?? null), }; }); return Response.json( diff --git a/umtool/app/api/report/render/route.ts b/umtool/app/api/report/render/route.ts @@ -8,6 +8,8 @@ import { validateLook } from "umtool-report-to-video/look"; import { TRANSITION_STYLES, validateTransitionStyle } from "umtool-report-to-video/transition"; import { refuseCaller } from "@/lib/report/caller"; import { INTRO_STYLES } from "yt-dlp-transcript-common/lib/report/intro.mjs"; +import { channelNamesWarnings } from "yt-dlp-transcript-common/lib/report/channelNames.mjs"; +import { channelsOfCut } from "@/lib/projects/report.mjs"; export const dynamic = "force-dynamic"; @@ -21,7 +23,9 @@ export const dynamic = "force-dynamic"; // GET ?project=<id> { look, mode, preset, deck, montage, styles, introStyles, keys, errors, token } // `mode`: "deck" | "basic" as the build resolves it (the look preset under the // manifest); the Look panel's Basic | Deck switch writes `patch: {mode}` -// PUT { project, token, patch } { ok, look, token } | 409 stale | 400 { errors } +// `channels`: the cut's channels for Channel names (render.channelNames): +// [{slug, clips, recordNames, name}]; `warnings`: a name naming no clip's channel +// PUT { project, token, patch } { ok, look, token, warnings? } | 409 stale | 400 { errors } // PUT { project, token, variants } render.variants, the ladder Make variants encodes // (null: the default ladder) → { ok, variants, token } @@ -55,6 +59,9 @@ export async function GET(request: Request) { // The encode ladder (video knobs): as written, and the default when it is absent. variants: render.variants ?? null, variantsDefault: VARIANTS_DEFAULT, + // The channels its clips are from, and what each is called (render.channelNames, lane channel-title). + channels: await channelsOfCut(r.project.dir, r.manifest), + warnings: channelNamesWarnings(r.manifest), token: await manifestToken(r.project.dir), }, { headers: noStore }, @@ -92,7 +99,7 @@ export async function PUT(request: Request) { token: body.token === undefined || body.token === null ? null : String(body.token), }), ); - return Response.json({ ok: true, look: res.look, token: res.token, editNotes }, { headers: noStore }); + return Response.json({ ok: true, look: res.look, token: res.token, warnings: res.warnings ?? [], editNotes }, { headers: noStore }); } catch (e) { if (e instanceof StaleToken) { return Response.json({ error: e.message, expected: e.expected, got: e.got, stale: true }, { status: 409 }); diff --git a/umtool/app/api/report/window/route.ts b/umtool/app/api/report/window/route.ts @@ -50,6 +50,8 @@ export async function PUT(request: Request) { "lockEnd", "note", "title", + // What the header calls the clip's channel, over the cut's render.channelNames (≤ 60, one line; empty clears). + "channelTitle", "date", "cite", "citeUrl", diff --git a/umtool/components/projects/ClipBench.tsx b/umtool/components/projects/ClipBench.tsx @@ -122,6 +122,8 @@ type Clip = { title: string | null; date: string | null; citeUrl: string | null; + /** What the header calls this clip's channel, over the cut's name for it (render.channelNames) and the record's. */ + channelTitle: string | null; lock: boolean; lockStart: boolean; lockEnd: boolean; @@ -208,8 +210,9 @@ const verdictLabel = (c: Clip): string => { return v === "rejected" ? `rejected — ${r?.label ?? "other"}` : "not yet reviewed"; }; -/** The five fields that decide the burned-in header and the QR. */ +/** The fields that decide the burned-in header and the QR, and the walk's notes. */ const ATTRIB = [ + ["channelTitle", "channel", "What the header calls this clip's channel (≤ 60 characters, one line). Empty uses the cut's name for the channel (Look: Channel names), else the archived record's uploader name."], ["title", "title", "What the header calls this stream. Empty uses the archived record's own title, cleaned."], ["date", "date", "The stream's own date, YYYY-MM-DD. Empty uses the archived copy's upload date — which for a VOD mirror is often years later."], ["cite", "cite", "The second the header prints, in absolute source seconds. Empty uses the clip's start."], @@ -252,6 +255,7 @@ const fromEntry = (prev: Clip, e: Record<string, unknown>): Clip => ({ title: (e.title as string) ?? null, date: (e.date as string) ?? null, citeUrl: (e.citeUrl as string) ?? null, + channelTitle: (e.channelTitle as string) ?? null, lock: !!e.lock, lockStart: !!e.lockStart, lockEnd: !!e.lockEnd, @@ -288,6 +292,8 @@ export type ClipBenchData = { uploadDate: string | null; /** Who the header will name, already resolved server-side. Heads the line. */ sourceChannel: string | null; + /** Who it would name without the clip's own channelTitle (the cut's name for the channel, else the record's). */ + sourceChannelDefault?: string | null; /** * Neighbours ON THE WALK, computed server-side: the nearest clip either side * that still needs judgement and is fetched. Null when there is none that @@ -2069,10 +2075,15 @@ export default function ClipBench({ date: draft.date.trim() || null, cite: draft.cite.trim() === "" ? null : Number(draft.cite), start: clip.start, - // The server already walked override -> record -> provenance -> slug, so - // the resolved name goes into the override slot rather than being - // re-derived here from fields this component does not have. - channelTitle: data.sourceChannel, + // The server already walked override -> the cut's name -> record -> + // provenance -> slug, so the resolved name goes into the override slot + // rather than being re-derived here from fields this component does not + // have. An edit of the channel field in flight shows as typed; emptied, + // what the server says the clip would name without its own. + channelTitle: + draft.channelTitle === attribValue(clip, "channelTitle") + ? data.sourceChannel + : draft.channelTitle.trim() || (data.sourceChannelDefault ?? data.sourceChannel), }, { title: data.sourceTitle, uploadDate: data.uploadDate }, ); @@ -4149,7 +4160,9 @@ export default function ClipBench({ ? String(clip.start) : k === "title" ? (data.sourceTitle ?? "") - : "" + : k === "channelTitle" + ? (data.sourceChannelDefault ?? "") + : "" } onChange={(e) => setDraft((d) => ({ ...d, [k]: e.target.value }))} onBlur={() => commit(k)} diff --git a/umtool/components/projects/report/LookPanel.tsx b/umtool/components/projects/report/LookPanel.tsx @@ -30,6 +30,11 @@ import AssistBox from "./AssistBox"; // cards or brand; post items and teasers left out), deck everything else. The // switch shows the mode as the build resolves it (over the cut's look preset) // and saves with the rest (`umtool look <p> mode=basic|deck`). +// CHANNEL NAMES (render.channelNames, lane channel-title): what every clip of a +// channel is called on screen in this cut, one field per channel its clips are +// from -- empty is the record's own name (shown as the placeholder; two when the +// recordings disagree). A clip's own channel field (the clip bench) still wins. +// `umtool look <p> channelNames.<slug>="…"` (`channelNames.<slug>=` clears it). type Look = { headerHeight?: number; @@ -46,12 +51,15 @@ type Look = { promo?: Promo | null; zooms?: { soften?: number } | null; desktop?: { tag?: boolean; qr?: boolean | { corner?: string; size?: number; links?: string }; captions?: { size?: string; lines?: number }; [k: string]: unknown } | null; + channelNames?: Record<string, string> | null; }; +/** A channel the cut's clips are from (the render route's `channels`). */ +type CutChannel = { slug: string; clips: number; recordNames: string[]; name: string | null }; type Mode = "deck" | "basic"; /** The channel promo (render.promo, report-to-video promo-card.mjs): the card a per-clip build ends on. */ type Promo = { name?: string | string[]; url?: string; qr?: string | false; portrait?: { file: string; box?: number[] }; kicker?: string; palette?: Record<string, string>; lead?: number; fade?: number; hold?: number; captions?: boolean; [k: string]: unknown }; const PROMO_DEFAULTS = { lead: 4.5, fade: 0.7, hold: 1.5 } as const; -type View = { look: Look; mode?: Mode; preset?: string | null; deck: boolean; montage: boolean; styles: string[]; introStyles?: string[]; errors: string[]; token: string | null }; +type View = { look: Look; mode?: Mode; preset?: string | null; deck: boolean; montage: boolean; styles: string[]; introStyles?: string[]; errors: string[]; token: string | null; channels?: CutChannel[]; warnings?: string[] }; /** The intro's style as written: a bare name or the object's `style`; "" for none. */ const introStyleOf = (v: Look["intro"]) => (typeof v === "string" ? v : v && typeof v === "object" ? String(v.style ?? "") : ""); @@ -95,6 +103,8 @@ type Draft = { promoHold: string; promoCaptions: boolean; zoomSoft: string; + /** render.channelNames as typed: slug → name ("" is none). */ + names: Record<string, string>; }; /** A desktop clip's code as the panel shows it: off, or its corner (br when on with none). */ @@ -185,9 +195,22 @@ function draftOf(l: Look, mode: Mode = "deck"): Draft { deskSize: l.desktop?.captions?.size ?? "l", ...promoDraftOf(l.promo), zoomSoft: String(l.zooms?.soften ?? 1), + names: { ...(l.channelNames ?? {}) }, }; } +/** The channelNames patch that takes the saved names to the draft's: a slug set, or null to clear it; null when none changed. */ +function namesPatchOf(was: Look["channelNames"], d: Draft): Record<string, string | null> | null { + const saved = was ?? {}; + const p: Record<string, string | null> = {}; + for (const slug of new Set([...Object.keys(saved), ...Object.keys(d.names)])) { + const next = (d.names[slug] ?? "").trim(); + if (next === (saved[slug] ?? "")) continue; + p[slug] = next || null; + } + return Object.keys(p).length ? p : null; +} + const SLIDE_KEYS = [ ["travel", "travel"], ["blur", "smear"], @@ -246,6 +269,11 @@ function patchOf(was: Look, d: Draft, view: View): Record<string, unknown> { const next = desktopNext(was.desktop, d); if (JSON.stringify(next ?? null) !== JSON.stringify(was.desktop ?? null)) p.desktop = next; } + // The cut's names for its channels (render.channelNames): merged by the writer, a slug null clears it. + { + const next = namesPatchOf(was.channelNames, d); + if (next) p.channelNames = next; + } // The output mode (render.mode): the writer keeps "deck" as no key unless a look preset's must be beaten. if (d.mode !== (view.mode ?? "deck")) p.mode = d.mode; // The blurred clips (render.blur): "on" is the default, written as no key. @@ -306,7 +334,7 @@ export default function LookPanel({ project }: { project: string }) { setError(null); try { const r = await fetch("/api/report/render", { method: "PUT", headers: { "content-type": "application/json" }, body: JSON.stringify({ project, token: view.token, patch }) }); - const j = (await r.json().catch(() => ({}))) as { error?: string; errors?: string[]; stale?: boolean; look?: Look; token?: string }; + const j = (await r.json().catch(() => ({}))) as { error?: string; errors?: string[]; stale?: boolean; look?: Look; token?: string; warnings?: string[] }; if (r.status === 409) { await load(); setError("the manifest changed since this was read — reloaded; check and save again"); @@ -316,7 +344,7 @@ export default function LookPanel({ project }: { project: string }) { setError((j.errors ?? [j.error ?? `HTTP ${r.status}`]).join("; ")); return; } - setView({ ...view, look: j.look ?? {}, mode: draft.mode, token: j.token ?? null, errors: [] }); + setView({ ...view, look: j.look ?? {}, mode: draft.mode, token: j.token ?? null, errors: [], warnings: j.warnings ?? view.warnings ?? [] }); setDraft(draftOf(j.look ?? {}, draft.mode)); setVersion((n) => n + 1); setStatus("Saved — the next render uses it"); @@ -487,6 +515,33 @@ export default function LookPanel({ project }: { project: string }) { </> )} </div> + {(view.channels?.length ?? 0) > 0 && ( + <div className="mt-3 space-y-1.5" data-look-channel-names=""> + <span className="text-[12.5px] text-text-2" title={'what every clip of a channel is called on screen; a clip\'s own channel field wins — umtool look <p> channelNames.<slug>="…"'}> + Channel names + </span> + <div className="flex flex-wrap items-end gap-3"> + {(view.channels ?? []).map((c) => ( + <Field key={c.slug} label={`${c.slug}${c.clips ? ` · ${c.clips} clip${c.clips === 1 ? "" : "s"}` : " · no clip"}`}> + <Input + data-look-channel-name={c.slug} + value={draft.names[c.slug] ?? ""} + maxLength={60} + placeholder={c.recordNames.join(" / ") || c.slug} + disabled={busy} + onChange={(e) => set({ names: { ...draft.names, [c.slug]: e.target.value.replace(/[\u0000-\u001f\u007f-\u009f]/g, "") } })} + className="w-[14em]" + /> + </Field> + ))} + </div> + {(view.warnings?.length ?? 0) > 0 && ( + <p className="m-0 text-[12px] text-muted" data-look-channel-warnings=""> + {(view.warnings ?? []).join("; ")} + </p> + )} + </div> + )} <div className="mt-3 flex flex-wrap items-end gap-x-5 gap-y-2" data-look-desktop=""> <span className="text-[12.5px] text-text-2" title="umtool vertical --desktop, umtool shorts --formats desktop: 16:9, the picture full frame">Desktop clips</span> {check("deskTag", "Source line", "data-look-desktop-tag")} diff --git a/umtool/docs/knobs.md b/umtool/docs/knobs.md @@ -38,6 +38,7 @@ that generates it ([notes.md](notes.md)). | `hideModules` — `["diet","streak",…]`: the measure extras (`goals` `peak` `promise` `diet` `streak`) hidden over THIS entry's span, each with its own fade, whatever it would otherwise do there -- for text in the footage no dodge can know of (a DM screenshot's refund email under the diet badge). Any entry, a post item too; an id no entry can hide is refused | — | `umtool set <p> <entry> hideModules=diet,streak` (`hideModules=` clears it; `--take <t>` writes the take's patch, the project's manifest untouched) | — | | `shelfNote` — one line of at most 80 characters on the shelf (`render.chrome.deck.shelf`, its `note` slot) over THIS entry's span, coming and going with it -- a short fact beside the footage for any video, with or without a measure slice ([Shelf](#shelf)). Any entry, a post item too | — | `umtool set <p> <entry> shelfNote='Weighed in on camera'` (`shelfNote=` clears it; `--take <t>` writes the take's patch) | — | | `chapter` — the entry's name in the chapter list (`out/…chapters`, `youtube.txt`, `umtool export --format chapters`): one line of at most 100 characters. An authored `chapter` wins over the entry's on-screen title (under the deck) and the line derived from its record; without one the list is as before. Any entry, a post item too | — | `umtool set <p> <entry> chapter='The weigh-in'` (`chapter=` clears it; `--take <t>` writes the take's patch, the project's manifest untouched) | — | +| `channelTitle` — what this clip's channel is called on screen (the header, the deck's source line, the chapter list, a short's end card): one line, at most 60 characters, no control character. Wins over the cut's name for its channel ([below](#a-channels-name-in-the-cut)) and the record's uploader name | clip bench, **channel** (beside title and date; empty shows what it falls back to) | `umtool set <p> <clip> channelTitle='Synth Channel'` (`channelTitle=` clears it; `--take <t>` writes the take's patch) | `PUT /api/report/window {project, clip, token, channelTitle}` | | `fx.zoom` — `{shot, focus, at?, hold?}`: a screenshot (a file in the project; a bare name under its `shots/` is written as `shots/<name>`) that comes up over the footage and pushes in on `focus` (`[left, top, right, bottom]`, fractions of the shot) — drawn once `render.chrome.fx.zoom` is on ([Effects](#effects)). **How long it stays**: up 0.2 s into the clip's clean span (rising in over 0.38 s), its focus box drawn 0.55 s later, the push at `at` (seconds into the clip; default as soon as the box has drawn) over 1 s, then a slow drift on the detail; it leaves with a 0.3 s fade 0.3 s before the clip's clean span ends — or, with `hold` (0.5–10 s), that long after the push lands (never past the clip's own leave) | — | `umtool set <p> <clip> fx.zoom='{"shot":"shots/x.png","focus":[0.1,0.2,0.9,0.4],"at":5.9,"hold":4}'` (`fx.zoom=` clears it) | `PUT /api/report/window {project, clip, "fx.zoom": {…} \| null}` | | `fx.receipts`, `fx.punch`, `fx.quote`, `fx.punchIn`, `fx.speakers` — the clip's other effect fields (`[{shot, mark?, at?, hold?, label?}]` 1–4, `at` the source second a receipt flies in at (default: as the clip comes up), `hold` 0.5–10 s it stays once landed (on every one: they leave then, not with the clip), `label` a line of at most 80 characters in a band under the screenshot (when it was taken, what it is); the words to punch; `false`: no line; 1–8 source seconds inside the clip; `[{at, who: 0\|1}]`), each inert until its effect is on; `fx` is all of them at once. Checked by the build's own `validateFxEntries` | — | `fx.punch="the words"` `fx.punchIn='[231.4]'` · `fx='{…}'` sets them all, `fx=` clears every one | `PUT /api/report/window {project, clip, fx}` (or one `"fx.<field>"`) | | `gaps` — `[{from, to}]`, SOURCE seconds cut out of the clip's middle: it renders as ONE segment of jump cuts (one pip, one card), not two clips with a crossfade ([below](#gaps-inside-a-clip)) | clip bench (Edit this clip), the waveform: **Select a gap** (`g`) or Alt + drag a span, **Cut gap** (`g`), **Hear it**; a click on a gap's band picks it: its settings and **Remove** under the waveform (`G`: put back the one at the playhead); **Undo** | `umtool window <p> <clip> --gap 12.3-15.1` (repeatable) · `--gap-remove 12.3` · `--gaps '12.3-15.1,20-20.6'` (`--gaps ''` clears) · `umtool set <p> <clip> gap.add=12.3-15.1 gap.remove=12.3 gaps=` · a gap's own: `gap.mark=12.3:off` `gap.why=12.3:dead-air` `gap.reason=12.3:walks off` `gap.corner=12.3:tr` (`…:default`, `gap.reason=12.3:` drop one) | `PUT /api/report/window {project, clip, token, gapAdd \| gapRemove \| gaps \| gapEdit}` | @@ -249,6 +250,50 @@ own `yt-dlp --simulate` probe (`out/availability.json`, render-cards.mjs `SOURCE build; the source line comes from the archive's records via the stamp. Until the two share the stamp, a card and a line about one recording can say different things. +## A channel's name in the cut + +A cut made from two recordings of one channel can show two names for it: each clip is named by its own record, and +an older recording's record carries the uploader name the channel had then. `render.channelNames` says once what +every clip of a channel is called in this cut: `{ "<slug>": "<name>" }`, the slug a clip's `channel` (or the sweep's +`provenance.channelSlug`). One resolver names a clip's channel everywhere it is printed (report-to-video +`attribution.mjs` `channelName`), in this order: + +1. the clip's own `channelTitle` ([A clip](#a-clip)); +2. the cut's `render.channelNames[<slug>]`; +3. the record's uploader name (its cue record's `channel`); +4. the sweep's display name (`provenance.channel`), for a clip of the sweep's own channel; +5. the slug. + +A cut without `render.channelNames` prints exactly what it printed before the key existed. + +| | In umtool | From a terminal | +|---|---|---| +| one channel's name for the whole cut | Build, **Look**: **Channel names** -- one field per channel the cut's clips are from, its placeholder what the records say (two names when its recordings disagree); empty clears it | `umtool look <p> channelNames.<slug>='Synth Channel'` (`channelNames.<slug>=` clears it, `channelNames=` clears them all; `channelNames='{"<slug>":"…"}'` merges) · a take: `umtool take <p> --id <t> --set render.channelNames='{"<slug>":"…"}'` | +| one clip's | clip bench, **channel** | `umtool set <p> <clip> channelTitle='…'` | + +The rules (common `lib/report/channelNames.mjs`, checked by the writer, the build's look validator and the editor's +video assistant): a name is words, at most 60 characters, one line with no control character (a newline or a tab is +refused). A name for a slug no clip of the cut is from is written and warned about (`WARN` from `umtool look`, a line +under the Look panel's fields), never refused. `umtool show` lists them (`channels`). + +Where it is printed: the burned-in header (a no-deck build, and the brand's coloured head), the deck's subtitle +and the stacked vertical deck's source line, the poster card of a clip with no picture, a short's or a desktop +clip's source tag, a short's end card, the chapter list (`out/…chapters`, `youtube.txt`), the analysis item's +"HEARD:" line, the clip bench's preview line and the walk's speaker. The Cut tab's rows show the slug, not a name. + +**What re-renders.** + +- **Under the deck** (16:9, or the stacked 9:16 deck): the deck's page draws the name, so a `--chrome-only` take + picks it up -- the schedule's subtitles change, the chrome is drawn again, the chapters re-muxed; no clip segment + is re-encoded. One exception: a clip with no picture (an audio-only source) plays over a poster card that names + its channel, and that poster is part of its segment. `--chrome-only` keeps the old poster; rebuild that clip + (a build without `--chrome-only`, or `--only <id>`). +- **No deck** (the burned-in header): the header is drawn into each clip's segment, so every clip of a renamed + channel is re-encoded (its header text is part of the segment's key); the other clips are reused as they are. +- **A short or a desktop clip without the stacked deck**: its source tag is drawn into the segment (its captions + file): those clips are re-encoded. +- **Basic mode** draws no name: only the chapter list changes. + ## Gaps inside a clip A clip may leave seconds out of its middle: you suggest one long clip and cut a gap or two out of it, rather than diff --git a/umtool/lib/projects/report.mjs b/umtool/lib/projects/report.mjs @@ -154,6 +154,44 @@ export async function deadOriginQrsOf(dir, m, { channelsDir = null } = {}) { } /** + * The channels this cut's clips are from, for the Look panel's Channel names (render.channelNames, lane + * channel-title): each slug once, in the cut's order, with how many clips are from it, the names the + * records of its recordings carry (what the header says with no name set -- two when its recordings + * disagree) and the cut's name for it. A name set for a slug no clip is from is listed too (`clips: 0`), + * so it can be cleared. + * + * @returns {Promise<Array<{ slug: string, clips: number, recordNames: string[], name: string | null }>>} + */ +export async function channelsOfCut(dir, m, { channelsDir = null } = {}) { + if (!m) return []; + const root = channelsDir ?? channelsDirFor(dir, m, { shadowExists: await hasShadowChannels(dir) }); + const names = m.render?.channelNames && typeof m.render.channelNames === "object" ? m.render.channelNames : {}; + const prov = m.provenance ?? {}; + /** @type {Map<string, { slug: string, clips: number, recordNames: string[], name: string | null }>} */ + const out = new Map(); + const docs = new Map(); + for (const e of clipsOf(m)) { + const slug = channelFor(m, e); + if (!slug) continue; + const row = out.get(slug) ?? { slug, clips: 0, recordNames: [], name: typeof names[slug] === "string" ? names[slug] : null }; + row.clips += 1; + out.set(slug, row); + const key = `${slug}/${e.video}`; + if (!docs.has(key)) { + const file = e.video ? cuePathFor(m, e, root) : null; + docs.set(key, file ? await readCues(file).catch(() => null) : null); + } + // What the record says, with neither the clip's own nor the cut's name. + const said = channelName({ channel: e.channel }, docs.get(key) ?? {}, prov); + if (said && !row.recordNames.includes(said)) row.recordNames.push(said); + } + for (const [slug, name] of Object.entries(names)) { + if (!out.has(slug)) out.set(slug, { slug, clips: 0, recordNames: [], name: typeof name === "string" ? name : null }); + } + return [...out.values()]; +} + +/** * Is the QR origin a defect? A SET origin that is dead (localhost, a LAN * address) always is: it is the archive the cut names, whatever links it * today. A MISSING one only when a code the cut draws is built from it @@ -1884,7 +1922,10 @@ export async function readClipDetail(dir, { manifest = null } = {}) { // the answer walks the clip's override, the record, the sweep's own // display name and the slug, and a preview that re-implemented that walk // is exactly the drift `attribution.mjs` exists to prevent. - sourceChannel: channelName(e, doc ?? {}, m.provenance ?? {}), + // The cut's own name for the channel (render.channelNames) is part of that walk. + sourceChannel: channelName(e, doc ?? {}, m.provenance ?? {}, m.render?.channelNames), + // What it would say WITHOUT the clip's own channelTitle: the clip bench's placeholder for that field. + sourceChannelDefault: channelName({ ...e, channelTitle: undefined }, doc ?? {}, m.provenance ?? {}, m.render?.channelNames), punctuationRate: doc?.punctuationRate ?? null, endCueText: endCue?.text ?? null, endsSentence, diff --git a/umtool/lib/report/benchData.ts b/umtool/lib/report/benchData.ts @@ -125,6 +125,7 @@ export async function clipBenchData( title: entry.title ?? null, date: entry.date ?? null, citeUrl: entry.citeUrl ?? null, + channelTitle: entry.channelTitle ?? null, lock: !!entry.lock, lockStart: !!entry.lockStart, lockEnd: !!entry.lockEnd, @@ -222,6 +223,7 @@ export async function clipBenchData( sourceTitle: entry.sourceTitleClean ?? null, uploadDate: entry.uploadDate ?? null, sourceChannel: entry.sourceChannel ?? null, + sourceChannelDefault: entry.sourceChannelDefault ?? null, prev: prev, next: next, index: order === "cut" ? ci + 1 : i + 1, diff --git a/umtool/lib/report/knobsCli.mjs b/umtool/lib/report/knobsCli.mjs @@ -13,7 +13,9 @@ // (`blur.on=` clears the whole blur; report-to-video clip-blur.mjs) // fx=<json> fx.zoom fx.receipts fx.punch fx.quote fx.punchIn fx.speakers // (the clip's effects; `fx=` clears them all; report-to-video fx.mjs) +// umtool set <project> <clip> channelTitle=… what the header calls the clip's channel (`channelTitle=` clears) // umtool look <project> key=value … factcheck.stamp.<k>, factcheck.verdicts.<V>.<k>, factcheck.tally.<k>, +// channelNames.<slug>=<name> (the cut's name for a channel; `=` clears), // deck.markers=<json>, deck.markerLayout=…, deck.claims=<json>, variants=<json>, // and the look's keys (transition=0.3, …) // umtool variants <project> [--take <t>] [--list] [--json] make the encode ladder (or list it) @@ -65,7 +67,7 @@ export const SIDE_SET_KEYS = Object.freeze(["side", "side.item", "side.post", "s export const KIT_SET_KEYS = Object.freeze(["qr", "qr.corner", "qr.links", "name", "promo", "promo.lead", "promo.fade", "promo.hold", "zooms", "coldOpen", "coldOpen.from", "coldOpen.to", "censor", "censor.boxes", "censor.style", "censor.strength", "censor.from", "censor.to"]); const SET_KEYS = [ "claim", ...CLAIM_KNOBS.map((k) => `claim.${k}`), ...MARK_KEYS, ...AUDIO_KNOBS.map((k) => `audio.${k}`), ...BLUR_KNOBS.map((k) => `blur.${k}`), "layout", ...REVIEW_KEYS, - ...FX_KEYS, ...GAP_KEYS, ...GAP_CUE_SET_KEYS, "chat", "hideModules", "shelfNote", "chapter", + ...FX_KEYS, ...GAP_KEYS, ...GAP_CUE_SET_KEYS, "chat", "hideModules", "shelfNote", "chapter", "channelTitle", // The vertical format (lane vertical): the clip's 9:16 crop and layout, and its side post. ...VERTICAL_SET_KEYS, ...SIDE_SET_KEYS, // The clip kit (lane clip-kit): its code and its name in a batch of shorts. @@ -115,6 +117,9 @@ export const SET_USAGE = [ " `note` slot) over this entry's span, coming and going with it; any entry; `shelfNote=` none.", " chapter='The weigh-in' names this entry in the chapter list (out/chapters, youtube.txt) in place of its on-screen", " title or the line derived from its record: one line, ≤ 100 characters; any entry; `chapter=` none.", + " channelTitle='Synth Channel' is what the header, the deck's source line and the chapter list call this clip's", + " channel, over the cut's name for it (umtool look <p> channelNames.<slug>=…) and the record's uploader name:", + " one line, ≤ 60 characters, no control character; `channelTitle=` the cut's / the record's again.", " --take <t>: the entry knobs (not claim.* or marks) land in takes/<t>/take.json's patch, an undo point first", " (`umtool timeline <p> --take <t> undo`); the project's manifest is untouched.", " vertical.crop='[x,y,w,h]' (fractions of the source: the 9:16 box a vertical render cuts; vertical.aspect the", @@ -170,6 +175,10 @@ export const LOOK_USAGE = [ " on one quiet line under the rail; .size .opacity .fade .color (auto|section|#hex|palette key); false or `=` is off", " pair=<json> | pair.<key>=…, chapter=<json> | chapter.<key>=…, status=<json> | status.<key>=…, chat=<json> | chat.<key>=…: the story modules", " (render.chrome.pair / .chapter / .status, docs/knobs.md \"Modules\"), checked by the build's rules", + " channelNames.<slug>='Synth Channel': every clip of that channel is called that on screen in this cut (the deck's", + " source line, the header, the chapter list, a short's end card), over the record's uploader name; a clip's own", + " channelTitle still wins (umtool set). ≤ 60 characters, one line. `channelNames.<slug>=` clears one, `channelNames=`", + " all; channelNames='{\"<slug>\":\"…\"}' merges. A slug no clip of the cut is from is written and warned about.", " variants='[{\"name\":\"master\"},{\"name\":\"720p\",\"height\":720,\"crf\":23},{\"name\":\"fit24\",\"maxMiB\":24}]'", ` the look: ${LOOK_KEYS.join(", ")} (a JSON value each)`, " `key=` clears it (the default).", @@ -282,6 +291,11 @@ export async function setCommand(args, { root = REPORTS_ROOT, out = (s) => conso entryPatch.shelfNote = value === null || value === undefined ? null : String(value); continue; } + if (key === "channelTitle") { + // What the header calls the clip's channel (manifest.mjs patchClipEntry checks it); words whatever they parse as. + entryPatch.channelTitle = value === null || value === undefined ? null : String(value); + continue; + } if (key === "chapter") { // The entry's name in the chapter list (manifest.mjs parseEntryChapter checks it); words whatever they parse as. entryPatch.chapter = value === null || value === undefined ? null : String(value); @@ -388,6 +402,7 @@ export async function setCommand(args, { root = REPORTS_ROOT, out = (s) => conso if ("hideModules" in entryPatch) results.hideModules = result.entry.hideModules ?? null; if ("shelfNote" in entryPatch) results.shelfNote = result.entry.shelfNote ?? null; if ("chapter" in entryPatch) results.chapter = result.entry.chapter ?? null; + if ("channelTitle" in entryPatch) results.channelTitle = result.entry.channelTitle ?? null; if ("audio" in entryPatch) results.audio = result.entry.audio ?? null; if ("blur" in entryPatch) results.blur = result.entry.blur ?? null; if ("layout" in entryPatch) results.layout = result.entry.layout ?? "clip"; @@ -433,6 +448,7 @@ export async function setCommand(args, { root = REPORTS_ROOT, out = (s) => conso if ("hideModules" in results) out(`${clipId}${results.take ? ` (take ${results.take.id})` : ""}: hideModules ${results.hideModules ? `${results.hideModules.join(", ")} (hidden over its span)` : "none"}`); if ("shelfNote" in results) out(`${clipId}${results.take ? ` (take ${results.take.id})` : ""}: shelfNote ${results.shelfNote ? JSON.stringify(results.shelfNote) + " (on the shelf over its span)" : "none"}`); if ("chapter" in results) out(`${clipId}${results.take ? ` (take ${results.take.id})` : ""}: chapter ${results.chapter ? JSON.stringify(results.chapter) + " (its name in the chapter list)" : "none (named by its on-screen title, else its record)"}`); + if ("channelTitle" in results) out(`${clipId}${results.take ? ` (take ${results.take.id})` : ""}: channelTitle ${results.channelTitle ? JSON.stringify(results.channelTitle) + " (its channel's name on screen)" : "none (the cut's name for its channel, else the record's)"}`); if (results.take?.undo) out(` undo point: ${results.take.undo} (umtool timeline ${project.id} --take ${results.take.id} undo)`); if ("chat" in results) out(`${clipId}: chat ${results.chat === true ? "on (its video's live_chat.cues.json beside the footage; the build says if there is none)" : results.chat === false ? "off" : "default (off)"}`); if ("fx" in results) out(`${clipId}: fx ${results.fx ? JSON.stringify(results.fx) : "none"}`); @@ -650,11 +666,23 @@ export async function lookCommand(args, { root = REPORTS_ROOT, out = (s) => cons const deck = pairs.filter(([k]) => k.startsWith("deck.")); const variants = pairs.filter(([k]) => k === "variants"); const look = pairs.filter(([k]) => LOOK_KEYS.includes(k)); + // The cut's name for ONE channel (render.channelNames.<slug>, lane channel-title): merged into the look's + // channelNames patch -- words whatever they parse as, `=` clears that slug. + const chanNames = pairs.filter(([k]) => k.startsWith("channelNames.")); + for (const [k, v] of chanNames) { + const slug = k.slice("channelNames.".length); + if (!slug) throw new CliError("channelNames.<slug>=<name>: name the channel's slug"); + const at = look.findIndex(([x]) => x === "channelNames"); + const cur = at >= 0 && look[at][1] && typeof look[at][1] === "object" ? look[at][1] : {}; + const next = { ...cur, [slug]: v === null || v === undefined ? null : String(v) }; + if (at >= 0) look[at] = ["channelNames", next]; + else look.push(["channelNames", next]); + } // The story modules (release 39): `pair=<json>`, `pair.style=…`, likewise chapter and status. const STORY = ["pair", "chapter", "status", "chat"]; const isStory = (k) => STORY.includes(k.split(".")[0]); const story = pairs.filter(([k]) => isStory(k)); - const unknown = pairs.filter(([k]) => !k.startsWith("factcheck.") && !k.startsWith("deck.") && k !== "variants" && !LOOK_KEYS.includes(k) && !isStory(k)); + const unknown = pairs.filter(([k]) => !k.startsWith("factcheck.") && !k.startsWith("deck.") && !k.startsWith("channelNames.") && k !== "variants" && !LOOK_KEYS.includes(k) && !isStory(k)); if (unknown.length) throw new CliError(`not a knob here: ${unknown.map(([k]) => k).join(", ")}\n\n${LOOK_USAGE}`); for (const [k] of deck) if (k.split(".").some((p) => !p)) throw new CliError(`${k}: name one of the deck's own keys (deck.<key>=<json>, or deck.<key>.<field>=…)`); const done = {}; @@ -699,13 +727,16 @@ export async function lookCommand(args, { root = REPORTS_ROOT, out = (s) => cons const r = await write((token) => updateVariants(project.dir, variants[0][1], { token })); done.variants = r.variants; } + let warnings = []; if (look.length) { const r = await write((token) => updateRender(project.dir, Object.fromEntries(look), { token })); done.look = r.look; + warnings = r.warnings ?? []; } - if (json) out(JSON.stringify({ ok: true, ...done, editNotes: notes }, null, 2)); + if (json) out(JSON.stringify({ ok: true, ...done, ...(warnings.length ? { warnings } : {}), editNotes: notes }, null, 2)); else { for (const [k, v] of Object.entries(done)) out(`${k}: ${v === null || v === undefined ? "(default)" : JSON.stringify(v)}`); + for (const w of warnings) out(`WARN ${w}`); const n = noted(notes); if (n) out(n); } @@ -824,6 +855,8 @@ export function knobsOf(manifest) { variantsDefault: !Array.isArray(manifest?.render?.variants), // render.blur "off": the uncensored variant (every clip's blur not drawn). blurOff: manifest?.render?.blur === "off", + // The cut's names for its channels (render.channelNames), as written. + channelNames: isObj(manifest?.render?.channelNames) ? manifest.render.channelNames : {}, }; } @@ -857,6 +890,7 @@ export function knobsLines(manifest) { } lines.push(` variants ${k.variants.map((v) => v.name).join(", ")}${k.variantsDefault ? " (default)" : ""}`); if (k.blurOff) lines.push(" blur off (render.blur: the uncensored variant — no clip is blurred)"); + if (Object.keys(k.channelNames).length) lines.push(` channels ${Object.entries(k.channelNames).map(([a, b]) => `${a}=${JSON.stringify(b)}`).join(" ")}`); return lines; } diff --git a/umtool/lib/report/knobsCli.test.mjs b/umtool/lib/report/knobsCli.test.mjs @@ -399,3 +399,51 @@ test("umtool set chapter='…': an entry's name in the chapter list, any entry; assert.equal(await run("chapter", "x01", "chapter=", "--take", "a9"), 0, lines.join("\n")); assert.equal("chapter" in (await resolveTakeManifest(dir, "a9")).manifest.timeline[2], false); }); + +test("umtool set channelTitle=…: the clip's own channel name, trimmed; `channelTitle=` clears it; a control character or > 60 is refused", async () => { + const dir = await project("chantitle"); + const { lines, run } = runner(setCommand); + assert.equal(await run("chantitle", "c02", "channelTitle= Synth Channel "), 0, lines.join("\n")); + assert.equal((await read(dir)).timeline[1].channelTitle, "Synth Channel", "trimmed"); + assert.match(lines.at(-1), /c02: channelTitle "Synth Channel"/); + assert.equal(await run("chantitle", "c02", "channelTitle=2031"), 0, lines.join("\n")); + assert.equal((await read(dir)).timeline[1].channelTitle, "2031", "words whatever they parse as"); + assert.equal(await run("chantitle", "c02", "channelTitle=Synth\u0007Channel"), 1); + assert.match(lines.at(-1), /control character/); + assert.equal(await run("chantitle", "c02", "channelTitle=Synth\nChannel"), 1); + assert.match(lines.at(-1), /control character/); + assert.equal(await run("chantitle", "c02", `channelTitle=${"x".repeat(61)}`), 1); + assert.match(lines.at(-1), /at most 60/); + assert.equal((await read(dir)).timeline[1].channelTitle, "2031", "a refused write changes nothing"); + assert.equal(await run("chantitle", "c02", "channelTitle="), 0); + assert.equal("channelTitle" in (await read(dir)).timeline[1], false); + assert.match(lines.at(-1), /c02: channelTitle none/); +}); + +test("umtool look channelNames.<slug>=…: one channel's name for the whole cut; `channelNames.<slug>=` clears one, `channelNames=` all", async () => { + const dir = await project("channames"); + const m = await read(dir); + m.timeline.push({ type: "clip", id: "c03", channel: "guest-chan", video: "v3", start: 1, end: 5 }); + await writeFile(path.join(dir, "video.manifest.json"), JSON.stringify(m, null, 2) + "\n"); + const { lines, run } = runner(lookCommand); + assert.equal(await run("channames", "channelNames.chan=Synth Channel"), 0, lines.join("\n")); + assert.deepEqual((await read(dir)).render.channelNames, { chan: "Synth Channel" }); + assert.equal(await run("channames", "channelNames.guest-chan=2031"), 0, lines.join("\n")); + assert.deepEqual((await read(dir)).render.channelNames, { chan: "Synth Channel", "guest-chan": "2031" }, "merged; words whatever they parse as"); + // A slug no clip of the cut uses: written, and warned about. + assert.equal(await run("channames", "channelNames.other-chan=Nobody"), 0, lines.join("\n")); + assert.equal((await read(dir)).render.channelNames["other-chan"], "Nobody"); + assert.match(lines.join("\n"), /WARN .*other-chan/); + // A control character: refused, nothing written. + assert.notEqual(await run("channames", "channelNames.chan=Synth\u0000Channel"), 0); + assert.match(lines.at(-1), /control character/); + assert.equal((await read(dir)).render.channelNames.chan, "Synth Channel"); + assert.equal(await run("channames", "channelNames.other-chan="), 0, lines.join("\n")); + assert.deepEqual((await read(dir)).render.channelNames, { chan: "Synth Channel", "guest-chan": "2031" }); + // The JSON form, and clearing the lot. + assert.equal(await run("channames", 'channelNames={"chan":null}'), 0, lines.join("\n")); + assert.deepEqual((await read(dir)).render.channelNames, { "guest-chan": "2031" }); + assert.ok(knobsLines(await read(dir)).some((l) => /channels\s+guest-chan="2031"$/.test(l)), "umtool show prints them"); + assert.equal(await run("channames", "channelNames="), 0, lines.join("\n")); + assert.equal("channelNames" in ((await read(dir)).render ?? {}), false); +}); diff --git a/umtool/lib/report/look.test.mjs b/umtool/lib/report/look.test.mjs @@ -46,7 +46,7 @@ const read = async (dir) => JSON.parse(await readFile(path.join(dir, MANIFEST_NA test("updateRender: the look's keys only, null removes one, the build's checks refuse a bad value", async () => { const p = await project({ transition: 0.4, crf: 21 }); try { - assert.deepEqual(LOOK_KEYS, ["headerHeight", "footerHeight", "qr", "transition", "transitionStyle", "loudness", "captions", "room", "slide", "blur", "intro", "format", "vertical", "mode", "basic", "tallWindows", "desktop", "promo", "zooms", "censor", "gapCue"]); + assert.deepEqual(LOOK_KEYS, ["headerHeight", "footerHeight", "qr", "transition", "transitionStyle", "loudness", "captions", "room", "slide", "blur", "intro", "format", "vertical", "mode", "basic", "tallWindows", "desktop", "promo", "zooms", "censor", "gapCue", "channelNames"]); const token = await manifestToken(p.dir); const r = await updateRender(p.dir, { headerHeight: 0, footerHeight: 0, qr: false, transition: 0.5, transitionStyle: "fadeblack", diff --git a/umtool/lib/report/manifest.mjs b/umtool/lib/report/manifest.mjs @@ -62,6 +62,7 @@ import { validateFxEntries } from "umtool-report-to-video/fx"; import { validateClipAudio } from "umtool-report-to-video/clip-audio"; import { GAP_WHY_VALUES, editGaps, gapOwnKeys, parseGapSpec, validateGaps } from "umtool-report-to-video/gaps"; import { gapCueErrors, patchGapCue } from "yt-dlp-transcript-common/lib/report/gapCue.mjs"; +import { channelNameProblem, channelNamesWarnings } from "yt-dlp-transcript-common/lib/report/channelNames.mjs"; import { BLUR_CAPTION_DEFAULT, BLUR_STRENGTH, validateClipBlur, validateClipBlurEntries } from "umtool-report-to-video/clip-blur"; import { CLAIM_KNOBS, CLAIM_MARKS_MAX, claimKnobsOf, claimKnobValue, freshMarkId, marksCopyOf, normalizeClaimKnobPatch, rawMarksOf, setMarks, stampingEntryId, @@ -462,6 +463,18 @@ export function patchClipEntry(manifest, clipId, patch, { edit = "trim", now = n else delete entry[k]; } + // What the header calls the clip's channel (attribution.mjs channelName: over the cut's render.channelNames and the + // record's uploader name). One line of words, at most 60 (common channelNames.mjs); empty deletes it. + if (patch.channelTitle !== undefined) { + const raw = patch.channelTitle === null ? "" : String(patch.channelTitle); + if (!raw.trim()) delete entry.channelTitle; + else { + const p = channelNameProblem(raw); + if (p) throw new Error(`channelTitle: ${p}`); + entry.channelTitle = raw.trim(); + } + } + if (patch.date !== undefined) { const v = String(patch.date ?? "").trim(); if (!v) delete entry.date; @@ -1940,7 +1953,7 @@ export async function updateRenderKeys(dir, { unset = [], chrome = null } = {}, * @param {string} dir * @param {Record<string, unknown>} patch * @param {{ token?: string | null }} [opts] - * @returns {Promise<{ look: Record<string, unknown>, token: string | null }>} + * @returns {Promise<{ look: Record<string, unknown>, token: string | null, snapshot?: Record<string, unknown>, warnings?: string[] }>} */ export async function updateRender(dir, patch, { token = null } = {}) { if (!isObj(patch)) throw new RenderRefused(["the patch must be an object of render keys"]); @@ -1967,7 +1980,9 @@ export async function updateRender(dir, patch, { token = null } = {}) { // it changes it (`gapCue: null` on a cut with none is no edit). const snapshot = "gapCue" in patch && JSON.stringify(render.gapCue ?? null) !== cueBefore ? await autoSnapshot(dir, "gaps") : null; const nextToken = await writeManifestAtomic(dir, manifest); - return { look: lookOf(render), token: nextToken, ...(snapshot ? { snapshot } : {}) }; + // A name for a channel no clip of the cut is from (render.channelNames): written, and said (common channelNames.mjs). + const warnings = "channelNames" in patch ? channelNamesWarnings(manifest) : []; + return { look: lookOf(render), token: nextToken, ...(snapshot ? { snapshot } : {}), ...(warnings.length ? { warnings } : {}) }; }); } diff --git a/umtool/lib/report/onscreen.mjs b/umtool/lib/report/onscreen.mjs @@ -291,7 +291,7 @@ function previewScheduleOf({ variantManifest, built, draft, metas, postsDraft, c const e = patchedEntries[i]; const meta = metas[i] ?? null; const status = subtitleStatusOn(deck.subtitle) ? clipSourceStatus(e, variantManifest.sourceStatus, provenance) : ""; - const { title, subtitle, subtitleParts, subtitleLines, subtitleLinesParts } = deckText(e, meta, provenance, deck, built.multiChannel, status); + const { title, subtitle, subtitleParts, subtitleLines, subtitleLinesParts } = deckText(e, meta, provenance, deck, built.multiChannel, status, render.channelNames); const keepBuilt = e.type === "clip" && e.onscreen?.subtitle === undefined && !meta; // A two-line subtitle's lines, and the line's parts by token, go with the subtitle they were cut from. const { subtitleLines: builtLines, subtitleParts: builtParts, subtitleLinesParts: builtLinesParts, ...seg } = s; diff --git a/umtool/lib/report/verticalCli.mjs b/umtool/lib/report/verticalCli.mjs @@ -176,7 +176,7 @@ export async function endCardOf({ render, knobs = {}, provenance = {}, timeline const V = await import("umtool-report-to-video/vertical"); if (!V.stackedDeckWanted({ ...render, format: "vertical", vertical: { ...(render?.vertical ?? {}), ...knobs } })) return null; const { endCardSources } = await import("umtool-report-to-video/outro"); - return { qrUrl: provenance.qrLink ?? provenance.siteOrigin ?? null, sources: endCardSources(timeline, schedule) }; + return { qrUrl: provenance.qrLink ?? provenance.siteOrigin ?? null, sources: endCardSources(timeline, schedule, render?.channelNames ?? null, provenance) }; } /** The heavy slot (report-to-video/heavy-gate.mjs), loaded at run time: `(cmd, fn) => …` with a declared estimate. */ diff --git a/umtool/report-to-video/attribution.mjs b/umtool/report-to-video/attribution.mjs @@ -56,6 +56,24 @@ export function uploadDateToIso(d) { } /** + * The cut's own name for this clip's channel (`render.channelNames[slug]`, + * the slug the clip's `channel`, else the sweep's), or "" when it gives none. + * A name that is not words is no name: the build's validator refuses it, and + * a preview must not draw "[object Object]" meanwhile. + * + * @param {{ channel?: string|null }} entry + * @param {{ channelSlug?: string|null }} [provenance] + * @param {Record<string, unknown> | null} [names] + */ +export function cutChannelName(entry, provenance = {}, names = null) { + if (!names || typeof names !== "object") return ""; + const slug = String(entry?.channel ?? provenance?.channelSlug ?? "").trim(); + if (!slug || !Object.prototype.hasOwnProperty.call(names, slug)) return ""; + const v = names[slug]; + return typeof v === "string" ? v.trim() : ""; +} + +/** * WHO is speaking, for the head of the header line. * * A compilation routinely spans several channels -- a streamer's own channel, @@ -63,12 +81,17 @@ export function uploadDateToIso(d) { * makes the viewer work out which of them they are watching from the furniture. * So the channel comes first and every clip in a cut reads the same way. * - * Four answers, in order, and each exists because the one after it is wrong + * Five answers, in order, and each exists because the one after it is wrong * somewhere: * * 1. `entry.channelTitle` — the per-clip override. A record's uploader name * can be a handle, a rebrand or an ALL-CAPS mirror name; this is the * author saying what to call it in this cut. + * 1b. `names[slug]` — the CUT's name for the clip's channel + * (`render.channelNames`, common lib/report/channelNames.mjs). Two + * recordings of one channel can carry two uploader names (the old one + * and the current one); this says once which every clip of it shows. + * Absent or empty: the answer is what it was before the key existed. * 2. `meta.channel` — the uploader name the cue record already carries, local * or from a published shard. Free: the record is loaded for the title and * the upload date anyway, so no lookup is added to a build. @@ -81,10 +104,13 @@ export function uploadDateToIso(d) { * @param {{ channelTitle?: string|null, channel?: string|null }} entry * @param {{ channel?: string|null }} [meta] * @param {{ channel?: string|null, channelSlug?: string|null }} [provenance] + * @param {Record<string, unknown> | null} [names] the cut's `render.channelNames` */ -export function channelName(entry, meta = {}, provenance = {}) { +export function channelName(entry, meta = {}, provenance = {}, names = null) { const override = String(entry?.channelTitle ?? "").trim(); if (override) return override; + const cut = cutChannelName(entry, provenance, names); + if (cut) return cut; const record = String(meta?.channel ?? "").trim(); if (record) return record; const slug = String(entry?.channel ?? provenance?.channelSlug ?? "").trim(); @@ -113,9 +139,10 @@ export function channelName(entry, meta = {}, provenance = {}) { * @param {{ title?: string|null, date?: string|null, cite?: number|null, start?: number|null, channel?: string|null, channelTitle?: string|null }} entry * @param {{ title?: string|null, uploadDate?: string|null, channel?: string|null }} meta * @param {{ channel?: string|null, channelSlug?: string|null }} [provenance] + * @param {Record<string, unknown> | null} [names] the cut's `render.channelNames` */ -export function attributionLine(entry, meta, provenance = {}) { - const { channel, title, date, at } = attributionParts(entry, meta, provenance); +export function attributionLine(entry, meta, provenance = {}, names = null) { + const { channel, title, date, at } = attributionParts(entry, meta, provenance, names); // A cut with no channel to name anywhere reproduces the old line exactly, // rather than opening on a stray separator. const head = [channel, title].filter((s) => String(s ?? "").length > 0).join(" · "); @@ -130,11 +157,13 @@ export function attributionLine(entry, meta, provenance = {}) { * header; the deck's subtitle (`deckSubtitle`) picks from them. One resolver, * so the two can never disagree about a clip's date or channel. * + * `names` is the cut's `render.channelNames` (channelName's 1b). + * * @returns {{ channel: string, title: string, date: string, at: number }} */ -export function attributionParts(entry, meta, provenance = {}) { +export function attributionParts(entry, meta, provenance = {}, names = null) { return { - channel: channelName(entry, meta, provenance), + channel: channelName(entry, meta, provenance, names), title: entry.title ?? cleanTitle(meta.title), date: entry.date ?? uploadDateToIso(meta.uploadDate), at: entry.cite ?? entry.start ?? 0, diff --git a/umtool/report-to-video/attribution.test.mjs b/umtool/report-to-video/attribution.test.mjs @@ -80,6 +80,46 @@ test("channelName: the four answers, in order", () => { assert.equal(channelName({}, {}, {}), ""); }); +test("channelName: the cut's per-channel name sits between the clip's own and the record's", () => { + const prov = { channelSlug: "own-chan", channel: "Own Channel" }; + const names = { "synth-chan": "Synth Channel", "own-chan": "Own Renamed" }; + // 1. the clip's own channelTitle still wins + assert.equal(channelName({ channelTitle: "Clip Says", channel: "synth-chan" }, { channel: "OLD UPLOADER" }, prov, names), "Clip Says"); + // 2. the project's name for the clip's channel beats the record's uploader name + assert.equal(channelName({ channel: "synth-chan" }, { channel: "OLD UPLOADER" }, prov, names), "Synth Channel"); + // ... and the sweep's own display name, for a clip of the sweep's channel (no `channel` of its own) + assert.equal(channelName({}, {}, prov, names), "Own Renamed"); + // ... and the bare slug + assert.equal(channelName({ channel: "synth-chan" }, {}, {}, names), "Synth Channel"); + // 3. a channel the map does not name falls through as before + assert.equal(channelName({ channel: "other" }, { channel: "Other Uploader" }, prov, names), "Other Uploader"); + // a blank name in the map is no name + assert.equal(channelName({ channel: "synth-chan" }, { channel: "OLD" }, prov, { "synth-chan": " " }), "OLD"); +}); + +test("channelName / attributionLine: no names (absent, null, {}) is today's answer exactly", () => { + const cases = [ + [{ channelTitle: "Destiny", channel: "x" }, { channel: "Y" }, { channelSlug: "omnibased", channel: "OmniBased" }], + [{ channel: "destiny" }, { channel: "Destiny" }, {}], + [{ channel: "omnibased" }, {}, { channelSlug: "omnibased", channel: "OmniBased" }], + [{ channel: "destiny", title: "T", date: "2026-01-02", cite: 75 }, {}, {}], + ]; + for (const [e, m, p] of cases) { + for (const names of [undefined, null, {}]) { + assert.equal(channelName(e, m, p, names), channelName(e, m, p)); + assert.equal(attributionLine(e, m, p, names), attributionLine(e, m, p)); + assert.deepEqual(attributionParts(e, m, p, names), attributionParts(e, m, p)); + } + } +}); + +test("attributionLine / attributionParts: the per-channel name reaches the header line and the parts", () => { + const e = { channel: "synth-chan", title: "Stream", date: "2031-03-01", cite: 2100 }; + const names = { "synth-chan": "Synth Channel" }; + assert.equal(attributionLine(e, { channel: "SYNTH OLD" }, {}, names), "Synth Channel · Stream · 2031-03-01 @ 35:00"); + assert.equal(attributionParts(e, { channel: "SYNTH OLD" }, {}, names).channel, "Synth Channel"); +}); + test("attributionLine: a cut that can name no channel reads as it always did", () => { assert.equal( attributionLine({ title: "Monday Mail #11", date: "2016-09-12", cite: 32989 }, {}), diff --git a/umtool/report-to-video/build-video.mjs b/umtool/report-to-video/build-video.mjs @@ -853,7 +853,7 @@ export function audioPosterParts({ posterIdx, box, render }) { * at the cut's fps, so the picture ends where the sound does. */ async function audioPosterInput({ entry, meta, provenance, render, outDir, box, seconds }) { - const parts = attributionParts(entry, meta ?? {}, provenance ?? {}); + const parts = attributionParts(entry, meta ?? {}, provenance ?? {}, render.channelNames); const card = { id: `${entry.id}.poster`, style: "chapter", @@ -1774,9 +1774,10 @@ async function buildClipSegment(entry, meta, render, dirs, opts, chrome, nodes, // a VOD mirror is often years after the stream. A clip may carry // `channelTitle`, `date` (the stream's own YYYY-MM-DD) and `title` (a display // title) to override the record's. - await replaceFile(attribPath, attributionLine(entry, meta, provenance)); + // `render.channelNames` (the cut's own name for a channel) sits between the clip's channelTitle and the record's. + await replaceFile(attribPath, attributionLine(entry, meta, provenance, render.channelNames)); // A brand draws the line's head -- the channel -- in the foreground colour. - const who = render.brand ? channelName(entry, meta, provenance) : ""; + const who = render.brand ? channelName(entry, meta, provenance, render.channelNames) : ""; const channelPath = who ? path.join(outDir, "segments", `${entry.id}.channel.txt`) : null; if (channelPath) await replaceFile(channelPath, who); @@ -1962,7 +1963,7 @@ async function buildClipSegment(entry, meta, render, dirs, opts, chrome, nodes, const graph = verticalClipGraph({ geo, srcW: sw, srcH: sh, crop: entry.vertical?.crop ?? null, blur: [...(await blurPicture(sw, sh)), ...zoom], side, fps: render.fps, W: width, H: height, }); - const tag = sourceTagText({ channel: channelName(entry, meta, provenance), date: entry.date ?? uploadDateToIso(meta.uploadDate) }); + const tag = sourceTagText({ channel: channelName(entry, meta, provenance, render.channelNames), date: entry.date ?? uploadDateToIso(meta.uploadDate) }); // The promo's timing for the captions (the card itself is drawn below): from when, over how long, into which band. const promoSpec = dirs.vertical.promoFor === entry.id ? promoOf(entry, render, segSeconds) : null; const promoNow = promoSpec ? { from: Math.max(0, segSeconds - promoSpec.lead), fade: promoSpec.fade, captions: promoSpec.captions, band: promoBand({ width, height, captions: promoSpec.captions }).band } : null; @@ -6484,7 +6485,7 @@ export async function segmentOffsets(segments, D, fps) { * the deck an `onscreen` value is not drawn, so it does not name a chapter * either: a manifest without `render.chrome` builds exactly as it did. */ -export async function chapterTitle(entry, index, provenance, { deck = false } = {}) { +export async function chapterTitle(entry, index, provenance, { deck = false, names = null } = {}) { if (entry.chapter) return entry.chapter; if (deck && entry.onscreen?.title) return entry.onscreen.title; // A teaser is named by its own words, with or without the deck. @@ -6517,7 +6518,7 @@ export async function chapterTitle(entry, index, provenance, { deck = false } = // while you watch. The channel is in both for the same reason: a chapter // list for a cut spanning three mirrors has to say which one each jump // lands in. - const who = channelName(entry, meta, provenance); + const who = channelName(entry, meta, provenance, names); const date = entry.date ?? uploadDateToIso(meta.uploadDate); const title = String(entry.title ?? meta.title ?? clipLabel(entry)); const tail = `${date} — ${title.length > 60 ? `${title.slice(0, 57)}…` : title}`.trim(); @@ -6765,7 +6766,7 @@ export function foldIntroChapter(chapters, entries) { // Returns the chapters it muxed (`{ chapters: [{ start, end, title }], total }`, // seconds) -- the list out/youtube.txt's Chapters are made from -- or null // when the cut is one segment and gets none. -async function muxChapters(finalPath, entries, segments, D, outDir, provenance, fps, deck = false, joins = null, { disclosure = null } = {}) { +async function muxChapters(finalPath, entries, segments, D, outDir, provenance, fps, deck = false, joins = null, { disclosure = null, names = null } = {}) { if (segments.length < 2) return null; // The cut's own offsets: under the deck a held clip is longer in the cut // than its file, and every chapter after it starts that much later. @@ -6777,7 +6778,7 @@ async function muxChapters(finalPath, entries, segments, D, outDir, provenance, // rather than on the outgoing one mid-dissolve. const start = i === 0 ? 0 : starts[i] + D; const end = i === entries.length - 1 ? total : starts[i + 1] + D; - const title = await chapterTitle(entries[i], i, provenance, { deck }); + const title = await chapterTitle(entries[i], i, provenance, { deck, names }); // `section`: the entry opens one of the cut's sections (a card) -- what // out/youtube.txt's Chapters keep (youtube.mjs youtubeChapters). // `id` and `cutStart` (where its segment starts, before the crossfade): @@ -7694,7 +7695,7 @@ export async function buildVideo({ manifestPath, opts = {}, out, only, fetchOnly } // Under the deck the cut's offsets include the holds: measured, not written. const joins = deck ? segmentJoins(await measureChromeSchedule({ manifest, entries, segments: segs, D })) : null; - const muxed = await muxChapters(finalPath, entries, segs, D, outDir, provenance, render.fps, deckOn(render), joins, { disclosure: await readCutDisclosure(narrationStore, manifest, " ") }); + const muxed = await muxChapters(finalPath, entries, segs, D, outDir, provenance, render.fps, deckOn(render), joins, { disclosure: await readCutDisclosure(narrationStore, manifest, " "), names: render.channelNames ?? null }); await writeYoutubeText(manifest, entries, outRoot, variant, muxed); return { out: finalPath, failures: [] }; } @@ -7731,7 +7732,7 @@ export async function buildVideo({ manifestPath, opts = {}, out, only, fetchOnly // gone. Put them back, or --rail-only quietly ships a chapterless cut. const muxed = opts.noChapters ? null - : await muxChapters(out, entries, segs, D, outDir, provenance, render.fps, deckOn(render), null, { disclosure: await readCutDisclosure(narrationStore, manifest, " ") }); + : await muxChapters(out, entries, segs, D, outDir, provenance, render.fps, deckOn(render), null, { disclosure: await readCutDisclosure(narrationStore, manifest, " "), names: render.channelNames ?? null }); await writeYoutubeText(manifest, entries, outRoot, variant, muxed, opts.noChapters ? "--no-chapters" : null); } EMIT("done", { out, failures: [] }); @@ -7926,7 +7927,7 @@ export async function buildVideo({ manifestPath, opts = {}, out, only, fetchOnly // The overlay re-encodes, so the chapters on the previous final are gone. const muxed = opts.noChapters ? null - : await muxChapters(dirs.final, entries, segs, D, outDir, provenance, render.fps, deckOn(render), joins, { disclosure: await readCutDisclosure(narrationStore, manifest, " ") }); + : await muxChapters(dirs.final, entries, segs, D, outDir, provenance, render.fps, deckOn(render), joins, { disclosure: await readCutDisclosure(narrationStore, manifest, " "), names: render.channelNames ?? null }); await writeYoutubeText(manifest, entries, outRoot, variant, muxed, opts.noChapters ? "--no-chapters" : null); await reportSync({ outDir, final: dirs.final, entries, segments: segs, D, render, joins }); await pruneFrames(); @@ -8118,7 +8119,7 @@ export async function buildVideo({ manifestPath, opts = {}, out, only, fetchOnly const muxed = opts.noChapters ? null - : await muxChapters(final, entries, segments, D, outDir, provenance, render.fps, deckOn(render), joins, { disclosure: await readCutDisclosure(narrationStore, manifest, " ") }); + : await muxChapters(final, entries, segments, D, outDir, provenance, render.fps, deckOn(render), joins, { disclosure: await readCutDisclosure(narrationStore, manifest, " "), names: render.channelNames ?? null }); await writeYoutubeText(manifest, entries, outRoot, variant, muxed, opts.noChapters ? "--no-chapters" : null); await reportSync({ outDir, final, entries, segments, D, render, joins }); diff --git a/umtool/report-to-video/channel-names.test.mjs b/umtool/report-to-video/channel-names.test.mjs @@ -0,0 +1,86 @@ +// render.channelNames (lane channel-title): the cut's own name for a channel, +// reaching every place a clip's channel is printed -- the deck's subtitle, the +// stacked deck's source line, a short's end card, the analysis item's +// citation -- and, absent, leaving every one of them exactly as it was. +// +// Run with: pnpm test:scripts +import assert from "node:assert/strict"; +import test from "node:test"; + +import { deckSchedule, deckText, resolveDeck, stackedSegmentFields } from "./deck.mjs"; +import { endCardSources } from "./outro.mjs"; +import { analysisSource } from "./modules/analysis.mjs"; + +const PALETTE = { bg: "#12101a", fg: "#f4f1ea", muted: "#9a93ad", accent: "#a97bff", amber: "#ffc860" }; +const BASE = { width: 1920, height: 1080, fps: 30, transition: 0.5, palette: PALETTE, chrome: { engine: "hyperframes", layout: "deck", deck: {} } }; +const PROV = { siteOrigin: "https://example.test", channelSlug: "synth-chan", channel: "Synth Sweep" }; +// Two recordings of ONE channel whose records carry two uploader names, and a guest. +const CLIPS = [ + { id: "c1", type: "clip", channel: "synth-chan", video: "a", start: 60, end: 70, date: "2031-03-01" }, + { id: "c2", type: "clip", channel: "synth-chan", video: "b", start: 0, end: 20, date: "2031-04-01" }, + { id: "c3", type: "clip", channel: "guest-chan", video: "c", start: 0, end: 6, date: "2031-05-01" }, +]; +const METAS = [ + { title: "Old stream", uploadDate: "20310301", channel: "SYNTH OLD NAME" }, + { title: "New stream", uploadDate: "20310401", channel: "Synth Channel" }, + { title: "Guest show", uploadDate: "20310501", channel: "Guest Show" }, +]; +const DURS = [10, 20, 6]; +const sched = (render) => deckSchedule({ entries: CLIPS, durs: DURS, D: 0.5, render, provenance: PROV, metas: METAS }); + +test("deckSchedule: render.channelNames absent, empty, or naming no clip's channel -- the schedule is what it was", () => { + const before = sched(BASE); + assert.deepEqual(sched({ ...BASE, channelNames: {} }), before); + assert.deepEqual(sched({ ...BASE, channelNames: { "unused-chan": "Nobody" } }), before); + assert.equal(before.multiChannel, true); + assert.match(before.segments[0].subtitle, /^SYNTH OLD NAME · /, "the record's name, as before"); +}); + +test("deckSchedule: one channel's name for the whole cut -- both recordings say it, the guest is untouched", () => { + const before = sched(BASE); + const after = sched({ ...BASE, channelNames: { "synth-chan": "Synth Channel" } }); + assert.match(after.segments[0].subtitle, /^Synth Channel · Old stream · /); + assert.match(after.segments[1].subtitle, /^Synth Channel · New stream · /); + assert.equal(after.segments[2].subtitle, before.segments[2].subtitle); + // Only the channel's words moved: the rest of the schedule is the same. + const strip = (d) => JSON.stringify(d).replaceAll("SYNTH OLD NAME", "Synth Channel"); + assert.equal(strip(after), strip(before)); + // A clip's own channelTitle still beats the cut's name. + const own = deckSchedule({ + entries: [{ ...CLIPS[0], channelTitle: "Clip Own" }, ...CLIPS.slice(1)], durs: DURS, D: 0.5, + render: { ...BASE, channelNames: { "synth-chan": "Synth Channel" } }, provenance: PROV, metas: METAS, + }); + assert.match(own.segments[0].subtitle, /^Clip Own · /); +}); + +test("deckText and stackedSegmentFields take the names; without them they say what they said", () => { + const deck = resolveDeck(BASE); + const a = deckText(CLIPS[0], METAS[0], PROV, deck, true, ""); + assert.deepEqual(deckText(CLIPS[0], METAS[0], PROV, deck, true, "", undefined), a); + assert.match(deckText(CLIPS[0], METAS[0], PROV, deck, true, "", { "synth-chan": "Synth Channel" }).subtitle, /^Synth Channel · /); + const s = stackedSegmentFields(CLIPS[0], METAS[0], PROV, deck); + assert.equal(s.vsource.channel, "SYNTH OLD NAME"); + assert.equal(stackedSegmentFields(CLIPS[0], METAS[0], PROV, deck, { "synth-chan": "Synth Channel" }).vsource.channel, "Synth Channel"); +}); + +test("endCardSources: the cut's name for a clip with no schedule part; a clip's own title first; absent as before", () => { + const timeline = [ + { type: "clip", id: "a", channel: "synth-chan", video: "v1", start: 61 }, + { type: "clip", id: "b", channel: "synth-chan", video: "v2", start: 5, channelTitle: "Clip Own" }, + { type: "clip", id: "c", channel: "guest-chan", video: "v3", start: 7 }, + ]; + assert.deepEqual(endCardSources(timeline), [{ date: "", label: "1:01" }, { date: "", label: "Clip Own · 0:05" }, { date: "", label: "0:07" }]); + assert.deepEqual(endCardSources(timeline, null, { "synth-chan": "Synth Channel" }), [ + { date: "", label: "Synth Channel · 1:01" }, + { date: "", label: "Clip Own · 0:05" }, + { date: "", label: "0:07" }, + ]); +}); + +test("analysisSource: the analysis item's citation names the channel by the cut's name", () => { + const manifest = { provenance: PROV, render: { ...BASE }, timeline: [...CLIPS, { type: "analysis", id: "x1", audio: { clip: "c1", start: 62 } }] }; + const entry = manifest.timeline[3]; + assert.equal(analysisSource(entry, manifest, METAS[0]).parts.channel, "SYNTH OLD NAME"); + const named = { ...manifest, render: { ...BASE, channelNames: { "synth-chan": "Synth Channel" } } }; + assert.equal(analysisSource(entry, named, METAS[0]).parts.channel, "Synth Channel"); +}); diff --git a/umtool/report-to-video/deck.mjs b/umtool/report-to-video/deck.mjs @@ -1300,9 +1300,12 @@ const sameTitle = (a, b) => titleKey(a) === titleKey(b); * its two lines too (`subtitleLines`, deckSubtitleLines) -- never an entry's * own `onscreen.subtitle`, which is the one line its author typed. A clip's * `onscreen.title` that only repeats its source's title (sameTitle) is - * dropped when the two lines show that title. + * dropped when the two lines show that title. `names`: the cut's + * `render.channelNames` (attribution.mjs channelName), absent as before. + * + * @param {Record<string, unknown> | null} [names] */ -export function deckText(entry, meta, provenance, deck, multiChannel, status = "") { +export function deckText(entry, meta, provenance, deck, multiChannel, status = "", names = null) { const o = entry.onscreen ?? {}; let title = o.title ?? ""; let subtitle = o.subtitle; @@ -1317,7 +1320,7 @@ export function deckText(entry, meta, provenance, deck, multiChannel, status = " if (entry.type === "clip") { // The source status (source-status.mjs), when the deck draws it and the // stamp names a state: else no key, and the parts are what they were. - const parts = { ...attributionParts(entry, meta ?? {}, provenance), ...(status ? { status } : {}) }; + const parts = { ...attributionParts(entry, meta ?? {}, provenance, names), ...(status ? { status } : {}) }; subtitle = deckSubtitle(parts, deck.subtitle, multiChannel); subtitleParts = deckSubtitleParts(parts, deck.subtitle, multiChannel); if (two) subtitleLines = deckSubtitleLines(parts, deck.subtitle, multiChannel); @@ -1539,7 +1542,7 @@ export function deckSchedule({ multiChannel, ...(feed ? { layout: "feed" } : {}), segments: entries.map((e, i) => { - const { title, subtitle, subtitleParts, subtitleLines, subtitleLinesParts } = deckText(e, metas[i] ?? null, provenance, deck, multiChannel, statusOf(e)); + const { title, subtitle, subtitleParts, subtitleLines, subtitleLinesParts } = deckText(e, metas[i] ?? null, provenance, deck, multiChannel, statusOf(e), render.channelNames); return { id: e.id, type: e.type, @@ -1578,7 +1581,7 @@ export function deckSchedule({ ...(finIds.has(e.id) && resolveFinale(render).pips === false ? { noPip: true } : {}), // Only in the stacked vertical deck (vertical-deck.mjs): a clip's source line in its parts (channel, // title, date, the clock at its start), and a twocrop clip's layout -- its strip and its small QR. - ...(stacked ? stackedSegmentFields(e, metas[i] ?? null, provenance, deck) : {}), + ...(stacked ? stackedSegmentFields(e, metas[i] ?? null, provenance, deck, render.channelNames) : {}), }; }), // The finale: present only when the cut has one. @@ -1649,11 +1652,13 @@ export function deckSchedule({ * A segment's fields only the stacked vertical deck's page reads: a clip's * source line in its four parts (`vsource`: channel, title -- the deck's own * title when the entry sets one --, date, the clock at its start) and a - * twocrop clip's layout (`vlayout`). + * twocrop clip's layout (`vlayout`). `names`: the cut's `render.channelNames`. + * + * @param {Record<string, unknown> | null} [names] */ -export function stackedSegmentFields(entry, meta, provenance, deck) { +export function stackedSegmentFields(entry, meta, provenance, deck, names = null) { if (entry?.type !== "clip") return {}; - const p = attributionParts(entry, meta ?? {}, provenance); + const p = attributionParts(entry, meta ?? {}, provenance, names); const title = String(entry.onscreen?.title ?? "").trim() || String(p.title ?? "").trim(); return { vsource: { diff --git a/umtool/report-to-video/modules/analysis.mjs b/umtool/report-to-video/modules/analysis.mjs @@ -24,7 +24,7 @@ export function analysisSource(entry, manifest, meta = null) { const at = { ...clip, cite: Number(a.start), start: Number(a.start) }; const links = resolveDeck(manifest?.render ?? {}).qr?.links; return { - parts: attributionParts(at, meta ?? {}, manifest?.provenance ?? {}), + parts: attributionParts(at, meta ?? {}, manifest?.provenance ?? {}, manifest?.render?.channelNames), url: deckQrUrl(at, manifest?.provenance ?? {}, { ...(links ? { links } : {}), meta }), }; } diff --git a/umtool/report-to-video/modules/panel.mjs b/umtool/report-to-video/modules/panel.mjs @@ -18,8 +18,8 @@ import { MODULES } from "./index.mjs"; const isObj = (v) => v !== null && typeof v === "object" && !Array.isArray(v); -/** Look keys whose writer merges a patch into what it holds (common look.mjs applyLookPatch): the gap mark's. */ -const MERGED_LOOK_KEYS = new Set(["gapCue"]); +/** Look keys whose writer merges a patch into what it holds (common look.mjs applyLookPatch): the gap mark's, the channel names. */ +const MERGED_LOOK_KEYS = new Set(["gapCue", "channelNames"]); /** Where a module's ui keys are rooted. */ export function uiBase(m) { diff --git a/umtool/report-to-video/outro.mjs b/umtool/report-to-video/outro.mjs @@ -31,6 +31,7 @@ import path from "node:path"; import { promisify } from "node:util"; import { FONTCONFIG_FILE } from "./brand.mjs"; +import { cutChannelName } from "./attribution.mjs"; const execFileP = promisify(execFile); const exists = (p) => access(p).then(() => true, () => false); @@ -219,14 +220,16 @@ export function endCardDate(d) { /** * The sources an end card lists: each clip of `timeline` once (by video), in order -- its date, its channel and - * the time it is from, from the build's schedule (a stacked deck's `vsource`) else what the entry says of itself. - * Pure. + * the time it is from, from the build's schedule (a stacked deck's `vsource`) else what the entry says of itself -- + * its own `channelTitle`, else the cut's name for its channel (`names`, the cut's `render.channelNames`). Pure. * * @param {Array<Record<string, any>>} timeline * @param {{ segments?: Array<Record<string, any>> } | null} [schedule] + * @param {Record<string, unknown> | null} [names] + * @param {{ channelSlug?: string | null }} [provenance] * @returns {Array<{ date: string, label: string }>} */ -export function endCardSources(timeline, schedule = null) { +export function endCardSources(timeline, schedule = null, names = null, provenance = {}) { const bySeg = new Map((Array.isArray(schedule?.segments) ? schedule.segments : []).map((x) => [x.id, x])); const seen = new Set(); const out = []; @@ -236,7 +239,7 @@ export function endCardSources(timeline, schedule = null) { if (seen.has(key)) continue; seen.add(key); const v = bySeg.get(e.id)?.vsource ?? bySeg.get(String(e.id).replace(/~\d+$/, ""))?.vsource ?? null; - const channel = String(v?.channel ?? e.channelTitle ?? "").trim(); + const channel = String(v?.channel ?? (String(e.channelTitle ?? "").trim() || cutChannelName(e, provenance, names))).trim(); const at = Number(e.cite ?? e.start); const clock = v?.clock ?? (Number.isFinite(at) ? hmsOf(at) : ""); const label = [channel, clock].filter(Boolean).join(" · ");