From 0ed029b2a34fcfa4a1e194520e32c40891c0a64c Mon Sep 17 00:00:00 2001 From: Marvin Schenkel Date: Fri, 31 Mar 2023 20:38:00 +0200 Subject: [PATCH] Fix search of artist in YTM. (#599) --- music_assistant/server/providers/ytmusic/helpers.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/music_assistant/server/providers/ytmusic/helpers.py b/music_assistant/server/providers/ytmusic/helpers.py index 6f6d8c25..23b0f177 100644 --- a/music_assistant/server/providers/ytmusic/helpers.py +++ b/music_assistant/server/providers/ytmusic/helpers.py @@ -243,10 +243,15 @@ async def search(query: str, ytm_filter: str = None, limit: int = 20) -> list[di # Sync result properties with uniformal objects for result in results: if result["resultType"] == "artist": - result["id"] = result["browseId"] - result["name"] = result["artist"] - del result["browseId"] - del result["artist"] + if "artists" in result and len(result["artists"]) > 0: + result["id"] = result["artists"][0]["id"] + result["name"] = result["artists"][0]["name"] + del result["artists"] + else: + result["id"] = result["browseId"] + result["name"] = result["artist"] + del result["browseId"] + del result["artist"] elif result["resultType"] == "playlist": if "playlistId" in result: result["id"] = result["playlistId"] -- 2.34.1