Hoffe hier kann mir jemand vielleicht helfen, bin neu hier weil ich ein Problem habe, bzw. nicht zurecht komme. Es geht nicht um einen Code von mir sondern darum einen bestehenden anzupassen oder zu erweitern.
Ich habe ein Sonos System am laufen und auf Github gibt es dazu eine SoCo Project über dieses sich Daten aus dem Sonos System auslesen lassen z.B.:
Code: Alles auswählen
def get_queue(self, start=0, max_items=100, full_album_art_uri=False):
"""Get information about the queue.
:param start: Starting number of returned matches
:param max_items: Maximum number of returned matches
:param full_album_art_uri: If the album art URI should include the
IP address
:returns: A :py:class:`~.soco.data_structures.Queue` object
This method is heavly based on Sam Soffes (aka soffes) ruby
implementation
"""
queue = []
response = self.contentDirectory.Browse([
('ObjectID', 'Q:0'),
('BrowseFlag', 'BrowseDirectChildren'),
('Filter', '*'),
('StartingIndex', start),
('RequestedCount', max_items),
('SortCriteria', '')
])
result = response['Result']
metadata = {}
for tag in ['NumberReturned', 'TotalMatches', 'UpdateID']:
metadata[camel_to_underscore(tag)] = int(response[tag])
# I'm not sure this necessary (any more). Even with an empty queue,
# there is still a result object. This shoud be investigated.
if not result:
# pylint: disable=star-args
return Queue(queue, **metadata)
items = from_didl_string(result)
for item in items:
# Check if the album art URI should be fully qualified
if full_album_art_uri:
self._update_album_art_to_full_uri(item)
queue.append(item)
# pylint: disable=star-args
return Queue(queue, **metadata)
Code: Alles auswählen
>>> SonosSoCo.get_queue()
Queue(items=[<DidlMusicTrack 'Heatseeker' at 0xb6180290L>, <DidlMusicTrack 'That's The Way I Wanna Rock N Roll' at 0xb6180230L>, <DidlMusicTrack 'Meanstreak' at 0xb6180070L>, <DidlMusicTrack 'Go Zone' at 0xb6180050L>, <DidlMusicTrack 'Kissin' Dynamite' at 0xb61133d0L>, <DidlMusicTrack 'Nick Of Time' at 0xb6113c70L>, <DidlMusicTrack 'Some Sin For Nuthin'' at 0xb6113ed0L>, <DidlMusicTrack 'Ruff Stuff' at 0xb6113d50L>, <DidlMusicTrack 'Two's Up' at 0xb6113af0L>, <DidlMusicTrack 'This Means War' at 0xb6113490L>])
>>>
mit SonosSoCo.get_current_track_info() kann ich das Aktuelle Lied abfragen und diese Daten auch auswerten
Code: Alles auswählen
>>> SonosSoCo.get_current_track_info()
{u'album': 'Blow Up Your Video', u'artist': 'AC/DC', u'title': 'Heatseeker', u'uri': 'x-file-cifs://192.168.0.100/Harddisk/music/ACDC/Blow%20up%20your%20Video/01%20Heat%20Seeker.mp3', u'playlist_position': '1', u'duration': '0:03:47', u'position': '0:02:07', u'album_art': u'http://192.168.0.84:1400/getaa?u=x-file-cifs%3a%2f%2f192.168.0.100%2fHarddisk%2fmusic%2fACDC%2fBlow%2520up%2520your%2520Video%2f01%2520Heat%2520Seeker.mp3&v=4', u'metadata': '<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="-1" parentID="-1" restricted="true"><res protocolInfo="x-file-cifs:*:audio/mpeg:*" duration="0:03:47">x-file-cifs://192.168.0.100/Harddisk/music/ACDC/Blow%20up%20your%20Video/01%20Heat%20Seeker.mp3</res><r:streamContent></r:streamContent><upnp:albumArtURI>/getaa?u=x-file-cifs%3a%2f%2f192.168.0.100%2fHarddisk%2fmusic%2fACDC%2fBlow%2520up%2520your%2520Video%2f01%2520Heat%2520Seeker.mp3&v=4</upnp:albumArtURI><dc:title>Heatseeker</dc:title><upnp:class>object.item.audioItem.musicTrack</upnp:class><dc:creator>AC/DC</dc:creator><upnp:album>Blow Up Your Video</upnp:album><upnp:originalTrackNumber>1</upnp:originalTrackNumber><r:albumArtist>AC/DC</r:albumArtist></item></DIDL-Lite>'}
>>>
Danke
