Adjusted code from previous PR
This commit is contained in:
parent
09ca778e51
commit
012db6f572
|
@ -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
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue