denysvitali / sonos-web

Web interface for Sonos audio systems
120 stars 14 forks source link

Add Spotify support #6

Open denysvitali opened 8 years ago

Vilasamuni commented 8 years ago

+1 :-)

Vilasamuni commented 8 years ago

You mentioned that the Spotify library for NodeJS was no longer being maintained but I've found another one that looks promising - https://github.com/FrontierPsychiatrist/node-spotify On further reading - node-spotify is a NodeJS wrapper for libspotify which has been deprecated.

Maybe the best way to go would be making requests directly to the Spotify Web API?

denysvitali commented 8 years ago

The problem with Spotify is that you can't get a stream URL without using their services. The Spotify Web API uses in fact (IIRC) their web player, and only provides track information / details

Vilasamuni commented 7 years ago

Dang, looks like you're right. Reading around on Stack Overflow and similar it looks like it's possible to access a 30 second preview of each treack with the Spotify Web API, but not full tracks.

denysvitali commented 7 years ago

You're right, but the seconds aren't 30: they are about 7. The unencrypted version (called head) is available via http://heads-akp.spotify.com/head/TRACK_KEY, while the encrypted is available at a similar url with /audio/ instead. The decryption method is available in the Spotify's player .swf file, but it's kind of tricky since it uses both swf and js to retrieve the key. I'll post here my notes when I return home / have some spare time

alexkreidler commented 6 years ago

I think Spotify has recently moved away from Flash, as it will be discontinued in 2020. I think they now use the Content Decryption Module built into most browsers.

I wonder how Sonos does its integration with Spotify.

denysvitali commented 6 years ago

Last time I checked they were decrypting some MP3 from Spotify's CDN. They may have changed their library though.

If I have time (unlikely this month or the next one) I'll check and report back

gieljnssns commented 5 years ago

any updates on spotify?

denysvitali commented 5 years ago

Unfortunately their encryption is kinda hard, I stopped looking into this issue a lot of months ago. I don't think it is possible to add support for Spotify for non-premium users. The thing we can do though is to support Spotify for premium users by using SONOS' URIs (I guess they've implemented an x-sonos-spotify:// protocol or something).

Unfortunately I'm in the process of moving to a new apartment and I don't have nor won't have access to my SONOS Play:3 speaker for the next weeks. I'll probably start re-maintaining this project (or start from scratch with sonos-web-rs) as soon as I get my speaker back and I settle down with this moving of mine.