Repository navigation
[YouTube] Expose captionTracks name on SubtitlesStream - #1551
Merged
Merged
Conversation
YouTube sometimes ships multiple caption tracks that share a language code (e.g. two "en" tracks with different `name` fields like "English - CC1" and "English - DTVCC1"). The extractor currently only passes the language code through, so downstream pickers can't tell them apart and render them as duplicate "English" entries. Pass the service-provided name through SubtitlesStream so clients can show the full descriptive label when available, falling back to the locale-derived display name when it isn't. Addresses TeamNewPipe/NewPipe#9218.
|
This was referenced Oct 4, 2026
TobiGr
pushed a commit
to TeamNewPipe/NewPipe
that referenced
this pull request
Oct 6, 2026
YouTube ships a user-facing `name` field per caption track that can differ even when the language code is identical (e.g. "English - CC1" vs "English - DTVCC1"). The extractor now surfaces that string via `SubtitlesStream#getName()`; prefer it in the player's caption menu so tracks that share a language code can finally be told apart. Falls back to the locale-derived display name when the service doesn't expose a track name. Fixes #9218. Depends on TeamNewPipe/NewPipeExtractor#1551 — the version-catalog pointer in libs.versions.toml is temporarily targeted at ibrahim-iqbal/NewPipeExtractor and will be flipped back to TeamNewPipe once the extractor PR merges.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



What
Pass the service-provided
namefield on each YouTube caption track throughSubtitlesStream, so downstream clients can tell apart tracks that share alanguage code.
Addresses TeamNewPipe/NewPipe#9218 (reporter observed two tracks both
labelled "English" on a video that actually has distinct CC1 and DTVCC1
tracks).
Why
For the issue's test video (
BISyIBU2gVY), YouTube'scaptionTracksresponse contains two entries, both with
languageCode: "en"but distinctnamefields:Today the extractor only forwards
languageCode, so NewPipe callsSubtitlesStream#getDisplayLanguageName()→locale.getDisplayName(locale)and gets the same "English" string for both. YouTube's own UI uses the
namefield, which is why the web client shows them correctly.How
SubtitlesStream: new optional nullablenamefield with aBuilder#setName(String)setter and a
getName()getter. Backwards compatible — existing extractors thatdon't call
setNamekeep returningnullhere, so their behaviour is unchanged.YoutubeStreamExtractor#getSubtitles: read thenameobject off eachcaptionTrack via the existing
getTextFromObjecthelper (which already handlesboth the
simpleTextandrunsshapes and returnsnullwhen the field ismissing), and forward it to the builder.
The downstream consumer in NewPipe should prefer
getName()when non-nulland fall back to
getDisplayLanguageName()otherwise.Tests
Added
SubtitlesStreamBuilderTestwith three focused checks:getName()nullis acceptedsetNameyieldsgetName() == null(guarantees backwards compatibility for every other service)
All existing extractor tests still pass locally against the fork.
Follow-up
NewPipe PR against
TeamNewPipe/NewPipeto actually consumegetName()inPlayerHelper#captionLanguageOfis coming right after this.Checklist
AI assistance
Used Claude to help scope the fix (locating
captionTrackshandling in both repos, scanning the test video's player response to confirm thenamefield exists per track, and sketching the test file). The code changes and the test content were reviewed and edited line-by-line against the surrounding codebase conventions before pushing.