2020-02-17 15:46:18 +00:00
|
|
|
#!/usr/bin/env python3
|
2020-02-23 21:51:16 +00:00
|
|
|
import click
|
|
|
|
from deemix.utils.misc import getIDFromLink, getTypeFromLink, getBitrateInt
|
|
|
|
from deemix.app.downloader import download_track, download_album, download_playlist
|
|
|
|
from deemix.app.settings import initSettings
|
2020-02-17 19:24:39 +00:00
|
|
|
|
2020-02-23 21:51:16 +00:00
|
|
|
@click.command()
|
|
|
|
@click.option('-b', '--bitrate', default=None, help='Overwrites the default bitrate selected')
|
|
|
|
@click.argument('url')
|
|
|
|
def download(bitrate, url):
|
|
|
|
settings = initSettings()
|
|
|
|
forcedBitrate = getBitrateInt(bitrate)
|
|
|
|
type = getTypeFromLink(url)
|
|
|
|
id = getIDFromLink(url, type)
|
|
|
|
if type == None or id == None:
|
|
|
|
click.echo("URL not recognized")
|
|
|
|
if type == "track":
|
|
|
|
download_track(id, settings, forcedBitrate)
|
|
|
|
elif type == "album":
|
|
|
|
download_album(id, settings, forcedBitrate)
|
|
|
|
elif type == "playlist":
|
|
|
|
download_playlist(id, settings, forcedBitrate)
|
|
|
|
else:
|
|
|
|
click.echo("URL not supported yet")
|
|
|
|
click.echo("All done!")
|
2020-02-17 15:46:18 +00:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2020-02-23 21:51:16 +00:00
|
|
|
download()
|