From c7e32b45909cdcc69e2711b1c63bbca59abff712 Mon Sep 17 00:00:00 2001 From: jzocb Date: Sun, 22 Mar 2026 15:58:13 -0400 Subject: [PATCH] fix: backfill chapter end times for cached videos Videos cached before the chapter end-time change would silently lack the 'end' field when loaded from cache. This adds a migration that detects missing 'end' fields on cache hit, computes them from adjacent chapters, and persists the updated meta.json. This ensures consistent output regardless of whether the data was freshly fetched or loaded from cache. --- skills/baoyu-youtube-transcript/scripts/main.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/skills/baoyu-youtube-transcript/scripts/main.ts b/skills/baoyu-youtube-transcript/scripts/main.ts index 53ada2d..d1ba3d9 100644 --- a/skills/baoyu-youtube-transcript/scripts/main.ts +++ b/skills/baoyu-youtube-transcript/scripts/main.ts @@ -699,6 +699,15 @@ async function processVideo(videoId: string, opts: Options): Promise 0 && meta.chapters[0].end === undefined) { + for (let i = 0; i < meta.chapters.length; i++) { + (meta.chapters[i] as any).end = i < meta.chapters.length - 1 + ? meta.chapters[i + 1].start + : meta.duration; + } + writeFileSync(join(videoDir, "meta.json"), JSON.stringify(meta, null, 2)); + } } if (needsFetch) {