commit 0ec4f7b308b618dc7cc55f3d797c7be300cae932
parent 8cafa35cdd92f70f64e2f3a26dcfb3f86380686b
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Mon, 9 Nov 2026 15:35:57 -0500
umtool: quick clip's --snap words on the recording's one clock
The snap already asks the build's lookup (resolveLocalSource), which maps a span through a
saved recording's time map (clock.json: windowStart is the cue second the file's 0 plays):
the span is transcribed on the file's clock and the words come back on the cues', as
quote-check does. Now said in the code, tested with a shifted clock, and an uncertain
clock over the span is said.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
2 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/umtool/lib/report/quickClip.mjs b/umtool/lib/report/quickClip.mjs
@@ -177,7 +177,7 @@ async function editorWords({ path: file, start, end, out }, { emit = () => {} }
* @param {{ spec: string, snap?: "words" | null, title?: string | null, site?: string | null, folder?: string | null }} ask
* @param {{ root?: string, channelsDir?: string, sitesDir?: string, say?: (s: string) => void, cfg?: any, pollMs?: number, progress?: string | null,
* log?: (s: string) => void, err?: (s: string) => void,
- * deps?: { fetch?: (project: { id: string, dir: string }) => Promise<void>, transcribe?: typeof editorWords, take?: (args: string[], o: any) => Promise<number> } }} [o]
+ * deps?: { fetch?: (project: { id: string, dir: string }) => Promise<void>, transcribe?: typeof editorWords, take?: (args: string[], o: any) => Promise<number>, resolve?: typeof resolveLocalSource } }} [o]
* @returns {Promise<{ project: string, dir: string, output: string, snapped: null | { cutStart: number, cutEnd: number, first: string, last: string }, share: { platform: string | null, archive: string | null, text: string } }>}
*/
export async function quickClip(ask, { root = REPORTS_ROOT, channelsDir = CHANNELS_DIR, sitesDir = SITES_DIR, say = () => {}, cfg = null, pollMs = POLL_MS, progress = null, log = console.log, err = console.error, deps = {} } = {}) {
@@ -223,8 +223,12 @@ export async function quickClip(ask, { root = REPORTS_ROOT, channelsDir = CHANNE
if (ask.snap === "words") {
const from = Math.max(0, spec.start - SNAP_PAD_S);
const to = spec.end + SNAP_PAD_S;
- const src = await resolveLocalSource({ video, slug: spec.channel, from, to }, { rawDir: path.join(project.dir, "out", "clips-raw"), channelsDir });
+ // ONE CLOCK PER RECORDING: the build's lookup (resolveLocalSource) maps the span through a saved recording's
+ // time map (clock.json, common recordingClock.mjs) -- its windowStart is the CUE second the file's 0 plays --
+ // so the span is asked on the file's clock and the words come back onto the cues', as quote-check does.
+ const src = await (deps.resolve ?? resolveLocalSource)({ video, slug: spec.channel, from, to }, { rawDir: path.join(project.dir, "out", "clips-raw"), channelsDir });
if (!src) throw new Error(`--snap words: no window on disk holds ${from.toFixed(2)}–${to.toFixed(2)} (the fetch landed a narrower one?)`);
+ if (src.clock && !src.clock.certain) say(`--snap words: ${path.basename(src.path)}'s clock is NOT certain over this span (a step in its time map) -- check the words land (umtool quote-check)`);
const { mkdir } = await import("node:fs/promises");
const work = path.join(project.dir, "out", "quick-clip");
await mkdir(work, { recursive: true });
diff --git a/umtool/lib/report/quickClip.test.mjs b/umtool/lib/report/quickClip.test.mjs
@@ -144,6 +144,23 @@ test("quickClip: a basic project, the window asked, the edges snapped, the take
// A failed fetch too.
await assert.rejects(quickClip({ spec: "yt/vid1@44-56", title: "No window" }, { root: REPORTS, channelsDir: CORPUS, sitesDir: SITES, deps: { ...deps, fetch: async () => { throw new Error("the editor refused"); } } }), /the editor refused/);
assert.equal(existsSync(path.join(REPORTS, "quick-clips", "no-window")), false);
+ // A saved whole recording with a time map (clock.json): the span asked on the FILE's clock, the words back on the cues'.
+ const shifted = [];
+ const clocked = {
+ ...deps,
+ fetch: async () => {},
+ resolve: async (want) => ({ kind: "saved-video", path: "/saved/whole.mp4", name: "whole.mp4", windowStart: -13.1, windowEnd: 9000, clock: { id: "c1", offset: 13.1, certain: false }, want }),
+ transcribe: async (req) => {
+ shifted.push(req);
+ // On the file's clock: the cue second t plays at t + 13.1.
+ return [{ w: "first", start: 40.2 + 13.1, end: 40.8 + 13.1 }, { w: "last", start: 59.5 + 13.1, end: 59.9 + 13.1 }];
+ },
+ };
+ const said = [];
+ const c = await quickClip({ spec: "yt/vid1@40-60", snap: "words", title: "Clocked" }, { root: REPORTS, channelsDir: CORPUS, sitesDir: SITES, deps: clocked, say: (x) => said.push(x) });
+ assert.deepEqual([shifted[0].start, shifted[0].end], [51.1, 75.1], "38–62 on the cues is 51.1–75.1 in the file");
+ assert.deepEqual([c.snapped.cutStart, c.snapped.cutEnd], [40.05, 60.2], "the cut on the cue clock");
+ assert.ok(said.some((x) => /NOT certain/.test(x)), "an uncertain clock is said");
// Refusals: a bad spec, a site with no siteUrl.
assert.equal(await quickClipCommand(["yt/vid1"], { root: REPORTS, log: () => {}, err: () => {} }), 2);
await assert.rejects(quickClip({ spec: "yt/vid1@1-2", site: "private" }, { root: REPORTS, channelsDir: CORPUS, sitesDir: SITES, deps }), /no public siteUrl/);