YouTube Music: ~1000% faster playback start by getting audio from the player API instead of yt-dlp#4370
Draft
rathlinus wants to merge 1 commit into
Draft
YouTube Music: ~1000% faster playback start by getting audio from the player API instead of yt-dlp#4370rathlinus wants to merge 1 commit into
rathlinus wants to merge 1 commit into
Conversation
Author
Click-to-play benchmarkytmusic_native vs the stock ytmusic provider tested with 12 tracks, on a Premium account Both play itag141 258 kbps AAC
Native spread: 114–452 ms. Stock spread: 3.8–6.1 s. native does one API call + an in-process cipher solve (~12 ms) against the One-off: native spends ~1.8 s at startup (grab base.js once), then every play is per-track (get-URL ms)
|
Author
|
Use this tool to extract the data for the native provider: https://github.com/rathlinus/ytm-login-grabber |
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 does this implement/fix?
Adds a new experimental music provider,
YouTube Music (Native).It talks to the YouTube Music InnerTube API directly instead of going through ytmusicapi, yt-dlp or deno, and it doesn't need a POtoken server. You set it up by pasting the cookie from a logged-in music.youtube.com session.
On the metadata side it covers search, your library (artists, albums, tracks, playlists), album/artist/playlist pages, artist albums and top tracks, similar tracks and recommendations.
For audio it plays the premium 256k streams (itag 141 / 774) by running the player's signature/n cipher in-process with an embedded V8. Without Node, or a browser, no po_token. If that can't run for some reason it falls back to the ANDROID_VR ~150k stream so playback still works. The only new dependency is mini-racer, which ships V8 as a normal pip wheel, so this works in the standard container without anything extra installed.
The existing YouTube Music provider is left as-is; this is a separate one for now.
Tested locally against two Premium accounts: setup, search, browsing an album, and playing a premium track (itag 141, 259 kbps, streams and transcodes fine).
Types of changes
bugfixnew-featureenhancementnew-providerbreaking-changerefactordocumentationmaintenancecidependenciesChecklist
pre-commit run --all-filespasses.pytestpasses, and tests have been added/updated undertests/where applicable.music-assistant/modelsis linked.music-assistant/frontendis linked.