Queueing fixed, errors propely display and queue properly concludes, release 1.0.1
This commit is contained in:
@@ -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>";
|
||||
});
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user