Merge branch 'master' of replydev/deemix into master

This commit is contained in:
RemixDev 2020-05-20 14:54:53 +00:00 committed by Gogs
commit 09ca778e51
2 changed files with 20 additions and 5 deletions

View File

@ -8,9 +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.argument('url', nargs=-1, required=True)
def download(bitrate, url):
settings = initSettings()
def download(bitrate, botmode, url):
settings = initSettings(botmode)
app.login()
if isfile(url[0]):
filename = url[0]
@ -19,6 +20,8 @@ def download(bitrate, url):
for u in url:
app.downloadLink(u, settings, bitrate)
click.echo("All done!")
if botmode:
click.echo(settings['downloadLocation']) #folder name output
if __name__ == '__main__':

View File

@ -2,6 +2,8 @@
import json
import os.path as path
from os import makedirs
import random
import string
import deemix.utils.localpaths as localpaths
@ -9,7 +11,7 @@ settings = {}
defaultSettings = {}
def initSettings():
def initSettings(bot_mode = False):
global settings
global defaultSettings
currentFolder = path.abspath(path.dirname(__file__))
@ -24,8 +26,13 @@ def initSettings():
with open(path.join(configFolder, 'config.json'), 'r') as configFile:
settings = json.load(configFile)
settingsCheck()
if settings['downloadLocation'] == "":
settings['downloadLocation'] = path.join(localpaths.getHomeFolder(), 'deemix Music')
if bot_mode:
print("Im using bot mode")
settings['downloadLocation'] = randomString(12)
elif settings['downloadLocation'] == "":
print("I'm using normal mode")
settings['downloadLocation'] = path.join(localpaths.getHomeFolder(), 'deemix Music')
saveSettings(settings)
makedirs(settings['downloadLocation'], exist_ok=True)
return settings
@ -63,3 +70,8 @@ def settingsCheck():
changes += 1
if changes > 0:
saveSettings(settings)
def randomString(stringLength=8):
letters = string.ascii_lowercase
return ''.join(random.choice(letters) for i in range(stringLength))