mirror of
https://gitlab.com/RemixDev/deezer-py.git
synced 2024-12-29 10:56:13 +00:00
Fixed private playlist username
This commit is contained in:
parent
2ac9bf0d0d
commit
f99f5f3aa2
|
@ -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"""
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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'
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue