bencevans / node-sonos

šŸ”ˆ Sonos Media Player Interface/Client
https://www.npmjs.com/package/sonos
MIT License
704 stars 147 forks source link

Function playSpotifyRadio(artistId, artistName) generates UPnP error 701 #392

Closed magnlund closed 5 years ago

magnlund commented 5 years ago

When trying to play Spotify Radio using function playSpotifyRadio(artistId, artistName) error UPnP 701 is raised. It used to work before but it does not anylonger. I use the code from the Example and have also verified correct Region settings (EU). All of the other Spotify play functions work fine though. Please advice

Versions (and Environment)

Node version: 8.9.3 node-sonos version: 1.6.0 OS: Linux (RPi)

Villarrealized commented 5 years ago

I can confirm that this issue exists in v1.8.1.

It looks like Spotify has changed some of the query flags and parameters needed when playing an artistRadio Id.

Specifically, sid=9 has changed to sid=12 and sn=7 changed to sn=5

// This fails with UPnP error 701
device.playSpotifyRadio('5schNIzWdI9gJ1QRK8SBnc','Ben Howard')
// This also fails, which is essentialy the same thing
device.setAVTransportURI({ uri: "x-sonosapi-radio:spotify:artistRadio:5schNIzWdI9gJ1QRK8SBnc?sid=9&flags=8300&sn=7", metadata: "" })

// Both of these work

// Play Ben Howard radio
device.setAVTransportURI({ uri: "x-sonosapi-radio:spotify:artistRadio:5schNIzWdI9gJ1QRK8SBnc?sid=12&flags=8300&sn=5", metadata: "" })

// Play Sarah Sparks radio
device.setAVTransportURI({ uri: "x-sonosapi-radio:spotify:artistRadio:1rNB96O30Md5JMUNgWwg99?sid=12&flags=8300&sn=5", metadata: "" })

We would need to change the following line in helpers.js

// Replace this line
uri: 'x-sonosapi-radio:' + spotifyUri + '?sid=9&flags=8300&sn=7',

// With this line
uri: 'x-sonosapi-radio:' + spotifyUri + '?sid=12&flags=8300&sn=5',

Will open a PR to fix this.

magnlund commented 5 years ago

Tried to change in helpers.js according to above solution but still the same issue

Villarrealized commented 5 years ago

Did you try this?

// Play Ben Howard radio
device.setAVTransportURI({ uri: "x-sonosapi-radio:spotify:artistRadio:5schNIzWdI9gJ1QRK8SBnc?sid=12&flags=8300&sn=5", metadata: "" })
magnlund commented 5 years ago

Tried that now instead of using the Playradio function and still the same issue

Regards Magnus Lundberg


Magnus Lundberg Phone: +46 730 23 09 36 Email: contact.magnus.lundberg@protonmail.com

Sent with ProtonMail Secure Email.

ā€ā€ā€ā€ā€ā€ā€ Original Message ā€ā€ā€ā€ā€ā€ā€ On Friday 4 January 2019 kl. 21:15, Villarrealized notifications@github.com wrote:

Did you try this?

//

Play Ben Howard radio

device

.

setAVTransportURI

({ uri

:

"

x-sonosapi-radio:spotify:artistRadio:5schNIzWdI9gJ1QRK8SBnc?sid=12&flags=8300&sn=5

"

, metadata

:

"

"

})

ā€” You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub, or mute the thread.

magnlund commented 5 years ago

Could it be a difference in the parameters depending on US or EU region?

Regards Magnus Lundberg


Magnus Lundberg Phone: +46 730 23 09 36 Email: contact.magnus.lundberg@protonmail.com

Sent with ProtonMail Secure Email.

ā€ā€ā€ā€ā€ā€ā€ Original Message ā€ā€ā€ā€ā€ā€ā€ On Friday 4 January 2019 kl. 21:22, Magnus Lundberg contact.magnus.lundberg@protonmail.com wrote:

Tried that now instead of using the Playradio function and still the same issue

Regards Magnus Lundberg


Magnus Lundberg Phone: +46 730 23 09 36 Email: contact.magnus.lundberg@protonmail.com

Sent with ProtonMail Secure Email.

ā€ā€ā€ā€ā€ā€ā€ Original Message ā€ā€ā€ā€ā€ā€ā€ On Friday 4 January 2019 kl. 21:15, Villarrealized notifications@github.com wrote:

Did you try this?

//

Play Ben Howard radio

device

.

setAVTransportURI

({ uri

:

"

x-sonosapi-radio:spotify:artistRadio:5schNIzWdI9gJ1QRK8SBnc?sid=12&flags=8300&sn=5

"

, metadata

:

"

"

})

ā€” You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub, or mute the thread.

Villarrealized commented 5 years ago

Might be worth upgrading to 1.8.1. Not sure if that will fix it, but at least help eliminate possible differences.

Villarrealized commented 5 years ago

I suppose it could be. Iā€™m in the US.

svrooij commented 5 years ago

@Villarrealized Spotify be like..... hate them for differentiating between regions. Maybe we should tackle this with queries based on region.

magnlund commented 5 years ago

Upgraded to 1.8.1 and changed the parameters and also tested with the avTransport function directly. Same issue! I'm located in EU, Sweden

Regards Magnus Lundberg


Magnus Lundberg Phone: +46 730 23 09 36 Email: contact.magnus.lundberg@protonmail.com

Sent with ProtonMail Secure Email.

ā€ā€ā€ā€ā€ā€ā€ Original Message ā€ā€ā€ā€ā€ā€ā€ On Friday 4 January 2019 kl. 21:26, Villarrealized notifications@github.com wrote:

I suppose it could be. Iā€™m in the US.

ā€” You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub, or mute the thread.

magnlund commented 5 years ago

Any suggestions on valid parameters for EU?

Regards Magnus Lundberg


Magnus Lundberg Phone: +46 730 23 09 36 Email: contact.magnus.lundberg@protonmail.com

Sent with ProtonMail Secure Email.

ā€ā€ā€ā€ā€ā€ā€ Original Message ā€ā€ā€ā€ā€ā€ā€ On Friday 4 January 2019 kl. 21:37, Stephan van Rooij notifications@github.com wrote:

@Villarrealized Spotify be like..... hate them for differentiating between regions. Maybe we should tackle this with queries based on region.

ā€” You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub, or mute the thread.

svrooij commented 5 years ago

The way I always find the correct commands is by sniffing out the data from the desktop application with Wireshark. (Sniff WiFi or ether net card, set the filter to tcp port 1400, send the command from the desktop app, extract the soap commands for wireshark)

Will try tomorrow, and will setup a page on the docs on how to do this.

Villarrealized commented 5 years ago

Interesting. I changed the spotify region back and forth from US to EU and ran the same commands multiple times and I had no issue.

@magnlund Are you sure that you have an active Spotify Premium account connected to your Sonos?

Villarrealized commented 5 years ago

I'm not sure if Spotify acts differently based on incoming ip, but I also changed my ip to an ip in Amsterdam and had the same working result no matter which region I set it to.

magnlund commented 5 years ago

I have verified that my premium account is linked to my Sonos and played around with the parameters in different ways. Issue still remains. What makes it weird is that it USED to work I think it was unitil August last year and then suddenly stopped working. I use the majority of the URIs on Spotify with Node Sonos and all of them work correct except this. Tried to reauthorize the account and verified premium and still same issue. Right now running out of ideas since it seems to be working on your side. Will await next version from you.