From 8080d858f85b0b0b2afcbf2a5d58388130a663c3 Mon Sep 17 00:00:00 2001 From: codey Date: Sun, 16 Feb 2025 06:36:31 -0500 Subject: [PATCH] bugfix get_artist_albums --- endpoints/lastfm.py | 5 +++++ lastfm_wrapper.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/endpoints/lastfm.py b/endpoints/lastfm.py index 4b268b4..e8bdb75 100644 --- a/endpoints/lastfm.py +++ b/endpoints/lastfm.py @@ -68,6 +68,11 @@ class LastFM(FastAPI): }) album_result: Union[dict, list[dict]] = await self.lastfm.get_artist_albums(artist=artist) + if isinstance(album_result, dict): + return JSONResponse(status_code=500, content={ + 'err': True, + 'errorText': 'General failure.', + }) album_result_out: list = [] seen_release_titles: list = [] diff --git a/lastfm_wrapper.py b/lastfm_wrapper.py index fba1130..ccdda5c 100644 --- a/lastfm_wrapper.py +++ b/lastfm_wrapper.py @@ -129,7 +129,7 @@ class LastFM: timeout=ClientTimeout(connect=3, sock_read=8)) as request: request.raise_for_status() json_data: dict = await request.json() - data: dict = data.get('topalbums', None).get('album') + data: dict = json_data.get('topalbums', None).get('album') ret_obj: list = [ { 'title': item.get('name')