This commit is contained in:
replydev 2020-05-20 16:36:01 +02:00
parent 8c2f2ee6af
commit 46594aa21b
2 changed files with 21 additions and 6 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__))
@ -17,14 +19,19 @@ def initSettings():
makedirs(configFolder, exist_ok=True)
with open(path.join(currentFolder, 'default.json'), 'r') as d:
defaultSettings = json.load(d)
defaultSettings['downloadLocation'] = path.join(localpaths.getHomeFolder(), 'deemix Music')
defaultSettings['downloadLocation'] = ""
if not path.isfile(path.join(configFolder, 'config.json')):
with open(path.join(configFolder, 'config.json'), 'w') as f:
json.dump(defaultSettings, f, indent=2)
with open(path.join(configFolder, 'config.json'), 'r') as configFile:
settings = json.load(configFile)
settingsCheck()
if settings['downloadLocation'] == "":
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)
@ -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))