mopidy-youtube
mopidy-youtube copied to clipboard
Add support for high quality YouTube Music streams for Premium users.
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.
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 ytmusicapi
to take a Cookie Jar object, if that will make proper authentication from within the library easier (see https://github.com/sigma67/ytmusicapi/issues/10)?
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. I hope I can get to it next week :)
@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 :)