From f5d953d9ce6f844d7107e1b946bf2ef0558aca32 Mon Sep 17 00:00:00 2001 From: Lars Noack Date: Tue, 21 May 2024 16:34:04 +0200 Subject: [PATCH] feat: theoretically fetching feature songs --- music_kraken/pages/genius.py | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/music_kraken/pages/genius.py b/music_kraken/pages/genius.py index f37715b..15f1ac2 100644 --- a/music_kraken/pages/genius.py +++ b/music_kraken/pages/genius.py @@ -182,7 +182,7 @@ class Genius(Page): return results def fetch_artist(self, source: Source, stop_at_level: int = 1) -> Artist: - artist = Artist() + artist: Artist = Artist() # https://genius.com/api/artists/24527/albums?page=1 r = self.connection.get(source.url, name=source.url) @@ -200,7 +200,26 @@ class Genius(Page): artist = self.parse_api_object(data.get("artist", {})) for e in data.get("artist_albums", []): - artist.album_collection.append(self.parse_api_object(e)) + r = self.parse_api_object(e) + if not isinstance(r, Album): + continue + + artist.album_collection.append(r) + + for e in data.get("artist_songs", []): + r = self.parse_api_object(e) + if not isinstance(r, Song): + continue + + """ + TODO + fetch the album for these songs, because the api doesn't + return them + """ + + artist.album_collection.extend(r.album_collection) + + artist.source_collection.append(source) return artist