sonos-web icon indicating copy to clipboard operation
sonos-web copied to clipboard

Add Spotify support

Open denysvitali opened this issue 7 years ago • 9 comments

denysvitali avatar Aug 20 '16 16:08 denysvitali

+1 :-)

Vilasamuni avatar Nov 29 '16 10:11 Vilasamuni

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?

Vilasamuni avatar Nov 29 '16 10:11 Vilasamuni

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

denysvitali avatar Nov 29 '16 12:11 denysvitali

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.

Vilasamuni avatar Dec 02 '16 10:12 Vilasamuni

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

denysvitali avatar Dec 02 '16 12:12 denysvitali

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.

alexkreidler avatar Dec 29 '17 17:12 alexkreidler

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

denysvitali avatar Dec 29 '17 18:12 denysvitali

any updates on spotify?

gieljnssns avatar Nov 09 '19 14:11 gieljnssns

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.

denysvitali avatar Nov 09 '19 14:11 denysvitali