Fixed some issues with downloading multiple tracks at once

This commit is contained in:
RemixDev 2020-06-19 20:14:20 +02:00
parent dd45835039
commit ffeb9d2ace
4 changed files with 12 additions and 6 deletions

View File

@ -13,12 +13,12 @@ from os.path import isfile
def download(bitrate, local, url): def download(bitrate, local, url):
settings = initSettings(local) settings = initSettings(local)
app.login() app.login()
url = list(url)
if isfile(url[0]): if isfile(url[0]):
filename = url[0] filename = url[0]
with open(filename) as f: with open(filename) as f:
url = f.readlines() url = f.readlines()
for u in url: app.downloadLink(url, settings, bitrate)
app.downloadLink(u, settings, bitrate)
click.echo("All done!") click.echo("All done!")
if local: if local:
click.echo(settings['downloadLocation']) #folder name output click.echo(settings['downloadLocation']) #folder name output

View File

@ -35,5 +35,4 @@ def login():
def downloadLink(url, settings, bitrate=None): def downloadLink(url, settings, bitrate=None):
url = url.strip()
addToQueue(dz, sp, url, settings, bitrate) addToQueue(dz, sp, url, settings, bitrate)

View File

@ -62,6 +62,7 @@ def generateQueueItem(dz, sp, url, settings, bitrate=None, albumAPI=None, interf
type = getTypeFromLink(url) type = getTypeFromLink(url)
id = getIDFromLink(url, type) id = getIDFromLink(url, type)
result = {} result = {}
result['link'] = url
if type == None or id == None: if type == None or id == None:
logger.warn("URL not recognized") logger.warn("URL not recognized")
result['error'] = "URL not recognized" result['error'] = "URL not recognized"
@ -254,6 +255,9 @@ def addToQueue(dz, sp, url, settings, bitrate=None, interface=None):
if type(url) is list: if type(url) is list:
queueItem = [] queueItem = []
for link in url: for link in url:
link = link.strip()
if link == "":
continue
logger.info("Generating queue item for: "+link) logger.info("Generating queue item for: "+link)
item = generateQueueItem(dz, sp, link, settings, bitrate, interface=interface) item = generateQueueItem(dz, sp, link, settings, bitrate, interface=interface)
if type(item) is list: if type(item) is list:
@ -261,12 +265,15 @@ def addToQueue(dz, sp, url, settings, bitrate=None, interface=None):
else: else:
queueItem.append(item) queueItem.append(item)
else: else:
url = url.strip()
if url == "":
return False
logger.info("Generating queue item for: "+url) logger.info("Generating queue item for: "+url)
queueItem = generateQueueItem(dz, sp, url, settings, bitrate, interface=interface) queueItem = generateQueueItem(dz, sp, url, settings, bitrate, interface=interface)
if type(queueItem) is list: if type(queueItem) is list:
for x in queueItem: for x in queueItem:
if 'error' in x: if 'error' in x:
logger.error(f"[{url}] {x['error']}") logger.error(f"[{x['link']}] {x['error']}")
continue continue
if x['uuid'] in list(queueList.keys()): if x['uuid'] in list(queueList.keys()):
logger.warn(f"[{x['uuid']}] Already in queue, will not be added again.") logger.warn(f"[{x['uuid']}] Already in queue, will not be added again.")
@ -278,7 +285,7 @@ def addToQueue(dz, sp, url, settings, bitrate=None, interface=None):
logger.info(f"[{x['uuid']}] Added to queue.") logger.info(f"[{x['uuid']}] Added to queue.")
else: else:
if 'error' in queueItem: if 'error' in queueItem:
logger.error(f"[{url}] {queueItem['error']}") logger.error(f"[{queueItem['link']}] {queueItem['error']}")
if interface: if interface:
interface.send("errorMessage", queueItem['error']) interface.send("errorMessage", queueItem['error'])
return False return False

View File

@ -7,7 +7,7 @@ README = (HERE / "README.md").read_text()
setup( setup(
name="deemix", name="deemix",
version="1.0.23", version="1.0.24",
description="A barebone deezer downloader library", description="A barebone deezer downloader library",
long_description=README, long_description=README,
long_description_content_type="text/markdown", long_description_content_type="text/markdown",