Skip to content

Commit

Permalink
Subsonic: Support track enumeration on older Navidrome servers (#1037)
Browse files Browse the repository at this point in the history
  • Loading branch information
khers authored Jan 28, 2024
1 parent 985e4e2 commit dfbef05
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions music_assistant/server/providers/opensubsonic/sonic_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit dfbef05

Please sign in to comment.