jishi / node-sonos-http-api

An HTTP API bridge for Sonos easing automation. Hostable on any node.js capable device, like a raspberry pi or similar.
http://jishi.github.io/node-sonos-http-api/
MIT License
1.83k stars 462 forks source link

500 error when attempting to start Spotify artist radio via musicsearch #775

Open obliojoe opened 3 years ago

obliojoe commented 3 years ago

When I try to play Spotify artist radio, I am getting a 500 error.

URL: http://localhost:5005/kitchen/musicsearch/spotify/station/wilco

Response: Error: Got status 500 when invoking /MediaRenderer/AVTransport/Control at Object.invoke (D:\dev\sonos\node-sonos-http-api\node_modules\sonos-discovery\lib\helpers\soap.js:99:10) at Player.play (D:\dev\sonos\node-sonos-http-api\node_modules\sonos-discovery\lib\models\Player.js:446:15) at D:\dev\sonos\node-sonos-http-api\lib\actions\musicSearch.js:229:44 at processTicksAndRejections (internal/process/task_queues.js:97:5)

I am able to call other musicsearch endpoints.

These both work: /musicsearch/spotify/song/wilco /musicsearch/spotify/album/wilco

And I can start Spotify artist radio manually from the Sonos app.

Any thoughts?

obliojoe commented 3 years ago

Interestingly, if I have the Sonos app open on my computer when I make this call, the app displays the error:

Unable to play 'Wilco Radio' - the connection to Spotify was lost.

obliojoe commented 3 years ago

Update: I used Wireshark to see what my Sonos app sends when I start Spotify artist radio and compared it to what the API is sending. The only difference was:

Sonos: x-sonosapi-radio:spotify%3aartistRadio%3a2QoU3awHVdcHS8LrZEKvSM?sid=12&flags=8300&sn=1 API: x-sonosapi-radio:spotify%3aartistRadio%3a2QoU3awHVdcHS8LrZEKvSM?sid=12&flags=8300&sn=14

The only difference was sn=14.

I found line 50 of musicsearch.js: https://github.com/jishi/node-sonos-http-api/blob/7b5d5e45863a4ea88a34aab3e554e282ab93b945/lib/music_services/spotifyDef.js#L149

If I change that to 1, everything seems to work as expected.

jishi commented 3 years ago

I don't remember what the sn-parameters refers to, and if it now differs between systems it needs to be discovered somehow. obviously someone changed this at some point, and I haven't used this music search api myself (it was contributed). If you find any more info about this, please share it.

mochi-co commented 3 years ago

@obliojoe tangentially off topic, but would you be able to share the process for using wireshark to sniff the Sonos traffic? I had a go with it earlier but couldn't seem to isolate it, but this would be very helpful in my efforts to bring the Deezer implementation up to date! Thank you