Merge branch 'main' into 'main'

Fixed downloading of private playlists

See merge request RemixDev/deemix!3
This commit is contained in:
RemixDev 2020-12-29 21:23:34 +03:00
commit 1721103646

View file

@ -2,6 +2,7 @@ from deemix.app.downloadjob import DownloadJob
from deemix.utils import getIDFromLink, getTypeFromLink, getBitrateInt from deemix.utils import getIDFromLink, getTypeFromLink, getBitrateInt
from deezer.gw import APIError as gwAPIError, LyricsStatus from deezer.gw import APIError as gwAPIError, LyricsStatus
from deezer.api import APIError from deezer.api import APIError
from deezer.utils import map_user_playlist
from spotipy.exceptions import SpotifyException from spotipy.exceptions import SpotifyException
from deemix.app.queueitem import QueueItem, QISingle, QICollection, QIConvertable from deemix.app.queueitem import QueueItem, QISingle, QICollection, QIConvertable
import logging import logging
@ -134,7 +135,8 @@ class QueueManager:
# Fallback to gw api if the playlist is private # Fallback to gw api if the playlist is private
if not playlistAPI: if not playlistAPI:
try: 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: except gwAPIError as e:
e = json.loads(str(e)) e = json.loads(str(e))
message = "Wrong URL" message = "Wrong URL"
@ -143,8 +145,8 @@ class QueueManager:
return QueueError("https://deezer.com/playlist/"+str(id), message) return QueueError("https://deezer.com/playlist/"+str(id), message)
# Check if private playlist and owner # Check if private playlist and owner
if not playlistAPI['public'] and playlistAPI['creator']['id'] != str(dz.current_user['id']): if not playlistAPI.get('public', False) and playlistAPI['creator']['id'] != str(dz.current_user['id']):
logger.warn("You can't download others private playlists.") 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") return QueueError("https://deezer.com/playlist/"+str(id), "You can't download others private playlists.", "notYourPrivatePlaylist")
playlistTracksAPI = dz.gw.get_playlist_tracks(id) playlistTracksAPI = dz.gw.get_playlist_tracks(id)