Fix artist albums without artist
authorMarvin Schenkel <marvinschenkel@gmail.com>
Fri, 8 Jul 2022 20:02:21 +0000 (22:02 +0200)
committerMarvin Schenkel <marvinschenkel@gmail.com>
Fri, 8 Jul 2022 20:02:21 +0000 (22:02 +0200)
music_assistant/music_providers/ytmusic/helpers.py
music_assistant/music_providers/ytmusic/ytmusic.py

index 97a4478679fb36ddd612f2732b169dfa6717febb..3f6b6f41e101f6714decec7e636fa201c52d9bc0 100644 (file)
@@ -85,7 +85,7 @@ async def get_library_artists(headers: Dict[str, str]) -> Dict[str, str]:
 
     def _get_library_artists():
         ytm = ytmusicapi.YTMusic(auth=json.dumps(headers))
-        artists = ytm.get_library_artists()
+        artists = ytm.get_library_artists(limit=999)
         # Sync properties with uniformal artist object
         for artist in artists:
             artist["id"] = artist["browseId"]
@@ -103,7 +103,7 @@ async def get_library_albums(headers: Dict[str, str]) -> Dict[str, str]:
 
     def _get_library_albums():
         ytm = ytmusicapi.YTMusic(auth=json.dumps(headers))
-        return ytm.get_library_albums()
+        return ytm.get_library_albums(limit=999)
 
     loop = asyncio.get_running_loop()
     return await loop.run_in_executor(None, _get_library_albums)
@@ -114,7 +114,7 @@ async def get_library_playlists(headers: Dict[str, str]) -> Dict[str, str]:
 
     def _get_library_playlists():
         ytm = ytmusicapi.YTMusic(auth=json.dumps(headers))
-        playlists = ytm.get_library_playlists()
+        playlists = ytm.get_library_playlists(limit=999)
         # Sync properties with uniformal playlist object
         for playlist in playlists:
             playlist["id"] = playlist["playlistId"]
@@ -130,7 +130,7 @@ async def get_library_tracks(headers: Dict[str, str]) -> Dict[str, str]:
 
     def _get_library_tracks():
         ytm = ytmusicapi.YTMusic(auth=json.dumps(headers))
-        tracks = ytm.get_library_songs()
+        tracks = ytm.get_library_songs(limit=999)
         return tracks
 
     loop = asyncio.get_running_loop()
index f303d34f0486f0cf53beb7970981986632ff784e..ae0b482c9c507650f98bb92291d8000adb0f774f 100644 (file)
@@ -207,10 +207,14 @@ class YoutubeMusicProvider(MusicProvider):
         """Get a list of albums for the given artist."""
         artist_obj = await get_artist(prov_artist_id=prov_artist_id)
         if "albums" in artist_obj and "results" in artist_obj["albums"]:
-            return [
-                await self._parse_album(album, album["browseId"])
-                for album in artist_obj["albums"]["results"]
-            ]
+            albums = []
+            for album_obj in artist_obj["albums"]["results"]:
+                if "artists" not in album_obj:
+                    album_obj["artists"] = [
+                        {"id": artist_obj["channelId"], "name": artist_obj["name"]}
+                    ]
+                albums.append(await self._parse_album(album_obj, album_obj["browseId"]))
+            return albums
         return []
 
     async def get_artist_toptracks(self, prov_artist_id) -> List[Track]: