2020-03-02 12:46:48 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
from deemix.api.deezer import Deezer
|
|
|
|
from deemix.utils.misc import getIDFromLink, getTypeFromLink, getBitrateInt
|
2020-04-06 13:57:10 +00:00
|
|
|
from deemix.app.downloader import download_track, download_album, download_playlist, download_artist, download_spotifytrack, download_spotifyalbum
|
2020-03-21 10:53:43 +00:00
|
|
|
from os import system as execute
|
2020-03-02 12:46:48 +00:00
|
|
|
|
|
|
|
dz = Deezer()
|
|
|
|
|
|
|
|
def downloadLink(url, settings, bitrate=None):
|
|
|
|
forcedBitrate = getBitrateInt(bitrate)
|
|
|
|
type = getTypeFromLink(url)
|
|
|
|
id = getIDFromLink(url, type)
|
2020-03-21 11:56:55 +00:00
|
|
|
folder = settings['downloadLocation']
|
2020-03-02 12:46:48 +00:00
|
|
|
if type == None or id == None:
|
|
|
|
print("URL not recognized")
|
|
|
|
if type == "track":
|
2020-03-21 11:56:55 +00:00
|
|
|
folder = download_track(dz, id, settings, forcedBitrate)
|
2020-03-02 12:46:48 +00:00
|
|
|
elif type == "album":
|
2020-03-21 11:56:55 +00:00
|
|
|
folder = download_album(dz, id, settings, forcedBitrate)
|
2020-03-02 12:46:48 +00:00
|
|
|
elif type == "playlist":
|
2020-03-21 11:56:55 +00:00
|
|
|
folder = download_playlist(dz, id, settings, forcedBitrate)
|
2020-03-02 12:46:48 +00:00
|
|
|
elif type == "artist":
|
|
|
|
download_artist(dz, id, settings, forcedBitrate)
|
2020-04-06 13:57:10 +00:00
|
|
|
elif type == "spotifytrack":
|
|
|
|
folder = download_spotifytrack(dz, id, settings, forcedBitrate)
|
|
|
|
elif type == "spotifyalbum":
|
|
|
|
folder = download_spotifyalbum(dz, id, settings, forcedBitrate)
|
2020-03-02 12:46:48 +00:00
|
|
|
else:
|
|
|
|
print("URL not supported yet")
|
2020-03-21 10:53:43 +00:00
|
|
|
return None
|
|
|
|
if settings['executeCommand'] != "":
|
2020-03-21 11:56:55 +00:00
|
|
|
execute(settings['executeCommand'].replace("%folder%", folder))
|