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

View File

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