deemix-py/deemix/__main__.py

34 lines
979 B
Python
Raw Normal View History

2020-02-17 15:46:18 +00:00
#!/usr/bin/env python3
import click
2020-08-15 21:03:05 +00:00
from deemix.app.cli import cli
from pathlib import Path
@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')
@click.option('-b', '--bitrate', default=None, help='Overwrites the default bitrate selected')
@click.option('-p', '--path', type=str, help='Downloads in the given folder')
@click.argument('url', nargs=-1, required=True)
2020-09-03 14:13:57 +00:00
def download(url, bitrate, portable, path):
localpath = Path('.')
configFolder = localpath / 'config' if portable else None
2020-09-03 14:13:57 +00:00
if path is not None:
if path == '': path = '.'
path = Path(path)
2020-09-03 14:13:57 +00:00
app = cli(path, configFolder)
app.login()
url = list(url)
2020-09-24 15:46:08 +00:00
if Path(url[0]).is_file():
filename = url[0]
with open(filename) as f:
url = f.readlines()
2020-08-15 21:03:05 +00:00
app.downloadLink(url, bitrate)
click.echo("All done!")
2020-02-17 15:46:18 +00:00
if __name__ == '__main__':
2020-08-14 18:31:37 +00:00
download()