-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for high quality YouTube Music streams for Premium users. #221
Conversation
6287527
to
2fd4526
Compare
This requires to supply yt-dlp with a cookiefile that exists on disk. The `musicapi_cookie` config option is replaced with a `musicapi_cookiefile` option. This also allows the cookies to be better protected by giving the file proper permissions or using Docker secrets in a Docker deployment. Some nasty glue code is needed to generate a Cookie header from the CookieJar (There is no functionality in the Python stdlib to do this cleanly). A better approach would be to refactor all code to take a CookieJar opbject (including ytmusicapi) that can be natively used in requests and urllib (assuming it is used somewhere). As this requires some work on a dependency I am refraining from doing this in this PR.
2fd4526
to
4b4fa1c
Compare
Thanks @ReneHollander - this is an interesting idea, and doesn't look too complicated. Appreciate you taking the time to submit. I'll have a look when I get a chance, and get back to you. @sigma67 might be interested in a PR allowing |
Sounds interesting, can you make a proposal for integrating this without breaking ytmusicapi for existing users? Might be possible to pass cookiejar cookiefile as filepath and detect whether the file is json (current assumption) or a cookiejar, depending on the file type. |
Thanks for the input! I will try to refactor the code to allow the usage of cookiejar. |
@ReneHollander any updates? |
@laur89 sadly no. I didn't get to setup mopidy/snapcast yet, as it's impossible to order Raspberry Pis currently. So I didn't need this functionality and didn't spend time finishing it. |
This would be really cool to add if it's still possible. Mopidy-YTMusic has the ability to play high quality streams, but that plugin has a bunch of other issues that make this one better. |
Thanks @ReneHollander for the code, and @fatg3erman for the reminder. This seems to work ok, so I merged it. 256k audio unlocked. |
Uh oh; looks like it might not work completely yet - see #234 |
Thanks for jumping on it so quickly. I'll try some tests in the next few days, missing playlists are not a thing I care about. If this works well I think I've found my Spotify replacement :) |
youtube.musicapi_cookie = config["youtube"].get("musicapi_cookie", None) | ||
youtube.musicapi_cookiefile = config["youtube"].get("musicapi_cookiefile", None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to provide None
default to get(key)
, None is the default value by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You technically don't even need to use get()
on Mopidy config objects, they already have a default value.
This requires to supply yt-dlp with a cookiefile that exists on disk.
The
musicapi_cookie
config option is replaced with amusicapi_cookiefile
option. This also allows the cookies to be betterprotected by giving the file proper permissions or using Docker secrets in a Docker deployment.
Some nasty glue code is needed to generate a Cookie header from the CookieJar (There is no functionality in the Python stdlib to do this cleanly). A better approach would be to refactor all code to take a CookieJar opbject (including ytmusicapi) that can be natively used in requests and urllib (assuming it is used somewhere). As this requires some work on a dependency I am refraining from doing this in this PR.