mirror of
https://gitlab.com/RemixDev/deezer-py.git
synced 2024-12-29 10:56:13 +00:00
Implemented get_track_with_fallback; Fixed charts
This commit is contained in:
parent
5a03419c53
commit
1856846992
|
@ -4,7 +4,7 @@ from deezer.gw import GW
|
|||
from deezer.api import API
|
||||
import json
|
||||
|
||||
__version__ = "0.0.2"
|
||||
__version__ = "0.0.3"
|
||||
|
||||
class TrackFormats():
|
||||
"""Number associtation for formats"""
|
||||
|
|
|
@ -265,7 +265,7 @@ class API:
|
|||
# Extra calls
|
||||
|
||||
def get_countries_charts(self):
|
||||
temp = self.get_user_playlists('637006841')
|
||||
temp = self.get_user_playlists('637006841', limit=-1)['data']
|
||||
result = sorted(temp, key=lambda k: k['title']) # Sort all playlists
|
||||
if not result[0]['title'].startswith('Top'): result = result[1:] # Remove loved tracks playlist
|
||||
return result
|
||||
|
|
15
deezer/gw.py
15
deezer/gw.py
|
@ -253,6 +253,21 @@ class GW:
|
|||
result['all'].append(obj)
|
||||
return result
|
||||
|
||||
def get_track_with_fallback(self, sng_id):
|
||||
body = None
|
||||
if int(sng_id) > 0:
|
||||
try:
|
||||
body = self.get_track_page(sng_id)
|
||||
except:
|
||||
pass
|
||||
if body:
|
||||
if 'LYRICS' in body:
|
||||
body['DATA']['LYRICS'] = body['LYRICS']
|
||||
body = body['DATA']
|
||||
else:
|
||||
body = self.get_track(sng_id)
|
||||
return body
|
||||
|
||||
class APIError(Exception):
|
||||
"""Base class for Deezer exceptions"""
|
||||
pass
|
||||
|
|
Loading…
Reference in a new issue