From 73684aed45d26f71205801f6aab107a55575bc8a Mon Sep 17 00:00:00 2001 From: RemixDev Date: Fri, 18 Sep 2020 13:43:54 +0200 Subject: [PATCH] Fixed pyinstaller spotipy issue and started working on favorites --- deemix/__init__.py | 2 +- deemix/api/deezer.py | 25 +++++++++++++++++++++++-- deemix/app/__init__.py | 2 -- deemix/app/spotifyhelper.py | 7 +++++-- setup.py | 2 +- 5 files changed, 30 insertions(+), 8 deletions(-) diff --git a/deemix/__init__.py b/deemix/__init__.py index 248a9b1..a11dcc4 100644 --- a/deemix/__init__.py +++ b/deemix/__init__.py @@ -1,3 +1,3 @@ #!/usr/bin/env python3 -__version__ = "1.3.8" +__version__ = "1.3.9" diff --git a/deemix/api/deezer.py b/deemix/api/deezer.py index 0835d6c..21f8935 100755 --- a/deemix/api/deezer.py +++ b/deemix/api/deezer.py @@ -23,7 +23,6 @@ class Deezer: } self.album_pictures_host = "https://e-cdns-images.dzcdn.net/images/cover/" self.artist_pictures_host = "https://e-cdns-images.dzcdn.net/images/artist/" - self.email = "" self.user = {} self.family = False self.childs = [] @@ -153,7 +152,6 @@ class Deezer: 'picture': user_data["results"]["USER"]["USER_PICTURE"] if "USER_PICTURE" in user_data["results"][ "USER"] else "" } - self.email = email self.logged_in = True return True @@ -516,6 +514,29 @@ class Deezer: result.append(item) return result + def get_all_feedbacks_gw(self, checksums=None): + return self.gw_api_call('user.getAllFeedbacks', {'checksums': checksums}) + + def add_to_favorites(self, type, id): + if type == 'track': + return self.gw_api_call('favorite_song.add', {'SNG_ID': id}) + elif type == 'album': + return self.gw_api_call('album.addFavorite', {'ALB_ID': id}) + elif type == 'artist': + return self.gw_api_call('artist.addFavorite', {'ART_ID': id}) + elif type == 'playlist': + return self.gw_api_call('playlist.addFavorite', {'PARENT_PLAYLIST_ID': id}) + + def remove_from_favorites(self, type, id): + if type == 'track': + return self.gw_api_call('favorite_song.remove', {'SNG_ID': id}) + elif type == 'album': + return self.gw_api_call('album.deleteFavorite', {'ALB_ID': id}) + elif type == 'artist': + return self.gw_api_call('artist.deleteFavorite', {'ART_ID': id}) + elif type == 'playlist': + return self.gw_api_call('playlist.deleteFavorite', {'PLAYLIST_ID': id}) + def get_user_playlists(self, user_id): return self.api_call('user/' + str(user_id) + '/playlists', {'limit': -1}) diff --git a/deemix/app/__init__.py b/deemix/app/__init__.py index cc07301..d924e42 100644 --- a/deemix/app/__init__.py +++ b/deemix/app/__init__.py @@ -1,6 +1,4 @@ #!/usr/bin/env python3 -import eventlet -eventlet.import_patched('requests.__init__') from deemix.api.deezer import Deezer from deemix.app.settings import Settings from deemix.app.queuemanager import QueueManager diff --git a/deemix/app/spotifyhelper.py b/deemix/app/spotifyhelper.py index 2a09d9f..1f04033 100644 --- a/deemix/app/spotifyhelper.py +++ b/deemix/app/spotifyhelper.py @@ -1,10 +1,13 @@ #!/usr/bin/env python3 +import eventlet import json import os.path as path from os import mkdir -import spotipy -from spotipy.oauth2 import SpotifyClientCredentials +eventlet.import_patched('requests.adapters') + +spotipy = eventlet.import_patched('spotipy') +SpotifyClientCredentials = spotipy.oauth2.SpotifyClientCredentials from deemix.utils.localpaths import getConfigFolder from deemix.app.queueitem import QIConvertable diff --git a/setup.py b/setup.py index 5c3ffc0..51bcf10 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ README = (HERE / "README.md").read_text() setup( name="deemix", - version="1.3.8", + version="1.3.9", description="A barebone deezer downloader library", long_description=README, long_description_content_type="text/markdown",