Fixed cli

This commit is contained in:
RemixDev 2021-07-05 18:18:57 +02:00
parent 07bdca4599
commit 536caee401
No known key found for this signature in database
GPG Key ID: B33962B465BDB51C
1 changed files with 19 additions and 3 deletions

View File

@ -10,6 +10,16 @@ from deemix.settings import load as loadSettings
from deemix.utils import getBitrateNumberFromText from deemix.utils import getBitrateNumberFromText
import deemix.utils.localpaths as localpaths import deemix.utils.localpaths as localpaths
from deemix.downloader import Downloader 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.command()
@click.option('--portable', is_flag=True, help='Creates the config folder in the same directory where the script is launched') @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) settings = loadSettings(configFolder)
dz = Deezer(settings.get('tagsLanguage', "")) dz = Deezer(settings.get('tagsLanguage', ""))
listener = LogListener()
def requestValidArl(): def requestValidArl():
while True: while True:
@ -38,6 +49,11 @@ 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 = {
"spotify": Spotify()
}
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)
links = [] links = []
@ -49,12 +65,12 @@ def download(url, bitrate, portable, path):
links.append(link) links.append(link)
for link in links: for link in links:
downloadObject = generateDownloadObject(dz, link, bitrate) downloadObject = generateDownloadObject(dz, link, bitrate, plugins, listener)
if isinstance(downloadObject, list): if isinstance(downloadObject, list):
for obj in downloadObject: for obj in downloadObject:
Downloader(dz, obj, settings).start() Downloader(dz, obj, settings, listener).start()
else: else:
Downloader(dz, downloadObject, settings).start() Downloader(dz, downloadObject, settings, listener).start()
if path is not None: if path is not None: