From 012db6f57211a318ef520e9ce18ad7d60d9742e9 Mon Sep 17 00:00:00 2001 From: RemixDev Date: Wed, 20 May 2020 17:02:24 +0200 Subject: [PATCH] Adjusted code from previous PR --- deemix/__main__.py | 8 ++++---- deemix/app/settings.py | 13 ++++++++----- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/deemix/__main__.py b/deemix/__main__.py index 4fd7874..8e9837f 100644 --- a/deemix/__main__.py +++ b/deemix/__main__.py @@ -8,10 +8,10 @@ from os.path import isfile @click.command() @click.option('-b', '--bitrate', default=None, help='Overwrites the default bitrate selected') -@click.option('-bot', '--botmode', is_flag=True, help='Enables bot mode') +@click.option('-l', '--local', is_flag=True, help='Downloads in a local folder insted of using the default') @click.argument('url', nargs=-1, required=True) -def download(bitrate, botmode, url): - settings = initSettings(botmode) +def download(bitrate, localFolder, url): + settings = initSettings(localFolder) app.login() if isfile(url[0]): filename = url[0] @@ -20,7 +20,7 @@ def download(bitrate, botmode, url): for u in url: app.downloadLink(u, settings, bitrate) click.echo("All done!") - if botmode: + if localFolder: click.echo(settings['downloadLocation']) #folder name output diff --git a/deemix/app/settings.py b/deemix/app/settings.py index a25dc79..bf55ddf 100644 --- a/deemix/app/settings.py +++ b/deemix/app/settings.py @@ -4,6 +4,10 @@ import os.path as path from os import makedirs import random import string +import logging + +logging.basicConfig(level=logging.INFO) +logger = logging.getLogger('deemix') import deemix.utils.localpaths as localpaths @@ -11,7 +15,7 @@ settings = {} defaultSettings = {} -def initSettings(bot_mode = False): +def initSettings(localFolder = False): global settings global defaultSettings currentFolder = path.abspath(path.dirname(__file__)) @@ -27,12 +31,11 @@ def initSettings(bot_mode = False): settings = json.load(configFile) settingsCheck() - if bot_mode: - print("Im using bot mode") + if localFolder: settings['downloadLocation'] = randomString(12) + logger.info("Using a local download folder: "+settings['downloadLocation']) elif settings['downloadLocation'] == "": - print("I'm using normal mode") - settings['downloadLocation'] = path.join(localpaths.getHomeFolder(), 'deemix Music') + settings['downloadLocation'] = path.join(localpaths.getHomeFolder(), 'deemix Music') saveSettings(settings) makedirs(settings['downloadLocation'], exist_ok=True) return settings