Skip to content

feat: read chapters from the video description - #17

Merged
solrevdev merged 1 commit into
masterfrom
feat/chapters
Oct 8, 2026
Merged

solrevdev merged 1 commit into
masterfrom
feat/chapters

Conversation

@solrevdev

Copy link
Copy Markdown
Owner

Closes #16. This PR ships as 1.2.0.

Changes

  • New chapters field with [{start, end, title}] in seconds. end is the next chapter's start, or the video's duration for the last chapter, or null for a live stream. It is [] when a video has none. It is filled with --metadata-only too, and appended as the last field so the existing order is unchanged.

  • Parsing. ParseChapters reads the description, which ytx already fetches, and applies YouTube's rules:

    • the list starts at 0:00
    • it has at least three entries
    • times strictly increase
    • every chapter lasts at least 10 seconds, including the last one
    • the lines form one block

    A list that breaks a rule gives []. The block rule allows blank lines, but any other line ends the list. This stops later prose like "Follow me at 99:00" from being added as a chapter.

  • Line layouts. 0:00 Intro, 0:00 - Intro, (00:00) - Intro, [1:02:03] Intro, • 3:12 | Intro, 03:12: Intro, 75:00 Intro, Intro - 12:34 and Intro (1:00:00). Both regexes are source-generated, so the code stays AOT-safe.

  • Markdown sections. transcript and -f md get a ## Title heading at each chapter. A chapter with no captions of its own still gets its heading, so the outline matches chapters.

Verification

  • 145 tests pass on net8.0 and net10.0. They cover 10 layouts, 6 rejections, 7 rule violations, a null end without a duration, timestamps before the list, heading placement, and golden JSON with chapters (indented) and [] (compact).
  • Live on NYFGCESmikA (5h15m): 23 chapters, from Episode highlight at 0 s to the last at 18338–18951 s, matching the description. The Markdown starts each chapter with ## Title.
  • Live on iG9CE55wbtY: [], with no headings.
  • AOT (osx-arm64): no warnings. Output is byte-identical to JIT for -c NYFGCESmikA, -f md NYFGCESmikA and --metadata-only iG9CE55wbtY.

Left out

  • Auto-generated "key moments", which need the watch page to be scraped.
  • A chapter index on each segment.
  • WebVTT chapter tracks.

Docs

  • README: the field, the parsing rules and the example.
  • CHANGELOG: a 1.2.0 entry.
  • AGENTS.md: the data flow, and the rule that new fields go at the end.
  • Write-up: a new section 6a in docs/investigations/2026-10-ytx-review-to-1.1.0.md.

Release

Merge with [skip ci], then run "Publish NuGet (ytx)" manually with minor to publish 1.2.0.

🤖 Generated with Claude Code

https://claude.ai/code/session_01FPou7f8nRjX78T2qR7hTjb

Adds a chapters array of {start, end, title}, parsed from the
description with YouTube's own rules: starts at 0:00, at least three,
strictly increasing, each at least 10 seconds, one block of lines. The
Markdown transcript gets a "## Title" heading at each chapter.

Closes #16

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FPou7f8nRjX78T2qR7hTjb
@solrevdev
solrevdev merged commit 19c96e2 into master Oct 8, 2026
4 checks passed
@solrevdev
solrevdev deleted the feat/chapters branch October 8, 2026 22:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: chapters from the video description

1 participant