2020-02-17 15:46:18 +00:00
|
|
|
#!/usr/bin/env python3
|
2020-02-23 21:51:16 +00:00
|
|
|
import click
|
2020-04-17 10:31:47 +00:00
|
|
|
|
2020-08-15 21:03:05 +00:00
|
|
|
from deemix.app.cli import cli
|
2020-09-03 14:13:57 +00:00
|
|
|
import os.path
|
2020-04-17 10:31:47 +00:00
|
|
|
|
2020-02-23 21:51:16 +00:00
|
|
|
@click.command()
|
2020-09-03 14:13:57 +00:00
|
|
|
@click.option('--portable', is_flag=True, help='Creates the config folder in the same directory where the script is launched')
|
2020-02-23 21:51:16 +00:00
|
|
|
@click.option('-b', '--bitrate', default=None, help='Overwrites the default bitrate selected')
|
2020-09-02 21:14:59 +00:00
|
|
|
@click.option('-p', '--path', type=str, help='Downloads in the given folder')
|
2020-05-14 22:06:40 +00:00
|
|
|
@click.argument('url', nargs=-1, required=True)
|
2020-09-03 14:13:57 +00:00
|
|
|
def download(url, bitrate, portable, path):
|
|
|
|
localpath = os.path.realpath('.')
|
|
|
|
|
|
|
|
configFolder = None
|
|
|
|
if portable:
|
|
|
|
configFolder = os.path.join(localpath, 'config')
|
|
|
|
if path is not None:
|
|
|
|
if path == '': path = '.'
|
|
|
|
path = os.path.realpath(path)
|
|
|
|
|
|
|
|
app = cli(path, configFolder)
|
2020-04-17 10:31:47 +00:00
|
|
|
app.login()
|
2020-06-19 18:14:20 +00:00
|
|
|
url = list(url)
|
2020-09-03 14:13:57 +00:00
|
|
|
if os.path.isfile(url[0]):
|
2020-05-15 15:46:50 +00:00
|
|
|
filename = url[0]
|
|
|
|
with open(filename) as f:
|
|
|
|
url = f.readlines()
|
2020-08-15 21:03:05 +00:00
|
|
|
app.downloadLink(url, bitrate)
|
2020-04-17 10:31:47 +00:00
|
|
|
click.echo("All done!")
|
|
|
|
|
2020-02-17 15:46:18 +00:00
|
|
|
if __name__ == '__main__':
|
2020-08-14 18:31:37 +00:00
|
|
|
download()
|