diff --git a/deezer/__init__.py b/deezer/__init__.py index 644f837..b2f4c9e 100644 --- a/deezer/__init__.py +++ b/deezer/__init__.py @@ -4,7 +4,7 @@ from deezer.gw import GW from deezer.api import API import json -__version__ = "0.0.7" +__version__ = "0.0.8" class TrackFormats(): """Number associtation for formats""" diff --git a/deezer/gw.py b/deezer/gw.py index 9f4cd75..eb8cf4a 100644 --- a/deezer/gw.py +++ b/deezer/gw.py @@ -283,10 +283,12 @@ class GW: return body def get_user_playlists(self, user_id): - data = self.get_user_profile_page(user_id, 'playlists', limit=-1)['TAB']['playlists']['data'] + user_profile_page = self.get_user_profile_page(user_id, 'playlists', limit=-1) + blog_name = user_profile_page['DATA']['USER'].get('BLOG_NAME', "Unkown") + data = user_profile_page['TAB']['playlists']['data'] result = [] for playlist in data: - result.append(map_user_playlist(playlist)) + result.append(map_user_playlist(playlist, blog_name)) return result def get_user_albums(self, user_id): diff --git a/deezer/utils.py b/deezer/utils.py index 48b8363..0af6816 100644 --- a/deezer/utils.py +++ b/deezer/utils.py @@ -78,7 +78,7 @@ def map_user_album(album): } # maps gw-light api user/playlists to standard api -def map_user_playlist(playlist): +def map_user_playlist(playlist, default_user_name=""): return { 'id': playlist['PLAYLIST_ID'], 'title': playlist['TITLE'], @@ -92,7 +92,7 @@ def map_user_playlist(playlist): 'tracklist': 'https://api.deezer.com/playlist/'+str(playlist['PLAYLIST_ID'])+'/tracks', 'creator': { 'id': playlist['PARENT_USER_ID'], - 'name': playlist['PARENT_USERNAME'] if 'PARENT_USERNAME' in playlist else self.user['name'] + 'name': playlist.get('PARENT_USERNAME', default_user_name) }, 'type': 'playlist' } diff --git a/setup.py b/setup.py index 649ca01..4d93786 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ README = (HERE / "README.md").read_text() setup( name="deezer-py", - version="0.0.7", + version="0.0.8", description="A wrapper for all Deezer's APIs", long_description=README, long_description_content_type="text/markdown",