Made spotipy an optional dependency

This commit is contained in:
RemixDev 2021-09-21 18:32:20 +02:00
parent c2b19eef33
commit 58f2b875fa
No known key found for this signature in database
GPG Key ID: B33962B465BDB51C
2 changed files with 14 additions and 7 deletions

View File

@ -11,7 +11,10 @@ from deemix.utils import getBitrateNumberFromText, formatListener
import deemix.utils.localpaths as localpaths import deemix.utils.localpaths as localpaths
from deemix.downloader import Downloader from deemix.downloader import Downloader
from deemix.itemgen import GenerationError from deemix.itemgen import GenerationError
from deemix.plugins.spotify import Spotify try:
from deemix.plugins.spotify import Spotify
except ImportError:
Spotify = None
class LogListener: class LogListener:
@classmethod @classmethod
@ -48,10 +51,12 @@ def download(url, bitrate, portable, path):
with open(configFolder / '.arl', 'w') as f: with open(configFolder / '.arl', 'w') as f:
f.write(arl) f.write(arl)
plugins = { plugins = {}
"spotify": Spotify(configFolder=configFolder) if Spotify:
} plugins = {
plugins["spotify"].setup() "spotify": Spotify(configFolder=configFolder)
}
plugins["spotify"].setup()
def downloadLinks(url, bitrate=None): def downloadLinks(url, bitrate=None):
if not bitrate: bitrate = settings.get("maxBitrate", TrackFormats.MP3_320) if not bitrate: bitrate = settings.get("maxBitrate", TrackFormats.MP3_320)
@ -77,7 +82,6 @@ def download(url, bitrate, portable, path):
downloadObjects.append(downloadObject) downloadObjects.append(downloadObject)
for obj in downloadObjects: for obj in downloadObjects:
print(obj.__type__)
if obj.__type__ == "Convertable": if obj.__type__ == "Convertable":
obj = plugins[obj.plugin].convert(dz, obj, settings, listener) obj = plugins[obj.plugin].convert(dz, obj, settings, listener)
Downloader(dz, obj, settings, listener).start() Downloader(dz, obj, settings, listener).start()

View File

@ -23,7 +23,10 @@ setup(
python_requires='>=3.7', python_requires='>=3.7',
packages=find_packages(exclude=("tests",)), packages=find_packages(exclude=("tests",)),
include_package_data=True, include_package_data=True,
install_requires=["click", "pycryptodomex", "mutagen", "requests", "spotipy>=2.11.0", "deezer-py>=1.1.2"], install_requires=["click", "pycryptodomex", "mutagen", "requests", "deezer-py>=1.2.2"],
extras_require={
"spotify": ["spotipy>=2.11.0"]
},
entry_points={ entry_points={
"console_scripts": [ "console_scripts": [
"deemix=deemix.__main__:download", "deemix=deemix.__main__:download",