dph / demo-soco-snapshot Goto Github PK
View Code? Open in Web Editor NEWfirst demo of a plugin for soco to snap and restore sonos state
first demo of a plugin for soco to snap and restore sonos state
Hey DPH, I've been writing a full security system for my house and used some of your example code to get a lot of my TTS for notifications and what not working. This stuff is excellent and I appreciate all the hard work you put into it.
I have one question however, and it was eluded to on the SoCo boards, about utf-8 encoding on the return function of snapshot (this is affected on both the plugin or the new built-in to soco function).
$ ./TestSnap2.py
Zone Player: Living Room - Coordinator Living Room
{'NextURI': u'', 'CurrentURI': 'pndrradio:1673412035410938911', 'NextURIMetaData': u'', 'RecordMedium': 'NOT_IMPLEMENTED', 'PlayMedium': 'NETWORK', 'NrTracks': '4', 'WriteStatus': 'NOT_IMPLEMENTED', 'MediaDuration': 'NOT_IMPLEMENTED', 'CurrentURIMetaData': u'<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="OOOX1673412035410938911" parentID="0" restricted="true"><dc:title>Michael Bubl\xe9 Radio</dc:title><upnp:class>object.item.audioItem.audioBroadcast.sonos-favorite</upnp:class><desc id="cdudn" nameSpace="urn:schemas-rinconnetworks-com:metadata-1-0/">[email protected]</desc></item></DIDL-Lite>'}
pndrradio:1673412035410938911
stream
{u'mute': False, u'volume': 1, u'source': u'stream', u'state': 'PAUSED_PLAYBACK', u'media_uri': 'pndrradio:1673412035410938911', u'media_meta': u'<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="OOOX1673412035410938911" parentID="0" restricted="true"><dc:title>Michael Bubl\xe9 Radio</dc:title><upnp:class>object.item.audioItem.audioBroadcast.sonos-favorite</upnp:class><desc id="cdudn" nameSpace="urn:schemas-rinconnetworks-com:metadata-1-0/">[email protected]</desc></item></DIDL-Lite>'}
> Image print for zone: Living Room
mute: False
volume: 1
source: stream
state: PAUSED_PLAYBACK
media_uri: pndrradio:1673412035410938911
media_meta: <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="OOOX1673412035410938911" parentID="0" restricted="true"><dc:title>**Michael Bublé Radio**</dc:title><upnp:class>object.item.audioItem.audioBroadcast.sonos-favorite</upnp:class><desc id="cdudn" nameSpace="urn:schemas-rinconnetworks-com:metadata-1-0/">SA_RINCON3_xxxx@xxxx.com</desc></item></DIDL-Lite>
resetting zones
Resetting Zone Player: Living Room
Traceback (most recent call last):
File "./TestSnap2.py", line 65, in <module>
zp.my_snap.restore(fade=True)
File "/usr/local/lib/python2.7/dist-packages/soco/plugins/snapshot.py", line 152, in restore
('CurrentURIMetaData', restore_meta)
File "/usr/local/lib/python2.7/dist-packages/soco/services.py", line 159, in _dispatcher
return self.send_command(action, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/soco/services.py", line 333, in send_command
self.base_url + self.control_url, headers=headers, data=body)
File "/usr/local/lib/python2.7/dist-packages/requests/api.py", line 99, in post
return request('post', url, data=data, json=json, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/api.py", line 49, in request
response = session.request(method=method, url=url, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 461, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 573, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/adapters.py", line 370, in send
timeout=timeout
File "/usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/connectionpool.py", line 518, in urlopen
body=body, headers=headers)
File "/usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/connectionpool.py", line 330, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/usr/lib/python2.7/httplib.py", line 962, in request
self._send_request(method, url, body, headers)
File "/usr/lib/python2.7/httplib.py", line 996, in _send_request
self.endheaders(body)
File "/usr/lib/python2.7/httplib.py", line 958, in endheaders
self._send_output(message_body)
File "/usr/lib/python2.7/httplib.py", line 822, in _send_output
self.send(message_body)
File "/usr/lib/python2.7/httplib.py", line 794, in send
self.sock.sendall(data)
File "/usr/lib/python2.7/socket.py", line 224, in meth
return getattr(self._sock,name)(*args)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 719: ordinal not in range(128)
If the radio station has a special character, accents, etc, it wont 'return' back to. I tried to encode everything several times, but I'm just not getting it correctly. Did you ever figure out how to get around that?
Thanks much!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.