Create artist.py
This commit is contained in:
parent
1ee7b65d71
commit
e91f605a7a
|
|
@ -0,0 +1,18 @@
|
|||
class Artist:
|
||||
"""The base class for a Spotify artist"""
|
||||
|
||||
def __init__(self, data: dict, tracks: list) -> None:
|
||||
self.name = f"Top tracks for {data['name']}"
|
||||
self.genres = ", ".join(genre for genre in data["genres"])
|
||||
self.followers = data["followers"]["total"]
|
||||
self.image = data["images"][0]["url"]
|
||||
self.tracks = tracks
|
||||
self.total_tracks = len(tracks)
|
||||
self.id = data["id"]
|
||||
self.uri = data["external_urls"]["spotify"]
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return (
|
||||
f"<Pomice.ext.spotify.Artist name={self.name} id={self.id} "
|
||||
f"total_tracks={self.total_tracks} tracks={self.tracks}>"
|
||||
)
|
||||
Loading…
Reference in New Issue