Implemented get_track_with_fallback; Fixed charts

This commit is contained in:
RemixDev 2020-11-19 20:42:41 +01:00
parent 5a03419c53
commit 1856846992
No known key found for this signature in database
GPG key ID: B33962B465BDB51C
4 changed files with 19 additions and 4 deletions

View file

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

View file

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

View file

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

View file

@ -7,7 +7,7 @@ README = (HERE / "README.md").read_text()
setup(
name="deezer-py",
version="0.0.2",
version="0.0.3",
description="A wrapper for all Deezer's APIs",
long_description=README,
long_description_content_type="text/markdown",