jishi / node-sonos-discovery

Simplified framework for Sonos built on node.js
MIT License
146 stars 75 forks source link

Add functionality to retrieve accounts from Sonos #49

Closed PythagoRascal closed 8 years ago

PythagoRascal commented 8 years ago

What I added:

Functions that call [sonos-device-ip]:1400/status/accounts and parse the resulting XML so I can use the sn, sid and username (looks like a token) of accounts registered on Sonos to format my requests.

What I want to do with it:

In our app a user can browse and queue music on Sonos in two different ways. They can browse Sonos directly and queue music they added via the Sonos app (anything in their Library, Favourites or Playlists). Alternatively they can browse another service they registered within our app (e.g. Spotify) and queue music directly without needing to add anything on Sonos.

I want to queue tracks, playlists or albums for both methods without needing to send music meta info (e.g. track title) along. Sonos should retrieve this info itself (because it obviously can in the Sonos app). The issue I struggle with at the moment is that I don't know how to build valid metaData to send to addURIToQueue. I checked with Wireshark what gets sent from the Sonos app when queueing something but there are still open questions.

Metadata from Wireshark:

<DIDL-Lite xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/"
xmlns:r="urn:schemas-rinconnetworks-com:metadata-1-0/"
xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/">
<item id="10032020spotify%3atrack%3a4myBMnNWZlgvVelYeTu55w"
parentID="100e206cyour_songs" restricted="true"><dc:title>Brown Eyed Girl</dc:title>
<upnp:class>object.item.audioItem.musicTrack</upnp:class>
<desc id="cdudn" nameSpace="urn:schemas-rinconnetworks-com:metadata-1-0/">
SA_RINCON2311_X_#Svc2311-[my-account-token]-Token</desc></item></DIDL-Lite>

What I found out through experimenting:

What I don't know yet:

I hope someone can help me answer my questions. Thanks in advance!

TL;DR

I want to queue tracks/playlists/albums on Sonos by sending only a (slightly formatted) service URI to `addURIToQueue. Examples: