Fix playback of local files on Sonos players (#702)
authorMarcel van der Veldt <m.vanderveldt@outlook.com>
Thu, 8 Jun 2023 23:47:48 +0000 (01:47 +0200)
committerGitHub <noreply@github.com>
Thu, 8 Jun 2023 23:47:48 +0000 (01:47 +0200)
* improve sonos discovery

* fix crash on image url

music_assistant/server/helpers/didl_lite.py
music_assistant/server/providers/sonos/__init__.py

index c35c875a7fdcad244344aaf56fdaf403ba1d30cd..744e39f632a655e1032bb0eabb8172a81fa2c7c8 100644 (file)
@@ -71,7 +71,7 @@ def create_didl_metadata(
         f"<upnp:duration>{queue_item.duration}</upnp:duration>"
         "<upnp:playlistTitle>Music Assistant</upnp:playlistTitle>"
         f"<dc:queueItemId>{queue_item.queue_item_id}</dc:queueItemId>"
-        f"<upnp:albumArtURI>{image_url}</upnp:albumArtURI>"
+        f"<upnp:albumArtURI>{_escape_str(image_url)}</upnp:albumArtURI>"
         f"<upnp:class>{item_class}</upnp:class>"
         f"<upnp:mimeType>audio/{ext}</upnp:mimeType>"
         f'<res duration="{duration_str}" protocolInfo="http-get:*:audio/{ext}:DLNA.ORG_OP=00;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=0d500000000000000000000000000000">{url}</res>'
index ab4c0d99174ae48f9825f01866b6159f4ad6dc5d..ccd3e57c8b06736f31ad496d617aecc9ecf1d16d 100644 (file)
@@ -395,7 +395,9 @@ class SonosPlayerProvider(PlayerProvider):
         try:
             self._discovery_running = True
             self.logger.debug("Sonos discovery started...")
-            discovered_devices: set[soco.SoCo] = await asyncio.to_thread(soco.discover, 60)
+            discovered_devices: set[soco.SoCo] = await asyncio.to_thread(
+                soco.discover, 120, allow_network_scan=True
+            )
             if discovered_devices is None:
                 discovered_devices = set()
             new_device_ids = {item.uid for item in discovered_devices}