fix spotify url issue and handle local tracks properly
This commit is contained in:
parent
ec02cbe146
commit
81bf0b9756
|
|
@ -11,7 +11,7 @@ class Album:
|
|||
self.total_tracks = data["total_tracks"]
|
||||
self.id = data["id"]
|
||||
self.image = data["images"][0]["url"]
|
||||
self.uri = f"https://open.spotify.com/album/{self.id}"
|
||||
self.uri = data["external_urls"]["spotify"]
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ class Playlist:
|
|||
self.total_tracks = data["tracks"]["total"]
|
||||
self.id = data["id"]
|
||||
self.image = data["images"][0]["url"]
|
||||
self.uri = f"https://open.spotify.com/playlist/{self.id}"
|
||||
self.uri = data["external_urls"]["spotify"]
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -7,12 +7,15 @@ class Track:
|
|||
self.length = data["duration_ms"]
|
||||
self.id = data["id"]
|
||||
|
||||
if data.get("album") and data["album"]["images"]:
|
||||
if data.get("album") and data["album"].get("images"):
|
||||
self.image = data["album"]["images"][0]["url"]
|
||||
else:
|
||||
self.image = None
|
||||
|
||||
self.uri = f"https://open.spotify.com/track/{self.id}"
|
||||
if data["is_local"]:
|
||||
self.uri = None
|
||||
else:
|
||||
self.uri = data["external_urls"]["spotify"]
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return (
|
||||
|
|
|
|||
Loading…
Reference in New Issue