From 744acc8c94bee5e9089bc5ec4d80c43b1359e6a5 Mon Sep 17 00:00:00 2001 From: hicksel <3989-hicksel@users.noreply.git.rip> Date: Tue, 29 Dec 2020 18:27:06 +0100 Subject: [PATCH] Fixed downloading of private playlists by mapping gw-api to public api Depends on RemixDev/deezer-py!2 --- deemix/app/queuemanager.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/deemix/app/queuemanager.py b/deemix/app/queuemanager.py index 93ae82e..45d3b61 100644 --- a/deemix/app/queuemanager.py +++ b/deemix/app/queuemanager.py @@ -2,6 +2,7 @@ from deemix.app.downloadjob import DownloadJob from deemix.utils import getIDFromLink, getTypeFromLink, getBitrateInt from deezer.gw import APIError as gwAPIError, LyricsStatus from deezer.api import APIError +from deezer.utils import map_user_playlist from spotipy.exceptions import SpotifyException from deemix.app.queueitem import QueueItem, QISingle, QICollection, QIConvertable import logging @@ -134,7 +135,8 @@ class QueueManager: # Fallback to gw api if the playlist is private if not playlistAPI: try: - playlistAPI = dz.gw.get_playlist_page(id) + userPlaylist = dz.gw.get_playlist_page(id) + playlistAPI = map_user_playlist(userPlaylist['DATA']) except gwAPIError as e: e = json.loads(str(e)) message = "Wrong URL" @@ -143,8 +145,8 @@ class QueueManager: return QueueError("https://deezer.com/playlist/"+str(id), message) # Check if private playlist and owner - if not playlistAPI['public'] and playlistAPI['creator']['id'] != str(dz.current_user['id']): - logger.warn("You can't download others private playlists.") + if not playlistAPI.get('public', False) and playlistAPI['creator']['id'] != str(dz.current_user['id']): + logger.warning("You can't download others private playlists.") return QueueError("https://deezer.com/playlist/"+str(id), "You can't download others private playlists.", "notYourPrivatePlaylist") playlistTracksAPI = dz.gw.get_playlist_tracks(id)