commit 72df4a331d471253b877084b07ef67202c3d831d
parent 9db5202544125de10c3595c35c5ef0c2aef99e8d
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Wed, 14 Oct 2026 03:05:25 -0400
umtool: out/youtube.txt's Chapters are the cut's sections, not one per clip
Found in the release 28 live smoke: the build muxes a chapter per segment (a player's navigation), and the
description listed every clip — the same recording's title two and three times. muxChapters marks the
chapters a card opens (`section`); youtubeChapters keeps those and folds every other entry into the
section before it, and leaves the block out when fewer than three remain.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
3 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/umtool/report-to-video/build-video.mjs b/umtool/report-to-video/build-video.mjs
@@ -3966,7 +3966,9 @@ async function muxChapters(finalPath, entries, segments, D, outDir, provenance,
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 });
- chapters.push({ start, end, title });
+ // `section`: the entry opens one of the cut's sections (a card) -- what
+ // out/youtube.txt's Chapters keep (youtube.mjs youtubeChapters).
+ chapters.push({ start, end, title, section: entries[i]?.type === "card" });
lines.push(
"[CHAPTER]",
"TIMEBASE=1/1000",
diff --git a/umtool/report-to-video/youtube.mjs b/umtool/report-to-video/youtube.mjs
@@ -44,11 +44,16 @@ const oneLine = (s) => String(s ?? "").replace(/\s+/g, " ").trim();
* span): `{ chapters, note }` -- `chapters` null when the block is left out,
* `note` saying what was folded or why the block is left out.
*
- * @param {Array<{ start: number, end?: number, title: string }> | null | undefined} list
+ * @param {Array<{ start: number, end?: number, title: string, section?: boolean }> | null | undefined} list
* @param {number | null} [total]
*/
export function youtubeChapters(list, total = null) {
if (!Array.isArray(list) || !list.length) return { chapters: null, note: "no chapters: the build made none" };
+ // The build's list has a chapter per segment (a player's navigation). A
+ // description's chapters are the cut's SECTIONS: when the list says which
+ // entries open one (`section`: a title or chapter card), every other entry
+ // folds into the section before it.
+ if (list.some((c) => c?.section === true)) list = list.filter((c, i) => i === 0 || c?.section === true);
const all = list.map((c) => ({ start: Math.floor(Number(c.start)), title: oneLine(c.title) || "Chapter" }));
if (all[0].start !== 0) return { chapters: null, note: `no chapters: the first starts at ${chapterStamp(all[0].start)}, not 0:00` };
const end = Number.isFinite(Number(total)) && total !== null
diff --git a/umtool/report-to-video/youtube.test.mjs b/umtool/report-to-video/youtube.test.mjs
@@ -89,3 +89,19 @@ test("the preview: the default cut's sources, no chapters", async () => {
assert.ok(!p.text.includes("qa-long-03&t=5"), "an entry of another variant is not in the default cut");
assert.equal(youtubePreview({ timeline: [] }).text, null);
});
+
+test("youtubeChapters: with sections marked, the clips fold into the section that opens before them", () => {
+ const list = [
+ { start: 0, title: "The title", section: true },
+ { start: 14, title: "Size and staffing", section: true },
+ { start: 32, title: "clip a", section: false },
+ { start: 44, title: "clip a again", section: false },
+ { start: 72, title: "Insulinoma", section: true },
+ { start: 82, title: "clip b", section: false },
+ { start: 110, title: "clip c", section: false },
+ ];
+ const r = youtubeChapters(list, 130);
+ assert.deepEqual(r.chapters.map((c) => c.title), ["The title", "Size and staffing", "Insulinoma"]);
+ // Too few sections: the block is left out rather than listing clips.
+ assert.equal(youtubeChapters(list.filter((c) => c.title !== "Insulinoma"), 130).chapters, null);
+});