commit e6a07ce54701019ee6f02725c0d3b2c5cae73f10 parent 46641414709bc523a2564dcd1abdc80abc45f2a0 Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st> Date: Fri, 13 Nov 2026 21:02:37 -0500 clip kit B: a clip's QR -- its corner, the source at its second, a short's code render.qr.corner (br default | bl | tr | tl) and render.qr.links (cite default | moment | channel), a clip's own `qr` (false | {corner, links}) over the cut's, and a short's code (render.vertical.qr, `umtool vertical --qr on --qr-corner tr|tl`: top of the safe area, the moment by default). A moment link is the clip's own recording at the second it plays from: its citeUrl retimed when it names this recording, else the record's webpage_url, a mirror's citeUrl as written (report-to-video clip-kit.mjs). One table for the per-platform seek rule, common/lib/platformSeek.mjs: momentUrl.ts (verified parameters only) and watchUrlAt (every platform's) read it; neither writes anything new. Kick's t= is marked unconfirmed in its comment; vodExpiry.ts reads the retention numbers from it. A moment code to a Kick or Twitch VOD is a lint note naming the expiry. Set from the Look panel (QR corner, QR links), the clip editor's Short panel (QR on this clip, op "kit"), umtool look qr={...}, umtool set qr.corner=/qr.links=/qr=/name=. No new key: the corner code's overlay and link are byte for byte as before (tested). Co-Authored-By: Claude <noreply@anthropic.com> Diffstat:
31 files changed, 762 insertions(+), 69 deletions(-)
diff --git a/common/lib/clips/assist.mjs b/common/lib/clips/assist.mjs @@ -17,6 +17,7 @@ // // Plain ESM with a .d.mts beside it. import { textIn } from "./clips.mjs"; +import { seekPlatformOfUrl, seekRuleOf, seekValue } from "../platformSeek.mjs"; export const ASSIST_BY = Object.freeze(["assistant", "operator"]); export const ASSIST_EDITS = Object.freeze(["trim", "split", "merge", "add", "restore"]); @@ -95,23 +96,22 @@ export const cutOf = (e) => (num(e?.cutStart) && num(e?.cutEnd) ? { start: e.cut * on no site links its source there): YouTube `t=<s>s`, Twitch `t=<h>h<m>m<s>s`, * Rumble `start=<s>`, anything else `t=<s>` — added with `&` or `?`, an * existing one of the same name replaced. Null for a URL that is not one. + * The rule per platform, and how sure it is (Kick's is NOT confirmed), is + * ../platformSeek.mjs; this writer writes every platform's parameter, sure or not. * @param {string | null | undefined} url the recording's `webpage_url` * @param {number} seconds * @returns {string | null} */ export function watchUrlAt(url, seconds) { if (typeof url !== "string" || !/^https?:\/\//i.test(url)) return null; - let host; try { - host = new URL(url).hostname.toLowerCase().replace(/^(?:www|m)\./, ""); + new URL(url); } catch { return null; } - const s = Math.max(0, Math.floor(Number(seconds) || 0)); - const youtube = host === "youtube.com" || host === "youtu.be" || host.endsWith(".youtube.com"); - const twitch = host === "twitch.tv" || host.endsWith(".twitch.tv"); - const key = host === "rumble.com" ? "start" : "t"; - const value = youtube ? `${s}s` : twitch ? `${Math.floor(s / 3600)}h${Math.floor((s % 3600) / 60)}m${s % 60}s` : String(s); + const rule = seekRuleOf(seekPlatformOfUrl(url)); + const key = rule.key; + const value = seekValue(rule, seconds); const hash = url.indexOf("#"); const base = hash >= 0 ? url.slice(0, hash) : url; const frag = hash >= 0 ? url.slice(hash) : ""; diff --git a/common/lib/momentUrl.ts b/common/lib/momentUrl.ts @@ -20,6 +20,7 @@ import { detectPlatform, type Platform } from "./platform"; import { parseWaybackUrl } from "./wayback"; +import { PLATFORM_SEEK, seekValue } from "./platformSeek.mjs"; export type MomentUrlInput = { // Public origin of the archilyzer viewer that owns this video (a RemoteSource @@ -35,18 +36,13 @@ export type MomentUrlInput = { platform?: Platform | null; }; -// Twitch watch/VOD URLs take an `XhYmZs` time token, not raw seconds. -function twitchTime(totalSeconds: number): string { - const s = Math.max(0, Math.floor(totalSeconds)); - const h = Math.floor(s / 3600); - const m = Math.floor((s % 3600) / 60); - return `${h}h${m}m${s % 60}s`; -} - -// Best-effort deep link into a platform's own watch page at `seconds`. Mirrors -// the per-platform time params the in-app players build. Platforms whose watch -// page has no reliable start param (Rumble, Kick, archive.org, BitChute) get -// the bare `webpageUrl`. +// Best-effort deep link into a platform's own watch page at `seconds`. WHICH +// parameter each platform takes, and how sure we are, is one table: +// lib/platformSeek.mjs (PLATFORM_SEEK). This writer's policy is to write only a +// `verified` one (YouTube, Twitch, Odysee); Rumble, Kick, archive.org, BitChute +// and anything unknown get the bare `webpageUrl` rather than a seek that may be +// ignored. (lib/clips/assist.mjs watchUrlAt reads the same table with the +// opposite policy: it writes every platform's parameter.) // Returns null only when there is no `webpageUrl` to work from. export function platformMomentUrl( webpageUrl: string | null | undefined, @@ -66,24 +62,10 @@ export function platformMomentUrl( } catch { return webpageUrl; } - switch (plat) { - case "youtube": - u.searchParams.set("t", `${secs}s`); - return u.toString(); - case "odysee": - u.searchParams.set("t", String(secs)); - return u.toString(); - case "twitch": - u.searchParams.set("t", twitchTime(secs)); - return u.toString(); - // Rumble / Kick / archive.org / BitChute / unknown: the watch page has no - // dependable start param — return the plain webpage URL rather than an - // invalid seek. (archive.org's and BitChute's own players take none we can - // rely on; the archive's viewer plays the file itself and seeks it — - // PlayerProvider.) - default: - return webpageUrl; - } + const rule = plat && Object.prototype.hasOwnProperty.call(PLATFORM_SEEK, plat) ? PLATFORM_SEEK[plat as keyof typeof PLATFORM_SEEK] : null; + if (!rule?.verified) return webpageUrl; + u.searchParams.set(rule.key, seekValue(rule, secs)); + return u.toString(); } // The archilyzer viewer deep link, or null when `siteOrigin`/`slug` are missing diff --git a/common/lib/platformSeek.d.mts b/common/lib/platformSeek.d.mts @@ -0,0 +1,10 @@ +// Types for ./platformSeek.mjs (lane clip-kit): the per-platform seek rule and the VOD retention table. + +export type SeekRule = { key: string; form: "seconds" | "seconds-s" | "hms"; verified: boolean; why: string }; + +export const PLATFORM_SEEK: Readonly<Record<"youtube" | "twitch" | "odysee" | "rumble" | "kick", SeekRule>>; +export const UNKNOWN_SEEK: SeekRule; +export const VOD_RETENTION_DAYS: Readonly<{ kick: number; twitch: number }>; +export function seekPlatformOfUrl(url: string | null | undefined): "youtube" | "twitch" | "rumble" | "kick" | "odysee" | null; +export function seekRuleOf(platform: string | null | undefined): SeekRule; +export function seekValue(rule: SeekRule, seconds: number): string; diff --git a/common/lib/platformSeek.mjs b/common/lib/platformSeek.mjs @@ -0,0 +1,68 @@ +// THE PER-PLATFORM SEEK RULE, in one place (lane clip-kit): which query parameter a platform's own watch page takes +// to start at a second, in what form, and how sure this repository is of it -- and how long a platform keeps a +// stream's VOD. Two writers read it, each with its own policy, and neither changed what it writes: +// +// common/lib/momentUrl.ts platformMomentUrl the archive, the MCP and publishing: only a `verified` parameter is +// written; any other platform gets its bare watch page. +// common/lib/clips/assist.mjs watchUrlAt the clip finder's citeUrl, the share line, the link policy and umtool's +// per-clip QR: every platform's parameter here, `t=<s>` for an unknown +// host. +// +// They disagree on purpose where the rule is unsure: Rumble and Kick. +// rumble `?start=<s>`: what the share line and the link policy have written since release 36. momentUrl.ts says +// the watch page has "no dependable start param", so it does not write it. +// kick NOT CONFIRMED. Nothing in this repository (code, docs or tests) shows that a kick.com VOD page honours +// a time parameter. watchUrlAt writes `?t=<s>` as it does for any host it does not know; at worst the +// page opens at its start. Kick also deletes free-tier VODs after about 30 days (VOD_RETENTION_DAYS). +// Confirm one by hand, then set `verified: true` here and every writer follows. +// +// Plain ESM, no imports: the TS app code and the plain-node build tools read the same table. + +/** + * @typedef {{ key: string, form: "seconds" | "seconds-s" | "hms", verified: boolean, why: string }} SeekRule + */ + +/** @type {Readonly<Record<string, SeekRule>>} */ +export const PLATFORM_SEEK = Object.freeze({ + youtube: Object.freeze({ key: "t", form: "seconds-s", verified: true, why: "YouTube's watch page: t=<s>s" }), + twitch: Object.freeze({ key: "t", form: "hms", verified: true, why: "Twitch's VOD page: t=<h>h<m>m<s>s" }), + odysee: Object.freeze({ key: "t", form: "seconds", verified: true, why: "Odysee's page: t=<s>" }), + rumble: Object.freeze({ key: "start", form: "seconds", verified: false, why: "Rumble's page: start=<s>, written by the share line; momentUrl.ts finds no dependable start param" }), + kick: Object.freeze({ key: "t", form: "seconds", verified: false, why: "Kick's VOD page: no time parameter is confirmed in this repository; t=<s> is the generic guess" }), +}); + +/** A host this rule does not know: the generic guess (watchUrlAt writes it; momentUrl.ts does not). */ +export const UNKNOWN_SEEK = Object.freeze({ key: "t", form: "seconds", verified: false, why: "an unknown platform: t=<s> is a guess" }); + +/** + * How long (days) a platform keeps a stream's VOD before it is deleted. Only platforms whose VODs expire; best-effort + * thresholds (common/lib/vodExpiry.ts explains each), not promises. + */ +export const VOD_RETENTION_DAYS = Object.freeze({ kick: 30, twitch: 14 }); + +/** The platform a watch page's host belongs to, among the ones the rule knows; null for any other. */ +export function seekPlatformOfUrl(url) { + let host; + try { + host = new URL(String(url)).hostname.toLowerCase().replace(/^(?:www|m)\./, ""); + } catch { + return null; + } + if (host === "youtube.com" || host === "youtu.be" || host.endsWith(".youtube.com")) return "youtube"; + if (host === "twitch.tv" || host.endsWith(".twitch.tv")) return "twitch"; + if (host === "rumble.com") return "rumble"; + if (host === "kick.com" || host.endsWith(".kick.com")) return "kick"; + if (host === "odysee.com") return "odysee"; + return null; +} + +/** A platform's rule (`platform` a Platform id), else the generic guess. */ +export const seekRuleOf = (platform) => (platform && Object.prototype.hasOwnProperty.call(PLATFORM_SEEK, platform) ? PLATFORM_SEEK[platform] : UNKNOWN_SEEK); + +/** A second written in a rule's form. */ +export function seekValue(rule, seconds) { + const s = Math.max(0, Math.floor(Number(seconds) || 0)); + if (rule.form === "seconds-s") return `${s}s`; + if (rule.form === "hms") return `${Math.floor(s / 3600)}h${Math.floor((s % 3600) / 60)}m${s % 60}s`; + return String(s); +} diff --git a/common/lib/platformSeek.test.ts b/common/lib/platformSeek.test.ts @@ -0,0 +1,38 @@ +// The per-platform seek rule (lane clip-kit): one table, two writers with their own policies, neither changed. +import { test } from "node:test"; +import assert from "node:assert/strict"; + +import { PLATFORM_SEEK, VOD_RETENTION_DAYS, seekPlatformOfUrl, seekRuleOf, seekValue } from "./platformSeek.mjs"; +import { platformMomentUrl } from "./momentUrl"; +import { watchUrlAt } from "./clips/assist.mjs"; +import { VOD_RETENTION_DAYS as EXPIRY_DAYS } from "./vodExpiry"; + +test("the table: each platform's parameter and form; Kick and Rumble not verified", () => { + assert.equal(seekValue(PLATFORM_SEEK.youtube, 3725.9), "3725s"); + assert.equal(seekValue(PLATFORM_SEEK.twitch, 3725), "1h2m5s"); + assert.equal(seekValue(PLATFORM_SEEK.kick, 10643.4), "10643"); + assert.deepEqual(Object.entries(PLATFORM_SEEK).filter(([, r]) => !r.verified).map(([p]) => p), ["rumble", "kick"]); + assert.equal(seekPlatformOfUrl("https://www.kick.com/x/videos/u"), "kick"); + assert.equal(seekPlatformOfUrl("https://youtu.be/abc"), "youtube"); + assert.equal(seekPlatformOfUrl("https://example.org/v"), null); + assert.equal(seekRuleOf(null).key, "t"); + assert.deepEqual(EXPIRY_DAYS, { ...VOD_RETENTION_DAYS }, "vodExpiry.ts reads the same numbers"); +}); + +test("watchUrlAt writes every platform's parameter, as it always did", () => { + assert.equal(watchUrlAt("https://www.youtube.com/watch?v=abc&t=5s", 61), "https://www.youtube.com/watch?v=abc&t=61s"); + assert.equal(watchUrlAt("https://www.twitch.tv/videos/1", 3725), "https://www.twitch.tv/videos/1?t=1h2m5s"); + assert.equal(watchUrlAt("https://rumble.com/v2abc-title.html", 61), "https://rumble.com/v2abc-title.html?start=61"); + assert.equal(watchUrlAt("https://kick.com/somechan/videos/u-u-i-d?t=1", 10643.7), "https://kick.com/somechan/videos/u-u-i-d?t=10643"); + assert.equal(watchUrlAt("https://example.org/v#frag", 7), "https://example.org/v?t=7#frag"); + assert.equal(watchUrlAt("not a url", 7), null); +}); + +test("platformMomentUrl writes only a verified parameter, as it always did", () => { + assert.equal(platformMomentUrl("https://www.youtube.com/watch?v=abc", "youtube", 61), "https://www.youtube.com/watch?v=abc&t=61s"); + assert.equal(platformMomentUrl("https://www.twitch.tv/videos/1", "twitch", 3725), "https://www.twitch.tv/videos/1?t=1h2m5s"); + assert.equal(platformMomentUrl("https://odysee.com/@c/v", "odysee", 9), "https://odysee.com/@c/v?t=9"); + assert.equal(platformMomentUrl("https://rumble.com/v2abc.html", "rumble", 61), "https://rumble.com/v2abc.html"); + assert.equal(platformMomentUrl("https://kick.com/somechan/videos/u", "kick", 61), "https://kick.com/somechan/videos/u"); + assert.equal(platformMomentUrl("https://kick.com/somechan/videos/u", "kick", 0), "https://kick.com/somechan/videos/u"); +}); diff --git a/common/lib/report/look.d.mts b/common/lib/report/look.d.mts @@ -6,6 +6,8 @@ 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"; export const LOOK_KEYS: readonly LookKey[]; +export const QR_CORNERS: readonly ["br", "bl", "tr", "tl"]; +export const QR_LINK_VALUES: readonly ["cite", "moment", "channel"]; export const BAND_MAX: number; export const TRANSITION_MAX: number; export const TRANSITION_DEFAULT: number; diff --git a/common/lib/report/look.mjs b/common/lib/report/look.mjs @@ -26,6 +26,9 @@ const q = (v) => JSON.stringify(v); const round2 = (n) => Number(Number(n).toFixed(2)); /** The render keys the Look panel writes, in its order. */ +/** 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"]); /** `headerHeight` / `footerHeight`: whole pixels, 0 (off) to this. */ @@ -432,7 +435,22 @@ export function applyLookPatch(manifest, patch) { if (v === false) render.qr = false; else if (v === true) { if (render.qr === false) delete render.qr; - } else errors.push("render.qr must be true (on) or false (off)"); + } else if (isObj(v)) { + // The clip kit (lane clip-kit): the code's corner and link, merged over its settings (a key null drops it). + const bad = Object.keys(v).filter((x) => !["corner", "links"].includes(x)); + if (bad.length) errors.push(`render.qr.${bad[0]} is not set here: corner (br, bl, tr, tl) and links (cite, moment, channel) are`); + else if (v.corner != null && !QR_CORNERS.includes(/** @type {string} */ (v.corner))) errors.push(`render.qr.corner is one of ${QR_CORNERS.join(", ")}`); + else if (v.links != null && !QR_LINK_VALUES.includes(/** @type {string} */ (v.links))) errors.push(`render.qr.links is one of ${QR_LINK_VALUES.join(", ")}`); + else { + const next = { ...(isObj(render.qr) ? render.qr : {}) }; + for (const [x, y] of Object.entries(v)) { + if (y === null) delete next[x]; + else next[x] = y; + } + if (Object.keys(next).length) render.qr = next; + else delete render.qr; + } + } else errors.push("render.qr must be true (on), false (off) or {corner?, links?}"); break; case "transition": if (typeof v !== "number" || !Number.isFinite(v) || v < 0 || v > TRANSITION_MAX) errors.push(`render.transition must be a number of seconds from 0 (a hard cut) to ${TRANSITION_MAX}`); diff --git a/common/lib/report/vertical.d.mts b/common/lib/report/vertical.d.mts @@ -17,6 +17,7 @@ export type VerticalKnobs = { safe: { top: number; bottom: number; right: number }; loudness: number; maxSeconds: number; + qr: false | true | { corner?: "tr" | "tl"; size?: number; links?: "cite" | "moment" | "channel" }; }; export const RENDER_FORMATS: readonly ("landscape" | "vertical")[]; export const VERTICAL_CLIP_LAYOUTS: readonly ClipLayout[]; @@ -46,3 +47,9 @@ export function validateClipSides(manifest: unknown): string[]; export function sidePostOf(entry: unknown, timeline?: unknown[]): Record<string, unknown> | null; export function sideSpan(side: unknown, seconds: number): { from: number; to: number } | null; export function validateVerticalFormat(manifest: unknown): string[]; + +export const VERTICAL_QR_CORNERS: readonly ["tr", "tl"]; +export const VERTICAL_QR_KEYS: readonly string[]; +export const VERTICAL_QR_SIZE: Readonly<{ min: number; max: number; default: number }>; +export const QR_LINKS: readonly ["cite", "moment", "channel"]; +export function verticalQrErrors(v: unknown, where?: string): string[]; diff --git a/common/lib/report/vertical.mjs b/common/lib/report/vertical.mjs @@ -74,6 +74,7 @@ export const VERTICAL_DEFAULTS = Object.freeze({ safe: Object.freeze({ top: 0.08, bottom: 0.2, right: 0.12 }), loudness: -14, maxSeconds: 60, + qr: false, }); export const VERTICAL_KEYS = Object.freeze(Object.keys(VERTICAL_DEFAULTS)); export const VERTICAL_SAFE_MAX = Object.freeze({ top: 0.25, bottom: 0.35, right: 0.25 }); @@ -95,9 +96,32 @@ export function verticalKnobs(render) { safe: { ...VERTICAL_DEFAULTS.safe, ...(isObj(v.safe) ? v.safe : {}) }, loudness: num(v.loudness) ? v.loudness : VERTICAL_DEFAULTS.loudness, maxSeconds: num(v.maxSeconds) ? v.maxSeconds : VERTICAL_DEFAULTS.maxSeconds, + qr: v.qr === true || isObj(v.qr) ? v.qr : VERTICAL_DEFAULTS.qr, }; } +/** A short's code (lane clip-kit; umtool report-to-video clip-kit.mjs draws it): where it may stand, its keys. */ +export const VERTICAL_QR_CORNERS = Object.freeze(["tr", "tl"]); +export const VERTICAL_QR_KEYS = Object.freeze(["corner", "size", "links"]); +export const VERTICAL_QR_SIZE = Object.freeze({ min: 0.1, max: 0.3, default: 0.16 }); +export const QR_LINKS = Object.freeze(["cite", "moment", "channel"]); + +/** Each thing wrong with `render.vertical.qr` ([] when fine): false (the default), true, or {corner?, size?, links?}. */ +export function verticalQrErrors(v, where = "render.vertical.qr") { + if (v === undefined || v === null || v === false || v === true) return []; + if (!isObj(v)) return [`${where} is true, false or {${VERTICAL_QR_KEYS.join(", ")}}`]; + const errors = []; + for (const k of Object.keys(v)) if (!VERTICAL_QR_KEYS.includes(k)) errors.push(`${where}.${k} is not a key (${VERTICAL_QR_KEYS.join(", ")})`); + if (v.corner !== undefined && !VERTICAL_QR_CORNERS.includes(v.corner)) { + errors.push(`${where}.corner is ${VERTICAL_QR_CORNERS.join(" or ")} (a short's captions run along its foot), not ${q(v.corner)}`); + } + if (v.size !== undefined && !(num(v.size) && v.size >= VERTICAL_QR_SIZE.min && v.size <= VERTICAL_QR_SIZE.max)) { + errors.push(`${where}.size is ${VERTICAL_QR_SIZE.min}–${VERTICAL_QR_SIZE.max} of the frame's width`); + } + if (v.links !== undefined && !QR_LINKS.includes(v.links)) errors.push(`${where}.links is one of ${QR_LINKS.join(", ")}, not ${q(v.links)}`); + return errors; +} + /** A clip's layout in a vertical cut: its own `vertical.layout`, else the cut's ("twocrop" is the stacked deck's: clipTwoCrop). */ export function clipLayoutOf(entry, render) { const own = entry?.vertical?.layout; @@ -155,6 +179,7 @@ export function validateVerticalRender(manifest) { } else if (!VERTICAL_HOOKS.includes(v.hook)) errors.push(`render.vertical.hook must be false, ${VERTICAL_HOOKS.map(q).join(", ")} or {text}`); } if (v.tag !== undefined && typeof v.tag !== "boolean") errors.push("render.vertical.tag must be true or false"); + errors.push(...verticalQrErrors(v.qr)); if (v.safe !== undefined) { if (!isObj(v.safe)) errors.push("render.vertical.safe must be {top?, bottom?, right?}"); else { diff --git a/common/lib/vodExpiry.ts b/common/lib/vodExpiry.ts @@ -1,5 +1,6 @@ import type { Platform } from "./platform"; import { daysSince } from "./format"; +import { VOD_RETENTION_DAYS as SEEK_RETENTION_DAYS } from "./platformSeek.mjs"; // Retention window (days) after which a platform's stream VODs are typically // deleted, making playback impossible. Only platforms whose VODs expire appear @@ -13,10 +14,8 @@ import { daysSince } from "./format"; // "Likely expired" wording + the tooltip acknowledge the uncertainty for // partner (still up to 60d) and regular (already gone at 7d) accounts. // Tune here if the retention policy changes. -export const VOD_RETENTION_DAYS: Partial<Record<Platform, number>> = { - kick: 30, - twitch: 14, -}; +// The numbers are lib/platformSeek.mjs's (one table: umtool's per-clip QR reads them too). +export const VOD_RETENTION_DAYS: Partial<Record<Platform, number>> = { ...SEEK_RETENTION_DAYS }; const RETENTION_TOOLTIP: Partial<Record<Platform, string>> = { kick: "Kick keeps VODs about 30 days after the stream, so this one has most likely been deleted. The transcript is still searchable here.", diff --git a/common/package.json b/common/package.json @@ -42,6 +42,7 @@ "./lib/atomicFile.mjs": "./lib/atomicFile.mjs", "./lib/cueWiden.mjs": "./lib/cueWiden.mjs", "./lib/detectPlatform.mjs": "./lib/detectPlatform.mjs", + "./lib/platformSeek.mjs": "./lib/platformSeek.mjs", "./lib/projectsRoot.mjs": "./lib/projectsRoot.mjs", "./lib/evidenceClip.mjs": "./lib/evidenceClip.mjs", "./lib/recordingClock.mjs": "./lib/recordingClock.mjs", diff --git a/editor/CHANGELOG.md b/editor/CHANGELOG.md @@ -1,6 +1,19 @@ # Changelog ## [Unreleased] +- **umtool: a clip's QR can stand in any corner and link the source at the clip's second.** + - `render.qr.corner` is `br` (the default) or `bl`, `tr` or `tl`, so the code can stay off the streamer's camera box. + - `render.qr.links` is `cite` (the default), `moment` or `channel`. `moment` links the clip's own recording at the + second it starts playing; `channel` links the promo's page. + - A clip's own `qr` (`false`, or `{corner, links}`) speaks over the cut's. + - A short can carry a code too: `umtool vertical --qr on|--qr-corner tr|tl`, or `render.vertical.qr`. It sits at the + top of the safe area and links the moment by default. + - Where to set them: the Look panel (**QR corner**, **QR links**), the clip editor's Short panel (**QR on this + clip**), `umtool look` and `umtool set <p> <clip> qr.corner=tl`. + - Each platform's time parameter now lives in one table, `common/lib/platformSeek.mjs`. Both link writers read it, + and neither writes anything new. Kick's `t=` is marked unconfirmed. + - A moment code to a Kick or Twitch VOD gets a lint note naming the platform's VOD expiry. + - With none of the new keys, the code is drawn exactly as before. - **umtool: a batch of shorts in one command, `umtool shorts`.** `umtool shorts <p> --take <t> (--items a,b | --all) --formats vertical,landscape` builds each clip in each format through the builder `umtool vertical` uses (the same layouts and flags), into the project's `shorts-<take>/`, as `<name>.<format>.mp4`. Each file gets its record, and the diff --git a/umtool/components/projects/report/LookPanel.tsx b/umtool/components/projects/report/LookPanel.tsx @@ -56,6 +56,8 @@ type Draft = { header: boolean; footer: boolean; qr: boolean; + qrCorner: string; + qrLinks: string; transition: string; style: string; loudness: "off" | "-16" | "custom"; @@ -76,12 +78,18 @@ type Draft = { mode: Mode; }; +/** One of render.qr's settings (the clip kit: corner, links), or its default. */ +const qrField = (qr: unknown, k: "corner" | "links", dflt: string) => + qr && typeof qr === "object" && typeof (qr as Record<string, unknown>)[k] === "string" ? String((qr as Record<string, unknown>)[k]) : dflt; + function draftOf(l: Look, mode: Mode = "deck"): Draft { const t = l.loudness?.target; return { header: l.headerHeight !== 0, footer: l.footerHeight !== 0, qr: l.qr !== false, + qrCorner: qrField(l.qr, "corner", "br"), + qrLinks: qrField(l.qr, "links", "cite"), transition: String(l.transition ?? 0.5), style: l.transitionStyle ?? "fade", loudness: typeof t !== "number" ? "off" : t === -16 ? "-16" : "custom", @@ -115,6 +123,10 @@ function patchOf(was: Look, d: Draft, view: View): Record<string, unknown> { if (d.header !== (was.headerHeight !== 0)) p.headerHeight = d.header ? null : 0; if (d.footer !== (was.footerHeight !== 0)) p.footerHeight = d.footer ? null : 0; if (d.qr !== (was.qr !== false)) p.qr = d.qr; + // The code's corner and link (the clip kit): merged into render.qr, a default written as no key. + if (d.qr && (d.qrCorner !== qrField(was.qr, "corner", "br") || d.qrLinks !== qrField(was.qr, "links", "cite"))) { + p.qr = { corner: d.qrCorner === "br" ? null : d.qrCorner, links: d.qrLinks === "cite" ? null : d.qrLinks }; + } const tr = Number(d.transition); if (tr !== (was.transition ?? 0.5)) p.transition = tr; if (d.style !== (was.transitionStyle ?? "fade")) p.transitionStyle = d.style === "fade" ? null : d.style; @@ -268,6 +280,25 @@ export default function LookPanel({ project }: { project: string }) { {check("header", "Header", "data-look-header")} {check("footer", "Timeline footer", "data-look-footer")} {check("qr", "QR code", "data-look-qr")} + {draft.qr && !view.deck && ( + <> + <Field label="QR corner"> + <Select data-look-qr-corner="" value={draft.qrCorner} disabled={busy} onChange={(e) => set({ qrCorner: e.target.value })}> + <option value="br">bottom right</option> + <option value="bl">bottom left</option> + <option value="tr">top right</option> + <option value="tl">top left</option> + </Select> + </Field> + <Field label="QR links" hint="moment: the source at the clip's second"> + <Select data-look-qr-links="" value={draft.qrLinks} disabled={busy} onChange={(e) => set({ qrLinks: e.target.value })}> + <option value="cite">the clip's link</option> + <option value="moment">the source at the clip's second</option> + <option value="channel">the channel (the promo's page)</option> + </Select> + </Field> + </> + )} </div> <div className="mt-3 flex flex-wrap items-end gap-4"> <Field label="Between clips, s"> diff --git a/umtool/components/projects/review/ClipEditor.tsx b/umtool/components/projects/review/ClipEditor.tsx @@ -890,7 +890,7 @@ export default function ClipEditor({ {view.reactionsError && <p className="m-0 text-[12px] text-reject-text">{view.reactionsError}</p>} {view.rulingsError && <p className="m-0 text-[12px] text-reject-text">{view.rulingsError}</p>} - <ShortMaker project={project} clipId={clip.id} short={view.shorts?.[clip.id] ?? null} framed={!!clip.vertical} framing={framing} onFraming={setFraming} onCentre={() => setCrop(null)} onMade={() => void reload().catch(() => {})} busy={busy} live={view.live?.status === "live"} /> + <ShortMaker project={project} clipId={clip.id} short={view.shorts?.[clip.id] ?? null} framed={!!clip.vertical} framing={framing} onFraming={setFraming} onCentre={() => setCrop(null)} onMade={() => void reload().catch(() => {})} busy={busy} live={view.live?.status === "live"} kit={clip.kit ?? {}} onKit={(patch, done) => void write({ op: "kit", clip: clip.id, kit: patch }, done)} /> <RenderTake project={project} render={render} takes={takes} takesHref={takesHref} /> </aside> </div> @@ -1591,7 +1591,7 @@ function SpeakerLabel({ speaker, busy, onSave }: { speaker: Speaker; busy: boole } /** Make a short: the clip at 1080x1920 from its box, a job; the one there is set aside, never overwritten. */ -function ShortMaker({ project, clipId, short, framed, framing, onFraming, onCentre, onMade, busy, live = false }: { +function ShortMaker({ project, clipId, short, framed, framing, onFraming, onCentre, onMade, busy, live = false, kit = {}, onKit }: { project: string; clipId: string; short: { mtimeMs: number; size: number; stale: boolean } | null; @@ -1604,6 +1604,9 @@ function ShortMaker({ project, clipId, short, framed, framing, onFraming, onCent // A live pre-clip project (plans/live-preclip.md): Share now cuts the window // from the recording in progress first (/api/report/live-share). live?: boolean; + // The clip kit (lane clip-kit): this clip's own keys as written, and their writer (op "kit"). + kit?: NonNullable<EditorClip["kit"]>; + onKit?: (patch: Record<string, unknown>, done: string) => void; }) { const [job, setJob] = useState<{ id: string; state: string; error: string | null } | null>(null); const [err, setErr] = useState<string | null>(null); @@ -1669,6 +1672,28 @@ function ShortMaker({ project, clipId, short, framed, framing, onFraming, onCent </a> )} </div> + {onKit && ( + <label className="flex items-center gap-1.5 text-[12px] text-text-2"> + QR on this clip + <select + data-kit-qr={clipId} + value={kit.qr === false ? "none" : kit.qr && typeof kit.qr === "object" && kit.qr.corner ? kit.qr.corner : "cut"} + disabled={busy} + onChange={(e) => { + const v = e.target.value; + onKit({ qr: v === "cut" ? null : v === "none" ? false : { ...(kit.qr && typeof kit.qr === "object" ? kit.qr : {}), corner: v } }, v === "cut" ? "The cut's QR on this clip" : v === "none" ? "No QR on this clip" : "Saved the clip's QR corner"); + }} + className="rounded-[3px] border border-seam-2 bg-transparent px-1 py-0.5 text-[12px] text-text" + > + <option value="cut">the cut’s</option> + <option value="none">none</option> + <option value="tr">top right</option> + <option value="tl">top left</option> + <option value="br">bottom right (16:9)</option> + <option value="bl">bottom left (16:9)</option> + </select> + </label> + )} {job && ( <p data-short-job={job.state} className="m-0 text-[12px] text-text-2"> {running ? "Rendering 1080×1920 in the heavy slot" : job.state === "done" ? "Made — on the Deliver tab's Shorts list" : `Failed${job.error ? `: ${job.error}` : ""}`} diff --git a/umtool/docs/cli.md b/umtool/docs/cli.md @@ -274,8 +274,8 @@ draft (the project's manifest); *project*: a project's other files, or reads; *c | `pool prune [--max-gb N] [--dry-run]` | the render pool pruned to its cap | form · *corpus* | | `pool verify [--sample N] [--all]` | the render pool's files checked | form · queued · *corpus* | | `trailer <project> [--take TAKE] [--reel REEL] [--beats BEATS] [--beats-json JSON] [--intro] [--finale N] [--xfade N] [--no-snap] [--out OUT] [--dry-run] [--candidates] [--vertical] [--layout reframe]` | a trailer or beat reel cut from a take's master | form · queued · *project* | -| `vertical <project> --take TAKE [--reel REEL] [--beats BEATS] [--items ITEMS] [--clip full\|framed\|quote] [--post card\|stack\|media] [--side split\|overlay] [--hook HOOK] [--captions l\|xl] [--lines 1\|2] [--loudness N] [--max N] [--name NAME] [--reframe] [--landscape] [--dry-run] [--intro] [--no-intro] [--no-outro] [--deck stacked\|bare]` | a vertical short (1080x1920) of a take's items | form · queued · *project* | -| `shorts <project> --take TAKE [--items ITEMS] [--all] [--again] [--formats FORMATS] [--clip full\|framed\|quote] [--post card\|stack\|media] [--side split\|overlay] [--hook HOOK] [--captions l\|xl] [--lines 1\|2] [--loudness N] [--max-vertical N] [--max-landscape N] [--deck stacked\|bare] [--replace] [--dry-run]` | a batch of shorts: each clip of a take in each format, into shorts-<take>/ | form · queued · *project* | +| `vertical <project> --take TAKE [--reel REEL] [--beats BEATS] [--items ITEMS] [--clip full\|framed\|quote] [--post card\|stack\|media] [--side split\|overlay] [--hook HOOK] [--captions l\|xl] [--lines 1\|2] [--loudness N] [--max N] [--name NAME] [--reframe] [--landscape] [--dry-run] [--intro] [--no-intro] [--no-outro] [--deck stacked\|bare] [--qr on\|off] [--qr-corner tr\|tl]` | a vertical short (1080x1920) of a take's items | form · queued · *project* | +| `shorts <project> --take TAKE [--items ITEMS] [--all] [--again] [--formats FORMATS] [--clip full\|framed\|quote] [--post card\|stack\|media] [--side split\|overlay] [--hook HOOK] [--captions l\|xl] [--lines 1\|2] [--loudness N] [--max-vertical N] [--max-landscape N] [--deck stacked\|bare] [--qr on\|off] [--qr-corner tr\|tl] [--replace] [--dry-run]` | a batch of shorts: each clip of a take in each format, into shorts-<take>/ | form · queued · *project* | | `trailer-beats <project> ls [--reel REEL]` | a reel's beats against its limit | form · *project* | | `trailer-beats <project> add <clip> [<span>] [--at N] [--label LABEL] [--take TAKE] [--reel REEL]` | a clip beat | form · *project* | | `trailer-beats <project> add-raw <at> <dur> [--at N] [--label LABEL] [--reel REEL]` | a beat of master seconds | form · *project* | @@ -549,6 +549,8 @@ $U vertical emberparadox/mr-obvious --take mid-14 --reel short-die --reframe --j - **The cut itself vertical**: `umtool look <p> format='"vertical"' vertical='{"clip":"framed","post":"card"}'` (or the same keys in a take's patch) renders the whole timeline 9:16 -- `umtool take` as ever. - `--landscape` builds the same items in the take's 16:9 look, to compare (a side post is a panel at the right). +- **A code on the short:** `--qr on` (or `--qr-corner tr|tl`) puts one at the top of the safe area, linking the source at + the second each clip plays from ([knobs.md](knobs.md#a-clips-qr-its-corner-and-its-link)). - **Many clips, both formats, one command:** `umtool shorts` ([below](#make-promo-clips-a-batch-of-shorts)). - **The intro and the outro card.** `--intro` opens the short on the brand intro re-laid 9:16 -- the same style, sound, timing and site swap, the drawing centred in the safe area -- from the take's `render.intro`, else diff --git a/umtool/docs/knobs.md b/umtool/docs/knobs.md @@ -379,6 +379,34 @@ project without the knob. |---|---|---|---| | taller windows | — | `umtool look <p> tallWindows=true` (`false` turns it off) | `PUT /api/report/render {patch: {tallWindows}}` | +## A clip's QR: its corner and its link + +The corner code a cut with no deck draws on each clip (`render.qr`), and the code a short draws (`render.vertical.qr`), +can stand in another corner and link another page (lane clip-kit; `report-to-video/clip-kit.mjs`). With none of these +keys the code is where it always was (bottom right) with the link it always had (the clip's `citeUrl`, else its moment +on the archive). + +| Knob | Values (default) | What it does | +|---|---|---| +| `render.qr.corner` | `br` · `bl` · `tr` · `tl` (`br`) | where the code stands: off the streamer's own camera box | +| `render.qr.links` | `cite` · `moment` · `channel` (`cite`) | `cite` the clip's link as it always was; `moment` the SOURCE at the second the clip starts playing; `channel` the channel promo's page (`render.promo.url`) | +| a clip's `qr` | `false` · `{corner?, links?}` | no code on this clip, or its own corner and link over the cut's (a short keeps `tr`/`tl`) | + +**A moment link** is the clip's own recording at the second it plays from (the build's snapped start): its `citeUrl` +retimed when the citeUrl names this recording (it carries the clip's video id); with no citeUrl, the record's +`webpage_url` at that second; a citeUrl naming another recording (a mirror cited on purpose) as written. The time +parameter per platform is one table, `common/lib/platformSeek.mjs`: YouTube `t=<s>s`, Twitch `t=<h>h<m>m<s>s`, Odysee +`t=<s>`, Rumble `start=<s>`, and **Kick `t=<s>`, which is not confirmed** — nothing in the repository shows a kick.com +VOD page honours it (at worst it opens at the start). A moment code to a Kick or Twitch VOD is a lint NOTE: those VODs +are deleted after about 30 / 14 days (`VOD_RETENTION_DAYS`), and the code stops opening then; `links: "channel"` +lasts. The build records a code that is not `cite` in the clip's cut record (`qr: {url, corner}`). + +| | In umtool | From a terminal | +|---|---|---| +| the cut's corner and link | Build, **Look**: **QR corner**, **QR links** (with **QR code** on) | `umtool look <p> qr='{"corner":"tl","links":"moment"}'` (`null` for a key: its default) | +| one clip's | the clip editor's **Short**: **QR on this clip** (the cut's / none / a corner) | `umtool set <p> <clip> qr.corner=tl` · `qr.links=moment` · `qr=false` · `qr=` (the cut's) | +| a short's code | — | `umtool vertical <p> … --qr on` · `--qr-corner tl` · `umtool look <p> vertical='{"qr":true}'` | + ## Basic output (the footage alone) `render.mode: "basic"` renders the cut as its footage and nothing else (`report-to-video/basic.mjs`): each clip's @@ -2170,6 +2198,7 @@ byte what it was. | `render.vertical.safe` | `{top, bottom, right}` fractions (0.08, 0.2, 0.12) | kept clear of every caption, tag, card and post (the platforms' buttons) | | `render.vertical.loudness` | LUFS -30 … -8 (-14) | each clip levelled to it in its segment; the short brought to it at the end | | `render.vertical.maxSeconds` | 5 … 600 (60) | a short over it is said so (a note, never a refusal) | +| `render.vertical.qr` | `false` · `true` · `{corner: "tr"\|"tl", size: 0.1–0.3, links}` (`false`) | a code at the top of the safe area (`tr` at the right, `tl` under the tag; a full layout's hook band moves below it), linking the source at the second the clip plays from (`links` `moment`, the default here) — [A clip's QR](#a-clips-qr-its-corner-and-its-link) | | a clip's `vertical` | `{crop: [x, y, w, h], aspect?, layout?, crops?}` | its 9:16 box on the source (else centred) and its own layout over the cut's; `layout: "twocrop"` with `crops: [[x, y, w, h], [x, y, w, h]]` (fractions of the source, the top one first) is the stacked deck's two-crop reframe | | a clip's `side` | `{item \| post, from, to, place?}` | a post shown BESIDE the clip while it plays: not read, the clip's sound on. `item` a post item of the cut, `post` its fields; `from`/`to` seconds into the clip; `place` `split`/`overlay` (vertical) or `right`/`left` (16:9: a panel over that side of the picture, sliding in) | diff --git a/umtool/lib/cli/verbs.mjs b/umtool/lib/cli/verbs.mjs @@ -323,7 +323,7 @@ export const VERBS = Object.freeze([ project(), takeOpt({ required: true, help: "the take" }), reel(), file("--beats", { help: "a beats file of the project" }), opt("--items", { help: "id,id" }), pick("--clip", ["full", "framed", "quote"]), pick("--post", ["card", "stack", "media"]), pick("--side", ["split", "overlay"]), opt("--hook", { help: "title | section | a line of the cut's own copy" }), pick("--captions", ["l", "xl"]), pick("--lines", ["1", "2"]), num("--loudness"), num("--max"), name("--name"), bool("--reframe", "recompose the finished 16:9 master"), bool("--landscape", "the same items in the take's 16:9 look"), dry(), bool("--intro"), bool("--no-intro"), bool("--no-outro"), - pick("--deck", ["stacked", "bare"]), + pick("--deck", ["stacked", "bare"]), pick("--qr", ["on", "off"]), pick("--qr-corner", ["tr", "tl"]), ], Q), form("shorts", "project", "a batch of shorts: each clip of a take in each format, into shorts-<take>/", [ project(), takeOpt({ required: true, help: "the take" }), opt("--items", { help: "id,id" }), bool("--all", "every clip of the take"), @@ -331,6 +331,7 @@ export const VERBS = Object.freeze([ pick("--clip", ["full", "framed", "quote"]), pick("--post", ["card", "stack", "media"]), pick("--side", ["split", "overlay"]), opt("--hook", { help: "title | section | a line of the cut's own copy" }), pick("--captions", ["l", "xl"]), pick("--lines", ["1", "2"]), num("--loudness"), num("--max-vertical", { help: "s (180): over it, a note" }), num("--max-landscape", { help: "s (140): over it, a note" }), pick("--deck", ["stacked", "bare"]), + pick("--qr", ["on", "off"]), pick("--qr-corner", ["tr", "tl"]), bool("--replace", "set a file there aside and make it again"), dry(), ], Q), diff --git a/umtool/lib/report/clipEditor.mjs b/umtool/lib/report/clipEditor.mjs @@ -51,6 +51,7 @@ import { quoteBetween, unusedProposals, wordsOf } from "./clipEditorModel.mjs"; import { WINDOW_PAD_S } from "yt-dlp-transcript-common/lib/clips/assist.mjs"; import { clipRoom } from "umtool-report-to-video/room"; import { BLUR_CAPTION_DEFAULT, BLUR_CAPTION_MAX, BLUR_STRENGTH, renderBlurOn } from "umtool-report-to-video/clip-blur"; +import { CLIP_KIT_KEYS } from "umtool-report-to-video/clip-kit"; export { StaleToken, StructureRefused }; @@ -94,7 +95,7 @@ export async function readWords(dir, reactions = null) { * @typedef {{ id: string, channel: string | null, video: string, start: number, end: number, * cutStart: number | null, cutEnd: number | null, quote: string | null, title: string | null, * assist: Record<string, unknown> | null, key: string | null, ruling: "keep" | "cut" | string | null, montage: boolean, - * vertical: { crop: number[], aspect?: number } | null, + * vertical: { crop: number[], aspect?: number } | null, kit: Record<string, unknown>, * room: false | { tail?: boolean, head?: boolean } | null, roomEdges: { tail: boolean, head: boolean } | null, * gaps?: Array<{ from: number, to: number }> }} EditorClip */ @@ -127,6 +128,8 @@ export async function clipEditorView(project) { montage: isObj(e.montage), // A short's framing (release 36): fractions of the source picture. vertical: isObj(e.vertical) && Array.isArray(e.vertical.crop) ? { crop: e.vertical.crop, ...(fin(e.vertical.aspect) ? { aspect: e.vertical.aspect } : {}) } : null, + // The clip kit (lane clip-kit): its own code and name for a per-clip build, as written. + kit: Object.fromEntries(CLIP_KIT_KEYS.filter((k) => e[k] !== undefined).map((k) => [k, e[k]])), // Room at its edges (release 36 lane E): the clip's own override as // written, and the edges it gets with the cut's render.room. room: e.room === false ? false : isObj(e.room) ? e.room : null, @@ -563,6 +566,17 @@ export async function runClipEditorOp(project, body, { now = null } = {}) { structural = false; break; } + case "kit": { + // The clip kit (lane clip-kit, clip-kit.mjs): its keys merged as `umtool set` merges them (a key null clears + // it), through the same writer. A "trim" that leaves the cut where it is; not structural. + const e = needClip(); + if (!isObj(body.kit) || !Object.keys(body.kit).length) throw new OpError(`kit is {${CLIP_KIT_KEYS.join("?, ")}?}: the keys to set`); + const bad = Object.keys(body.kit).filter((k) => !CLIP_KIT_KEYS.includes(k.split(".")[0])); + if (bad.length) throw new OpError(`kit: ${bad.join(", ")} is not a clip kit key (${CLIP_KIT_KEYS.join(", ")})`); + result = await updateClip(dir, e.id, body.kit, { token, edit: "trim", now }); + structural = false; + break; + } case "room": { const e = needClip(); if (body.room !== null && body.room !== false && !isObj(body.room)) throw new OpError("room is false, {tail?, head?}, or null for the cut's"); @@ -618,7 +632,7 @@ export async function runClipEditorOp(project, body, { now = null } = {}) { break; } default: - throw new OpError("op must be trim, restore, split, merge, flash-forward, add, bring-in, ruling, role, label, vertical, room, claim, marks, audio, blur or onscreen"); + throw new OpError("op must be trim, restore, split, merge, flash-forward, add, bring-in, ruling, role, label, vertical, kit, room, claim, marks, audio, blur or onscreen"); } let carried = null; if (structural) { diff --git a/umtool/lib/report/clipEditorTypes.ts b/umtool/lib/report/clipEditorTypes.ts @@ -29,6 +29,8 @@ export type EditorClip = { gaps?: { from: number; to: number }[]; /** A short's framing (release 36): `crop` = [x, y, w, h], fractions of the source picture. */ vertical: { crop: number[]; aspect?: number } | null; + /** The clip kit (lane clip-kit): its own code (`qr`: false or {corner?, links?}) and batch `name`, as written. */ + kit?: { qr?: false | { corner?: string; links?: string }; name?: string; [k: string]: unknown }; /** Room at its edges (release 36 lane E): the clip's own `room` as written (false: none), and the edges it gets. */ room?: false | { tail?: boolean; head?: boolean } | null; roomEdges?: { tail: boolean; head: boolean } | null; diff --git a/umtool/lib/report/clipKit.test.mjs b/umtool/lib/report/clipKit.test.mjs @@ -0,0 +1,45 @@ +// The clip kit's keys written (lane clip-kit): `umtool set`'s and the clip editor's writer (manifest.mjs updateClip) +// takes a clip's `qr` (whole or one field) and its batch `name`, refuses what the build would, and clears with null. +import assert from "node:assert/strict"; +import { mkdtemp, readFile, rm, writeFile } from "node:fs/promises"; +import { tmpdir } from "node:os"; +import path from "node:path"; +import test from "node:test"; + +import { MANIFEST_NAME, updateClip } from "./manifest.mjs"; + +const manifest = () => ({ + schemaVersion: 1, + slug: "kit", + provenance: { channelSlug: "chan", siteOrigin: "" }, + render: { width: 640, height: 360, fps: 15 }, + timeline: [{ type: "clip", id: "w01", video: "01a1d292-6d30", start: 10, end: 20, citeUrl: "https://kick.com/somechan/videos/01a1d292-6d30" }], +}); +const read = async (dir) => JSON.parse(await readFile(path.join(dir, MANIFEST_NAME), "utf8")).timeline[0]; + +test("updateClip: a clip's qr (whole or one field) and name; refused in the build's words; null clears", async () => { + const dir = await mkdtemp(path.join(tmpdir(), "umtool-kit-")); + try { + await writeFile(path.join(dir, MANIFEST_NAME), JSON.stringify(manifest(), null, 2) + "\n"); + await updateClip(dir, "w01", { "qr.corner": "tl" }); + assert.deepEqual((await read(dir)).qr, { corner: "tl" }); + await updateClip(dir, "w01", { "qr.links": "moment" }); + assert.deepEqual((await read(dir)).qr, { corner: "tl", links: "moment" }); + await updateClip(dir, "w01", { "qr.corner": null }); + assert.deepEqual((await read(dir)).qr, { links: "moment" }); + await updateClip(dir, "w01", { qr: false }); + assert.equal((await read(dir)).qr, false); + await updateClip(dir, "w01", { qr: null }); + assert.equal("qr" in (await read(dir)), false); + await updateClip(dir, "w01", { name: " toms-toast " }); + assert.equal((await read(dir)).name, "toms-toast"); + await assert.rejects(updateClip(dir, "w01", { "qr.corner": "middle" }), /w01\.qr\.corner is one of br, bl, tr, tl/); + await assert.rejects(updateClip(dir, "w01", { name: "x".repeat(61) }), /name is a file name of 1 to 60/); + // A refused write leaves the file as it was. + assert.deepEqual(await read(dir), { ...manifest().timeline[0], name: "toms-toast" }); + await updateClip(dir, "w01", { name: "" }); + assert.equal("name" in (await read(dir)), false); + } finally { + await rm(dir, { recursive: true, force: true }); + } +}); diff --git a/umtool/lib/report/knobsCli.mjs b/umtool/lib/report/knobsCli.mjs @@ -57,11 +57,15 @@ const FX_KEYS = ["fx", ...FX_ENTRY_FIELDS.map((k) => `fx.${k}`)]; const GAP_KEYS = ["gaps", "gap.add", "gap.remove"]; export const VERTICAL_SET_KEYS = Object.freeze(["vertical", "vertical.crop", "vertical.layout", "vertical.aspect", "vertical.crops"]); export const SIDE_SET_KEYS = Object.freeze(["side", "side.item", "side.post", "side.from", "side.to", "side.place"]); +/** The clip kit (lane clip-kit; report-to-video clip-kit.mjs): a clip's code in a per-clip build, its batch file name. */ +export const KIT_SET_KEYS = Object.freeze(["qr", "qr.corner", "qr.links", "name"]); 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, "chat", "hideModules", "shelfNote", "chapter", // 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. + ...KIT_SET_KEYS, ]; export const SET_USAGE = [ @@ -115,6 +119,9 @@ export const SET_USAGE = [ " side.item=<post item id> | side.post='{\"author\",\"handle\",\"date\",\"text\",…}' -- a post shown BESIDE the", " clip while it plays, never read, the clip's sound running; side.from / side.to seconds into the clip;", " side.place=split|overlay (vertical) | right|left (16:9). `side=` removes it (docs/knobs.md \"Vertical\").", + " qr=false: no code on this clip; qr.corner=br|bl|tr|tl (a short: tr|tl) and qr.links=cite|moment|channel over", + " the cut's (render.qr, render.vertical.qr); `qr=` the cut's again. name=<file name>: its files in a batch of", + " shorts (umtool shorts) are called that, not its title's slug; `name=` the title's again.", " gap.add=12.3-15.1 cuts those source seconds out of the clip's middle (one segment of jump cuts; inside", " the cut, ≥ 0.2 s, 0.5 s kept between); gap.remove=<sec> the gap holding it; gaps=12.3-15.1,20-20.6 (or", " a JSON list of {from,to}) the whole list, `gaps=` none. The same as `umtool window --gap/--gap-remove/--gaps`.", @@ -244,6 +251,11 @@ export async function setCommand(args, { root = REPORTS_ROOT, out = (s) => conso entryPatch[key] = key === "side.item" && value !== null ? String(value) : value; continue; } + if (KIT_SET_KEYS.includes(key)) { + // A name is words whatever it parses as; the rest as given (clip-kit.mjs checks them in the writer). + entryPatch[key] = key === "name" && value !== null ? String(value) : value; + continue; + } if (key === "shelfNote") { // A note on the shelf over this entry's span (deck.mjs parseShelfNote checks it); words whatever they parse as. entryPatch.shelfNote = value === null || value === undefined ? null : String(value); @@ -350,6 +362,8 @@ export async function setCommand(args, { root = REPORTS_ROOT, out = (s) => conso if ("chat" in entryPatch) results.chat = result.entry.chat ?? null; if (VERTICAL_SET_KEYS.some((k) => k in entryPatch)) results.vertical = result.entry.vertical ?? null; if (SIDE_SET_KEYS.some((k) => k in entryPatch)) results.side = result.entry.side ?? null; + if (["qr", "qr.corner", "qr.links"].some((k) => k in entryPatch)) results.qr = result.entry.qr ?? null; + if ("name" in entryPatch) results.name = result.entry.name ?? null; if (FX_KEYS.some((k) => k in entryPatch)) results.fx = result.entry.fx ?? null; if ("gaps" in entryPatch || "gapAdd" in entryPatch || "gapRemove" in entryPatch) { results.gaps = result.entry.gaps ?? []; @@ -387,6 +401,8 @@ export async function setCommand(args, { root = REPORTS_ROOT, out = (s) => conso if ("fx" in results) out(`${clipId}: fx ${results.fx ? JSON.stringify(results.fx) : "none"}`); if ("vertical" in results) out(`${clipId}: vertical ${results.vertical ? JSON.stringify(results.vertical) : "the cut's (the centred crop)"}`); if ("side" in results) out(`${clipId}: side ${results.side ? JSON.stringify({ ...results.side, ...(results.side.post ? { post: `@${results.side.post.handle ?? results.side.post.author}` } : {}) }) : "none"}`); + if ("qr" in results) out(`${clipId}: qr ${results.qr === false ? "none on this clip" : results.qr ? JSON.stringify(results.qr) : "the cut's"}`); + if ("name" in results) out(`${clipId}: name ${results.name ? JSON.stringify(results.name) : "its title's slug"}`); if ("gaps" in results) out(`${clipId}: ${results.gaps.length ? `gaps ${results.gaps.map((g) => `${g.from}–${g.to}`).join(", ")}` : "no gaps (the cut plays whole)"}`); if (results.review) { const r = results.review; diff --git a/umtool/lib/report/manifest.mjs b/umtool/lib/report/manifest.mjs @@ -38,6 +38,9 @@ import { import { validateThreadEntries } from "yt-dlp-transcript-common/lib/report/panels.mjs"; import { validateAssist } from "yt-dlp-transcript-common/lib/clips/assist.mjs"; import { verticalErrors } from "umtool-report-to-video/look"; +import { CLIP_KIT_KEYS, clipKitErrors } from "umtool-report-to-video/clip-kit"; +/** The kit keys a clip patch sets (clip-kit.mjs), whole or one dotted field. */ +const CLIP_KIT_PATCH_KEYS = CLIP_KIT_KEYS; import { LOOK_KEYS, applyLookPatch, basicOn, lookOf } from "yt-dlp-transcript-common/lib/report/look.mjs"; import { sideErrors } from "yt-dlp-transcript-common/lib/report/vertical.mjs"; import { validateRoom } from "umtool-report-to-video/room"; @@ -849,6 +852,28 @@ export function patchClipEntry(manifest, clipId, patch, { edit = "trim", now = n if (errors.length) throw new Error(errors.join("; ")); } + // ---- the clip kit (lane clip-kit; report-to-video clip-kit.mjs) ---------- + // + // A clip's own code for a per-clip build (`qr`: false, or {corner?, links?}, whole or one field) and its pinned + // file name in a batch of shorts (`name`). null / "" removes one. Checked by the build's own rules. + for (const key of CLIP_KIT_PATCH_KEYS) { + const whole = patch[key]; + const fields = Object.keys(patch).filter((k) => k.startsWith(`${key}.`)); + if (whole === undefined && !fields.length) continue; + let next = whole !== undefined ? (whole === null || whole === "" ? null : whole) : isObj(entry[key]) ? { ...entry[key] } : {}; + for (const k of fields) { + const f = k.slice(key.length + 1); + const v = patch[k]; + if (next === null || !isObj(next)) next = {}; + if (v === null || v === "") delete next[f]; + else next[f] = v; + } + if (next === null || (isObj(next) && !Object.keys(next).length)) delete entry[key]; + else entry[key] = typeof next === "string" ? next.trim() : next; + const errors = clipKitErrors(entry, clipId); + if (errors.length) throw new Error(errors.join("; ")); + } + // ---- the walk's verdict ------------------------------------------------- // // Whether somebody has LOOKED at this clip, and what they said: confirmed, diff --git a/umtool/lib/report/shortsBatch.test.mjs b/umtool/lib/report/shortsBatch.test.mjs @@ -64,7 +64,7 @@ test("formats, items and the record's again", () => { test("the snapshot: the project keys a clip has, null for one it lacks; laid over the project's entries", () => { const e = { type: "clip", id: "a", vertical: { crop: [0.6, 0, 0.3164, 1] } }; - assert.deepEqual(snapshotOf(e, PROJECT_KEYS), { vertical: { crop: [0.6, 0, 0.3164, 1] }, side: null }); + assert.deepEqual(snapshotOf(e, PROJECT_KEYS), { vertical: { crop: [0.6, 0, 0.3164, 1] }, side: null, qr: null }); const project = [{ type: "clip", id: "a", vertical: { crop: [0.1, 0, 0.3164, 1] }, side: { item: "p", from: 0, to: 3 } }]; const laid = withOverrides(project, { a: { vertical: { crop: [0.6, 0, 0.3164, 1] }, side: null, title: "ignored" } }); assert.deepEqual(laid[0], { type: "clip", id: "a", vertical: { crop: [0.6, 0, 0.3164, 1] } }); @@ -118,7 +118,7 @@ test("umtool shorts: each clip in each format into shorts-<take>/, named, record assert.deepEqual(files, ["batch.json", "toms-toast-w01.landscape.mp4", "toms-toast-w01.vertical.mp4", "toms-toast.landscape.mp4", "toms-toast.vertical.mp4"]); // The builder was asked one clip at a time, with the flags' knobs and each format's cap. assert.deepEqual(calls.map((c) => [c.items[0], c.landscape, c.knobs.maxSeconds, c.knobs.clip]), [["m01", false, 180, "framed"], ["m01", true, 140, "framed"], ["w01", false, 180, "framed"], ["w01", true, 140, "framed"]]); - assert.deepEqual(calls[2].overrides, { w01: { vertical: { crop: [0.6, 0, 0.3164, 1] }, side: null } }); + assert.deepEqual(calls[2].overrides, { w01: { vertical: { crop: [0.6, 0, 0.3164, 1] }, side: null, qr: null } }); const rec = JSON.parse(await readFile(path.join(folder, "batch.json"), "utf8")); assert.equal(rec.kind, "shorts-batch"); assert.deepEqual(rec.last.argv, ["shorts", "proj", "--take", "kit", "--items", "m01,w01", "--formats", "vertical,landscape"]); diff --git a/umtool/lib/report/shortsCli.mjs b/umtool/lib/report/shortsCli.mjs @@ -23,7 +23,7 @@ export const SHORTS_USAGE = [ " [--clip full|framed|quote] [--post card|stack|media] [--side split|overlay]", " [--hook title|section|\"<a line of the cut's own copy>\"] [--captions l|xl] [--lines 1|2]", " [--loudness -14] [--max-vertical 180] [--max-landscape 140] [--deck stacked|bare]", - " [--replace] [--dry-run] [--json]", + " [--qr on|off] [--qr-corner tr|tl] [--replace] [--dry-run] [--json]", "", "A batch of shorts: each clip (--items, or --all of the take's) in each format -- vertical (1080x1920, the", "`umtool vertical` layouts and flags) and landscape (the take's own 16:9 look) -- into the project's", @@ -35,7 +35,7 @@ export const SHORTS_USAGE = [ "heavy slot, as `umtool vertical`'s does; a clip that fails is recorded and the rest go on (exit 1 at the end).", ].join("\n"); -const VALUED = new Set(["--take", "--items", "--formats", "--clip", "--post", "--side", "--hook", "--captions", "--lines", "--loudness", "--max-vertical", "--max-landscape", "--deck"]); +const VALUED = new Set(["--take", "--items", "--formats", "--clip", "--post", "--side", "--hook", "--captions", "--lines", "--loudness", "--max-vertical", "--max-landscape", "--deck", "--qr", "--qr-corner"]); const BOOL = new Set(["--all", "--again", "--replace", "--dry-run", "--json", "--help"]); function parse(args) { diff --git a/umtool/lib/report/verticalCli.mjs b/umtool/lib/report/verticalCli.mjs @@ -28,7 +28,7 @@ export const VERTICAL_USAGE = [ " [--clip full|framed|quote] [--post card|stack|media] [--side split|overlay]", " [--hook title|section|\"<a line of the cut's own copy>\"] [--captions l|xl] [--lines 1|2]", " [--loudness -14] [--max 60] [--name N] [--out FILE] [--reframe | --landscape] [--dry-run] [--json]", - " [--intro | --no-intro] [--no-outro] [--deck stacked|bare]", + " [--intro | --no-intro] [--no-outro] [--deck stacked|bare] [--qr on|off] [--qr-corner tr|tl]", "", "A vertical short (1080x1920, the take's fps) of a take's items: a reel's beats (promo/<r>-beats.json, as", "`umtool trailer --reel` reads them), a beats file, or whole items. Built natively: each clip cut again in", @@ -54,11 +54,13 @@ export const VERTICAL_USAGE = [ "--deck stacked (the default for a cut with a deck: render.vertical.deck) keeps the deck in 9:16 -- the rail", "under the top band, the picture at full width, the captions under it, the instruments in two columns, the", "source line and its QR above the bottom band; --deck bare is the vertical with no deck, as it first shipped.", + "--qr on (or --qr-corner tr|tl) puts a code at the top of the safe area linking the source at the second each", + "clip plays from (render.vertical.qr; a clip's own `qr` speaks over it); off by default.", ].join("\n"); export class CliError extends Error {} -const VALUED = new Set(["--take", "--reel", "--beats", "--items", "--clip", "--post", "--side", "--hook", "--captions", "--lines", "--loudness", "--max", "--name", "--out", "--deck"]); +const VALUED = new Set(["--take", "--reel", "--beats", "--items", "--clip", "--post", "--side", "--hook", "--captions", "--lines", "--loudness", "--max", "--name", "--out", "--deck", "--qr", "--qr-corner"]); const BOOL = new Set(["--reframe", "--landscape", "--dry-run", "--json", "--help", "--intro", "--no-intro", "--no-outro"]); export function parse(args) { @@ -94,6 +96,11 @@ export function knobsOfFlags(flags) { } if (flags["--loudness"] !== undefined) k.loudness = Number(flags["--loudness"]); if (flags["--max"] !== undefined) k.maxSeconds = Number(flags["--max"]); + // The short's code (clip-kit.mjs): --qr on|off, --qr-corner tr|tl (a corner alone turns it on). + if (flags["--qr"] !== undefined || flags["--qr-corner"] !== undefined) { + const on = flags["--qr"] === undefined ? true : ["on", "true"].includes(flags["--qr"]) ? true : ["off", "false"].includes(flags["--qr"]) ? false : flags["--qr"]; + k.qr = on === true && flags["--qr-corner"] !== undefined ? { corner: flags["--qr-corner"] } : on; + } return k; } diff --git a/umtool/report-to-video/build-video.mjs b/umtool/report-to-video/build-video.mjs @@ -231,9 +231,11 @@ import { buildPostSegment } from "./post-render.mjs"; import { clipGeometry, clipVerticalLayout, landscapeSideGeometry, landscapeSideOverlay, sidePostOf, sideSpan, sourceTagText, sectionTitlesOf, validateVerticalRender, verticalAss, verticalClipGraph, verticalHookOf, verticalNotes, verticalOn, - verticalPostBox, verticalPostEntry, verticalRender, + verticalPostBox, verticalPostEntry, verticalRender, safeArea, } from "./vertical.mjs"; import { renderSideCard, sideFitFilter } from "./side-card.mjs"; +// THE CLIP KIT (lane clip-kit): a per-clip build's code -- its corner, its link (clip-kit.mjs). +import { clipQrUrl, cornerOverlayXY, cornerQrOf, validateClipKit, verticalQrBox, verticalQrOf } from "./clip-kit.mjs"; // THE STACKED VERTICAL DECK (vertical-deck.mjs): a 9:16 cut that keeps its deck -- the picture at full width, the // captions under it, a clip's two crops, a post item's hero card -- and the modules it leaves out. import { ENLARGE_WARN, clipTwoCrop, leftOutWords, stackedCaptionGeo, stackedGeometry, stackedOn, twoCropEnlargement, twoCropGraph } from "./vertical-deck.mjs"; @@ -1837,16 +1839,32 @@ async function buildClipSegment(entry, meta, render, dirs, opts, chrome, nodes, side = { idx: next, ...sideUp }; next += 1; } + // The short's code (clip-kit.mjs, render.vertical.qr): the source at the second it plays from, at the top of the + // safe area -- off unless the cut or the command asks. Its PNG the input after the rest. + const vqr = verticalQrOf(entry, render); + const qrPng = vqr ? await qrForEntry(entry, provenance, render, outDir, { links: vqr.links, at: cutRecord.start, webpageUrl: meta.webpageUrl ?? null }) : null; + const qrBox = qrPng ? verticalQrBox(vqr, { W: width, safe: safeArea(render, width, height), tag: geo.tag }) : null; + let qrIdx = null; + if (qrBox) { + inputs.push("-i", qrPng.png); + qrIdx = next; + next += 1; + } const g = gapped(ain); const graph = verticalClipGraph({ geo, srcW: sw, srcH: sh, crop: entry.vertical?.crop ?? null, blur: await blurPicture(sw, sh), side, fps: render.fps, W: width, H: height, }); const tag = sourceTagText({ channel: channelName(entry, meta, provenance), date: entry.date ?? uploadDateToIso(meta.uploadDate) }); + // A code at the top of a full layout pushes its hook band down below it. + const capGeo = qrBox && geo.hook?.top !== undefined ? { ...geo, hook: { ...geo.hook, top: Math.max(geo.hook.top, qrBox.y + qrBox.size + Math.round(height * 0.012)) } } : geo; const cap = await segmentCaptions({ entry, provenance, look: dirs.look, render, outDir, from: cutRecord.start, seconds: segSeconds, bottom: 0, gaps: cutRecord.gaps ?? [], - vertical: { geo, tag, hook: verticalHookOf(entry, render, dirs.vertical.sections), side: sideUp }, + vertical: { geo: capGeo, tag, hook: verticalHookOf(entry, render, dirs.vertical.sections), side: sideUp }, }); - cutRecord.vertical = { layout, crop: entry.vertical?.crop ?? null, width, height, ...(cap ? { captions: cap.lines } : {}) }; + cutRecord.vertical = { layout, crop: entry.vertical?.crop ?? null, width, height, ...(cap ? { captions: cap.lines } : {}), ...(qrBox ? { qr: { url: qrPng.url, corner: vqr.corner, ...qrBox } } : {}) }; + const qrParts = qrBox + ? [`[${qrIdx}:v]scale=${qrBox.size}:${qrBox.size}:flags=neighbor,setsar=1[vqr]`, `[vp0][vqr]overlay=x=${qrBox.x}:y=${qrBox.y}:format=auto[vp]`] + : []; await encodeClipSegment({ seg, outDir, render, opts, id: entry.id, record: cutRecord, argv: [ @@ -1855,7 +1873,8 @@ async function buildClipSegment(entry, meta, render, dirs, opts, chrome, nodes, "-filter_complex", [ ...g.parts, ...levelParts(null, g.a), - `${g.v}${graph}[vp]`, + `${g.v}${graph}${qrBox ? "[vp0]" : "[vp]"}`, + ...qrParts, cap ? `[vp]${cap.filter}[v]` : "[vp]null[v]", ].join(";"), "-map", "[v]", "-map", audioMap, @@ -2011,8 +2030,13 @@ async function buildClipSegment(entry, meta, render, dirs, opts, chrome, nodes, // float over the bottom-right of the picture — the one part of the frame this // cut promises never to draw on. Manifests with no rail keep the old overlay, // byte for byte. - const qr = - render.qr === false || render.rail ? null : await qrForEntry(entry, provenance, render, outDir); + // The clip kit (clip-kit.mjs): the code's corner and its link -- the clip's `qr` over render.qr's; `br` and the + // citeUrl (as it always was) when neither says. + const cornerQr = render.rail ? null : cornerQrOf(entry, render); + const qr = cornerQr + ? await qrForEntry(entry, provenance, render, outDir, { links: cornerQr.links, at: cutRecord.start, webpageUrl: meta.webpageUrl ?? null }) + : null; + if (qr && cornerQr.links !== "cite") cutRecord.qr = { url: qr.url, corner: cornerQr.corner }; const qrM = render.qr?.margin ?? 28; // Bound the bar strip SHORTER than the clip. An overlay secondary that outruns @@ -2090,7 +2114,7 @@ async function buildClipSegment(entry, meta, render, dirs, opts, chrome, nodes, // Sit above the footer when there is one, so the code never straddles the chrome. parts.push( qr - ? `[${q}][${qrIdx}:v]overlay=x=${VW}-w-${qrM}:y=H-h-${FH + qrM}[v]` + ? `[${q}][${qrIdx}:v]overlay=${cornerOverlayXY(cornerQr.corner, { VW, FH, HH, m: qrM })}[v]` : `[${q}]null[v]`, ); // A montage's cut style and its counter, over the finished frame. @@ -2741,14 +2765,15 @@ export async function readCutRecord(seg) { // Two rules learned the hard way: it must be FULLY OPAQUE (a translucent QR will // not scan) and it must keep its quiet zone (the white border is part of the // symbol, not decoration). -async function qrForEntry(entry, provenance, render, outDir) { +async function qrForEntry(entry, provenance, render, outDir, { links = "cite", at = null, webpageUrl = null } = {}) { // A `src` clip's file has no page on the archive: only its own citeUrl. if (hasLocalMedia(entry) && !entry.citeUrl) return null; const q = render.qr ?? {}; // A mirror's LOCAL slug is not the id the site serves, and a clip taken from a // copy whose archived transcript is broken should point at the copy that reads — // so an explicit per-clip citeUrl always wins over the derived one. - const url = entry.citeUrl ?? archiveMomentUrl(entry, provenance, entry.start); + // `links` (clip-kit.mjs): "moment" the source at the second it plays from, "channel" the promo's page. + const url = clipQrUrl(entry, provenance, { links, at, webpageUrl, channelUrl: render.promo?.url ?? null }); const png = path.join(outDir, "qr", `${entry.id}.png`); await execFileP(QRENCODE, [ "-o", png, @@ -3392,7 +3417,7 @@ async function buildImageSegment(entry, render, outDir, chrome, provenance, base } parts.push( qr - ? `[${q}][${qrIdx}:v]overlay=x=${VW}-w-${qrM}:y=H-h-${FH + qrM}[v]` + ? `[${q}][${qrIdx}:v]overlay=${cornerOverlayXY(cornerQr.corner, { VW, FH, HH, m: qrM })}[v]` : `[${q}]null[v]`, ); @@ -6861,7 +6886,7 @@ export async function buildVideo({ manifestPath, opts = {}, out, only, fetchOnly ...validateFlipEntries(whole), ...validateNarration(whole), ...validateDrafted(whole), ...validatePublish(whole), ...validateStatsEntries(whole), ...validateMontage(whole), ...validateAssist(whole), ...validateFxEntries(whole, { schedule: false }), ...validateTransitionStyle(whole), ...validateLook(whole), ...validateClipAudioEntries(whole), ...validateClipBlurEntries(whole), ...validateFinaleEntries(whole), - ...validateGapEntries(whole), ...measureSettingsProblems(whole), ...validateAnalysisEntries(whole), + ...validateGapEntries(whole), ...measureSettingsProblems(whole), ...validateAnalysisEntries(whole), ...validateClipKit(whole), ]; if (errors.length) throw new Error(`manifest: ${errors.join("; ")}`); } diff --git a/umtool/report-to-video/clip-kit.mjs b/umtool/report-to-video/clip-kit.mjs @@ -0,0 +1,171 @@ +// THE CLIP KIT's rules (lane clip-kit): the keys a clip carries for a per-clip build (a short, a desktop clip, a +// batch), checked here once -- the writer (lib/report/manifest.mjs updateClip), `umtool set`, the lint and the build +// all call these. This file holds the QR's (slice B); each later slice adds its keys. +// +// render.qr false | { scale?, quiet?, ecc?, margin?, corner?, links? } the corner code of a cut with no deck +// corner "br" (the default: where it always was) | "bl" | "tr" | "tl" +// links "cite" (the default: the clip's citeUrl, else its moment on the archive -- as it always was) +// | "moment" (the SOURCE at the second the clip starts playing: platformSeek.mjs's rule) +// | "channel" (the promo's channel page, render.promo.url) +// render.vertical.qr false (the default) | true | { corner?: "tr" | "tl", size?, links? } a code on a 9:16 short +// (its links default "moment": the operator asked for "a QR to the channel at the timestamp") +// clip.qr false (no code on this clip) | { corner?, links? } over the cut's +// +// A MOMENT link is the clip's own recording at the second it plays from (the build's snapped start): +// - its citeUrl, when that names this recording (it carries the clip's video id), retimed with watchUrlAt; +// - else, with no citeUrl, the record's webpage_url at the second; +// - else (a citeUrl that names another recording: a mirror the cut cites on purpose) the citeUrl as written. +// Kick's time parameter is not confirmed (common/lib/platformSeek.mjs): watchUrlAt writes `?t=<s>` there, and the +// lint notes that a Kick (or Twitch) VOD is deleted after its retention, so the code stops opening. +// +// PURE: no fs, no ffmpeg. +import { watchUrlAt } from "yt-dlp-transcript-common/lib/clips/assist.mjs"; +import { VOD_RETENTION_DAYS, seekPlatformOfUrl } from "yt-dlp-transcript-common/lib/platformSeek.mjs"; +import { QR_LINKS, VERTICAL_QR_CORNERS, VERTICAL_QR_KEYS, VERTICAL_QR_SIZE, verticalQrErrors } from "yt-dlp-transcript-common/lib/report/vertical.mjs"; +import { archiveMomentUrl } from "./site-links.mjs"; + +const isObj = (v) => v !== null && typeof v === "object" && !Array.isArray(v); +const q = (v) => JSON.stringify(v); + +export const QR_CORNERS = Object.freeze(["br", "bl", "tr", "tl"]); +/** The keys of `render.qr` (the first four the corner code always read). */ +export const QR_KEYS = Object.freeze(["scale", "quiet", "ecc", "margin", "corner", "links"]); +export { QR_LINKS, VERTICAL_QR_CORNERS, VERTICAL_QR_KEYS, VERTICAL_QR_SIZE, verticalQrErrors }; + +/** The keys a clip may carry for the kit (vertical-plan.mjs reads them from the project over a take's). */ +export const CLIP_KIT_KEYS = Object.freeze(["qr", "name"]); +/** A clip's pinned file name in a batch (shortsBatch.mjs): at most this many characters. */ +export const CLIP_NAME_MAX = 60; + +/** Each thing wrong with `render.qr`'s new keys ([] when fine). The older keys are as unchecked as they were. */ +export function qrSettingsErrors(qr, where = "render.qr") { + if (qr === undefined || qr === null || qr === false || qr === true) return []; + if (!isObj(qr)) return [`${where} is false or {${QR_KEYS.join(", ")}}`]; + const errors = []; + if (qr.corner !== undefined && !QR_CORNERS.includes(qr.corner)) errors.push(`${where}.corner is one of ${QR_CORNERS.join(", ")}, not ${q(qr.corner)}`); + if (qr.links !== undefined && !QR_LINKS.includes(qr.links)) errors.push(`${where}.links is one of ${QR_LINKS.join(", ")}, not ${q(qr.links)}`); + return errors; +} + +/** Each thing wrong with a clip's kit keys ([] when fine), named `<where>.<key>`. */ +export function clipKitErrors(entry, where = "clip") { + const errors = []; + if (!isObj(entry)) return errors; + if (entry.qr !== undefined && entry.qr !== false) { + if (!isObj(entry.qr)) errors.push(`${where}.qr is false (no code on this clip) or {corner?, links?}`); + else { + for (const k of Object.keys(entry.qr)) if (!["corner", "links"].includes(k)) errors.push(`${where}.qr.${k} is not a key (corner, links)`); + errors.push(...qrSettingsErrors({ corner: entry.qr.corner, links: entry.qr.links }, `${where}.qr`)); + } + } + if (entry.name !== undefined && !(typeof entry.name === "string" && entry.name.trim() && entry.name.length <= CLIP_NAME_MAX)) { + errors.push(`${where}.name is a file name of 1 to ${CLIP_NAME_MAX} characters`); + } + if ((entry.qr !== undefined || entry.name !== undefined) && entry.type !== undefined && entry.type !== "clip") { + errors.push(`${where}: qr and name are a clip's`); + } + return errors; +} + +/** Every clip's kit errors in a manifest, and the render's QR settings' ([] when fine). */ +export function validateClipKit(manifest) { + // render.vertical.qr is checked with the vertical knobs (common vertical.mjs validateVerticalRender). + const errors = [...qrSettingsErrors(manifest?.render?.qr)]; + for (const e of manifest?.timeline ?? []) errors.push(...clipKitErrors(e, `timeline ${e?.id ?? "?"}`)); + const wantsChannel = [manifest?.render?.qr?.links, isObj(manifest?.render?.vertical?.qr) ? manifest.render.vertical.qr.links : null, ...(manifest?.timeline ?? []).map((e) => (isObj(e?.qr) ? e.qr.links : null))].includes("channel"); + if (wantsChannel && !(typeof manifest?.render?.promo?.url === "string" && /^https?:\/\//.test(manifest.render.promo.url))) { + errors.push("a QR's links is \"channel\", which is the channel promo's page: set render.promo.url (an https link)"); + } + return errors; +} + +/** Does `url` name the recording `video` (its id is in it)? */ +export const namesRecording = (url, video) => typeof url === "string" && typeof video === "string" && video.length >= 4 && url.includes(video); + +/** + * The source at a second: the clip's citeUrl retimed when it names this recording, else the record's page at it, + * else the citeUrl as written (a mirror cited on purpose), else null. + * + * @param {{ citeUrl?: string, video?: string }} entry + * @param {number} at the source second the clip starts playing from + * @param {string | null} [webpageUrl] its record's webpage_url + */ +export function momentLinkOf(entry, at, webpageUrl = null) { + const cite = typeof entry?.citeUrl === "string" && entry.citeUrl ? entry.citeUrl : null; + if (cite && namesRecording(cite, entry.video)) return watchUrlAt(cite, at) ?? cite; + if (!cite && webpageUrl) return watchUrlAt(webpageUrl, at); + return cite; +} + +/** + * The code's settings a clip draws with: off (null) for `render.qr: false` or `clip.qr: false`, else + * `{corner, links}` -- the clip's over the cut's, the defaults (`br`, `cite`) under both. + */ +export function cornerQrOf(entry, render) { + if (render?.qr === false || entry?.qr === false) return null; + const cut = isObj(render?.qr) ? render.qr : {}; + const own = isObj(entry?.qr) ? entry.qr : {}; + return { corner: own.corner ?? cut.corner ?? "br", links: own.links ?? cut.links ?? "cite" }; +} + +/** A 9:16 short's code: null when off (the default), else `{corner, size, links}`. A clip's `qr` speaks over it. */ +export function verticalQrOf(entry, render) { + const v = render?.vertical?.qr; + if (!v || entry?.qr === false) return null; + const cut = isObj(v) ? v : {}; + const own = isObj(entry?.qr) ? entry.qr : {}; + const corner = own.corner && VERTICAL_QR_CORNERS.includes(own.corner) ? own.corner : cut.corner ?? "tr"; + return { corner, size: cut.size ?? VERTICAL_QR_SIZE.default, links: own.links ?? cut.links ?? "moment" }; +} + +/** + * The link a clip's code carries. `links` "cite" is the corner code's link as it always was (the citeUrl, else the + * clip's moment on the archive); "moment" the source at `at` (momentLinkOf), falling back to that; "channel" the + * promo's page. Null: no link to draw (a `src` clip with no citeUrl). + * + * @param {Record<string, any>} entry + * @param {Record<string, any>} provenance + * @param {{ links?: string, at?: number | null, webpageUrl?: string | null, channelUrl?: string | null, local?: boolean }} [o] + * `local`: the clip plays a file of its own (`src`). + */ +export function clipQrUrl(entry, provenance, { links = "cite", at = null, webpageUrl = null, channelUrl = null, local = false } = {}) { + if (local && !entry.citeUrl) return null; + const cite = () => entry.citeUrl ?? archiveMomentUrl(entry, provenance, entry.start); + if (links === "channel" && channelUrl) return channelUrl; + if (links === "moment") return momentLinkOf(entry, Number.isFinite(at) ? at : entry.cutStart ?? entry.start, webpageUrl) ?? cite(); + return cite(); +} + +/** + * The overlay that places the corner code (ffmpeg `overlay` x/y): `br` is the one the build always drew, + * byte for byte. `VW` the picture's width, `FH` the footer's height, `HH` the header's, `m` the margin. + */ +export function cornerOverlayXY(corner, { VW, FH = 0, HH = 0, m = 28 }) { + const x = corner === "bl" || corner === "tl" ? `${m}` : `${VW}-w-${m}`; + const y = corner === "tr" || corner === "tl" ? `${HH + m}` : `H-h-${FH + m}`; + return `x=${x}:y=${y}`; +} + +/** + * Where a 9:16 short's code stands, px: under the top band, at the safe area's right (`tr`) or left (`tl`) edge; a + * code at the left stands under the source tag. `safe` is vertical.mjs safeArea's; `tag` its geometry's tag. + */ +export function verticalQrBox(qr, { W, safe, tag = null }) { + const size = Math.max(2, 2 * Math.round((W * qr.size) / 2)); + const top = safe.y0 + Math.round(W * 0.02); + const y = qr.corner === "tl" && tag ? Math.max(top, tag.y + Math.round(tag.size * 1.9)) : top; + const x = qr.corner === "tl" ? safe.x0 : safe.x1 - size; + return { x, y, size }; +} + +/** + * A NOTE (never a refusal) for a code that links a stream's VOD on a platform that deletes them: the code stops + * opening after the retention (platformSeek.mjs VOD_RETENTION_DAYS). Null for any other link. + */ +export function expiringLinkNote(url, where) { + const p = seekPlatformOfUrl(url); + const days = p ? VOD_RETENTION_DAYS[p] : undefined; + if (!days || !/\/videos?\//.test(String(url))) return null; + const name = p === "kick" ? "Kick" : "Twitch"; + return `${where}: its QR links a ${name} VOD (${url}); ${name} deletes VODs about ${days} days after the stream, so the code will stop opening then — link the channel instead (qr links "channel") if it must last`; +} diff --git a/umtool/report-to-video/clip-kit.test.mjs b/umtool/report-to-video/clip-kit.test.mjs @@ -0,0 +1,114 @@ +// The clip kit's QR (lane clip-kit, slice B): the corner, the link at the clip's second, a short's code, the notes -- +// and, with none of the new keys, the corner code exactly as it always was. +import { test } from "node:test"; +import assert from "node:assert/strict"; + +import { + clipKitErrors, clipQrUrl, cornerOverlayXY, cornerQrOf, expiringLinkNote, momentLinkOf, namesRecording, qrSettingsErrors, + validateClipKit, verticalQrBox, verticalQrOf, +} from "./clip-kit.mjs"; +import { archiveMomentUrl } from "./site-links.mjs"; +import { qrsOf, lintManifest } from "./lint.mjs"; +import { safeArea, clipGeometry, validateVerticalRender, verticalKnobs } from "./vertical.mjs"; + +const KICK = "https://kick.com/somechan/videos/01a1d292-6d30-7092-867d-d46a2db2f3e8"; +const clip = (o = {}) => ({ type: "clip", id: "w01", video: "01a1d292-6d30-7092-867d-d46a2db2f3e8", start: 10643.6, end: 10764, ...o }); + +test("no new keys: the corner code is where it always was, with the link it always had", () => { + // The overlay the build drew before the kit, byte for byte. + const VW = 1920, FH = 0, qrM = 28; + assert.equal(cornerOverlayXY("br", { VW, FH, HH: 56, m: qrM }), `x=${VW}-w-${qrM}:y=H-h-${FH + qrM}`); + assert.equal(cornerOverlayXY("br", { VW: 1600, FH: 40, m: 20 }), "x=1600-w-20:y=H-h-60"); + assert.deepEqual(cornerQrOf(clip(), {}), { corner: "br", links: "cite" }); + const prov = { siteOrigin: "https://archive.example", channelSlug: "chan" }; + const e = clip({ channel: "chan" }); + assert.equal(clipQrUrl(e, prov), archiveMomentUrl(e, prov, e.start)); + assert.equal(clipQrUrl(clip({ citeUrl: KICK }), prov), KICK); + assert.equal(clipQrUrl(clip({ citeUrl: null, src: "a.mp4" }), prov, { local: true }), null); + // The lint's corner codes: the same links as before. + const m = { render: { width: 1920, height: 1080 }, provenance: prov, timeline: [e, clip({ id: "w02", citeUrl: KICK })] }; + assert.deepEqual(qrsOf(m).map((q) => [q.url, "links" in q]), [[archiveMomentUrl(e, prov, e.start), false], [KICK, false]]); + assert.deepEqual(validateClipKit(m), []); + // A short asks for no code: none (the vertical knobs' default). + assert.equal(verticalKnobs({ format: "vertical" }).qr, false); + assert.equal(verticalQrOf(clip(), { format: "vertical" }), null); +}); + +test("the corners, a clip's own over the cut's, off for one clip", () => { + assert.equal(cornerOverlayXY("tl", { VW: 1920, HH: 56, m: 28 }), "x=28:y=84"); + assert.equal(cornerOverlayXY("tr", { VW: 1920, HH: 0, m: 28 }), "x=1920-w-28:y=28"); + assert.equal(cornerOverlayXY("bl", { VW: 1920, FH: 0, m: 28 }), "x=28:y=H-h-28"); + assert.deepEqual(cornerQrOf(clip({ qr: { corner: "tl" } }), { qr: { corner: "bl", links: "moment" } }), { corner: "tl", links: "moment" }); + assert.equal(cornerQrOf(clip({ qr: false }), {}), null); + assert.equal(cornerQrOf(clip(), { qr: false }), null); +}); + +test("a moment link: this recording's citeUrl retimed; a mirror kept; else the record's page; the channel", () => { + // The citeUrl names this recording (its id is in it): retimed to the second the clip plays from. + assert.equal(momentLinkOf(clip({ citeUrl: KICK }), 10643.9), `${KICK}?t=10643`); + assert.equal(momentLinkOf(clip({ citeUrl: `${KICK}?t=10600` }), 10643.9), `${KICK}?t=10643`); + // A mirror (another recording): as written. + assert.equal(momentLinkOf(clip({ citeUrl: "https://www.youtube.com/watch?v=mirror1&t=5s" }), 99), "https://www.youtube.com/watch?v=mirror1&t=5s"); + // No citeUrl: the record's page at the second. + assert.equal(momentLinkOf(clip(), 61.2, "https://www.youtube.com/watch?v=abc"), "https://www.youtube.com/watch?v=abc&t=61s"); + assert.equal(momentLinkOf(clip(), 61.2, null), null); + assert.ok(namesRecording(KICK, "01a1d292-6d30-7092-867d-d46a2db2f3e8")); + assert.equal(namesRecording(KICK, "abc"), false, "an id too short to tell is not taken as a match"); + const prov = { siteOrigin: "https://archive.example", channelSlug: "chan" }; + assert.equal(clipQrUrl(clip({ citeUrl: KICK }), prov, { links: "moment", at: 10650 }), `${KICK}?t=10650`); + // No moment to link: the cite as before. + assert.equal(clipQrUrl(clip({ channel: "chan" }), prov, { links: "moment", at: 5 }), archiveMomentUrl(clip({ channel: "chan" }), prov, 10643.6)); + assert.equal(clipQrUrl(clip({ citeUrl: KICK }), prov, { links: "channel", channelUrl: "https://kick.com/somechan" }), "https://kick.com/somechan"); +}); + +test("the rules refuse what cannot be drawn, by name", () => { + assert.deepEqual(qrSettingsErrors({ scale: 4, corner: "tl", links: "moment" }), []); + assert.match(qrSettingsErrors({ corner: "middle" }).join(), /render\.qr\.corner is one of br, bl, tr, tl/); + assert.match(qrSettingsErrors({ links: "site" }).join(), /render\.qr\.links is one of cite, moment, channel/); + assert.match(clipKitErrors({ type: "clip", qr: { corner: "tl", size: 2 } }, "w01").join(), /w01\.qr\.size is not a key/); + assert.match(clipKitErrors({ type: "clip", qr: "yes" }, "w01").join(), /w01\.qr is false/); + assert.match(clipKitErrors({ type: "clip", name: "x".repeat(61) }, "w01").join(), /w01\.name is a file name of 1 to 60/); + assert.match(clipKitErrors({ type: "post", qr: false }, "p1").join(), /qr and name are a clip's/); + assert.match(validateClipKit({ render: { qr: { links: "channel" } }, timeline: [] }).join(), /set render\.promo\.url/); + assert.deepEqual(validateClipKit({ render: { qr: { links: "channel" }, promo: { url: "https://kick.com/somechan" } }, timeline: [] }), []); + // A short's code: at the top only (its captions run along the foot), a size in bounds. + assert.deepEqual(validateVerticalRender({ render: { vertical: { qr: { corner: "tl", size: 0.2, links: "moment" } } } }), []); + assert.match(validateVerticalRender({ render: { vertical: { qr: { corner: "br" } } } }).join(), /corner is tr or tl/); + assert.match(validateVerticalRender({ render: { vertical: { qr: { size: 0.5 } } } }).join(), /size is 0\.1–0\.3/); +}); + +test("a short's code: on, the moment by default, at the top of the safe area, never over the tag", () => { + const render = { format: "vertical", vertical: { qr: true } }; + assert.deepEqual(verticalQrOf(clip(), render), { corner: "tr", size: 0.16, links: "moment" }); + assert.deepEqual(verticalQrOf(clip({ qr: { corner: "tl", links: "cite" } }), render), { corner: "tl", size: 0.16, links: "cite" }); + assert.equal(verticalQrOf(clip({ qr: false }), render), null); + // A clip's bottom corner is the landscape code's: a short keeps its own corner. + assert.equal(verticalQrOf(clip({ qr: { corner: "br" } }), render).corner, "tr"); + const W = 1080, H = 1920; + const safe = safeArea(render, W, H); + for (const layout of ["full", "framed", "quote", "split"]) { + const geo = clipGeometry(layout, render, W, H); + for (const corner of ["tr", "tl"]) { + const b = verticalQrBox({ corner, size: 0.16 }, { W, safe, tag: geo.tag }); + assert.ok(b.x >= safe.x0 && b.x + b.size <= safe.x1 && b.y >= safe.y0 && b.y + b.size <= safe.y1, `${layout} ${corner} inside the safe area`); + if (corner === "tl" && geo.tag) assert.ok(b.y >= geo.tag.y + geo.tag.size, `${layout}: under the tag`); + } + } +}); + +test("a moment code to a Kick or Twitch VOD is a NOTE naming the expiry; a channel page or YouTube is not", () => { + assert.match(expiringLinkNote(`${KICK}?t=10643`, "w01"), /w01: its QR links a Kick VOD .* about 30 days/); + assert.match(expiringLinkNote("https://www.twitch.tv/videos/123?t=1h0m0s", "w01"), /Twitch deletes VODs about 14 days/); + assert.equal(expiringLinkNote("https://kick.com/somechan", "w01"), null); + assert.equal(expiringLinkNote("https://www.youtube.com/watch?v=abc&t=5s", "w01"), null); + // In the lint: a warning for a moment code, none for the same link cited as it always was. + const base = { render: { width: 1920, height: 1080 }, provenance: { siteOrigin: "https://archive.example" } }; + const moment = lintManifest({ ...base, render: { ...base.render, qr: { links: "moment" } }, timeline: [clip({ citeUrl: KICK })] }, { validators: false }); + assert.ok(moment.warnings.some((w) => /Kick deletes VODs/.test(w)), moment.warnings.join("\n")); + assert.equal(moment.errors.length, 0, moment.errors.join("\n")); + const cite = lintManifest({ ...base, timeline: [clip({ citeUrl: KICK })] }, { validators: false }); + assert.ok(!cite.warnings.some((w) => /deletes VODs/.test(w))); + // A short's code is measured and noted too. + const short = lintManifest({ ...base, render: { width: 1080, height: 1920, format: "vertical", qr: false, vertical: { qr: true } }, timeline: [clip({ citeUrl: KICK })] }, { validators: false }); + assert.ok(short.warnings.some((w) => /timeline w01 \(its QR\): its QR links a Kick VOD/.test(w)), short.warnings.join("\n")); +}); diff --git a/umtool/report-to-video/lint.mjs b/umtool/report-to-video/lint.mjs @@ -123,6 +123,7 @@ import { ENLARGE_WARN, STACKED_QR_SHARE, STACKED_QR_SMALL_SHARE, clipTwoCrop, st import { roomWindowWarnings } from "./room.mjs"; import { qrUrlFor } from "./render-cards.mjs"; import { archiveMomentUrl } from "./site-links.mjs"; +import { clipQrUrl, cornerQrOf, expiringLinkNote, validateClipKit, verticalQrOf } from "./clip-kit.mjs"; import { cardNarrationSeconds, hasNarration, narrationsOf, validateNarration } from "./narration.mjs"; import { validatePodcast } from "./build-podcast.mjs"; import { draftsReviewFromNarration, draftsReviewProblems, readDraftsReview } from "./drafts-review.mjs"; @@ -219,6 +220,15 @@ export function qrsOf(manifest, { only = null, metaOf = null } = {}) { } return out; } + // A 9:16 short's code (clip-kit.mjs, render.vertical.qr): each clip's, at the top of the safe area. + if (verticalOn(render)) { + for (const e of timeline) { + const vq = e.type === "clip" ? verticalQrOf(e, render) : null; + if (!vq || (e.src != null && !e.citeUrl)) continue; + const url = clipQrUrl(e, provenance, { links: vq.links, at: e.cutStart ?? e.start, channelUrl: render.promo?.url ?? null, webpageUrl: metaOf?.(e)?.webpageUrl ?? null }); + if (url) out.push({ where: `timeline ${e.id} (its QR)`, id: e.id, source: "entry", url, links: vq.links, px: Math.round((Number(render.width) || 1080) * vq.size) }); + } + } if (render.qr === false) return out; if (render.rail) { // The rail's foot: a tile per entry (a card's is the sweep's link), the @@ -235,13 +245,18 @@ export function qrsOf(manifest, { only = null, metaOf = null } = {}) { const scale = Number(render.qr?.scale ?? 4); for (const e of timeline) { let url = null; + let links = "cite"; if (e.type === "clip") { if (e.src != null && !e.citeUrl) continue; - url = e.citeUrl ?? archiveMomentUrl(e, provenance, e.start); + // The clip kit (clip-kit.mjs): a clip's `qr: false` draws none; `links` "moment" / "channel" another link. + const cq = cornerQrOf(e, render); + if (!cq) continue; + links = cq.links; + url = clipQrUrl(e, provenance, { links, at: e.cutStart ?? e.start, channelUrl: render.promo?.url ?? null, webpageUrl: metaOf?.(e)?.webpageUrl ?? null }); } else if (e.type === "image" && e.citeUrl) { url = e.citeUrl; } - if (url) out.push({ where: `timeline ${e.id} (its corner QR)`, id: e.id, source: "entry", url, px: null, perModule: scale }); + if (url) out.push({ where: `timeline ${e.id} (its corner QR)`, id: e.id, source: "entry", url, px: null, perModule: scale, ...(links !== "cite" ? { links } : {}) }); } return out; } @@ -338,6 +353,8 @@ export function validatorErrors(whole) { ...validateStatsEntries(whole), // A clip's `chat` and render.chrome.chat (chat.mjs). ...validateChatEntries(whole), + // The clip kit: a clip's `qr` and `name`, render.qr's corner and links (clip-kit.mjs). + ...validateClipKit(whole), // Release 33: render.montage, its keys and what it does not combine with. ...validateMontage(whole), // Release 35: a clip's `assist` (the clip finder's provenance; the render ignores it). @@ -516,6 +533,11 @@ export function lintManifest(manifest, { const what = `${q.where}: ${per.toFixed(2)} px per module at 720p ` + `(${q.px === null ? `scale ${q.perModule}` : `${q.px} px`} on a ${height}p frame, a version-${version} code, ${modules} modules)`; + // A code that links a stream's VOD at its second, on a platform that deletes VODs: a note (clip-kit.mjs). + if (q.links === "moment") { + const n = expiringLinkNote(q.url, q.where); + if (n) warnings.push(n); + } if (per < MIN_QR_PX_PER_MODULE_720P) { errors.push(`${what} — too small to scan; make it larger or the link shorter (at least ${MIN_QR_PX_PER_MODULE_720P})`); } else if (per < WARN_QR_PX_PER_MODULE_720P) { diff --git a/umtool/report-to-video/package.json b/umtool/report-to-video/package.json @@ -28,6 +28,7 @@ "./vertical": "./vertical.mjs", "./vertical-deck": "./vertical-deck.mjs", "./vertical-plan": "./vertical-plan.mjs", + "./clip-kit": "./clip-kit.mjs", "./reframe": "./reframe.mjs", "./side-card": "./side-card.mjs", "./check-availability": "./check-availability.mjs", diff --git a/umtool/report-to-video/vertical-plan.mjs b/umtool/report-to-video/vertical-plan.mjs @@ -39,7 +39,7 @@ export function beatsOf(doc) { * The keys of a clip a short reads from the PROJECT over the take's: set with `umtool set` after the take was made * (its framing, its side post, the clip kit's keys). A batch's record snapshots them (lib/report/shortsBatch.mjs). */ -export const PROJECT_KEYS = Object.freeze(["vertical", "side"]); +export const PROJECT_KEYS = Object.freeze(["vertical", "side", "qr"]); /** The project's per-clip framing (PROJECT_KEYS) laid over a take's entry. */ export function withProjectFraming(entry, projectById) {