Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ This is `ytx`, a .NET Global Tool that extracts YouTube video metadata and trans
**Main Components:**
- `src/Ytx/Program.cs` - Single-file console application with async main method
- `Input` record - Simple DTO for JSON input parsing
- `Output` class - JSON output contract (1.1.0): canonical url, videoId, metadata, caption status and track, transcriptRaw, transcript. Property order is the field order; README documents each field
- `Output` class - JSON output contract (1.1.0): canonical url, videoId, metadata, caption status and track, transcriptRaw, transcript, segments. Property order is the field order; README documents each field. Changing a field name or order is a breaking change
- Uses YoutubeExplode library for YouTube API interactions and caption extraction

**Data Flow:**
1. Input validation (command-line args or JSON via stdin)
2. YouTube video data extraction via YoutubeExplode
3. Caption track discovery and selection (prefers English, falls back to any available)
3. Caption track discovery and selection (`SelectTrack`: best `--language` match, then English, then manual over auto-generated)
4. Transcript formatting (raw text + markdown with timestamped links) and caption status
5. JSON serialization to stdout, or a transcript-only format (`--format md|txt|srt|vtt`) built from the normalized segments

Expand All @@ -40,7 +40,7 @@ dotnet tool install -g solrevdev.ytx --add-source ./nupkg
## CI/CD Integration

**GitHub Actions Workflow** (`.github/workflows/publish.yml`):
- Pull requests that change the project or workflow run read-only restore, build, and pack validation
- Pull requests that change the project, tests or workflow run read-only restore, build, test (net8.0, net9.0, net10.0) and pack validation
- Pushes to `master` automatically use a patch bump; manual dispatch can select patch, minor, or major
- Builds and packs before publishing the exact package to NuGet with `--skip-duplicate`
- Only after NuGet publication succeeds, atomically pushes the version commit and tag
Expand All @@ -49,6 +49,10 @@ dotnet tool install -g solrevdev.ytx --add-source ./nupkg

**Manual Release:** GitHub Actions β†’ "Publish NuGet (ytx)" β†’ "Run workflow"

**Batching PRs into one release:** merge each PR with `[skip ci]` in the merge commit subject so no patch is published, then run the workflow manually with the bump you want. Merge stacked PRs one at a time: retarget the next PR to `master` before deleting the merged branch, then update it so CI runs.

**Other workflows:** `codeql.yml` analyzes C# on PRs and weekly. `.github/dependabot.yml` proposes weekly Actions and NuGet updates. Actions are pinned to commit SHAs with a version comment.

## Important Implementation Details

**Caption Detection Logic:** `SelectTrack` ranks tracks by exact language code, then exact name, then code prefix (`en` matches `en-GB`), then name substring (only for preferences longer than 3 characters, because "fr" is inside "Afrikaans"). Ties prefer a manual track over an auto-generated one. Unknown languages fall back to English, then any track.
Expand Down
37 changes: 33 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,43 @@ All notable changes to ytx are listed here. The format follows

## [Unreleased]

## [1.1.0] - 2026-10-08

This release fixes the caption bugs from the v1.0.7 review ([#3](https://github.com/solrevdev/solrevdev.ytx/issues/3)) and settles the JSON contract.

### Breaking

- `url` is now the canonical watch URL, not the input echoed back.
- With no transcript, `transcript` and `transcriptRaw` are empty instead of holding placeholder text. Check `captionStatus`.
- Caption failures other than YouTube and HTTP errors now exit 1 instead of being reported as "no captions".

### Added

- Output fields: `videoId`, `channel`, `channelId`, `uploadDate`, `durationSeconds`, `viewCount`, `keywords`, `captionStatus` (`ok`, `none`, `skipped`, `blocked`, `error`), `captionLanguage`, `captionLanguageName`, `captionIsAutoGenerated`, `captionError` and `segments`.
- Exit code 3 when metadata is written but captions were blocked or failed, and 130 for Ctrl+C.
- `--format md|txt|srt|vtt` to write only the transcript.
- `--segments` for `{start, end, text}` with millisecond times.
- `--list-languages` to list a video's caption tracks.
- `--proxy <url>` for http, https and socks proxies. `HTTPS_PROXY` is documented.
- `--timeout <seconds>`.
- A stderr warning when no track matches `--language` and ytx falls back, and when `--language` is used with `--metadata-only`.
- NuGet package icon, symbols package (`.snupkg`) and SourceLink metadata.
- Dependabot for GitHub Actions and NuGet, and a CodeQL workflow.
- `LICENSE` file, Dependabot and a CodeQL workflow.

### Fixed

- Human-written captions are preferred over auto-generated ones.
- Short language codes match exactly or by prefix, so `-l fr` no longer returns Afrikaans and `-l pt` finds `pt-BR`.
- `&nbsp;` is replaced before whitespace is collapsed, so no double spaces remain.

### Changed

- GitHub Actions are pinned to commit SHAs.
- Tests run on .NET 8, 9 and 10.
- YoutubeExplode 6.6.2, which removes the AngleSharp `NU1902` advisory.
- GitHub Actions are pinned to commit SHAs, and tests run on .NET 8, 9 and 10.

### Removed

- The stale `docs/html-viewer-feature.md`.

## [1.0.8] - 2026-10-08

Expand Down Expand Up @@ -64,7 +92,8 @@ All notable changes to ytx are listed here. The format follows

- First release: title, description, raw transcript and Markdown transcript as JSON.

[Unreleased]: https://github.com/solrevdev/solrevdev.ytx/compare/v1.0.8...HEAD
[Unreleased]: https://github.com/solrevdev/solrevdev.ytx/compare/v1.1.0...HEAD
[1.1.0]: https://github.com/solrevdev/solrevdev.ytx/compare/v1.0.8...v1.1.0
[1.0.8]: https://github.com/solrevdev/solrevdev.ytx/compare/v1.0.7...v1.0.8
[1.0.7]: https://github.com/solrevdev/solrevdev.ytx/compare/v1.0.6...v1.0.7
[1.0.6]: https://github.com/solrevdev/solrevdev.ytx/compare/v1.0.5...v1.0.6
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ dotnet tool install -g solrevdev.ytx --add-source ./nupkg
β”œβ”€β”€ .github/workflows/codeql.yml # CodeQL analysis
β”œβ”€β”€ assets/icon.svg # Package icon source (icon.png is rendered from it)
β”œβ”€β”€ CHANGELOG.md # Release history
β”œβ”€β”€ docs/investigations/ # Write-ups of reviews and investigations
└── README.md # User and maintainer documentation
```

Expand Down Expand Up @@ -230,6 +231,11 @@ The GitHub Actions workflow uses NuGet Trusted Publishing and does not need a st
- Markdown timestamps are rounded down to whole seconds; `segments`, SRT and WebVTT keep milliseconds
- Large transcripts are not truncated (full output provided)

## Background

- [CHANGELOG.md](CHANGELOG.md) lists the changes in each release.
- [docs/investigations/2026-10-ytx-review-to-1.1.0.md](docs/investigations/2026-10-ytx-review-to-1.1.0.md) tells the story of the v1.0.7 review and the 1.1.0 release: the bugs, evidence, decisions and traps.

## Dependencies

- [YoutubeExplode](https://github.com/Tyrrrz/YoutubeExplode) β€” YouTube video data extraction
Expand Down
Loading
Loading