command to play a sonos favorite?

815 views
Skip to first unread message

pol...@hotmail.com

unread,
Nov 18, 2015, 9:12:23 PM11/18/15
to SoCo - Sonos Controller
I'm trying to figure out how to play a sonos favorite.  Can anyone help me with this.  I'm scouring all the documentation I can, but I have yet to come across such a thing and need the help of those who know much more than I.  Thank You.

Roveer

Jim Bretschneider

unread,
Nov 18, 2015, 9:33:23 PM11/18/15
to SoCo - Sonos Controller
+1

Jim Bretschneider

unread,
Nov 26, 2015, 7:32:59 PM11/26/15
to SoCo - Sonos Controller
You can access the sonos favorites this way: 

import soco
device = soco.SoCo('10.0.1.102')
r = device.contentDirectory.Browse([('ObjectID', 'FV:2'), 
                                    ('BrowseFlag', 'BrowseDirectChildren'),
                                    ('Filter', '*'),   
                                    ('StartingIndex', '1'),
                                    ('RequestedCount', '1'),
                                    ('SortCriteria', '')])
print r['Result']




<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="FV:2/27" paren
tID="FV:2" restricted="false"><dc:title>Classic Rock</dc:title><upnp:class>object.itemobject.item.sonos-favorite</upnp:class><r:ordinal>1</r:ordinal><res protocolInfo="x-rincon-cpcontainer:*:*:*">x-rincon-cpcontainer:1006206cplaylist_spotif
y%3aplaylist-534597253</res><upnp:albumArtURI>http://api.deezer.com/2.0/playlist/534597253/image?size=180</upnp:albumArtURI><r:type>instantPlay</r:type><r:description>Deezer Playlist</r:description><r:resMD>&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;1006206cplaylist_spotify%3aplaylist-534597253&quot; parentID=&quot;100a2664playlists&quot; restricted=&quot;true&quot;&gt;&lt;dc:title&gt;Classic Rock&lt;/dc:title&gt;&lt;upnp:class&gt;object.container.playlistContainer&lt;/upnp:clas
s&gt;&lt;desc id=&quot;cdudn&quot; nameSpace=&quot;urn:schemas-rinconnetworks-com:metadata-1-0/&quot;&gt;SA_RINCO...@email.com&lt;/desc&gt;&lt;/item&gt;&lt;/DIDL-Lite&gt;</r:resMD></item></DIDL-Lite>  


In this case this is returning the 2nd favorite on your list based on startingIndex and RequestedCount. These can be any source - music library, Sonos, Deezer, Radio etc, and I am not sure how do go from the didl XML to the URI. Let me know if you get to that.




On Wednesday, November 18, 2015 at 9:12:23 PM UTC-5, pol...@hotmail.com wrote:
Reply all
Reply to author
Forward
0 new messages