From cbaa67d90f59d1e136a41395f7f47fef7cef5191 Mon Sep 17 00:00:00 2001 From: vveeps <54472340+vveeps@users.noreply.github.com> Date: Wed, 6 Oct 2021 23:57:34 +0300 Subject: [PATCH 1/2] add playlist thumbnail and uri --- pomice/node.py | 8 ++++++-- pomice/objects.py | 17 ++++++++++++++++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/pomice/node.py b/pomice/node.py index ee066c8..c9cdb8a 100644 --- a/pomice/node.py +++ b/pomice/node.py @@ -286,7 +286,9 @@ class Node: playlist_info={"name": results.name, "selectedTrack": tracks[0]}, tracks=tracks, ctx=ctx, - spotify=True + spotify=True, + thumbnail=results.images[0].url, + uri=results.url, ) except SpotifyException: @@ -324,7 +326,9 @@ class Node: playlist_info={"name": results.name, "selectedTrack": tracks[0]}, tracks=tracks, ctx=ctx, - spotify=True + spotify=True, + thumbnail=results.images[0].url, + uri=results.url, ) except SpotifyException: diff --git a/pomice/objects.py b/pomice/objects.py index 49f1c87..6707df7 100644 --- a/pomice/objects.py +++ b/pomice/objects.py @@ -57,7 +57,9 @@ class Playlist: playlist_info: dict, tracks: list, ctx: Optional[commands.Context] = None, - spotify: bool = False + spotify: bool = False, + thumbnail: Optional[str] = None, + uri: Optional[str] = None, ): self.playlist_info = playlist_info self.tracks_raw = tracks @@ -66,6 +68,9 @@ class Playlist: self.name = playlist_info.get("name") self.selected_track = playlist_info.get("selectedTrack") + self.thumbnail = thumbnail + self.uri = uri + if self.spotify: self.tracks = tracks else: @@ -81,3 +86,13 @@ class Playlist: def __repr__(self): return f"" + + @property + def uri(self) -> Optional[str]: + """Spotify album/playlist URI, or None if not a Spotify object.""" + return self.uri + + @property + def thumbnail(self) -> Optional[str]: + """Spotify album/playlist thumbnail, or None if not a Spotify object.""" + return self.thumbnail From 4d4e5bfb518ef05dfc0349161eaeea30319886cd Mon Sep 17 00:00:00 2001 From: vveeps <54472340+vveeps@users.noreply.github.com> Date: Thu, 7 Oct 2021 00:06:21 +0300 Subject: [PATCH 2/2] bugfix --- pomice/objects.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pomice/objects.py b/pomice/objects.py index 6707df7..d103691 100644 --- a/pomice/objects.py +++ b/pomice/objects.py @@ -68,8 +68,8 @@ class Playlist: self.name = playlist_info.get("name") self.selected_track = playlist_info.get("selectedTrack") - self.thumbnail = thumbnail - self.uri = uri + self._thumbnail = thumbnail + self._uri = uri if self.spotify: self.tracks = tracks @@ -90,9 +90,9 @@ class Playlist: @property def uri(self) -> Optional[str]: """Spotify album/playlist URI, or None if not a Spotify object.""" - return self.uri + return self._uri @property def thumbnail(self) -> Optional[str]: """Spotify album/playlist thumbnail, or None if not a Spotify object.""" - return self.thumbnail + return self._thumbnail