From d447b103803b8a95e4833d0b2f31d9c6ad746ab7 Mon Sep 17 00:00:00 2001 From: Kur01234 Date: Wed, 5 Jun 2024 13:33:18 +0200 Subject: [PATCH] feat: youtube music album and artist artwork --- music_kraken/pages/youtube_music/youtube_music.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/music_kraken/pages/youtube_music/youtube_music.py b/music_kraken/pages/youtube_music/youtube_music.py index 08e2207..334bf15 100644 --- a/music_kraken/pages/youtube_music/youtube_music.py +++ b/music_kraken/pages/youtube_music/youtube_music.py @@ -438,6 +438,7 @@ class YoutubeMusic(SuperYouTube): data: dict = r.json() header = data.get("header", {}) musicDetailHeaderRenderer = header.get("musicDetailHeaderRenderer", {}) + musicImmersiveHeaderRenderer = header.get("musicImmersiveHeaderRenderer", {}) title_runs: List[dict] = musicDetailHeaderRenderer.get("title", {}).get("runs", []) subtitle_runs: List[dict] = musicDetailHeaderRenderer.get("subtitle", {}).get("runs", []) @@ -450,6 +451,11 @@ class YoutubeMusic(SuperYouTube): renderer_list = r.json().get("contents", {}).get("singleColumnBrowseResultsRenderer", {}).get("tabs", [{}])[ 0].get("tabRenderer", {}).get("content", {}).get("sectionListRenderer", {}).get("contents", []) + # fetch artist artwork + artist_thumbnails = musicImmersiveHeaderRenderer.get("thumbnail", {}).get("musicThumbnailRenderer", {}).get("thumbnail", {}).get("thumbnails", {}) + for artist_thumbnail in artist_thumbnails: + artist.artwork.append(**artist_thumbnail) + if DEBUG: for i, content in enumerate(renderer_list): dump_to_file(f"{i}-artists-renderer.json", json.dumps(content), is_json=True, exit_after_dump=False) @@ -496,7 +502,12 @@ class YoutubeMusic(SuperYouTube): # album details header = data.get("header", {}) musicDetailHeaderRenderer = header.get("musicDetailHeaderRenderer", {}) - + + # album artwork + album_thumbnails = musicDetailHeaderRenderer.get("thumbnail", {}).get("croppedSquareThumbnailRenderer", {}).get("thumbnail", {}).get("thumbnails", {}) + for album_thumbnail in album_thumbnails: + album.artwork.append(**album_thumbnail) + title_runs: List[dict] = musicDetailHeaderRenderer.get("title", {}).get("runs", []) subtitle_runs: List[dict] = musicDetailHeaderRenderer.get("subtitle", {}).get("runs", [])