Skip to content

Commit 2aaee9a

Browse files
authored
Add support for fetching albums of an artist (#315)
1 parent 01393c8 commit 2aaee9a

File tree

4 files changed

+5096
-0
lines changed

4 files changed

+5096
-0
lines changed

src/spotifyaio/spotify.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
Episode,
2727
FeaturedPlaylistResponse,
2828
NewReleasesResponse,
29+
NewReleasesResponseInner,
2930
PlaybackState,
3031
PlayedTrack,
3132
PlayedTrackResponse,
@@ -155,6 +156,13 @@ async def get_artist(self, artist_id: str) -> Artist:
155156
response = await self._get(f"v1/artists/{identifier}")
156157
return Artist.from_json(response)
157158

159+
async def get_artist_albums(self, artist_id: str) -> list[SimplifiedAlbum]:
160+
"""Get artist albums."""
161+
params: dict[str, Any] = {"limit": 48}
162+
identifier = artist_id.split(":")[-1]
163+
response = await self._get(f"v1/artists/{identifier}/albums", params=params)
164+
return NewReleasesResponseInner.from_json(response).items
165+
158166
async def get_playback(self) -> PlaybackState | None:
159167
"""Get playback state."""
160168
response = await self._get(

0 commit comments

Comments
 (0)