Fixed artist download issue

This commit is contained in:
RemixDev
2021-05-29 16:21:00 +02:00
parent b33601e86a
commit 5291cbbd16
4 changed files with 11 additions and 14 deletions

View File

@@ -66,7 +66,7 @@ export async function addToQueue(dz: any, url: string[], bitrate: number) {
console.log(`Adding ${link} to queue`)
let downloadObj = await deemix.generateDownloadObject(dz, link, bitrate, plugins, listener)
if (Array.isArray(downloadObj)){
downloadObjs.concat(downloadObj)
downloadObjs = downloadObjs.concat(downloadObj)
} else {
downloadObjs.push(downloadObj)
}
@@ -81,8 +81,11 @@ export async function addToQueue(dz: any, url: string[], bitrate: number) {
downloadObjs.forEach((downloadObj: any) => {
// Check if element is already in queue
if (Object.keys(queue).includes(downloadObj.uuid))
throw new AlreadyInQueue(downloadObj.getEssentialDict(), !isSingleObject)
if (Object.keys(queue).includes(downloadObj.uuid)){
listener.send('alreadyInQueue', downloadObj.getEssentialDict())
return
}
// Save queue status when adding something to the queue
if (!fs.existsSync(configFolder + 'queue')) fs.mkdirSync(configFolder + 'queue')

View File

@@ -18,10 +18,6 @@ const handler: ApiHandler['handler'] = async (req, res) => {
obj = await addToQueue(dz, url, bitrate)
} catch (e) {
switch (e.name) {
case 'AlreadyInQueue':
res.send({ result: false, errid: e.name, data: { url, bitrate, obj: e.item } })
listener.send('alreadyInQueue', e.item)
break
case 'NotLoggedIn':
res.send({ result: false, errid: e.name, data: { url, bitrate } })
listener.send('loginNeededToDownload')