Queueing fixed, errors propely display and queue properly concludes, release 1.0.1

This commit is contained in:
Ben
2019-01-09 15:03:20 +00:00
parent 7fe15edc55
commit e4d44c5e4f
2 changed files with 20 additions and 21 deletions

View File

@@ -80,19 +80,19 @@ socket.on('download-count', async (data) => {
downloadCount = data.num;
});
socket.on('download-done', async(data) => {
completedDownloads++;
socket.on('download-done', async(data) => {
downloads[data.video] = {title: data.title, percent: 'Complete!'};
renderDownloads();
if (completedDownloads == downloadCount) {
completedDownloads = 0; downloadCount = 0;
isDownloading = false;
downloads = [];
}
});
socket.on('download-progress', async (data) => {
downloads[data.video] = data;
renderDownloads();
});
socket.on('queue-concluded', async (data) => {
completedDownloads = 0; downloadCount = 0;
isDownloading = false;
downloads = [];
document.getElementById('VideoBox').innerHTML += "<h>Queue Concluded...</h>";
});

View File

@@ -60,22 +60,21 @@ module.exports.setupDownloadQueue = async (arr, socket, options) => {
videos: { }
}
for (const [key, value] of Object.entries(arr)) {
if (ytdl.validateURL(key)) {
numOfDownloads++;
for (const [key, value] of Object.entries(arr))
if (ytdl.validateURL(key))
socket.emit('download-progress', {video: key, percent: "Queued", title: value.title});
}
}
socket.emit('download-count', {num: numOfDownloads});
for (const [key, value] of Object.entries(arr)) {
if (ytdl.validateURL(key)) {
await runQueueAsync(socket.id);
await download(key, value.title, socket, options.audioOnly);
await new Promise(async (resolve, reject) => {
for (const [key, value] of Object.entries(arr)) {
if (ytdl.validateURL(key)) {
await runQueueAsync(socket.id);
await download(key, value.title, socket, options.audioOnly);
}
// if (arr.indexOf(key) == arr.length) {resolve();}
}
}
resolve();
});
socket.emit('queue-concluded');
}
async function runQueueAsync(socketID) {