commit 522abc6e4b7af460ed4aad133c6f335f577209b1
parent bd87090e51b8be61de4b9157b7a9c1136626ff40
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Sat, 21 Nov 2026 21:00:36 -0500
record-live: a YouTube from-start part is proven by the platform and its age, not by a format the metadata never lists
REVIEW-LF-3 1, confirmed against a real live record: the metadata read
passes no --live-from-start, so a live YouTube record lists HLS formats
only (m3u8_native), never the generator protocol the proof looked for. No
real YouTube part was ever marked, and Record again over a shutdown's
short landing always ended "not landed". On YouTube a --live-from-start
run either fails (and falls to index 0, never marked) or downloads only
the extractor's generator from fragment 0: the proof is now the platform
(the plan's, or the record's extractor) plus the existing 120 h age test.
The YT_META fixture now carries what a real live record does (HLS formats
only, is_live, a release_timestamp); on the previous tip five tests fail
with it. A positive containment test is back: a proven, same-kind,
shorter part of the run is removed after the landing. OPERATING.md says a
retry that wrote only audio leaves that part staged for a person.
Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat:
4 files changed, 45 insertions(+), 13 deletions(-)
diff --git a/OPERATING.md b/OPERATING.md
@@ -1453,11 +1453,12 @@ pnpm ops keep-videos --json '{"slug":"example-rumble","ids":["v1abcde"],"note":
VOD that covers the stream removes the channel's live-edge part; one that does not keeps it. A part not from the
start (a live-edge part, one no row describes) goes only when the landed file is from the start and at least the
ENDED stream's own duration less 60 s — never on a coverage by the clock. Only a part PROVEN to begin at the start
- (`provenStart`: YouTube's from-start generator on a stream under 120 h old; on Rumble, Twitch and the rest only a
+ (`provenStart`: a YouTube `--live-from-start` part (not one that fell to index 0) on a stream under 120 h old; on Rumble, Twitch and the rest only a
first attempt whose playlist read still listed the start; a Kick VOD whose poll began at its first segment) counts as from the start for
a removal, a replacement or the coverage; an index-0 part, the browser path and a part of a row written before the
mark do not. A part with a picture is never "inside" an audio-only landed part, nor one merged here from separate
- streams. A stored container that cannot be read, or a `source-media` file no pointer names, counts as stored. **A recording already in the store** (an earlier run's landing, a shutdown's included) is replaced
+ streams. A retry that wrote only its audio leaves that audio-only part staged beside the landed one, and the row
+ asks for a person (its sound is not proven inside the landed file). A stored container that cannot be read, or a `source-media` file no pointer names, counts as stored. **A recording already in the store** (an earlier run's landing, a shutdown's included) is replaced
only by a file that holds the whole stream from its start; otherwise nothing lands, every part stays listed
(`keptParts`), the run is `failed` ("not landed: …") and needs a person — and whenever the landing keeps the stored
container, nothing is removed.
diff --git a/common/controller/recordLive.test.ts b/common/controller/recordLive.test.ts
@@ -508,14 +508,17 @@ const realLand = {
},
freeBytes: async () => 1e15,
};
+// What a real live YouTube record carries (the metadata read passes no
+// --live-from-start, so no generator formats: HLS only), started two hours ago.
const YT_META = (id: string) => ({
id,
extractor: "youtube",
title: "A YouTube live stream",
live_status: "is_live",
+ release_timestamp: Math.floor(Date.now() / 1000) - 7200,
formats: [
- { format_id: "234", protocol: "http_dash_segments_generator", vcodec: "none", acodec: "mp4a.40.2", url: "https://dash.example/234" },
- { format_id: "270", protocol: "http_dash_segments_generator", height: 1080, vcodec: "avc1", acodec: "none", url: "https://dash.example/270" },
+ { format_id: "91", protocol: "m3u8_native", height: 144, vcodec: "avc1.4d400c", acodec: "mp4a.40.5", url: "https://manifest.example/91.m3u8" },
+ { format_id: "95", protocol: "m3u8_native", height: 720, vcodec: "avc1.4d401f", acodec: "mp4a.40.2", url: "https://manifest.example/95.m3u8" },
],
});
@@ -1124,7 +1127,7 @@ test("not covered (d): a stream whose length cannot be established keeps every o
const id = "exmplcov0d1";
const earlier = await leftover(id, 300);
// No start time and no duration: the stream's length is not known.
- const { run } = await incidentRun(id, writesAfter(0), { meta: YT_META(id) });
+ const { run } = await incidentRun(id, writesAfter(0), { meta: { ...YT_META(id), release_timestamp: undefined } });
assert.equal((await run).status, "landed");
assert.ok((await stat(earlier)).size > 0, "kept");
const row = (await rowOf(id))[0]!;
@@ -1589,3 +1592,26 @@ test("LF2 note 7: with a container stored, a zero-byte file and a fragments-only
assert.ok(await stat(zero).then(() => true, () => false), "the zero-byte file stays");
assert.ok(await stat(path.join(store(), `${frag}.ytdl`)).then(() => true, () => false), "the .ytdl stays");
});
+
+test("LF3 note 5: a proven, same-kind, shorter part of this run IS removed after the landing (inside the landed part)", async () => {
+ const id = "exmpllfcon1";
+ // Every attempt writes only its audio (the video fails): the from-start
+ // attempts 100 s, 200 s, 5000 s, the live-edge ones 10 s each.
+ const secs = [100, 200, 5000, 10, 10, 10];
+ const { run } = await incidentRun(
+ id,
+ async (args, n) => {
+ await writeFile(`${outOf(args)}.f140.m4a`, `format=mp4;seconds=${secs[n - 1]};v=none;`);
+ return { exitCode: 1, stderrTail: "1: ERROR: The downloaded file is empty\n", signalled: false };
+ },
+ { request: { doNotClean: false, note: undefined } },
+ );
+ await run.catch(() => {});
+ const row = (await rowOf(id))[0]!;
+ assert.equal(row.parts[row.landedPart ?? -1]?.seconds, 5000, "the longest from-start part landed");
+ const gone = (row.removedParts ?? []).filter((r) => /a shorter part of this run from its start/.test(r.why));
+ assert.equal(gone.length, 2, "the two shorter from-start audio parts are inside it, and go");
+ const files = await left(id);
+ assert.ok(!files.some((n) => /-a2\.f140|ytdlp\.f140/.test(n)), `removed from staging: ${files.join(", ")}`);
+ assert.equal(files.filter((n) => /edge/.test(n)).length, 3, "the live-edge parts (not proven) are kept");
+});
diff --git a/common/controller/recordLive.ts b/common/controller/recordLive.ts
@@ -1086,13 +1086,17 @@ async function recordLiveRunInner(
// the same thing for a DVR playlist); "index0": `--no-live-from-start` with
// ffmpeg told index 0 — for an extractor that does not mark a format from
// the start; "now": the live edge.
- // YouTube's from-start formats come from the extractor's own fragment
- // generator (`http_dash_segments_generator`), which begins at fragment 0
- // for a stream under 120 h old (extractor/youtube/_video.py MAX_DURATION).
- const dashGenerator =
- Array.isArray(meta?.formats) && (meta!.formats as Record<string, unknown>[]).some((f) => /http_dash_segments_generator/.test(String(f.protocol ?? "")));
+ // YouTube (REVIEW-LF-3 1): a `--live-from-start` run there either fails
+ // "no formats that can be downloaded from the start" (→ index 0, never
+ // marked) or downloads only the extractor's own fragment generator, which
+ // begins at fragment 0 for a stream under 120 h old (YoutubeDL.py's
+ // is_from_start format filter; extractor/youtube/_video.py MAX_DURATION).
+ // So the proof is the platform plus the age — not the metadata read's
+ // formats, which never carry the generator protocol (that read passes no
+ // --live-from-start: a real live record lists HLS formats only).
+ const youtube = plan.platform === "youtube" || /^youtube/i.test(String(meta?.extractor ?? ""));
const startProvable = (first: boolean): boolean => {
- if (dashGenerator) {
+ if (youtube) {
// Its age: from its start time, else (an ended stream) its duration.
const age = streamStartSec !== null ? now().getTime() / 1000 - streamStartSec : typeof meta?.duration === "number" ? (meta.duration as number) : null;
return age !== null && age < 120 * 3600;
diff --git a/common/lib/liveCapture.ts b/common/lib/liveCapture.ts
@@ -452,8 +452,9 @@ export type LivePart = {
// Recorded `--no-live-from-start` with ffmpeg at the playlist's first listed
// segment: from the start only if the playlist reaches it.
index0?: boolean;
- // Proven to begin at the stream's start, by what was recorded: YouTube's
- // from-start generator on a stream under 120 h old; another platform's
+ // Proven to begin at the stream's start, by what was recorded: a YouTube
+ // `--live-from-start` part (not one fallen to index 0) on a stream under
+ // 120 h old; another platform's
// `--live-from-start` only when that run's first playlist read listed the
// start; a platform VOD whose poll began at its first segment. A part
// without it (index-0, the browser path, a later attempt, rows written