-
Notifications
You must be signed in to change notification settings - Fork 33
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 Spotify playlists #101
base: main
Are you sure you want to change the base?
Conversation
@@ -12,6 +12,7 @@ class Helper | |||
{ | |||
const TRACK_HASH = "00032020"; | |||
const ALBUM_HASH = "0004206c"; | |||
const PLAYLIST_HASH = "0006006c"; |
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.
Is there a "known source" for these hashes @duncan3dc? It seems like a whole host of different ones work for playlists;
0004006c
0006006c
10050024
10060a6c
The playlist hash I used here is from this issue I found, however the Sonos desktop application seems to use 10060a6c
with my Sonos 🤔.
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 they're complete black magic. For Sonos resources (local media library) they're pretty reliable, but as soon as you move to streaming services there's a range in use with no obvious pattern (as you've discovered).
I've made several unsuccessful attempts to figure this out in the past to support Spotify albums. Last time I checked none of the libraries for other languages handled this successfully/reliably, but you might wanna check out their recent versions to see if they've cracked it.
Alternatively I've started a new library (sonos-cloud) which uses the recently published public API for Sonos. This is obviously a lot more reliable than reverse engineering their SOAP calls, but I've not built much with it yet to know if it supports your use case here
@@ -28,7 +28,7 @@ public function __construct(string $uri) | |||
{ | |||
# If this is a spotify playlist ID and not a URI then convert it to a URI now | |||
if (substr($uri, 0, strlen(self::PREFIX)) !== self::PREFIX) { | |||
$uri = self::PREFIX . urlencode($uri); | |||
$uri = self::PREFIX . Helper::PLAYLIST_HASH . urlencode($uri); |
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.
Oddly enough the playlist hash is actually required as part of EnqueuedURI
, which seems to be different when compared to the other sources (which only need it as part of the item ID in EnqueuedURIMetaData
).
Hey Jack, I can't get this to work with any of the playlists I've tried, do you have an example Spotify playlist ID? |
It works fine for me when using |
f48dcd6
to
3657860
Compare
Ah I was just passing |
It's a pain but it seems to need user ID too, although I could be missing something here. |
It appears that some changes were made in June last year to allow Spotify playlist URIs without the user ID (in the form |
e220ff1
to
269c378
Compare
I'm not really a fan of my implementation here as I'm somewhat masquerading a collection of tracks as a single
Track
object, however it seems that the library doesn't have a concept of a "Playlist" yet (although this is something that #98 may change).I've left a comment or two below regarding my changes.
Fixes #56.