Fix: Only 50 library artists retrieved from Spotify (#325)
authorMarcel van der Veldt <m.vanderveldt@outlook.com>
Wed, 18 May 2022 22:39:53 +0000 (00:39 +0200)
committerGitHub <noreply@github.com>
Wed, 18 May 2022 22:39:53 +0000 (00:39 +0200)
* Fix only 50 artists spotify

music_assistant/controllers/music/providers/spotify.py
music_assistant/helpers/audio.py

index fe0c390556e7b19c8ac60bef281f098fa4672dbb..ab5a9db2f89f70401cf83c92e85414360d84b567 100644 (file)
@@ -124,12 +124,19 @@ class SpotifyProvider(MusicProvider):
 
     async def get_library_artists(self) -> AsyncGenerator[Artist, None]:
         """Retrieve library artists from spotify."""
-        spotify_artists = await self._get_data(
-            "me/following", type="artist", limit=50, skip_cache=True
-        )
-        for item in spotify_artists["artists"]["items"]:
-            if item and item["id"]:
-                yield await self._parse_artist(item)
+        endpoint = "me/following"
+        while True:
+            spotify_artists = await self._get_data(
+                endpoint, type="artist", limit=50, skip_cache=True
+            )
+            for item in spotify_artists["artists"]["items"]:
+                if item and item["id"]:
+                    yield await self._parse_artist(item)
+            if spotify_artists["artists"]["next"]:
+                endpoint = spotify_artists["artists"]["next"]
+                endpoint = endpoint.replace("https://api.spotify.com/v1/", "")
+            else:
+                break
 
     async def get_library_albums(self) -> AsyncGenerator[Album, None]:
         """Retrieve library albums from the provider."""
index 0d5c0836294084c4177948aa668ff92fff6589fd..3251d6f235527de3c3078b7ae538a0047b823649 100644 (file)
@@ -256,7 +256,7 @@ async def get_gain_correct(
     """Get gain correction for given queue / track combination."""
     queue = mass.players.get_player_queue(queue_id)
     if not queue or not queue.settings.volume_normalization_enabled:
-        return 0
+        return (0, 0)
     target_gain = queue.settings.volume_normalization_target
     track_loudness = await mass.music.get_track_loudness(item_id, provider)
     if track_loudness is None: