From c0ba5316ccabd8a016ae4c0abc98bd0bb374171f Mon Sep 17 00:00:00 2001 From: RemixDev Date: Tue, 4 Aug 2020 14:42:02 +0200 Subject: [PATCH] Added get_artist_discography_gw --- deemix/__init__.py | 2 +- deemix/api/deezer.py | 47 ++++++++++++++++++++++++++++++++++++++++++++ setup.py | 2 +- 3 files changed, 49 insertions(+), 2 deletions(-) diff --git a/deemix/__init__.py b/deemix/__init__.py index c6c853a..301b2f4 100644 --- a/deemix/__init__.py +++ b/deemix/__init__.py @@ -1,3 +1,3 @@ #!/usr/bin/env python3 -__version__ = "1.1.27" +__version__ = "1.1.28" diff --git a/deemix/api/deezer.py b/deemix/api/deezer.py index 5054b5a..8a332e2 100755 --- a/deemix/api/deezer.py +++ b/deemix/api/deezer.py @@ -275,6 +275,53 @@ class Deezer: tracks_array.append(track) return tracks_array + def get_artist_discography_gw(self, art_id, nb=10): + start = 0 + releases = [] + RELEASE_TYPE = ["single", "album", "compile", "ep"] + result = {'all': []} + while True: + response = self.gw_api_call('album.getDiscography', {'art_id': art_id, "discography_mode":"all", 'nb': nb, 'nb_songs': 0, 'start': start}) + releases += response['results']['data'] + start += nb + if start > response['results']['total']: + break + for release in releases: + obj = { + 'id': release['ALB_ID'], + 'title': release['ALB_TITLE'], + 'link': f"https://www.deezer.com/album/{release['ALB_ID']}", + 'cover': f"https://api.deezer.com/album/{release['ALB_ID']}/image", + 'cover_small': f"https://cdns-images.dzcdn.net/images/cover/{release['ALB_PICTURE']}/56x56-000000-80-0-0.jpg", + 'cover_medium': f"https://cdns-images.dzcdn.net/images/cover/{release['ALB_PICTURE']}/250x250-000000-80-0-0.jpg", + 'cover_big': f"https://cdns-images.dzcdn.net/images/cover/{release['ALB_PICTURE']}/500x500-000000-80-0-0.jpg", + 'cover_xl': f"https://cdns-images.dzcdn.net/images/cover/{release['ALB_PICTURE']}/1000x1000-000000-80-0-0.jpg", + 'genre_id': release['GENRE_ID'], + 'fans': release['RANK'], + 'release_date': release['PHYSICAL_RELEASE_DATE'], + 'record_type': RELEASE_TYPE[int(release['TYPE'])], + 'tracklist': f"https://api.deezer.com/album/{release['ALB_ID']}/tracks", + 'explicit_lyrics': int(release['EXPLICIT_LYRICS']) > 0, + 'type': release['__TYPE__'], + 'nb_song': release['NUMBER_TRACK'], + 'nb_disk': release['NUMBER_DISK'] + } + if release['ART_ID'] == art_id or release['ART_ID'] != art_id and release['ROLE_ID'] == 0 and release['ARTISTS_ALBUMS_IS_OFFICIAL']: + if not obj['record_type'] in result: + result[obj['record_type']] = [] + result[obj['record_type']].append(obj) + result['all'].append(obj) + else: + if release['ROLE_ID'] == 5: + if not 'featured' in result: + result['featured'] = [] + result['featured'].append(obj) + elif release['ROLE_ID'] == 0: + if not 'more' in result: + result['more'] = [] + result['more'].append(obj) + return result + def search_main_gw(self, term): term = term results = self.gw_api_call('deezer.pageSearch', diff --git a/setup.py b/setup.py index ca18a90..1d60784 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ README = (HERE / "README.md").read_text() setup( name="deemix", - version="1.1.27", + version="1.1.28", description="A barebone deezer downloader library", long_description=README, long_description_content_type="text/markdown",