From 7119fa481e0c76e3949d5974264ceaac73108878 Mon Sep 17 00:00:00 2001 From: aj Date: Sat, 7 Mar 2020 21:55:55 +0000 Subject: [PATCH] added basic image link parsing --- spotframework/model/playlist.py | 4 +++- spotframework/net/network.py | 7 ++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/spotframework/model/playlist.py b/spotframework/model/playlist.py index 4d4678c..8b7aebd 100644 --- a/spotframework/model/playlist.py +++ b/spotframework/model/playlist.py @@ -130,7 +130,8 @@ class SpotifyPlaylist(Playlist): collaborative: bool = None, public: bool = None, - ext_spotify: str = None): + ext_spotify: str = None, + images: List[str] = None): super().__init__(name=name, description=description) @@ -148,6 +149,7 @@ class SpotifyPlaylist(Playlist): self.collaborative = collaborative self.public = public self.ext_spotify = ext_spotify + self.images = images def __str__(self): diff --git a/spotframework/net/network.py b/spotframework/net/network.py index f7bf3ca..4e797e8 100644 --- a/spotframework/net/network.py +++ b/spotframework/net/network.py @@ -1275,6 +1275,10 @@ class Network: public = playlist_dict.get('public', None) uri = playlist_dict.get('uri', None) + images = playlist_dict.get('images', []) + images.sort(key=lambda x: x.get('height', 0)) + images = [i.get('url') for i in images] + return SpotifyPlaylist(uri=uri, name=name, owner=owner, @@ -1282,7 +1286,8 @@ class Network: href=href, collaborative=collaborative, public=public, - ext_spotify=ext_spotify) + ext_spotify=ext_spotify, + images=images) @staticmethod def parse_context(context_dict) -> Context: