added basic image link parsing

This commit is contained in:
aj 2020-03-07 21:55:55 +00:00
parent 7f60f65403
commit 7119fa481e
2 changed files with 9 additions and 2 deletions

View File

@ -130,7 +130,8 @@ class SpotifyPlaylist(Playlist):
collaborative: bool = None, collaborative: bool = None,
public: bool = None, public: bool = None,
ext_spotify: str = None): ext_spotify: str = None,
images: List[str] = None):
super().__init__(name=name, description=description) super().__init__(name=name, description=description)
@ -148,6 +149,7 @@ class SpotifyPlaylist(Playlist):
self.collaborative = collaborative self.collaborative = collaborative
self.public = public self.public = public
self.ext_spotify = ext_spotify self.ext_spotify = ext_spotify
self.images = images
def __str__(self): def __str__(self):

View File

@ -1275,6 +1275,10 @@ class Network:
public = playlist_dict.get('public', None) public = playlist_dict.get('public', None)
uri = playlist_dict.get('uri', 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, return SpotifyPlaylist(uri=uri,
name=name, name=name,
owner=owner, owner=owner,
@ -1282,7 +1286,8 @@ class Network:
href=href, href=href,
collaborative=collaborative, collaborative=collaborative,
public=public, public=public,
ext_spotify=ext_spotify) ext_spotify=ext_spotify,
images=images)
@staticmethod @staticmethod
def parse_context(context_dict) -> Context: def parse_context(context_dict) -> Context: