From 9aabe40d8e23fed27e4c3cb930fa609726ff80ee Mon Sep 17 00:00:00 2001 From: codey Date: Wed, 14 Aug 2024 07:43:55 -0400 Subject: [PATCH] Resolves #9 --- endpoints/lastfm.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/endpoints/lastfm.py b/endpoints/lastfm.py index a5e184b..893cb66 100644 --- a/endpoints/lastfm.py +++ b/endpoints/lastfm.py @@ -48,6 +48,7 @@ class LastFM(FastAPI): "get_artist_by_name": self.artist_by_name_handler, "get_artist_albums": self.artist_album_handler, "get_release": self.release_detail_handler, + "get_album_tracklist": self.release_tracklist_handler, #tbd } @@ -133,3 +134,27 @@ class LastFM(FastAPI): 'success': True, 'result': ret_obj } + + async def release_tracklist_handler(self, data: ValidAlbumDetailRequest): + """ + /get_release_tracklist/ + Get track list for a particular release by an artist + """ + artist = data.a.strip() + release = data.a2.strip() + + if not artist or not release: + return { + 'err': True, + 'errorText': 'Invalid request' + } + + tracklist_result = await self.lastfm.get_album_tracklist(artist=artist, album=release) + return { + 'success': True, + 'id': tracklist_result.get('id'), + 'artists': tracklist_result.get('artists'), + 'title': tracklist_result.get('title'), + 'summary': tracklist_result.get('summary'), + 'tracks': tracklist_result.get('tracks') + }