deemix-py/deemix/__main__.py

37 lines
1.1 KiB
Python

#!/usr/bin/env python3
import click
import deemix.app.cli as app
from deemix.app.settings import initSettings
from os.path import isfile
import random
import string
def randomString(stringLength=8):
letters = string.ascii_lowercase
return ''.join(random.choice(letters) for i in range(stringLength))
@click.command()
@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.argument('url', nargs=-1, required=True)
def download(bitrate, local, url):
settings = initSettings()
if local:
settings['downloadLocation'] = randomString(12)
click.echo("Using a local download folder: "+settings['downloadLocation'])
app.login()
url = list(url)
if isfile(url[0]):
filename = url[0]
with open(filename) as f:
url = f.readlines()
app.downloadLink(url, settings, bitrate)
click.echo("All done!")
if local:
click.echo(settings['downloadLocation']) #folder name output
if __name__ == '__main__':
download()