Fixed private playlist username

This commit is contained in:
RemixDev 2020-11-19 22:05:26 +01:00
parent 2ac9bf0d0d
commit f99f5f3aa2
No known key found for this signature in database
GPG key ID: B33962B465BDB51C
4 changed files with 8 additions and 6 deletions

View file

@ -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"""

View file

@ -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):

View file

@ -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'
}

View file

@ -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",