From 49cf46013192d8b24e9921710ec7a50f500a926d Mon Sep 17 00:00:00 2001 From: RemixDev Date: Wed, 7 Oct 2020 21:43:13 +0200 Subject: [PATCH] Added catch for empty artists and made release type safe in case deezer adds a new release type --- deemix/__init__.py | 2 +- deemix/api/deezer.py | 4 ++-- deemix/app/queuemanager.py | 2 +- setup.py | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/deemix/__init__.py b/deemix/__init__.py index fe091b4..ebdb4e1 100644 --- a/deemix/__init__.py +++ b/deemix/__init__.py @@ -1,3 +1,3 @@ #!/usr/bin/env python3 -__version__ = "1.5.10" +__version__ = "1.5.11" diff --git a/deemix/api/deezer.py b/deemix/api/deezer.py index 9928f5b..0aed561 100755 --- a/deemix/api/deezer.py +++ b/deemix/api/deezer.py @@ -391,7 +391,7 @@ class Deezer: def get_artist_discography_gw(self, art_id, nb=100): start = 0 releases = [] - RELEASE_TYPE = ["single", "album", "compile", "ep", "bundle"] + RELEASE_TYPE = {0:"single", 1:"album", 2:"compile", 3:"ep", 4:"bundle"} result = {'all': []} IDs = [] while True: @@ -415,7 +415,7 @@ class Deezer: 'genre_id': release['GENRE_ID'], 'fans': release['RANK'], 'release_date': release['PHYSICAL_RELEASE_DATE'], - 'record_type': RELEASE_TYPE[int(release['TYPE'])], + 'record_type': RELEASE_TYPE.get(int(release['TYPE']), "unknown"), 'tracklist': f"https://api.deezer.com/album/{release['ALB_ID']}/tracks", 'explicit_lyrics': int(release['EXPLICIT_LYRICS']) > 0, 'type': release['__TYPE__'], diff --git a/deemix/app/queuemanager.py b/deemix/app/queuemanager.py index 3ba7260..3b4ed32 100644 --- a/deemix/app/queuemanager.py +++ b/deemix/app/queuemanager.py @@ -185,7 +185,7 @@ class QueueManager: if interface: interface.send("startAddingArtist", {'name': artistAPI['name'], 'id': artistAPI['id']}) artistDiscographyAPI = dz.get_artist_discography_gw(id, 100) - allReleases = artistDiscographyAPI.pop('all', None) + allReleases = artistDiscographyAPI.pop('all', []) albumList = [] for album in allReleases: albumList.append(self.generateAlbumQueueItem(dz, album['id'], settings, bitrate)) diff --git a/setup.py b/setup.py index 46fe69a..ba2ff9b 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ README = (HERE / "README.md").read_text() setup( name="deemix", - version="1.5.10", + version="1.5.11", description="A barebone deezer downloader library", long_description=README, long_description_content_type="text/markdown",