svrooij / node-sonos-ts

:speaker: Sonos control library, use this library in your own appliction.
https://sonos-ts.svrooij.io/
MIT License
84 stars 18 forks source link

BUG: artistRadio not working #189

Closed danielvandenberg95 closed 4 months ago

danielvandenberg95 commented 9 months ago

What happened

Hi, I'm trying to use artist radio in a library dependent on this one. For some reason it's giving UPnP error 804, while all other Spotify features do work. Artist, playlist etc do work.

I'm not sure if it's something within this library or if it's being called incorrectly/incompletely. I'm hopeful someone here can point out what's going wrong. Thank you for your time and this awesome library!

Using node-red-contrib-sonos-plus, https://github.com/hklages/node-red-contrib-sonos-plus/blob/99b3afa567de8418f203d8e5375650c33cdbf4eb/src/sonos-universal.js#L1804, artistRadio does not work.

See also https://github.com/hklages/node-red-contrib-sonos-plus/issues/277

What did you expect to happen

Artist radio to start playing.

How to reproduce it (minimal and precise)

Install node-red. Install the latest version of node-red-contrib-sonos-plus. Configure a universal node with "group.queue.uriSpotify" Inject "spotify:artistRadio:72qVrKXRp9GeFQOesj0Pmv" (taken from https://sonos.svrooij.io/metadata)

This triggers the following code:

    const validated = await validatedGroupProperties(msg)
    const groupData = await getGroupCurrent(tsPlayer, validated.playerName)
    const tsCoordinator = new SonosDevice(groupData.members[0].urlObject.hostname)
    tsCoordinator.urlObject = groupData.members[0].urlObject
    // position in queue = 0 (at the end), enqueue next true (only effective in shuffle mode)
    const result = await tsCoordinator.AddUriToQueue(validatedUri, 0, true)

Debug logging

2024-02-12T17:52:18.703Z sonos:service:zonegrouptopology:192.168.0.109 GetZoneGroupState()
2024-02-12T17:52:18.743Z sonos:metadata Guessing metadata for spotify:artistRadio:72qVrKXRp9GeFQOesj0Pmv
2024-02-12T17:52:18.745Z sonos:service:avtransport:192.168.0.109 AddURIToQueue({ InstanceID: 0, EnqueuedURI: 'x-sonosapi-radio:spotify:artistRadio:72qVrKXRp9GeFQOesj0Pmv?sid=9&flags=8300&sn=7', EnqueuedURIMetaData: { Title: 'Artist radio', CdUdn: 'SA_RINCON2311_X_#Svc2311-0-Token', TrackUri: 'x-sonosapi-radio:spotify%3aartistRadio%3a72qVrKXRp9GeFQOesj0Pmv?sid=9&flags=8300&sn=7', ItemId: '100c206cspotify%3aartistRadio%3a72qVrKXRp9GeFQOesj0Pmv', UpnpClass: 'object.item.audioItem.audioBroadcast.#artistRadio', ParentId: '10052064spotify%3aartist%3a72qVrKXRp9GeFQOesj0Pmv' }, DesiredFirstTrackNumberEnqueued: 0, EnqueueAsNext: true })
2024-02-12T17:52:18.914Z sonos:service:avtransport:192.168.0.109 Sonos error on AddURIToQueue { faultcode: 's:Client', faultstring: 'UPnPError', detail: { UPnPError: { errorCode: 804 } } }
12 Feb 18:52:18 - [error] [sonos-universal:5298733c96e7dce5] group.queue.urispotify:Sonos error on AddURIToQueue UPnPError 804 (undefined) :: Details: {"stack":"SonosError: Sonos error on AddURIToQueue UPnPError 804 (undefined)\n    at AVTransportService.handleErrorResponse (/data/node_modules/@svrooij/sonos/lib/services/base-service.js:227:23)\n    at runMicrotasks (<anonymous>)\n    at processTicksAndRejections (node:internal/process/task_queues:96:5)\n    at async AVTransportService.handleRequestAndParseResponse (/data/node_modules/@svrooij/sonos/lib/services/base-service.js:199:15)\n    at async AVTransportService.AddURIToQueue (/data/node_modules/@svrooij/sonos/lib/services/av-transport.service.js:75:41)\n    at async SonosDevice.AddUriToQueue (/data/node_modules/@svrooij/sonos/lib/sonos-device.js:95:16)\n    at async Object.groupQueueUriFromSpotify [as group.queue.urispotify] (/data/node_modules/node-red-contrib-sonos-plus/src/sonos-universal.js:1816:20)","message":"Sonos error on AddURIToQueue UPnPError 804 (undefined)","Action":"AddURIToQueue","FaultCode":"s:Client","Fault":"UPnPError","UpnpErrorCode":804,"name":"SonosError"}

Environment

Checklist

Please confirm the following before creating the issue.

svrooij commented 9 months ago

If I do the command with the official computer controller, it sends this message:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<s:Body>
<u:SetAVTransportURI xmlns:u="urn:schemas-upnp-org:service:AVTransport:1">
<InstanceID>0</InstanceID>
<CurrentURI>x-sonosapi-radio:spotify%3aartistRadio%3a72qVrKXRp9GeFQOesj0Pmv?sid=9&amp;flags=8300&amp;sn=2</CurrentURI>
<CurrentURIMetaData>&lt;DIDL-Lite xmlns:dc=&quot;http://purl.org/dc/elements/1.1/&quot; xmlns:upnp=&quot;urn:schemas-upnp-org:metadata-1-0/upnp/&quot; xmlns:r=&quot;urn:schemas-rinconnetworks-com:metadata-1-0/&quot; xmlns=&quot;urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/&quot;&gt;&lt;item id=&quot;100c206cspotify%3aartistRadio%3a72qVrKXRp9GeFQOesj0Pmv&quot; parentID=&quot;10052064spotify%3aartist%3a72qVrKXRp9GeFQOesj0Pmv&quot; restricted=&quot;true&quot;&gt;&lt;dc:title&gt;Guus Meeuwis Radio&lt;/dc:title&gt;&lt;upnp:class&gt;object.item.audioItem.audioBroadcast.#artistRadio&lt;/upnp:class&gt;&lt;dc:creator&gt;Guus Meeuwis&lt;/dc:creator&gt;&lt;upnp:albumArtURI&gt;https://i.scdn.co/image/ab6761610000e5ebf5eda5ecd45cdbc2cc3c184a&lt;/upnp:albumArtURI&gt;&lt;r:albumArtist&gt;Guus Meeuwis&lt;/r:albumArtist&gt;&lt;r:description&gt;Guus Meeuwis&lt;/r:description&gt;&lt;desc id=&quot;cdudn&quot; nameSpace=&quot;urn:schemas-rinconnetworks-com:metadata-1-0/&quot;&gt;SA_RINCON2311_X_#Svc2311-0-Token&lt;/desc&gt;&lt;/item&gt;&lt;/DIDL-Lite&gt;</CurrentURIMetaData>
</u:SetAVTransportURI>
</s:Body>
</s:Envelope>

if send sonos.SetAVTransportURI('spotify:artistRadio:72qVrKXRp9GeFQOesj0Pmv') it sends this.

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<s:Body>
<u:SetAVTransportURI xmlns:u="urn:schemas-upnp-org:service:AVTransport:1">
<InstanceID>0</InstanceID>
<CurrentURI>x-sonosapi-radio:spotify%3aartistRadio%3a72qVrKXRp9GeFQOesj0Pmv?sid=9&amp;flags=8300&amp;sn=7</CurrentURI>
<CurrentURIMetaData>&lt;DIDL-Lite xmlns:dc=&quot;http://purl.org/dc/elements/1.1/&quot; xmlns:upnp=&quot;urn:schemas-upnp-org:metadata-1-0/upnp/&quot; xmlns:r=&quot;urn:schemas-rinconnetworks-com:metadata-1-0/&quot; xmlns=&quot;urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/&quot;&gt;&lt;item id=&quot;100c206cspotify%3aartistRadio%3a72qVrKXRp9GeFQOesj0Pmv&quot; restricted=&quot;true&quot; parentID=&quot;10052064spotify%3aartist%3a72qVrKXRp9GeFQOesj0Pmv&quot;&gt;&lt;dc:title&gt;Artist radio&lt;/dc:title&gt;&lt;upnp:class&gt;object.item.audioItem.audioBroadcast.#artistRadio&lt;/upnp:class&gt;&lt;desc id=&quot;cdudn&quot; nameSpace=&quot;urn:schemas-rinconnetworks-com:metadata-1-0/&quot;&gt;SA_RINCON2311_X_#Svc2311-0-Token&lt;/desc&gt;&lt;/item&gt;&lt;/DIDL-Lite&gt;</CurrentURIMetaData>
</u:SetAVTransportURI>
</s:Body>
</s:Envelope>

They differ a little bit, but I think the most noteable difference is the sn=7 vs sn=2 in the CurrentURI. I've seen this before and in seems that this is related to at which index the connection to spotify (or other music service) is stored. Not sure if it's related. To test this out yourself, you need to play an artist radio get the CurrentTrackURI for me.

Or you can use wireshark off course.

For now it temporarily seems broken, I'm not even sure is artist radio ever worked. 😊

danielvandenberg95 commented 8 months ago

Awesome, I'll look into the URL asap, hopefully tomorrow afternoon.

svrooij commented 7 months ago

@danielvandenberg95 can you provide the url?

svrooij commented 4 months ago

You can re-open if this is still relevant