One llong queue working, failed downloads working, just a few more bugs and 3 long client spesific queues to get working

This commit is contained in:
Ben
2019-01-09 11:15:47 +00:00
parent ff73f5dcd4
commit fd210e5ad2

View File

@@ -29,14 +29,14 @@ module.exports.resolveVideos = async (arr) => {
} catch (e) {
output.data[video] = {found: false};
output.contents = true;
logger.log(`Error resolving video ${video}`);
logger.log(`Error resolving video ${video}: ${e}`);
}
}
return output;
}
let downloadQueue;
let downloadQueue = [];
module.exports.setupDownloadQueue = async (arr, socket, options) => {
let numOfDownloads;
@@ -71,7 +71,6 @@ async function runQueueAsync(socketID) {
async function download(video, videoName ,socket, audioOnly, path = './') {
return new Promise(async (resolve, reject) => {
let stream;
try {
if (audioOnly) {
stream = await ytdl(video, {quality: 'highest', filter: (format) => format.container === 'mp4'});
@@ -105,6 +104,7 @@ async function download(video, videoName ,socket, audioOnly, path = './') {
} catch (e) {
logger.log(`Socket id '${socket.id}' failed to download ${videoName}: ${e}`);
socket.emit('download-done', {video: video, title: videoName});
socket.emit('download-progress', {video: video, percent: "Failed", title: videoName});
resolve('error');
}
});