soco 0.32.2__tar.gz → 0.32.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (224) hide show
  1. {soco-0.32.2/soco.egg-info → soco-0.32.4}/PKG-INFO +1 -1
  2. {soco-0.32.2 → soco-0.32.4}/doc/conf.py +3 -2
  3. {soco-0.32.2 → soco-0.32.4}/soco/__init__.py +1 -1
  4. {soco-0.32.2 → soco-0.32.4}/soco/alarms.py +139 -10
  5. {soco-0.32.2 → soco-0.32.4}/soco/events_asyncio.py +2 -1
  6. {soco-0.32.2 → soco-0.32.4}/soco/events_base.py +35 -1
  7. {soco-0.32.2 → soco-0.32.4}/soco/music_services/accounts.py +6 -2
  8. {soco-0.32.2 → soco-0.32.4/soco.egg-info}/PKG-INFO +1 -1
  9. soco-0.32.4/tests/test_alarms.py +394 -0
  10. {soco-0.32.2 → soco-0.32.4}/tests/test_events.py +54 -2
  11. {soco-0.32.2 → soco-0.32.4}/tests/test_musicservices.py +18 -0
  12. soco-0.32.2/tests/test_alarms.py +0 -172
  13. {soco-0.32.2 → soco-0.32.4}/AUTHORS.rst +0 -0
  14. {soco-0.32.2 → soco-0.32.4}/LICENSE.rst +0 -0
  15. {soco-0.32.2 → soco-0.32.4}/MANIFEST.in +0 -0
  16. {soco-0.32.2 → soco-0.32.4}/README.rst +0 -0
  17. {soco-0.32.2 → soco-0.32.4}/dev_tools/analyse_ws.ini +0 -0
  18. {soco-0.32.2 → soco-0.32.4}/dev_tools/analyse_ws.py +0 -0
  19. {soco-0.32.2 → soco-0.32.4}/dev_tools/pychecker.bat +0 -0
  20. {soco-0.32.2 → soco-0.32.4}/dev_tools/pychecker.sh +0 -0
  21. {soco-0.32.2 → soco-0.32.4}/dev_tools/release.py +0 -0
  22. {soco-0.32.2 → soco-0.32.4}/dev_tools/sonosdump.py +0 -0
  23. {soco-0.32.2 → soco-0.32.4}/doc/Makefile +0 -0
  24. {soco-0.32.2 → soco-0.32.4}/doc/_static/imageMapResizer.min.js +0 -0
  25. {soco-0.32.2 → soco-0.32.4}/doc/_templates/page.html +0 -0
  26. {soco-0.32.2 → soco-0.32.4}/doc/advanced/data-structures-mod.rst +0 -0
  27. {soco-0.32.2 → soco-0.32.4}/doc/advanced/events.rst +0 -0
  28. {soco-0.32.2 → soco-0.32.4}/doc/advanced/events_asyncio.rst +0 -0
  29. {soco-0.32.2 → soco-0.32.4}/doc/advanced/events_twisted.rst +0 -0
  30. {soco-0.32.2 → soco-0.32.4}/doc/advanced/index.rst +0 -0
  31. {soco-0.32.2 → soco-0.32.4}/doc/advanced/services.rst +0 -0
  32. {soco-0.32.2 → soco-0.32.4}/doc/advanced/topology.rst +0 -0
  33. {soco-0.32.2 → soco-0.32.4}/doc/api/soco.alarms.rst +0 -0
  34. {soco-0.32.2 → soco-0.32.4}/doc/api/soco.cache.rst +0 -0
  35. {soco-0.32.2 → soco-0.32.4}/doc/api/soco.config.rst +0 -0
  36. {soco-0.32.2 → soco-0.32.4}/doc/api/soco.core.rst +0 -0
  37. {soco-0.32.2 → soco-0.32.4}/doc/api/soco.data_structures.rst +0 -0
  38. {soco-0.32.2 → soco-0.32.4}/doc/api/soco.discovery.rst +0 -0
  39. {soco-0.32.2 → soco-0.32.4}/doc/api/soco.events.rst +0 -0
  40. {soco-0.32.2 → soco-0.32.4}/doc/api/soco.exceptions.rst +0 -0
  41. {soco-0.32.2 → soco-0.32.4}/doc/api/soco.favorites.rst +0 -0
  42. {soco-0.32.2 → soco-0.32.4}/doc/api/soco.groups.rst +0 -0
  43. {soco-0.32.2 → soco-0.32.4}/doc/api/soco.ms_data_structures.rst +0 -0
  44. {soco-0.32.2 → soco-0.32.4}/doc/api/soco.music_library.rst +0 -0
  45. {soco-0.32.2 → soco-0.32.4}/doc/api/soco.music_services.accounts.rst +0 -0
  46. {soco-0.32.2 → soco-0.32.4}/doc/api/soco.music_services.music_service.rst +0 -0
  47. {soco-0.32.2 → soco-0.32.4}/doc/api/soco.music_services.rst +0 -0
  48. {soco-0.32.2 → soco-0.32.4}/doc/api/soco.music_services.token_store.rst +0 -0
  49. {soco-0.32.2 → soco-0.32.4}/doc/api/soco.plugins.example.rst +0 -0
  50. {soco-0.32.2 → soco-0.32.4}/doc/api/soco.plugins.plex.rst +0 -0
  51. {soco-0.32.2 → soco-0.32.4}/doc/api/soco.plugins.rst +0 -0
  52. {soco-0.32.2 → soco-0.32.4}/doc/api/soco.plugins.sharelink.rst +0 -0
  53. {soco-0.32.2 → soco-0.32.4}/doc/api/soco.plugins.spotify.rst +0 -0
  54. {soco-0.32.2 → soco-0.32.4}/doc/api/soco.plugins.wimp.rst +0 -0
  55. {soco-0.32.2 → soco-0.32.4}/doc/api/soco.rst +0 -0
  56. {soco-0.32.2 → soco-0.32.4}/doc/api/soco.services.rst +0 -0
  57. {soco-0.32.2 → soco-0.32.4}/doc/api/soco.snapshot.rst +0 -0
  58. {soco-0.32.2 → soco-0.32.4}/doc/api/soco.soap.rst +0 -0
  59. {soco-0.32.2 → soco-0.32.4}/doc/api/soco.utils.rst +0 -0
  60. {soco-0.32.2 → soco-0.32.4}/doc/api/soco.xml.rst +0 -0
  61. {soco-0.32.2 → soco-0.32.4}/doc/authors.rst +0 -0
  62. {soco-0.32.2 → soco-0.32.4}/doc/development/index.rst +0 -0
  63. {soco-0.32.2 → soco-0.32.4}/doc/development/release-howto.rst +0 -0
  64. {soco-0.32.2 → soco-0.32.4}/doc/development/unittests.rst +0 -0
  65. {soco-0.32.2 → soco-0.32.4}/doc/examples.rst +0 -0
  66. {soco-0.32.2 → soco-0.32.4}/doc/faq.rst +0 -0
  67. {soco-0.32.2 → soco-0.32.4}/doc/getting_started.rst +0 -0
  68. {soco-0.32.2 → soco-0.32.4}/doc/graphics/data_structures.png +0 -0
  69. {soco-0.32.2 → soco-0.32.4}/doc/graphics/data_structures.svg +0 -0
  70. {soco-0.32.2 → soco-0.32.4}/doc/index.rst +0 -0
  71. {soco-0.32.2 → soco-0.32.4}/doc/make.bat +0 -0
  72. {soco-0.32.2 → soco-0.32.4}/doc/plugins.rst +0 -0
  73. {soco-0.32.2 → soco-0.32.4}/doc/release_notes.rst +0 -0
  74. {soco-0.32.2 → soco-0.32.4}/doc/releases/0.10.rst +0 -0
  75. {soco-0.32.2 → soco-0.32.4}/doc/releases/0.11.1.rst +0 -0
  76. {soco-0.32.2 → soco-0.32.4}/doc/releases/0.11.rst +0 -0
  77. {soco-0.32.2 → soco-0.32.4}/doc/releases/0.12.rst +0 -0
  78. {soco-0.32.2 → soco-0.32.4}/doc/releases/0.13.rst +0 -0
  79. {soco-0.32.2 → soco-0.32.4}/doc/releases/0.14.rst +0 -0
  80. {soco-0.32.2 → soco-0.32.4}/doc/releases/0.15.rst +0 -0
  81. {soco-0.32.2 → soco-0.32.4}/doc/releases/0.16.rst +0 -0
  82. {soco-0.32.2 → soco-0.32.4}/doc/releases/0.17.rst +0 -0
  83. {soco-0.32.2 → soco-0.32.4}/doc/releases/0.18.rst +0 -0
  84. {soco-0.32.2 → soco-0.32.4}/doc/releases/0.19.rst +0 -0
  85. {soco-0.32.2 → soco-0.32.4}/doc/releases/0.20.rst +0 -0
  86. {soco-0.32.2 → soco-0.32.4}/doc/releases/0.21.rst +0 -0
  87. {soco-0.32.2 → soco-0.32.4}/doc/releases/0.22.rst +0 -0
  88. {soco-0.32.2 → soco-0.32.4}/doc/releases/0.23.rst +0 -0
  89. {soco-0.32.2 → soco-0.32.4}/doc/releases/0.24.rst +0 -0
  90. {soco-0.32.2 → soco-0.32.4}/doc/releases/0.25.rst +0 -0
  91. {soco-0.32.2 → soco-0.32.4}/doc/releases/0.26.rst +0 -0
  92. {soco-0.32.2 → soco-0.32.4}/doc/releases/0.27.rst +0 -0
  93. {soco-0.32.2 → soco-0.32.4}/doc/releases/0.28.rst +0 -0
  94. {soco-0.32.2 → soco-0.32.4}/doc/releases/0.29.rst +0 -0
  95. {soco-0.32.2 → soco-0.32.4}/doc/releases/0.30.rst +0 -0
  96. {soco-0.32.2 → soco-0.32.4}/doc/releases/0.31.0.rst +0 -0
  97. {soco-0.32.2 → soco-0.32.4}/doc/releases/0.32.0.rst +0 -0
  98. {soco-0.32.2 → soco-0.32.4}/doc/releases/0.6.rst +0 -0
  99. {soco-0.32.2 → soco-0.32.4}/doc/releases/0.7.rst +0 -0
  100. {soco-0.32.2 → soco-0.32.4}/doc/releases/0.8.rst +0 -0
  101. {soco-0.32.2 → soco-0.32.4}/doc/releases/0.9.rst +0 -0
  102. {soco-0.32.2 → soco-0.32.4}/doc/releases/index.rst +0 -0
  103. {soco-0.32.2 → soco-0.32.4}/doc/requirements.txt +0 -0
  104. {soco-0.32.2 → soco-0.32.4}/doc/tutorial.rst +0 -0
  105. {soco-0.32.2 → soco-0.32.4}/examples/commandline/README.rst +0 -0
  106. {soco-0.32.2 → soco-0.32.4}/examples/commandline/discover.py +0 -0
  107. {soco-0.32.2 → soco-0.32.4}/examples/commandline/screenshot.png +0 -0
  108. {soco-0.32.2 → soco-0.32.4}/examples/commandline/tunein.py +0 -0
  109. {soco-0.32.2 → soco-0.32.4}/examples/events_asyncio_verify_listener_fix.py +0 -0
  110. {soco-0.32.2 → soco-0.32.4}/examples/play_local_files/play_local_files.py +0 -0
  111. {soco-0.32.2 → soco-0.32.4}/examples/plugins/socoplugins.py +0 -0
  112. {soco-0.32.2 → soco-0.32.4}/examples/snapshot/basic_snap.py +0 -0
  113. {soco-0.32.2 → soco-0.32.4}/examples/snapshot/multi_zone_snap.py +0 -0
  114. {soco-0.32.2 → soco-0.32.4}/examples/webapp/.gitignore +0 -0
  115. {soco-0.32.2 → soco-0.32.4}/examples/webapp/README.md +0 -0
  116. {soco-0.32.2 → soco-0.32.4}/examples/webapp/index.py +0 -0
  117. {soco-0.32.2 → soco-0.32.4}/examples/webapp/requirements.txt +0 -0
  118. {soco-0.32.2 → soco-0.32.4}/examples/webapp/screenshot.png +0 -0
  119. {soco-0.32.2 → soco-0.32.4}/examples/webapp/settings.py.example +0 -0
  120. {soco-0.32.2 → soco-0.32.4}/examples/webapp/static/css/bootstrap.min.css +0 -0
  121. {soco-0.32.2 → soco-0.32.4}/examples/webapp/static/css/main.css +0 -0
  122. {soco-0.32.2 → soco-0.32.4}/examples/webapp/static/img/blank.jpg +0 -0
  123. {soco-0.32.2 → soco-0.32.4}/examples/webapp/static/img/glyphicons-halflings-white.png +0 -0
  124. {soco-0.32.2 → soco-0.32.4}/examples/webapp/static/img/glyphicons-halflings.png +0 -0
  125. {soco-0.32.2 → soco-0.32.4}/examples/webapp/static/js/bootstrap.min.js +0 -0
  126. {soco-0.32.2 → soco-0.32.4}/examples/webapp/static/js/jquery.min.js +0 -0
  127. {soco-0.32.2 → soco-0.32.4}/examples/webapp/templates/index.html +0 -0
  128. {soco-0.32.2 → soco-0.32.4}/makefile +0 -0
  129. {soco-0.32.2 → soco-0.32.4}/pylintrc +0 -0
  130. {soco-0.32.2 → soco-0.32.4}/pyproject.toml +0 -0
  131. {soco-0.32.2 → soco-0.32.4}/requirements-dev.txt +0 -0
  132. {soco-0.32.2 → soco-0.32.4}/requirements.txt +0 -0
  133. {soco-0.32.2 → soco-0.32.4}/setup.cfg +0 -0
  134. {soco-0.32.2 → soco-0.32.4}/setup.py +0 -0
  135. {soco-0.32.2 → soco-0.32.4}/soco/cache.py +0 -0
  136. {soco-0.32.2 → soco-0.32.4}/soco/config.py +0 -0
  137. {soco-0.32.2 → soco-0.32.4}/soco/core.py +0 -0
  138. {soco-0.32.2 → soco-0.32.4}/soco/data_structure_quirks.py +0 -0
  139. {soco-0.32.2 → soco-0.32.4}/soco/data_structures.py +0 -0
  140. {soco-0.32.2 → soco-0.32.4}/soco/data_structures_entry.py +0 -0
  141. {soco-0.32.2 → soco-0.32.4}/soco/discovery.py +0 -0
  142. {soco-0.32.2 → soco-0.32.4}/soco/events.py +0 -0
  143. {soco-0.32.2 → soco-0.32.4}/soco/events_twisted.py +0 -0
  144. {soco-0.32.2 → soco-0.32.4}/soco/exceptions.py +0 -0
  145. {soco-0.32.2 → soco-0.32.4}/soco/favorites.py +0 -0
  146. {soco-0.32.2 → soco-0.32.4}/soco/groups.py +0 -0
  147. {soco-0.32.2 → soco-0.32.4}/soco/ms_data_structures.py +0 -0
  148. {soco-0.32.2 → soco-0.32.4}/soco/music_library.py +0 -0
  149. {soco-0.32.2 → soco-0.32.4}/soco/music_services/__init__.py +0 -0
  150. {soco-0.32.2 → soco-0.32.4}/soco/music_services/data_structures.py +0 -0
  151. {soco-0.32.2 → soco-0.32.4}/soco/music_services/music_service.py +0 -0
  152. {soco-0.32.2 → soco-0.32.4}/soco/music_services/token_store.py +0 -0
  153. {soco-0.32.2 → soco-0.32.4}/soco/plugins/__init__.py +0 -0
  154. {soco-0.32.2 → soco-0.32.4}/soco/plugins/example.py +0 -0
  155. {soco-0.32.2 → soco-0.32.4}/soco/plugins/plex.py +0 -0
  156. {soco-0.32.2 → soco-0.32.4}/soco/plugins/sharelink.py +0 -0
  157. {soco-0.32.2 → soco-0.32.4}/soco/plugins/spotify.py +0 -0
  158. {soco-0.32.2 → soco-0.32.4}/soco/plugins/wimp.py +0 -0
  159. {soco-0.32.2 → soco-0.32.4}/soco/services.py +0 -0
  160. {soco-0.32.2 → soco-0.32.4}/soco/snapshot.py +0 -0
  161. {soco-0.32.2 → soco-0.32.4}/soco/soap.py +0 -0
  162. {soco-0.32.2 → soco-0.32.4}/soco/utils.py +0 -0
  163. {soco-0.32.2 → soco-0.32.4}/soco/xml.py +0 -0
  164. {soco-0.32.2 → soco-0.32.4}/soco/zonegroupstate.py +0 -0
  165. {soco-0.32.2 → soco-0.32.4}/soco.egg-info/SOURCES.txt +0 -0
  166. {soco-0.32.2 → soco-0.32.4}/soco.egg-info/dependency_links.txt +0 -0
  167. {soco-0.32.2 → soco-0.32.4}/soco.egg-info/requires.txt +0 -0
  168. {soco-0.32.2 → soco-0.32.4}/soco.egg-info/top_level.txt +0 -0
  169. {soco-0.32.2 → soco-0.32.4}/tests/conftest.py +0 -0
  170. {soco-0.32.2 → soco-0.32.4}/tests/data/data_structures_entry_integration/album.json +0 -0
  171. {soco-0.32.2 → soco-0.32.4}/tests/data/data_structures_entry_integration/album.xml +0 -0
  172. {soco-0.32.2 → soco-0.32.4}/tests/data/data_structures_entry_integration/album_compilation.xml +0 -0
  173. {soco-0.32.2 → soco-0.32.4}/tests/data/data_structures_entry_integration/album_favorite.xml +0 -0
  174. {soco-0.32.2 → soco-0.32.4}/tests/data/data_structures_entry_integration/album_list.xml +0 -0
  175. {soco-0.32.2 → soco-0.32.4}/tests/data/data_structures_entry_integration/artist.json +0 -0
  176. {soco-0.32.2 → soco-0.32.4}/tests/data/data_structures_entry_integration/artist.xml +0 -0
  177. {soco-0.32.2 → soco-0.32.4}/tests/data/data_structures_entry_integration/audio_broadcast.json +0 -0
  178. {soco-0.32.2 → soco-0.32.4}/tests/data/data_structures_entry_integration/audio_broadcast.xml +0 -0
  179. {soco-0.32.2 → soco-0.32.4}/tests/data/data_structures_entry_integration/composer.json +0 -0
  180. {soco-0.32.2 → soco-0.32.4}/tests/data/data_structures_entry_integration/composer.xml +0 -0
  181. {soco-0.32.2 → soco-0.32.4}/tests/data/data_structures_entry_integration/genre.json +0 -0
  182. {soco-0.32.2 → soco-0.32.4}/tests/data/data_structures_entry_integration/genre.xml +0 -0
  183. {soco-0.32.2 → soco-0.32.4}/tests/data/data_structures_entry_integration/playlist.json +0 -0
  184. {soco-0.32.2 → soco-0.32.4}/tests/data/data_structures_entry_integration/playlist.xml +0 -0
  185. {soco-0.32.2 → soco-0.32.4}/tests/data/data_structures_entry_integration/playlist_favorite.xml +0 -0
  186. {soco-0.32.2 → soco-0.32.4}/tests/data/data_structures_entry_integration/radio_show.json +0 -0
  187. {soco-0.32.2 → soco-0.32.4}/tests/data/data_structures_entry_integration/radio_show.xml +0 -0
  188. {soco-0.32.2 → soco-0.32.4}/tests/data/data_structures_entry_integration/recent_show.xml +0 -0
  189. {soco-0.32.2 → soco-0.32.4}/tests/data/data_structures_entry_integration/same_artist.xml +0 -0
  190. {soco-0.32.2 → soco-0.32.4}/tests/data/data_structures_entry_integration/share.json +0 -0
  191. {soco-0.32.2 → soco-0.32.4}/tests/data/data_structures_entry_integration/share.xml +0 -0
  192. {soco-0.32.2 → soco-0.32.4}/tests/data/data_structures_entry_integration/source_linein.xml +0 -0
  193. {soco-0.32.2 → soco-0.32.4}/tests/data/data_structures_entry_integration/track.json +0 -0
  194. {soco-0.32.2 → soco-0.32.4}/tests/data/data_structures_entry_integration/track.xml +0 -0
  195. {soco-0.32.2 → soco-0.32.4}/tests/data/data_structures_entry_integration/tracklist.xml +0 -0
  196. {soco-0.32.2 → soco-0.32.4}/tests/data/media_metadata_payloads/bbc.json +0 -0
  197. {soco-0.32.2 → soco-0.32.4}/tests/data/media_metadata_payloads/cifs.json +0 -0
  198. {soco-0.32.2 → soco-0.32.4}/tests/data/media_metadata_payloads/pandora.json +0 -0
  199. {soco-0.32.2 → soco-0.32.4}/tests/data/media_metadata_payloads/sonos_radio.json +0 -0
  200. {soco-0.32.2 → soco-0.32.4}/tests/data/media_metadata_payloads/tunein.json +0 -0
  201. {soco-0.32.2 → soco-0.32.4}/tests/data/media_metadata_payloads/tunein_2.json +0 -0
  202. {soco-0.32.2 → soco-0.32.4}/tests/official_and_extended_didl_classes.txt +0 -0
  203. {soco-0.32.2 → soco-0.32.4}/tests/soco_unittest.py +0 -0
  204. {soco-0.32.2 → soco-0.32.4}/tests/test_cache.py +0 -0
  205. {soco-0.32.2 → soco-0.32.4}/tests/test_core.py +0 -0
  206. {soco-0.32.2 → soco-0.32.4}/tests/test_data_structures_entry_integration.py +0 -0
  207. {soco-0.32.2 → soco-0.32.4}/tests/test_discovery.py +0 -0
  208. {soco-0.32.2 → soco-0.32.4}/tests/test_events_asyncio.py +0 -0
  209. {soco-0.32.2 → soco-0.32.4}/tests/test_favorites.py +0 -0
  210. {soco-0.32.2 → soco-0.32.4}/tests/test_integration.py +0 -0
  211. {soco-0.32.2 → soco-0.32.4}/tests/test_metadata_parsing.py +0 -0
  212. {soco-0.32.2 → soco-0.32.4}/tests/test_ms_data_structures.py +0 -0
  213. {soco-0.32.2 → soco-0.32.4}/tests/test_music_library.py +0 -0
  214. {soco-0.32.2 → soco-0.32.4}/tests/test_music_service_data_structures.py +0 -0
  215. {soco-0.32.2 → soco-0.32.4}/tests/test_new_datastructures.py +0 -0
  216. {soco-0.32.2 → soco-0.32.4}/tests/test_release_script.py +0 -0
  217. {soco-0.32.2 → soco-0.32.4}/tests/test_services.py +0 -0
  218. {soco-0.32.2 → soco-0.32.4}/tests/test_sharelink.py +0 -0
  219. {soco-0.32.2 → soco-0.32.4}/tests/test_singleton.py +0 -0
  220. {soco-0.32.2 → soco-0.32.4}/tests/test_snapshot.py +0 -0
  221. {soco-0.32.2 → soco-0.32.4}/tests/test_soap.py +0 -0
  222. {soco-0.32.2 → soco-0.32.4}/tests/test_utils.py +0 -0
  223. {soco-0.32.2 → soco-0.32.4}/tests/test_xml.py +0 -0
  224. {soco-0.32.2 → soco-0.32.4}/tests/test_zonegroupstate.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: soco
3
- Version: 0.32.2
3
+ Version: 0.32.4
4
4
  Summary: SoCo (Sonos Controller) is a simple library to control Sonos speakers.
5
5
  Author-email: The SoCo-Team <python-soco@googlegroups.com>
6
6
  License-Expression: MIT
@@ -12,8 +12,9 @@
12
12
  # All configuration values have a default; values that are commented out
13
13
  # serve to show the default.
14
14
 
15
- import sys
15
+ import datetime
16
16
  import os
17
+ import sys
17
18
 
18
19
  sys.path.insert(0, os.path.abspath(".."))
19
20
  import soco # noqa: E402
@@ -58,7 +59,7 @@ master_doc = "index"
58
59
 
59
60
  # General information about the project.
60
61
  project = "SoCo"
61
- copyright = "2015-2024, The SoCo Team"
62
+ copyright = f"2015-{datetime.date.today().year}, The SoCo Team"
62
63
  author = "`The SoCo Team"
63
64
 
64
65
  # The version info for the project you're documenting, acts as replacement for
@@ -17,7 +17,7 @@ from .exceptions import SoCoException, UnknownSoCoException
17
17
  __author__ = "The SoCo-Team <python-soco@googlegroups.com>"
18
18
  # Please increment the version number and add the suffix "-dev" after
19
19
  # a release, to make it possible to identify in-development code
20
- __version__ = "0.32.2"
20
+ __version__ = "0.32.4"
21
21
  __website__ = "https://github.com/SoCo/SoCo"
22
22
  __license__ = "MIT License"
23
23
 
@@ -4,8 +4,8 @@ import logging
4
4
  import re
5
5
  from datetime import datetime, timedelta
6
6
 
7
- from . import discovery
8
- from .core import _SocoSingletonBase, PLAY_MODES
7
+ from . import config, discovery
8
+ from .core import _ArgsSingleton, _SocoSingletonBase, PLAY_MODES
9
9
  from .exceptions import SoCoException
10
10
  from .xml import XML
11
11
 
@@ -59,6 +59,11 @@ class Alarms(_SocoSingletonBase):
59
59
 
60
60
  Is a singleton and every `Alarms()` object will return the same instance.
61
61
 
62
+ Alarms are stored per Sonos household. If speakers from more than one
63
+ household are in use, pass a household ID to get a separate singleton
64
+ for each household: ``Alarms(zone.household_id)``. `Alarms()` without a
65
+ household ID is a shared instance that is not bound to a household.
66
+
62
67
  Example use:
63
68
 
64
69
  >>> get_alarms()
@@ -99,8 +104,20 @@ class Alarms(_SocoSingletonBase):
99
104
 
100
105
  _class_group = "Alarms"
101
106
 
102
- def __init__(self):
103
- """Initialize the instance."""
107
+ @staticmethod
108
+ def _singleton_key(household_id=None):
109
+ """Return the singleton key, so `Alarms()` keeps its legacy key."""
110
+ return () if household_id is None else (household_id,)
111
+
112
+ def __init__(self, household_id=None):
113
+ """Initialize the instance.
114
+
115
+ Args:
116
+ household_id (str, optional): The ID of the Sonos household
117
+ these alarms belong to. If `None`, the instance is not bound
118
+ to a household.
119
+ """
120
+ self.household_id = household_id
104
121
  self.alarms = {}
105
122
  self.alarms_skipped = {}
106
123
  self._last_zone_used = None
@@ -120,6 +137,11 @@ class Alarms(_SocoSingletonBase):
120
137
  self.last_id = int(last_id)
121
138
  self._last_alarm_list_version = alarm_list_version
122
139
 
140
+ def __repr__(self):
141
+ return "<{} household:{} at {}>".format(
142
+ self.__class__.__name__, self.household_id, hex(id(self))
143
+ )
144
+
123
145
  def __iter__(self):
124
146
  """Return an interator for all alarms."""
125
147
  yield from list(self.alarms.values())
@@ -139,16 +161,47 @@ class Alarms(_SocoSingletonBase):
139
161
  def update(self, zone=None):
140
162
  """Update all alarms and current alarm list version.
141
163
 
164
+ Args:
165
+ zone (`SoCo`, optional): The zone to query. If `None`, the last
166
+ zone used is queried, or else any known zone (from this
167
+ instance's household, if `household_id` is set). If
168
+ `household_id` is set and the last zone used cannot be
169
+ reached, another known zone of the household is queried.
170
+
142
171
  Raises:
143
172
  SoCoException: If the 'CurrentAlarmListVersion' value is unexpected.
144
173
  May occur if the provided zone is from a different household.
174
+ If `household_id` is set, raised if the zone belongs to a
175
+ different household or no zone of the household is known.
145
176
  """
177
+ # Only a remembered zone of a household instance is replaced if it
178
+ # cannot be reached. Alarms() keeps its existing behaviour.
179
+ can_fall_back = (
180
+ zone is None
181
+ and self._last_zone_used is not None
182
+ and self.household_id is not None
183
+ )
146
184
  if zone is None:
147
- zone = self._last_zone_used or discovery.any_soco()
185
+ zone = self._last_zone_used or self._any_zone()
148
186
 
149
- self._last_zone_used = zone
187
+ if self.household_id is not None and zone.household_id != self.household_id:
188
+ raise SoCoException(
189
+ "Zone {} belongs to household {}, not {}".format(
190
+ zone.uid, zone.household_id, self.household_id
191
+ )
192
+ )
150
193
 
151
- response = zone.alarmClock.ListAlarms()
194
+ try:
195
+ response = zone.alarmClock.ListAlarms()
196
+ except OSError:
197
+ if not can_fall_back:
198
+ raise
199
+ # The last zone used is unreachable, e.g. it was unplugged or
200
+ # its network went down. Try another zone of the household.
201
+ zone = self._any_zone(exclude=zone)
202
+ response = zone.alarmClock.ListAlarms()
203
+
204
+ self._last_zone_used = zone
152
205
  current_alarm_list_version = response["CurrentAlarmListVersion"]
153
206
 
154
207
  if self.last_alarm_list_version:
@@ -177,13 +230,16 @@ class Alarms(_SocoSingletonBase):
177
230
  existing_alarm = self.alarms.get(alarm_id) or old_skipped.get(alarm_id)
178
231
  if existing_alarm:
179
232
  existing_alarm.update(**kwargs)
233
+ existing_alarm._alarms = self # pylint: disable=protected-access
180
234
  if existing_alarm.zone is None:
181
235
  self.alarms_skipped[alarm_id] = existing_alarm
182
236
  else:
183
237
  self.alarms[alarm_id] = existing_alarm
184
238
  else:
185
239
  new_alarm = Alarm(**kwargs)
186
- new_alarm._alarm_id = alarm_id # pylint: disable=protected-access
240
+ # pylint: disable=protected-access
241
+ new_alarm._alarm_id = alarm_id
242
+ new_alarm._alarms = self
187
243
  if new_alarm.zone is None:
188
244
  self.alarms_skipped[alarm_id] = new_alarm
189
245
  else:
@@ -194,6 +250,32 @@ class Alarms(_SocoSingletonBase):
194
250
  if not new_alarms.get(alarm_id):
195
251
  self.alarms.pop(alarm_id)
196
252
 
253
+ def _any_zone(self, exclude=None):
254
+ """Return a known zone to query, from this household if set.
255
+
256
+ Args:
257
+ exclude (`SoCo`, optional): A zone not to return. Only used when
258
+ `household_id` is set.
259
+ """
260
+ if self.household_id is None:
261
+ return discovery.any_soco()
262
+ cls = config.SOCO_CLASS
263
+ # pylint: disable=no-member, protected-access
264
+ for zone in list(cls._instances.get(cls._class_group, {}).values()):
265
+ if zone is exclude:
266
+ continue
267
+ # household_id first: it is cached and avoids fetching topology.
268
+ try:
269
+ if zone.household_id == self.household_id and zone.is_visible:
270
+ return zone
271
+ except (OSError, SoCoException):
272
+ continue
273
+ raise SoCoException(
274
+ "No known zone in household {}; pass a zone to update()".format(
275
+ self.household_id
276
+ )
277
+ )
278
+
197
279
  def update_skipped(self, zone):
198
280
  """Update the zone for any skipped alarms and move to main list if possible."""
199
281
  for alarm_id, alarm in list(self.alarms_skipped.items()):
@@ -314,6 +396,8 @@ class Alarm:
314
396
  self.include_linked_zones = include_linked_zones
315
397
  self.room_uuid = room_uuid
316
398
  self._alarm_id = None
399
+ # The `Alarms` instance that caches this alarm, set when it is cached.
400
+ self._alarms = None
317
401
 
318
402
  def __repr__(self):
319
403
  middle = str(self.start_time.strftime(TIME_FORMAT))
@@ -417,14 +501,17 @@ class Alarm:
417
501
  ("IncludeLinkedZones", "1" if self.include_linked_zones else "0"),
418
502
  ]
419
503
  if self.alarm_id is None:
504
+ # Resolve the cache before creating the alarm, so a failed lookup
505
+ # cannot leave an alarm on the speaker that is missing from it.
506
+ alarms = self._owning_alarms()
420
507
  response = self.zone.alarmClock.CreateAlarm(args)
421
508
  self._alarm_id = response["AssignedID"]
422
- alarms = Alarms()
423
509
  if alarms.last_id == int(self.alarm_id) - 1:
424
510
  alarms.last_alarm_list_version = "{}:{}".format(
425
511
  alarms.last_uid, self.alarm_id
426
512
  )
427
513
  alarms.alarms[self.alarm_id] = self
514
+ self._alarms = alarms
428
515
  else:
429
516
  # The alarm has been saved before. Update it instead.
430
517
  args.insert(0, ("ID", self.alarm_id))
@@ -440,12 +527,29 @@ class Alarm:
440
527
  Returns:
441
528
  bool: If the removal was sucessful.
442
529
  """
530
+ alarms = self._owning_alarms()
443
531
  result = self.zone.alarmClock.DestroyAlarm([("ID", self.alarm_id)])
444
- alarms = Alarms()
445
532
  alarms.alarms.pop(self.alarm_id, None)
446
533
  self._alarm_id = None
447
534
  return result
448
535
 
536
+ def _owning_alarms(self):
537
+ """Return the `Alarms` instance that caches this alarm.
538
+
539
+ This is the instance that cached it, if that instance is still the
540
+ current singleton. It is not after `soco_reset`, which clears the
541
+ singletons. Otherwise, see `_alarms_for_zone`.
542
+ """
543
+ alarms = self._alarms
544
+ if alarms is not None:
545
+ # pylint: disable=protected-access
546
+ instances = _ArgsSingleton._instances.get(Alarms._class_group, {})
547
+ key = Alarms._singleton_key(alarms.household_id)
548
+ current = instances.get(key)
549
+ if current is alarms:
550
+ return current
551
+ return _alarms_for_zone(self.zone)
552
+
449
553
  @property
450
554
  def alarm_id(self):
451
555
  """`str`: The ID of the alarm, or `None`."""
@@ -512,6 +616,22 @@ class Alarm:
512
616
  )
513
617
 
514
618
 
619
+ def _alarms_for_zone(zone):
620
+ """Return the `Alarms` instance to cache a new alarm for ``zone``.
621
+
622
+ This is the instance for the zone's household if one has been created,
623
+ otherwise the shared `Alarms()` instance.
624
+ """
625
+ # pylint: disable=protected-access
626
+ instances = _ArgsSingleton._instances.get(Alarms._class_group, {})
627
+ # Only query the household ID when household instances are in use.
628
+ if any(key != () for key in list(instances)):
629
+ household_alarms = instances.get((zone.household_id,))
630
+ if household_alarms is not None:
631
+ return household_alarms
632
+ return Alarms()
633
+
634
+
515
635
  def get_alarms(zone=None):
516
636
  """Get a set of all alarms known to the Sonos system.
517
637
 
@@ -521,6 +641,10 @@ def get_alarms(zone=None):
521
641
 
522
642
  Returns:
523
643
  set: A set of `Alarm` instances
644
+
645
+ Note:
646
+ Uses the shared `Alarms()` instance. With more than one Sonos
647
+ household, use ``Alarms(household_id).update(zone)`` instead.
524
648
  """
525
649
  alarms = Alarms()
526
650
  alarms.update(zone)
@@ -537,6 +661,11 @@ def remove_alarm_by_id(zone, alarm_id):
537
661
 
538
662
  Returns:
539
663
  bool: `True` if the alarm is found and removed, `False` otherwise.
664
+
665
+ Note:
666
+ Uses the shared `Alarms()` instance. With more than one Sonos
667
+ household, use ``Alarms(household_id)`` to find the alarm and call
668
+ `Alarm.remove` instead.
540
669
  """
541
670
  alarms = Alarms()
542
671
  alarms.update(zone)
@@ -85,6 +85,7 @@ from .events_base import Event # noqa: F401
85
85
  from .events_base import ( # noqa: E402
86
86
  get_listen_ip,
87
87
  parse_event_xml,
88
+ redact_event_content,
88
89
  EventNotifyHandlerBase,
89
90
  EventListenerBase,
90
91
  SubscriptionBase,
@@ -123,7 +124,7 @@ class EventNotifyHandler(EventNotifyHandlerBase):
123
124
  timestamp = time.time()
124
125
  service = subscription.service
125
126
  self.log_event(seq, service.service_id, timestamp)
126
- log.debug("Event content: %s", content)
127
+ log.debug("Event content: %s", redact_event_content(content))
127
128
  if "x-sonos-http" in content:
128
129
  # parse_event_xml will generate I/O if
129
130
  # x-sonos-http is in the content
@@ -10,6 +10,7 @@
10
10
  import atexit
11
11
  from functools import lru_cache
12
12
  import logging
13
+ import re
13
14
  import socket
14
15
  import time
15
16
  import threading
@@ -24,6 +25,37 @@ from .xml import XML
24
25
 
25
26
  log = logging.getLogger(__name__) # pylint: disable=C0103
26
27
 
28
+ # Evented variables whose values contain credentials. The
29
+ # ThirdPartyMediaServersX blob holds the household's music service accounts,
30
+ # including access and refresh tokens. It is encrypted, but it has been
31
+ # reported that it can be decrypted using information available on the LAN.
32
+ # See https://github.com/SoCo/SoCo/issues/1009
33
+ REDACTED_VARIABLES = ("ThirdPartyMediaServersX",)
34
+ REDACTED_VALUE = "[redacted]"
35
+
36
+ _REDACT_PATTERN = "(<({tags})>).*?(</\\2>)".format(tags="|".join(REDACTED_VARIABLES))
37
+ _REDACT_RE_STR = re.compile(_REDACT_PATTERN, re.DOTALL)
38
+ _REDACT_RE_BYTES = re.compile(_REDACT_PATTERN.encode("ascii"), re.DOTALL)
39
+
40
+
41
+ def redact_event_content(content):
42
+ """Redact the values of credential-bearing variables in a raw event body.
43
+
44
+ Used so that the raw event body can be logged safely.
45
+
46
+ Args:
47
+ content (str or bytes): the raw body of a UPnP event.
48
+
49
+ Returns:
50
+ str or bytes: the content, of the same type as was passed in, with
51
+ the values of `REDACTED_VARIABLES` replaced by ``[redacted]``.
52
+ """
53
+ if isinstance(content, bytes):
54
+ return _REDACT_RE_BYTES.sub(
55
+ b"\\1" + REDACTED_VALUE.encode("ascii") + b"\\3", content
56
+ )
57
+ return _REDACT_RE_STR.sub("\\1" + REDACTED_VALUE + "\\3", content)
58
+
27
59
 
28
60
  @lru_cache()
29
61
  def parse_event_xml(xml_event):
@@ -121,6 +153,8 @@ def parse_event_xml(xml_event):
121
153
  result[tag][channel] = value
122
154
  else:
123
155
  result[tag] = value
156
+ elif variable.tag in REDACTED_VARIABLES:
157
+ result[camel_to_underscore(variable.tag)] = REDACTED_VALUE
124
158
  else:
125
159
  result[camel_to_underscore(variable.tag)] = variable.text
126
160
  return result
@@ -229,7 +263,7 @@ class EventNotifyHandlerBase:
229
263
  if subscription:
230
264
  service = subscription.service
231
265
  self.log_event(seq, service.service_id, timestamp)
232
- log.debug("Event content: %s", content)
266
+ log.debug("Event content: %s", redact_event_content(content))
233
267
  variables = parse_event_xml(content)
234
268
  # Build the Event object
235
269
  event = Event(sid, seq, service, timestamp, variables)
@@ -69,12 +69,16 @@ class Account:
69
69
  # It is likely that the same information is available over UPnP as well
70
70
  # via a call to
71
71
  # systemProperties.GetStringX([('VariableName','R_SvcAccounts')]))
72
- # This returns an encrypted string, and, so far, we cannot decrypt it
72
+ # This returns an encrypted string. It has been reported that the
73
+ # related ThirdPartyMediaServersX value (which contains music service
74
+ # account tokens) can be decrypted; see
75
+ # https://github.com/SoCo/SoCo/issues/1009
73
76
  device = soco or discovery.any_soco()
74
77
  log.debug("Fetching account data from %s", device)
75
78
  settings_url = device.base_url + "/status/accounts"
76
79
  result = requests.get(settings_url, timeout=config.REQUEST_TIMEOUT).content
77
- log.debug("Account data: %s", result)
80
+ # Don't log the content: it may contain account credentials
81
+ log.debug("Account data: %d bytes", len(result))
78
82
  return result
79
83
 
80
84
  @classmethod
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: soco
3
- Version: 0.32.2
3
+ Version: 0.32.4
4
4
  Summary: SoCo (Sonos Controller) is a simple library to control Sonos speakers.
5
5
  Author-email: The SoCo-Team <python-soco@googlegroups.com>
6
6
  License-Expression: MIT