This commit is contained in:
codey 2024-08-14 07:43:55 -04:00
parent 2f4daca71c
commit 9aabe40d8e

View File

@ -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')
}