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.command()
|
||||||
@click.option('-b', '--bitrate', default=None, help='Overwrites the default bitrate selected')
|
@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)
|
@click.argument('url', nargs=-1, required=True)
|
||||||
def download(bitrate, botmode, url):
|
def download(bitrate, localFolder, url):
|
||||||
settings = initSettings(botmode)
|
settings = initSettings(localFolder)
|
||||||
app.login()
|
app.login()
|
||||||
if isfile(url[0]):
|
if isfile(url[0]):
|
||||||
filename = url[0]
|
filename = url[0]
|
||||||
|
@ -20,7 +20,7 @@ def download(bitrate, botmode, url):
|
||||||
for u in url:
|
for u in url:
|
||||||
app.downloadLink(u, settings, bitrate)
|
app.downloadLink(u, settings, bitrate)
|
||||||
click.echo("All done!")
|
click.echo("All done!")
|
||||||
if botmode:
|
if localFolder:
|
||||||
click.echo(settings['downloadLocation']) #folder name output
|
click.echo(settings['downloadLocation']) #folder name output
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,10 @@ import os.path as path
|
||||||
from os import makedirs
|
from os import makedirs
|
||||||
import random
|
import random
|
||||||
import string
|
import string
|
||||||
|
import logging
|
||||||
|
|
||||||
|
logging.basicConfig(level=logging.INFO)
|
||||||
|
logger = logging.getLogger('deemix')
|
||||||
|
|
||||||
import deemix.utils.localpaths as localpaths
|
import deemix.utils.localpaths as localpaths
|
||||||
|
|
||||||
|
@ -11,7 +15,7 @@ settings = {}
|
||||||
defaultSettings = {}
|
defaultSettings = {}
|
||||||
|
|
||||||
|
|
||||||
def initSettings(bot_mode = False):
|
def initSettings(localFolder = False):
|
||||||
global settings
|
global settings
|
||||||
global defaultSettings
|
global defaultSettings
|
||||||
currentFolder = path.abspath(path.dirname(__file__))
|
currentFolder = path.abspath(path.dirname(__file__))
|
||||||
|
@ -27,11 +31,10 @@ def initSettings(bot_mode = False):
|
||||||
settings = json.load(configFile)
|
settings = json.load(configFile)
|
||||||
settingsCheck()
|
settingsCheck()
|
||||||
|
|
||||||
if bot_mode:
|
if localFolder:
|
||||||
print("Im using bot mode")
|
|
||||||
settings['downloadLocation'] = randomString(12)
|
settings['downloadLocation'] = randomString(12)
|
||||||
|
logger.info("Using a local download folder: "+settings['downloadLocation'])
|
||||||
elif 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)
|
saveSettings(settings)
|
||||||
makedirs(settings['downloadLocation'], exist_ok=True)
|
makedirs(settings['downloadLocation'], exist_ok=True)
|
||||||
|
|
Loading…
Reference in New Issue