From dfbef058bb461e348369fdb20e7d2a86b1bb375d Mon Sep 17 00:00:00 2001 From: Eric Munson Date: Sun, 28 Jan 2024 16:46:48 -0500 Subject: [PATCH] Subsonic: Support track enumeration on older Navidrome servers (#1037) --- .../providers/opensubsonic/sonic_provider.py | 31 +++++++++++++------ 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/music_assistant/server/providers/opensubsonic/sonic_provider.py b/music_assistant/server/providers/opensubsonic/sonic_provider.py index 00a7bc8a0..0f862cd57 100644 --- a/music_assistant/server/providers/opensubsonic/sonic_provider.py +++ b/music_assistant/server/providers/opensubsonic/sonic_provider.py @@ -453,23 +453,36 @@ async def get_library_tracks(self) -> AsyncGenerator[Track | AlbumTrack, None]: 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,