Subsonic: Support track enumeration on older Navidrome servers (#1037)
authorEric Munson <eric@munsonfam.org>
Sun, 28 Jan 2024 21:46:48 +0000 (16:46 -0500)
committerGitHub <noreply@github.com>
Sun, 28 Jan 2024 21:46:48 +0000 (22:46 +0100)
music_assistant/server/providers/opensubsonic/sonic_provider.py

index 00a7bc8a09c326ce045fae8b0cd7930f76bd4d23..0f862cd5767272867011cc815f4087b5f17b583f 100644 (file)
@@ -453,23 +453,36 @@ class OpenSonicProvider(MusicProvider):
 
         Note the lack of item count on this method.
         """
+        query = ""
         offset = 0
         count = 500
-        results = await self._run_async(
-            self._conn.search3,
-            query="",
-            artistCount=0,
-            albumCount=0,
-            songOffset=offset,
-            songCount=count,
-        )
+        try:
+            results = await self._run_async(
+                self._conn.search3,
+                query=query,
+                artistCount=0,
+                albumCount=0,
+                songOffset=offset,
+                songCount=count,
+            )
+        except ParameterError:
+            # Older Navidrome does not accept an empty string and requires the empty quotes
+            query = '""'
+            results = await self._run_async(
+                self._conn.search3,
+                query=query,
+                artistCount=0,
+                albumCount=0,
+                songOffset=offset,
+                songCount=count,
+            )
         while results["songs"]:
             for entry in results["songs"]:
                 yield self._parse_track(entry)
             offset += count
             results = await self._run_async(
                 self._conn.search3,
-                query="",
+                query=query,
                 artistCount=0,
                 albumCount=0,
                 songOffset=offset,