Merge pull request 'Added path cli switch for downloading to a path' (#38) from TheUltimateC0der/deemix:main into main

Reviewed-on: https://codeberg.org/RemixDev/deemix/pulls/38
This commit is contained in:
RemixDev 2020-09-03 15:41:14 +02:00
commit 01dc66dadd
2 changed files with 7 additions and 3 deletions

View File

@ -7,9 +7,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('-l', '--local', is_flag=True, help='Downloads in a local folder insted of using the default') @click.option('-l', '--local', is_flag=True, help='Downloads in a local folder insted of using the default')
@click.option('-p', '--path', type=str, help='Downloads in the given folder')
@click.argument('url', nargs=-1, required=True) @click.argument('url', nargs=-1, required=True)
def download(bitrate, local, url): def download(bitrate, local, url, path):
app = cli(local) app = cli(local, path)
app.login() app.login()
url = list(url) url = list(url)
if isfile(url[0]): if isfile(url[0]):

View File

@ -11,8 +11,11 @@ def randomString(stringLength=8):
return ''.join(random.choice(letters) for i in range(stringLength)) return ''.join(random.choice(letters) for i in range(stringLength))
class cli(deemix): class cli(deemix):
def __init__(self, local, configFolder=None): def __init__(self, local, path, configFolder=None):
super().__init__(configFolder) super().__init__(configFolder)
if path:
self.set.settings['downloadLocation'] = str(path)
print("Using folder: "+self.set.settings['downloadLocation'])
if local: if local:
self.set.settings['downloadLocation'] = randomString(12) self.set.settings['downloadLocation'] = randomString(12)
print("Using a local download folder: "+self.set.settings['downloadLocation']) print("Using a local download folder: "+self.set.settings['downloadLocation'])