commit 16d4e9559c39f1fff73219402180dc094edd3feb
parent 059ee9b9d8ca3a0b539f45ce2262111d50e246d2
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Thu, 19 Nov 2026 15:00:10 -0500
availability: a first-seen day only history anchors; no removal from a fetch; the re-read settles
Review fixes 1-3 of lane missing-source.
- recordAvailability seeds an empty history from the record's own top level
(reading + checkedAt, checkedBy or "backfill") before the new observation,
so a same-value recheck no longer slides the first-seen day.
- resolveEffectiveAvailabilityObserved dates a state only by a history entry:
a legacy checkedAt or an outcome's finishedAt gives no day (published as
the state alone).
- The sentence and the badge tooltip say "<state>; first seen <day>", not
"since <day>".
- refusalAvailability records members-only and private only: a removal is
never taken from a fetch's refusal; the availability check owns it.
- buildIndex marks each re-derived non-available record availabilityDayRead,
so "no day" is settled and a held channel no longer re-pages every build.
- fetchLiveChat: the cookie-retry-succeeds case; help text, COMMANDS.md and
the editor changelog follow.
Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat:
14 files changed, 259 insertions(+), 40 deletions(-)
diff --git a/COMMANDS.md b/COMMANDS.md
@@ -140,7 +140,7 @@ Drives a running editor over HTTP (`/api/ops/*`, the same actions its pages run)
| `rename-channel` | rename-channel moves a channel to a new slug, as Danger → Rename does: {"slug", "newSlug"}. Refused while the channel is busy (a job, a lane unit, media in transition) or when the new slug is taken. Old links break. | `pnpm ops rename-channel --json '{"slug":"old-slug","newSlug":"new-slug"}'` |
| `delete-channel` | delete-channel removes a channel's whole directory, as Danger → Delete does: {"slug", "confirm"} — "confirm" must repeat the slug. Every site whose pool or cited scope names it is rewritten without it (answered as "sitesUpdated"; a site whose write is refused is a "warnings" line). No undo outside the transcripts/ repo's own history. | `pnpm ops delete-channel --json '{"slug":"x","confirm":"x"}'` |
| `metadata-scan` | metadata-scan reads every listed video's title, date and description into the channel's scan file, fetching no media: {"slug"}. Not held by the download pause and needs no disk floor; one request per video, so it respects the platform's cooldown and records one when pushed back. | `pnpm ops metadata-scan --json '{"slug":"the-quartering"}'` |
-| `refresh-metadata` | refresh-metadata re-reads ONE video's metadata.info.json from its source (no subtitles, no media) on the platform's queue: {"slug", "id"}. The job's log ends with what the source now says — live\_status, formats, audio-only formats and whether any is non-fragmented, English captions, the keys that changed. An id with no data/<id>/ is refused (a refresh re-reads a video already archived), as are archive.org and Wayback records. A refusal for the video (members-only, private, removed), or a metadata availability field that changes the reading, is recorded in its availability.json (source fetch): the one-video availability recheck. | `pnpm ops refresh-metadata --json '{"slug":"the-quartering","id":"<videoId>"}' --wait` |
+| `refresh-metadata` | refresh-metadata re-reads ONE video's metadata.info.json from its source (no subtitles, no media) on the platform's queue: {"slug", "id"}. The job's log ends with what the source now says — live\_status, formats, audio-only formats and whether any is non-fragmented, English captions, the keys that changed. An id with no data/<id>/ is refused (a refresh re-reads a video already archived), as are archive.org and Wayback records. A refusal for the video as members-only or private, or a metadata availability field that changes the reading, is recorded in its availability.json (source fetch): the one-video availability recheck. A removal is recorded only by the channel's Check availability. | `pnpm ops refresh-metadata --json '{"slug":"the-quartering","id":"<videoId>"}' --wait` |
| `browser-lookup` | browser-lookup reads Odysee records from their pages in a headless browser, for when yt-dlp's lookup answers 429: {"slug", "ids": \[...\]} (at most 50) writes each record (none yet: whole, `_source: "browser"`) or completes it (the keys it lacks, and the one media file the page's player asked for); "listing": true (with "scrolls", default 5, at most 40) adds the uploads the channel page shows to the playlist, newest first, through the title match filter. One page a minute; not refused for a held platform. The log ends with a `summary: {...}` line. | `pnpm ops browser-lookup --json '{"slug":"demo-odysee","ids":["<claimId>"]}' --wait`<br>`pnpm ops browser-lookup --json '{"slug":"demo-odysee","listing":true,"scrolls":5}' --wait` |
| `import-video` | import-video imports one video by URL into a channel: {"slug", "url"}. An archive.org URL becomes its canonical item or file (an item of several media files is refused — see import-archive-org); a BitChute or Odysee URL runs on that platform's queue at its pace, refused while it is held or cooling down, and refused when already on disk; a Wayback capture is named by what it copies. | `pnpm ops import-video --json '{"slug":"demo-archive","url":"https://archive.org/details/example-item"}'` |
| `import-archive-org` | import-archive-org imports archive.org media into a channel, as one job on archive.org's queue: {"slug", "item", "files": \[...\] \| "match": "<regex>"} for one item; {"slug", "items": \["<id>" \| {"item", "files"? \| "match"?}, ...\]} for many (a bare id takes "match", else every media original); or {"slug", "query": "<archive.org search>", "limit"?: 100} for the first items a search finds (at most 500). One file at a time, a jittered pause between files and between items; a record already held (on disk, or in the saved-video store) is skipped. "dryRun": true lists each file as held, RESTRICTED (archive.org marks it not for download: a fetch would answer 401/403) or would get, and fetches nothing. A 401/403 skips the rest of its item; three such items in a row, a 429 or three failures in a row stop the job. The log ends with a summary: line; a re-run resumes. | `pnpm ops import-archive-org --json '{"slug":"demo-archive","item":"example-item","match":"\\.mp4$"}' --wait`<br>`pnpm ops import-archive-org --json '{"slug":"demo-archive","query":"collection:example-collection","dryRun":true}' --wait` |
@@ -236,7 +236,7 @@ Drives a running editor over HTTP (`/api/ops/*`, the same actions its pages run)
| `mirror-scan` | mirror-scan pairs a mirror channel with the creator it copies: {"slug", "dryRun"?} -> {jobId}. The channel's config names the creator's channels (mirror.of; channel-config's "mirrorOf"); refused without them. Each of the mirror's videos, dated by its recorded date (else its upload date), is matched with the creator's videos uploaded one day before to two after, by title words and duration (the index's records; no media, no network); per video the matches and a status: only-copy (no creator platform has it public), creator-deleted (removed on one platform, public on another), never-uploaded (missing on one platform, public on the rest) or creator-public. The other way: the creator's removed (deleted or private) uploads dated inside the mirror's window, and which the mirror holds. Written to transcripts/mirrors/<slug>.json (private: never published); the channel page's Mirror stage shows it. dryRun writes nothing. The log ends with @@mirror-scan {slug, dryRun, file?, of, missing?, window, videos, matched, byStatus, byPlatform, creatorRemoved: {inWindow, held, byChannel}}. | `pnpm ops mirror-scan --json '{"slug":"demo-vod-archive","dryRun":true}' --wait`<br>`pnpm ops mirror-scan --json '{"slug":"demo-vod-archive"}' --wait` |
| `report-schedule` | report-schedule keeps a recurring report on a cadence the editor ticks: {"action": "list" \| "create" \| "update" \| "pause" \| "resume" \| "delete" \| "tick-now" \| "reset-triage" \| "learn" \| "unlearn" \| "promote-alias" \| "add-spelling", …}. create takes {"shape": "living" \| "series", "topic", "question"?, "channels", "case"?, "from"?, "terms"?, "regex"?, "cadence" ({"kind": "daily" \| "weekly" \| "every", "at": "HH:MM", "dow"?, "days"?} or "weekly mon 06:00"), "tz"?, "article"? (living), "autoMakeCurrent"? (living), "model"?, "maxUsd"?, "dryRun"?} -> {plan, schedule?}: the plan names the first tick, the model and its cap. A living report is one article kept current: each tick fetches the scope (R4's stage 1) and refreshes it, the new iteration left ready (or made current with autoMakeCurrent); its first tick is its first sweep. A series makes an edition each tick: a new article <series>-<date> over the window since the last edition ("<topic> · week of <date>"); a window the terms (or, with none, any recording) do not match is a quiet edition: recorded, no article, $0. Ticks run as report-tick jobs, one at a time, never on an idle boot, held by the lane's gate (lane report-schedule); a window missed while the editor was down is ONE catch-up tick. A cap refusal ends a tick held-by-cap. update {"id", …} (a new cadence re-plans from now); pause / resume {"id"}; delete {"id", "confirm"?} answers the plan unless confirm is true; tick-now {"id"} -> {jobId} (refused while a tick of it is queued or running); --wait prints the tick's @@report-tick {json}. list {"id"?} answers the schedules with their chip, call and spend, and the lane. A tick whose scan hit a cap (or did not reach a channel) and found nothing ends partial, naming what it did not reach — never quiet. reset-triage {"id", "k"?, "confirm"?} discards a schedule's triage state (its runs from run k on, default all; seen.json, so the next run counts new from its since; the quiet editions they covered): the plan unless confirm is true; refused while a tick runs. learn {"id", "dryRun"?} runs the proposal pass now (R6.3: learned spellings): the triage model lists likely mis-hearings of each name in the terms; each must occur in scope (an uncapped count) and the judge must say, quoting the line, that it means the name, before it joins the candidate query as an escaped literal ("terms + N learned"); the answer is the plan (the names it asks about) and the job (a report-draft job on the triage model's lane); dryRun answers the plan only. A create of a schedule that triages, a change of its terms, and a tick a week after the last pass start one too. unlearn {"id", "spelling"} removes a learned spelling (never learned again). promote-alias {"id", "spelling", "site"?, "confirm"?} writes it as a search alias (global, or the site's), a new alias or a trigger on the one for that name: the plan unless confirm is true. add-spelling {"id", "spelling", "means"} adds a spelling by hand (no model): "means" is one of the names the terms watch; it is counted in scope and its proving line found by code, and kept (source hand) only when it occurs; a removed spelling added by hand is no longer blocked. | `pnpm ops report-schedule --json '{"action":"create","shape":"series","topic":"Co-host updates","channels":["demo-channel"],"cadence":"weekly mon 06:00","dryRun":true}'`<br>`pnpm ops report-schedule --json '{"action":"create","shape":"watch","topic":"Co-host watch","channels":["demo-channel"],"terms":"co-host","cadence":"daily 06:00","dryRun":true}'`<br>`pnpm ops report-schedule --json '{"action":"list"}'`<br>`pnpm ops report-schedule --json '{"action":"tick-now","id":"co-host-updates"}' --wait`<br>`pnpm ops report-schedule --json '{"action":"delete","id":"co-host-updates","confirm":true}'`<br>`pnpm ops report-schedule --json '{"action":"reset-triage","id":"co-host-updates"}'`<br>`pnpm ops report-schedule --json '{"action":"learn","id":"co-host-updates","dryRun":true}'`<br>`pnpm ops report-schedule --json '{"action":"promote-alias","id":"co-host-updates","spelling":"Gothics"}'` |
| `audio-audit` | audio-audit decodes every audio file a channel holds, with error tolerance, and writes the verdict beside it in audio-integrity.json: {"slug" \| "platform" (every channel on it, e.g. "odysee"), "scope"? ("untranscribed", the default: videos with no transcript yet; "all": every video holding audio), "max"? (files decoded across the run), "force"? (decode again a file whose record is still its own)} -> {jobIds, channels, refused}. One audio-audit job per channel on the audio-audit queue: one file at a time machine-wide, at idle I/O priority and nice 19. The verdict is clean, damaged (a gap, or under 98% of the container's duration decodes) or undecodable, with the decoded seconds, the gaps, the file's size and mtime and ffmpeg's version. The same body again resumes (a file whose record matches is skipped). A channel whose media is unreachable is refused; a drive that stops answering mid-run ends that channel's job with the sentence (failed), as do two decodes in a row past their deadline (a minute plus a tenth of the audio's length). Corrupt full sources are left to their retry. Damaged untranscribed files (and their salvage transcripts) are the report's corruptHeldAudio bucket, held out of the transcription lane: retry-bucket {"bucket": "corruptHeldAudio"} refetches them; a transcription of one salvages automatically. Each log ends with @@audio-audit {slug, scope, held, fresh, planned, checked, clean, damaged, undecodable, unmeasured, timedOut, corruptFullSource, stopped?}. | `pnpm ops audio-audit --json '{"platform":"odysee","scope":"untranscribed"}' --wait`<br>`pnpm ops audio-audit --json '{"slug":"demo-odysee","scope":"all","max":50}'` |
-| `fetch-chat` | fetch-chat fetches ONE video's live chat replay and nothing else: {"slug", "id"} — the chat-only yt-dlp pass (the channel's cookies, the platform's pace) on the platform's download queue, then live\_chat.cues.json. YouTube only: another platform answers "no chat fetcher for <platform>" (info, no job), as do a chat already here and fresh and a video never live. A pass that finds no replay ends done and says so. A pass the source refuses for the video (members-only, private, removed) records that in its availability.json (source fetch). | `pnpm ops fetch-chat --json '{"slug":"demo-yt","id":"<videoId>"}' --wait` |
+| `fetch-chat` | fetch-chat fetches ONE video's live chat replay and nothing else: {"slug", "id"} — the chat-only yt-dlp pass (the channel's cookies, the platform's pace) on the platform's download queue, then live\_chat.cues.json. YouTube only: another platform answers "no chat fetcher for <platform>" (info, no job), as do a chat already here and fresh and a video never live. A pass that finds no replay ends done and says so. A pass the source refuses for the video as members-only or private records that in its availability.json (source fetch); a removal is recorded only by the channel's Check availability. | `pnpm ops fetch-chat --json '{"slug":"demo-yt","id":"<videoId>"}' --wait` |
| `find-clips` | find-clips runs the clip finder's chain for ONE video as one job: {"slug", "id", "target"? (the cut's seconds), "segment"? (one umtool found, "s2"), "project"? (the umtool project a run makes), "whilePaused"?, "dryRun"?}. Persist the source video, the corpus transcript, word timings (data/<id>/words.json), the chat replay (YouTube), diarization — each step skipped when its output exists, named in the log — then umtool's clip finder (POST UMTOOL\_URL/api/report/clips {mode: "new"}), followed to the end. "whilePaused": true runs this one video past the holds: the two transcriptions during a pause-all on a worker the pause alone switched off, and its diarization in the job when the backfill lane is held. "dryRun": true answers each step's plan and starts nothing. With --wait the result — {project, url, created, segments: \[{id, from, to, why}\], steps} — is printed on stdout. | `pnpm ops find-clips --json '{"slug":"demo-yt","id":"<videoId>","dryRun":true}'`<br>`pnpm ops find-clips --json '{"slug":"demo-yt","id":"<videoId>","target":600}' --wait`<br>`pnpm ops find-clips --json '{"slug":"demo-yt","id":"<videoId>","segment":"s2","whilePaused":true}' --wait` |
| `fetch-chat-backlog` | fetch-chat-backlog fetches a channel's stream chats after its downloads: {"slug", "dryRun"?, "limit"?, "queueKey"?} — every held video whose metadata says it was a stream (live\_status was\_live / post\_live) and whose chat is not here, newest first, one at a time through fetch-chat's pass with the batch downloads' gap between two, as one fetch-chat-backlog job on the platform's download queue; a raw replay already here is only normalized. It stops on a rate limit, a held platform, three failures in a row, a drain or "limit" chats; a re-run skips the chats here and the streams known to have none (chat-backlog.json), and a restart resumes it. The download lane queues it by itself (25 a run) for a channel whose "chat" is "later" once it has nothing left to download. "dryRun": true counts from the disk and starts nothing: chats, normalizeOnly, have, settled, notStreams, ids (the first 50). | `pnpm ops fetch-chat-backlog --json '{"slug":"demo-yt","dryRun":true}'` |
| `x-run` | x-run fetches several X posts channels IN SEQUENCE as ONE job on X's queue: {"channels": \[slug, ...\]} in that order, each a fetch-posts sync new of at most 200 posts ("limit": N, 1-200, caps it lower), X's queue gap (pacing.jobGapSeconds.twitter) between two channels. Before EACH channel the jar is checked again: once it is past social.x.maxCookieAgeMinutes (or the X alert is up) the run stops and the rest are DEFERRED until the next refresh. It never refreshes the jar: Refresh cookies on /cookies, then {"resume": "<run id>"} runs the deferred channels (the console's Resume; a Retry of the job is the same). One run at a time; refused before a job on a stale jar (a new run's channels are kept, deferred). An interrupted run is not resumed on boot: it ends deferred. Answers {jobId, run}; get x-run follows it. The log ends with @@x-run {id, status, stopped?, counts, summary}. | `pnpm ops x-run --json '{"channels":["example-x","other-x"]}'`<br>`pnpm ops x-run --json '{"resume":"xr-01J…"}'` |
diff --git a/common/components/badges.tsx b/common/components/badges.tsx
@@ -51,7 +51,7 @@ const STATE_STYLES: Record<
};
// `since` (YYYYMMDD, lane missing-source): the day the archive first saw the
-// state, added to the tooltip ("… since 19 Nov 2026"). The label and test id
+// state, added to the tooltip ("…; first seen 19 Nov 2026"). The label and test id
// are unchanged.
export function VideoStateBadge({ state, since }: { state: VideoState; since?: string }) {
if (state === "available") return null;
diff --git a/common/controller/buildIndex.test.ts b/common/controller/buildIndex.test.ts
@@ -844,6 +844,7 @@ test("(m) lane missing-source: a record no longer public carries its state and t
const rec = value as Record<string, unknown>;
if (!rec.availabilityDay) continue;
delete rec.availabilityDay;
+ delete rec.availabilityDayRead;
mt.putSync(key, rec);
}
db("meta").removeSync("stateSince");
@@ -856,6 +857,44 @@ test("(m) lane missing-source: a record no longer public carries its state and t
assert.ok(!again.log.some((l) => /State since v1/.test(l)));
});
+test("(n) lane missing-source: an undated state with a channel held is re-read once, not on every build", async () => {
+ resetCorpus();
+ seedVideo("n1");
+ seedDriveChannel();
+ // Removed, recorded before history existed: no day is known.
+ writeJson(path.join(videoDir("n1"), "availability.json"), {
+ checkedAt: "2023-04-02T00:00:00.000Z",
+ checkedBy: "check",
+ availability: "deleted",
+ });
+ await runIndex();
+ const n1 = transcriptRecord("n1", CHANNEL) as Published & { stateSince?: string };
+ assert.equal(n1.state, "deleted");
+ assert.ok(!("stateSince" in n1), "a legacy checkedAt publishes no day");
+
+ // An index from before the day was cached, and the drive away: the version
+ // cannot be recorded while a channel is held.
+ withIndex((db) => {
+ db("meta").removeSync("stateSince");
+ const mt = db("mtimes");
+ for (const { key, value } of [...mt.getRange()]) {
+ const rec = value as Record<string, unknown>;
+ if (!("availabilityDayRead" in rec)) continue;
+ delete rec.availabilityDayRead;
+ mt.putSync(key, rec);
+ }
+ });
+ unmount();
+ const second = await runIndex();
+ assert.deepEqual(second.res.heldChannels, [DRIVE_CHANNEL]);
+ assert.ok(second.log.some((l) => /State since v1: 1 record\(s\) re-read\./.test(l)), second.log.join("\n"));
+ const third = await runIndex();
+ assert.deepEqual(third.res.heldChannels, [DRIVE_CHANNEL]);
+ assert.equal(third.res.changed, 0, third.log.join("\n"));
+ assert.ok(third.log.some((l) => /State since v1: 0 record\(s\) re-read\./.test(l)), third.log.join("\n"));
+ assert.ok(third.log.some((l) => l.startsWith("Shared transcript pages up to date")), third.log.join("\n"));
+});
+
test("(z) no write this file caused landed outside its temp root", () => {
// LMDB writes natively, past the spy: its file must be under the root too.
assert.ok(paths.lmdbPath.startsWith(ROOT + path.sep), paths.lmdbPath);
diff --git a/common/controller/buildIndex.ts b/common/controller/buildIndex.ts
@@ -266,7 +266,10 @@ const ALT_TRACKS_KEY = "altTracks";
// transcript pages carry `state` + `stateSince` on such a record. The first
// build that sees a new STATE_SINCE_VERSION re-derives every record whose
// cached state is not "available" and that has no day yet — sparse by
-// construction — then records the version, only when no channel is held.
+// construction — then records the version, only when no channel is held. Each
+// re-derived record also carries `availabilityDayRead`, so one with no day to
+// find is not taken again on the next build (a held channel would otherwise
+// keep the version unrecorded and re-page the shared tree on every build).
const STATE_SINCE_VERSION = 1;
const STATE_SINCE_KEY = "stateSince";
@@ -356,6 +359,12 @@ type MtimeRecord = {
// The day (YYYYMMDD) the archive first saw `availability`, written only when
// it is not an "available" state (lane missing-source; STATE_SINCE_VERSION).
availabilityDay?: string;
+ // The STATE_SINCE_VERSION this record's day was derived under, written beside
+ // a non-available `availability` whether or not a day was found: "no day" (a
+ // legacy record with no history entry behind its state) is a SETTLED answer,
+ // so the one-time re-read never takes this record again — not even while a
+ // held channel keeps the version itself from being recorded.
+ availabilityDayRead?: number;
isDeleted: boolean;
isUnlisted: boolean;
indexKey: IndexKey;
@@ -1006,7 +1015,8 @@ export async function buildIndex({
for (const s of live) {
const pk: PathKey = [s.channelSlug, s.videoDir];
const prev = mtimes.get(pk);
- if (!prev || prev.availabilityDay || stateFromRecord(prev) === "available") continue;
+ if (!prev || stateFromRecord(prev) === "available") continue;
+ if (prev.availabilityDay || prev.availabilityDayRead === STATE_SINCE_VERSION) continue;
reread++;
if (!queued.has(pathKeyId(pk))) changed.push(s);
}
@@ -1399,11 +1409,13 @@ export async function buildIndex({
// directly, so the two can't disagree.
let availability: Availability | undefined;
let availabilityDay: string | undefined;
+ let availabilityDayRead: number | undefined;
if (s.availabilityMs !== null) {
const observed = await resolveEffectiveAvailabilityObserved(videoFullDir);
availability = observed?.availability;
if (availability && stateFromAvailability(availability) !== "available") {
availabilityDay = isoDay(observed?.observedAt);
+ availabilityDayRead = STATE_SINCE_VERSION;
}
}
@@ -1416,6 +1428,7 @@ export async function buildIndex({
digestMs: s.digestMs,
...(availability ? { availability } : {}),
...(availabilityDay ? { availabilityDay } : {}),
+ ...(availabilityDayRead ? { availabilityDayRead } : {}),
isDeleted: availability === "deleted",
isUnlisted: availability === "unlisted",
indexKey,
diff --git a/common/controller/fetchLiveChat.test.ts b/common/controller/fetchLiveChat.test.ts
@@ -232,6 +232,69 @@ test("a members-only refusal is recorded as the video's availability, and the jo
assert.equal(await readFile(path.join(dir, "availability.json"), "utf8"), before);
});
+test("a members-only refusal is recorded even when the cookie retry then fetches the chat", async () => {
+ const dir = await video("ym2", { webpage_url: "https://www.youtube.com/watch?v=ym2", was_live: true });
+ await writeFile(
+ path.join(dir, "availability.json"),
+ JSON.stringify({
+ checkedAt: "2026-01-02T03:00:00.000Z",
+ checkedBy: "backfill",
+ availability: "public",
+ history: [{ availability: "public", observedAt: "2026-01-02T03:00:00.000Z", source: "backfill" }],
+ }),
+ );
+ const calls: string[][] = [];
+ const refusedThenOk = async (cwd: string, args: string[]): Promise<AttemptOutcome> => {
+ calls.push(args);
+ if (calls.length === 1) {
+ return {
+ exitCode: 1,
+ stderrTail: "ERROR: [youtube] ym2: Join this channel to get access to members-only content like this video, and other exclusive perks.",
+ archiveLine: null,
+ formatLine: null,
+ };
+ }
+ const base = args[args.findIndex((a) => a.startsWith("subtitle:"))].slice("subtitle:".length);
+ await writeFile(path.join(cwd, `${base}.live_chat.json`), REPLAY);
+ return { exitCode: 0, stderrTail: "", archiveLine: null, formatLine: null };
+ };
+ const r = await fetchLiveChat({
+ paths, slug: SLUG, videoId: "ym2", videoUrl: "https://www.youtube.com/watch?v=ym2",
+ channelConfig: CONFIG, cookiePolicy: { cookies: "firefox", mode: "when-required" },
+ onLog: () => {}, signal: new AbortController().signal, run: refusedThenOk, paceSeconds: 0,
+ });
+ assert.equal(r.status, "fetched");
+ assert.equal(calls.length, 2);
+ assert.ok(calls[1].includes("--cookies-from-browser"), "the retry carried the members' cookies");
+ const rec = JSON.parse(await readFile(path.join(dir, "availability.json"), "utf8"));
+ assert.equal(rec.availability, "members_only");
+ assert.equal(rec.checkedBy, "fetch");
+});
+
+test("a removal is never recorded from a chat refusal: only the availability check establishes one", async () => {
+ const dir = await video("yd1", { webpage_url: "https://www.youtube.com/watch?v=yd1", was_live: true });
+ const before = JSON.stringify({
+ checkedAt: "2026-01-02T03:00:00.000Z",
+ checkedBy: "backfill",
+ availability: "public",
+ history: [{ availability: "public", observedAt: "2026-01-02T03:00:00.000Z", source: "backfill" }],
+ });
+ await writeFile(path.join(dir, "availability.json"), before);
+ const { run } = stubRunner({
+ exitCode: 1,
+ stderr: "ERROR: [youtube] yd1: Video unavailable. This video has been removed by the uploader",
+ writes: null,
+ });
+ await assert.rejects(
+ fetchLiveChat({
+ paths, slug: SLUG, videoId: "yd1", videoUrl: "https://www.youtube.com/watch?v=yd1",
+ channelConfig: CONFIG, cookiePolicy: { cookies: undefined, mode: "defer" },
+ onLog: () => {}, signal: new AbortController().signal, run, paceSeconds: 0,
+ }),
+ );
+ assert.equal(await readFile(path.join(dir, "availability.json"), "utf8"), before);
+});
+
test("a rate-limited or soft-blocked chat pass records no availability", async () => {
const dir = await video("yr1", { webpage_url: "https://www.youtube.com/watch?v=yr1", was_live: true });
for (const stderr of [
diff --git a/common/controller/refreshVideoMetadata.test.ts b/common/controller/refreshVideoMetadata.test.ts
@@ -351,6 +351,32 @@ test("a refresh writes availability only when the video's own field changes it",
}
});
+test("a removal is never recorded from a refresh's refusal: only the availability check establishes one", async () => {
+ const f = await fixture({ meta: BEFORE });
+ try {
+ const before = JSON.stringify({
+ checkedAt: "2026-01-02T03:00:00.000Z",
+ checkedBy: "backfill",
+ availability: "public",
+ history: [{ availability: "public", observedAt: "2026-01-02T03:00:00.000Z", source: "backfill" }],
+ });
+ await writeFile(path.join(f.videoDir, "availability.json"), before);
+ const { run } = stubRunner([
+ { exitCode: 1, stderr: `ERROR: [youtube] ${ID}: Video unavailable. This video has been removed by the uploader` },
+ ]);
+ await assert.rejects(
+ refreshVideoMetadata({
+ paths: f.paths, slug: SLUG, videoId: ID, videoUrl: URL, channelConfig: CONFIG,
+ cookiePolicy: { cookies: undefined, mode: "when-required" },
+ onLog: () => {}, signal: new AbortController().signal, run, paceSeconds: 1,
+ }),
+ );
+ assert.equal(await readFile(path.join(f.videoDir, "availability.json"), "utf8"), before);
+ } finally {
+ await rm(f.root, { recursive: true, force: true });
+ }
+});
+
test("a rate-limited refresh records the platform cooldown, rewrites nothing and fails", async () => {
const f = await fixture({ meta: BEFORE });
try {
diff --git a/common/lib/availability-server.test.ts b/common/lib/availability-server.test.ts
@@ -5,6 +5,7 @@ import { tmpdir } from "node:os";
import path from "node:path";
import {
platformPresence,
+ recordAvailability,
recordFetchObservation,
resolveEffectiveAvailabilityObserved,
} from "./availability-server";
@@ -59,7 +60,7 @@ test("a fetch that reads 'public' with no record writes nothing", async () => {
}
});
-test("observed: the first entry of the trailing run, else checkedAt, else the outcome's time", async () => {
+test("observed: the first entry of the trailing run; a day only a history entry anchors", async () => {
const d = await dir();
try {
assert.equal(await resolveEffectiveAvailabilityObserved(d), null);
@@ -79,15 +80,18 @@ test("observed: the first entry of the trailing run, else checkedAt, else the ou
availability: "members_only",
observedAt: "2026-01-05T00:00:00.000Z",
});
+ // A legacy record (no history): its checkedAt is when it was last checked,
+ // not when it changed, so no day.
await writeFile(
path.join(d, "availability.json"),
JSON.stringify({ checkedAt: "2026-01-09T00:00:00.000Z", availability: "private" }),
);
assert.deepEqual(await resolveEffectiveAvailabilityObserved(d), {
availability: "private",
- observedAt: "2026-01-09T00:00:00.000Z",
+ observedAt: null,
});
- // A newer download outcome that found it removed wins, dated by its finish.
+ // A newer download outcome that found it removed wins; with no history
+ // entry agreeing, its finish (which moves with every attempt) is no day.
await writeFile(
path.join(d, "download-outcome.json"),
JSON.stringify({
@@ -101,7 +105,43 @@ test("observed: the first entry of the trailing run, else checkedAt, else the ou
);
const got = await resolveEffectiveAvailabilityObserved(d);
assert.equal(got?.availability, "deleted");
- assert.equal(got?.observedAt, "2026-01-10T00:01:00.000Z");
+ assert.equal(got?.observedAt, null);
+ } finally {
+ await rm(d, { recursive: true, force: true });
+ }
+});
+
+test("a legacy record's first write seeds its history, so a same-value recheck never moves the day", async () => {
+ const d = await dir();
+ try {
+ // Removed long ago, recorded before history existed.
+ await writeFile(
+ path.join(d, "availability.json"),
+ JSON.stringify({ checkedAt: "2023-04-02T00:00:00.000Z", checkedBy: "check", availability: "deleted", history: [] }),
+ );
+ assert.equal((await resolveEffectiveAvailabilityObserved(d))?.observedAt, null);
+ await recordAvailability(d, { availability: "deleted", observedAt: "2026-11-19T00:00:00.000Z", source: "check" });
+ const rec = JSON.parse(await readFile(path.join(d, "availability.json"), "utf8"));
+ assert.equal(rec.checkedAt, "2026-11-19T00:00:00.000Z");
+ assert.deepEqual(rec.history, [{ availability: "deleted", observedAt: "2023-04-02T00:00:00.000Z", source: "check" }]);
+ assert.equal((await resolveEffectiveAvailabilityObserved(d))?.observedAt, "2023-04-02T00:00:00.000Z");
+ // And again: the day stays where it was.
+ await recordAvailability(d, { availability: "deleted", observedAt: "2026-11-20T00:00:00.000Z", source: "check" });
+ assert.equal((await resolveEffectiveAvailabilityObserved(d))?.observedAt, "2023-04-02T00:00:00.000Z");
+
+ // A legacy record with no checkedBy, then a change: the old reading is kept
+ // ahead of the new one, as the weakest claim ("backfill").
+ await writeFile(
+ path.join(d, "availability.json"),
+ JSON.stringify({ checkedAt: "2026-01-02T00:00:00.000Z", availability: "public" }),
+ );
+ await recordAvailability(d, { availability: "members_only", observedAt: "2026-01-05T00:00:00.000Z", source: "fetch" });
+ const moved = JSON.parse(await readFile(path.join(d, "availability.json"), "utf8"));
+ assert.deepEqual(moved.history, [
+ { availability: "public", observedAt: "2026-01-02T00:00:00.000Z", source: "backfill" },
+ { availability: "members_only", observedAt: "2026-01-05T00:00:00.000Z", source: "fetch" },
+ ]);
+ assert.equal((await resolveEffectiveAvailabilityObserved(d))?.observedAt, "2026-01-05T00:00:00.000Z");
} finally {
await rm(d, { recursive: true, force: true });
}
diff --git a/common/lib/availability-server.ts b/common/lib/availability-server.ts
@@ -62,6 +62,21 @@ export async function recordAvailability(
const changed = lastAvail !== obs.availability;
const history: AvailabilityHistoryEntry[] = [...(existing?.history ?? [])];
+ // A LEGACY RECORD (written before history existed, or by a path that left it
+ // empty) is seeded on its first write from its own top level — the reading
+ // and the checkedAt it was made at — before the new observation is applied.
+ // Without it a same-value recheck appended nothing and only moved checkedAt,
+ // so a day derived from it slid forward on every recheck (a video removed in
+ // 2023 read "first seen" today). With it the first-seen day is fixed from
+ // then on. A record that never said who wrote it is seeded as "backfill", the
+ // weakest claim.
+ if (existing && history.length === 0) {
+ history.push({
+ availability: existing.availability,
+ observedAt: existing.checkedAt,
+ source: existing.checkedBy ?? "backfill",
+ });
+ }
if (changed) {
history.push({
availability: obs.availability,
@@ -129,8 +144,12 @@ export async function resolveEffectiveAvailability(
// The effective availability (as resolveEffectiveAvailability) AND the instant
// the archive first observed it — the start of the trailing run of history
-// entries that agree with it, else the record's checkedAt, else the outcome's
-// finishedAt. The published `stateSince` is this instant's day (buildIndex).
+// entries that agree with it. ONLY a history entry dates it: a record's
+// checkedAt is when it was last checked and an outcome's finishedAt when it was
+// last attempted, and both move with every recheck, so a state with no
+// history entry behind it has `observedAt: null` and the site publishes no day
+// for it (we do not know when it changed). The published `stateSince` is this
+// instant's day (buildIndex).
export async function resolveEffectiveAvailabilityObserved(
videoDir: string,
): Promise<{ availability: Availability; observedAt: string | null } | null> {
@@ -145,14 +164,14 @@ export async function resolveEffectiveAvailabilityObserved(
new Date(outcome.finishedAt) > new Date(explicit.checkedAt)));
if (fromOutcome && outcome) {
// A download's class also appends a history entry (downloadOneManaged), so
- // the history can date it when it agrees; else the outcome's own time.
+ // the history dates it when it agrees; else no day.
const since = explicit ? firstOfTrailingRun(explicit, outcome.availability) : null;
- return { availability: outcome.availability, observedAt: since ?? outcome.finishedAt };
+ return { availability: outcome.availability, observedAt: since };
}
if (!explicit) return null;
return {
availability: explicit.availability,
- observedAt: firstOfTrailingRun(explicit, explicit.availability) ?? explicit.checkedAt,
+ observedAt: firstOfTrailingRun(explicit, explicit.availability),
};
}
diff --git a/common/lib/availability.test.ts b/common/lib/availability.test.ts
@@ -216,15 +216,18 @@ test("a subtitle 429 beside another subtitle failure classes as the OTHER failur
);
});
-test("refusalAvailability: only a per-video 'not public there' reason counts", async () => {
+test("refusalAvailability: only members-only and private count, never a removal", async () => {
const { refusalAvailability } = await import("./availability");
assert.equal(
refusalAvailability("ERROR: [youtube] abc: Join this channel to get access to members-only content like this video."),
"members_only",
);
assert.equal(refusalAvailability("ERROR: [youtube] abc: Private video. Sign in if you've been granted access"), "private");
- assert.equal(refusalAvailability("ERROR: [youtube] abc: Video unavailable. This video has been removed by the uploader"), "deleted");
for (const nothing of [
+ // A removal is never taken from a fetch's refusal: its wording matches
+ // loosely, and only the availability check job establishes one.
+ "ERROR: [youtube] abc: Video unavailable. This video has been removed by the uploader",
+ "ERROR: [youtube] abc: Video unavailable",
"ERROR: [youtube] abc: HTTP Error 429: Too Many Requests",
"ERROR: [youtube] abc: This content isn't available, try again later. The current session has been rate-limited",
"ERROR: [youtube] abc: Sign in to confirm you're not a bot",
diff --git a/common/lib/availability.ts b/common/lib/availability.ts
@@ -398,15 +398,19 @@ export function classifyDownloadFailure(
}
// WHAT A REFUSED FETCH OF ONE VIDEO SAYS ABOUT IT, or null when it says
-// nothing (lane missing-source). Only the per-video classes that mean "not
-// public there" count: members-only, private, removed. A rate limit, the soft
-// block, the bot check, a network failure or an unclassified error never saw
-// the video; an age gate (needs_auth) is the video answering, and a login
+// nothing (lane missing-source). Only members-only and private count: the
+// platform names them for this one video in words nothing else uses. A REMOVAL
+// IS NEVER TAKEN FROM A FETCH: the "deleted" group matches loosely (a bare
+// "Video unavailable" is also how a region block or a transient answer reads),
+// and the site would then publish "removed" on it — a removal is established
+// only by the availability check job (checkAvailability.ts). A rate limit, the
+// soft block, the bot check, a network failure or an unclassified error never
+// saw the video; an age gate (needs_auth) is the video answering, and a login
// retry may still read it.
export function refusalAvailability(stderrTail: string): Availability | null {
const cls = parseUnavailableFromStderr(stderrTail);
if (classifyDownloadFailure(stderrTail, cls) !== "per_video") return null;
- return cls === "members_only" || cls === "private" || cls === "deleted" ? cls : null;
+ return cls === "members_only" || cls === "private" ? cls : null;
}
// Map the `availability` field that yt-dlp puts in --dump-json output to our
diff --git a/common/lib/sourceMissing.test.ts b/common/lib/sourceMissing.test.ts
@@ -10,18 +10,18 @@ import {
// Run with:
// pnpm --filter yt-dlp-transcript-common exec tsx --test lib/sourceMissing.test.ts
-test("the sentence names the state and the day, and nothing else", () => {
+test("the sentence names the state and the day it was first seen, and nothing else", () => {
assert.equal(
sourceMissingSentence({ state: "members_only", stateSince: "20261119", platform: "youtube", isLivestream: true }),
- "This stream is no longer public on YouTube (members-only since 19 Nov 2026). The transcript is kept here.",
+ "This stream is no longer public on YouTube (members-only; first seen 19 Nov 2026). The transcript is kept here.",
);
assert.equal(
sourceMissingSentence({ state: "private", stateSince: "20260301", platform: "rumble" }),
- "This video is no longer public on Rumble (private since 1 Mar 2026). The transcript is kept here.",
+ "This video is no longer public on Rumble (private; first seen 1 Mar 2026). The transcript is kept here.",
);
assert.equal(
sourceMissingSentence({ state: "deleted", stateSince: "20251231", platform: "youtube" }),
- "This video is no longer public on YouTube (removed since 31 Dec 2025). The transcript is kept here.",
+ "This video is no longer public on YouTube (removed; first seen 31 Dec 2025). The transcript is kept here.",
);
// No day: the state alone.
assert.equal(
@@ -40,7 +40,7 @@ test("the marked link, the badge title, the day format", () => {
assert.equal(sourceLinkLabel("youtube", "members_only"), "Open on YouTube (members-only)");
assert.equal(sourceLinkLabel("twitch", "deleted"), "Open on Twitch (removed)");
assert.equal(sourceLinkLabel(undefined, "private"), "Open on its platform (private)");
- assert.equal(stateSinceTitle("Members-only on the source platform", "20261119"), "Members-only on the source platform since 19 Nov 2026");
+ assert.equal(stateSinceTitle("Members-only on the source platform", "20261119"), "Members-only on the source platform; first seen 19 Nov 2026");
assert.equal(stateSinceTitle("Deleted", undefined), "Deleted");
assert.equal(formatStateDay("2026-11-19"), null);
assert.equal(formatStateDay("20261319"), null);
diff --git a/common/lib/sourceMissing.ts b/common/lib/sourceMissing.ts
@@ -4,7 +4,9 @@
// (availability.ts NOT_PUBLIC_STATES) gets no player on the export site: a
// sentence in its place, the platform link kept but marked, and the transcript
// as for any video. The sentence names the state and the day the archive first
-// saw it (`stateSince`) and nothing else — never who observed it or how.
+// saw it (`stateSince`) and nothing else — never who observed it or how. It
+// says "first seen", never "since": the archive knows when it first saw the
+// state, not when the platform changed it.
//
// Pure: client-safe, no node: imports.
@@ -49,9 +51,10 @@ export type SourceGone = {
stateSince?: string;
};
-// The one sentence: "This stream is no longer public on YouTube (members-only
-// since 19 Nov 2026). The transcript is kept here." With no day, the
-// parenthesis is the state alone. Null for a state that keeps its player.
+// The one sentence: "This stream is no longer public on YouTube (members-only;
+// first seen 19 Nov 2026). The transcript is kept here." With no day (a state
+// whose first sighting is not on record), the parenthesis is the state alone.
+// Null for a state that keeps its player.
export function sourceMissingSentence(o: {
state: VideoState | null | undefined;
stateSince?: string | null;
@@ -62,7 +65,7 @@ export function sourceMissingSentence(o: {
const what = o.isLivestream ? "stream" : "video";
const word = STATE_WORDS[o.state as string];
const day = formatStateDay(o.stateSince);
- const paren = day ? `${word} since ${day}` : word;
+ const paren = day ? `${word}; first seen ${day}` : word;
return `This ${what} is no longer public on ${sourcePlatformName(o.platform)} (${paren}). The transcript is kept here.`;
}
@@ -73,8 +76,9 @@ export function sourceLinkLabel(platform: string | null | undefined, state: Vide
return word ? `Open on ${name} (${word})` : `Open on ${name}`;
}
-// The badge tooltip's day: "Members-only on YouTube since 19 Nov 2026".
+// The badge tooltip's day: "Members-only on the source platform; first seen
+// 19 Nov 2026".
export function stateSinceTitle(base: string, stateSince: string | null | undefined): string {
const day = formatStateDay(stateSince);
- return day ? `${base} since ${day}` : base;
+ return day ? `${base}; first seen ${day}` : base;
}
diff --git a/editor/CHANGELOG.md b/editor/CHANGELOG.md
@@ -5,15 +5,21 @@
- The chat replay pass (`fetch-chat`, the chat backlog, find-clips) and `refresh-metadata` used to drop a refusal
such as "Join this channel to get access to members-only content". A stream backfilled "public" while it was
live kept reading public after it went members-only.
- - Both now record members-only, private or removed in the video's `availability.json` as source `fetch`. A
- refresh also records the video's own metadata field when it changes the reading.
+ - Both now record members-only or private in the video's `availability.json` as source `fetch`. A refresh also
+ records the video's own metadata field when it changes the reading.
+ - A removal is never taken from a fetch's refusal (its wording matches too loosely): only the channel's Check
+ availability records one.
- Written only when the reading changes, and never for a rate limit, the soft block, the bot check or an age gate.
- A `fetch` is not a `check`: compaction still trusts only a real check to say a source is on its platform.
- To recheck one video: `pnpm ops refresh-metadata {"slug","id"}` (one paced request on the platform's queue).
- **The index publishes when a state was first seen.**
- A transcript record whose source is members-only, private, deleted or unlisted carries `state` and
`stateSince` (YYYYMMDD). Summaries carry `stateSince` beside `state`.
- - The first index build after this re-reads only the records with such a state and no day yet.
+ - The day is the first history entry of the current state. A record written before history existed has no such
+ entry and publishes no day; its first rewrite seeds the history from the reading it held, so a same-value
+ recheck never moves the day forward.
+ - The first index build after this re-reads only the records with such a state and no day yet, once each: a
+ record with no day to find is settled, even while a channel is held.
- **X jobs run on X's queue only, under a cap no setting can raise.**
- A job that asks X is refused on any queue but `platform:twitter`, when it is queued and where it runs: a posts
fetch in any mode, a resumed backfill, a Sync, a capture, a trending read, an import of an X post, an
diff --git a/scripts/archilyzer-ops.mjs b/scripts/archilyzer-ops.mjs
@@ -1876,8 +1876,9 @@ export function usage() {
' only: another platform answers "no chat fetcher for <platform>" (info, no',
" job), as do a chat already here and fresh and a video never live. A pass",
" that finds no replay ends done and says so. A pass the source refuses for",
- " the video (members-only, private, removed) records that in its",
- " availability.json (source fetch).",
+ " the video as members-only or private records that in its",
+ " availability.json (source fetch); a removal is recorded only by the",
+ " channel's Check availability.",
"",
'fetch-chat-backlog fetches a channel\'s stream chats after its downloads:',
' {"slug", "dryRun"?, "limit"?, "queueKey"?} — every held video whose',
@@ -1913,9 +1914,10 @@ export function usage() {
' audio-only formats and whether any is non-fragmented, English captions,',
' the keys that changed. An id with no data/<id>/ is refused (a refresh',
' re-reads a video already archived), as are archive.org and Wayback records.',
- " A refusal for the video (members-only, private, removed), or a metadata",
+ " A refusal for the video as members-only or private, or a metadata",
" availability field that changes the reading, is recorded in its",
- " availability.json (source fetch): the one-video availability recheck.",
+ " availability.json (source fetch): the one-video availability recheck. A",
+ " removal is recorded only by the channel's Check availability.",
"",
'browser-lookup reads Odysee records from their pages in a headless browser,',
' for when yt-dlp\'s lookup answers 429: {"slug", "ids": [...]} (at most 50)',