From 536caee401b3f4daa03bc1a56e912e665558a44c Mon Sep 17 00:00:00 2001 From: RemixDev Date: Mon, 5 Jul 2021 18:18:57 +0200 Subject: [PATCH] Fixed cli --- deemix/__main__.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/deemix/__main__.py b/deemix/__main__.py index f740cf0..0910e3f 100644 --- a/deemix/__main__.py +++ b/deemix/__main__.py @@ -10,6 +10,16 @@ from deemix.settings import load as loadSettings from deemix.utils import getBitrateNumberFromText import deemix.utils.localpaths as localpaths from deemix.downloader import Downloader +from deemix.plugins.spotify import Spotify + +class LogListener: + @classmethod + def send(cls, key, value): + if value: + print(key, value) + else: + print(key) + @click.command() @click.option('--portable', is_flag=True, help='Creates the config folder in the same directory where the script is launched') @@ -23,6 +33,7 @@ def download(url, bitrate, portable, path): settings = loadSettings(configFolder) dz = Deezer(settings.get('tagsLanguage', "")) + listener = LogListener() def requestValidArl(): while True: @@ -38,6 +49,11 @@ def download(url, bitrate, portable, path): with open(configFolder / '.arl', 'w') as f: f.write(arl) + plugins = { + "spotify": Spotify() + } + plugins["spotify"].setup() + def downloadLinks(url, bitrate=None): if not bitrate: bitrate = settings.get("maxBitrate", TrackFormats.MP3_320) links = [] @@ -49,12 +65,12 @@ def download(url, bitrate, portable, path): links.append(link) for link in links: - downloadObject = generateDownloadObject(dz, link, bitrate) + downloadObject = generateDownloadObject(dz, link, bitrate, plugins, listener) if isinstance(downloadObject, list): for obj in downloadObject: - Downloader(dz, obj, settings).start() + Downloader(dz, obj, settings, listener).start() else: - Downloader(dz, downloadObject, settings).start() + Downloader(dz, downloadObject, settings, listener).start() if path is not None: