readded fluent download bars (needs testing)
authorRemixDev <deezloaderremix@gmail.com>
Wed, 16 Oct 2019 10:01:17 +0000 (12:01 +0200)
committerRemixDev <deezloaderremix@gmail.com>
Wed, 16 Oct 2019 10:01:17 +0000 (12:01 +0200)
app/app.js

index 4628791129fbe4ead40f69214a6a6e6164e3e527..24be9e0e36c32223053a15114d2ec9033c167e6c 100644 (file)
@@ -1084,10 +1084,10 @@ io.sockets.on('connection', function (s) {
                                                                downloading.errorLog += `${t.id} | ${t.artist.name} - ${t.title} | ${err}\r\n`
                                                                logger.error(`[${t.artist.name} - ${t.title}] ${err}`)
                                                        }
-                                                       io.sockets.emit("downloadProgress", {
+                                                       /*io.sockets.emit("downloadProgress", {
                                                                queueId: downloading.queueId,
                                                                percentage: ((downloading.downloaded+downloading.failed) / downloading.size) * 100
-                                                       });
+                                                       });*/
                                                        io.sockets.emit("updateQueue", {
                                                                name: downloading.name,
                                                                artist: downloading.artist,
@@ -1173,10 +1173,10 @@ io.sockets.on('connection', function (s) {
                                                                downloading.errorLog += `${t.id} | ${t.artist.name} - ${t.title} | ${err}\r\n`
                                                                logger.error(`[${t.artist.name} - ${t.title}] ${err}`)
                                                        }
-                                                       io.sockets.emit("downloadProgress", {
+                                                       /*io.sockets.emit("downloadProgress", {
                                                                queueId: downloading.queueId,
                                                                percentage: ((downloading.downloaded+downloading.failed) / downloading.size) * 100
-                                                       });
+                                                       });*/
                                                        io.sockets.emit("updateQueue", {
                                                                name: downloading.name,
                                                                artist: downloading.artist,
@@ -1308,10 +1308,10 @@ io.sockets.on('connection', function (s) {
                                                                downloading.errorLog += `${t.id} | ${t.artist.name} - ${t.title} | ${err}\r\n`
                                                                logger.error(`[${t.artist.name} - ${t.title}] ${err.stack ? err.stack : err}`)
                                                        }
-                                                       io.sockets.emit("downloadProgress", {
+                                                       /*io.sockets.emit("downloadProgress", {
                                                                queueId: downloading.queueId,
                                                                percentage: ((downloading.downloaded+downloading.failed) / downloading.size) * 100
-                                                       });
+                                                       });*/
                                                        io.sockets.emit("updateQueue", {
                                                                name: downloading.name,
                                                                artist: downloading.artist,
@@ -1925,11 +1925,20 @@ io.sockets.on('connection', function (s) {
                                                                                reject("Not in Queue")
                                                                        }
                                                                        try{
+                                                                               if (!downloadQueue[queueId].percentage) {
+                                                                                       downloadQueue[queueId].percentage = 0
+                                                                               }
                                                                                let complete = track.selectedFilesize
                                                                                let percentage = (chunkLength / complete) * 100;
                                                                                if ((percentage - downloadQueue[queueId].tracksData[track.position].progress > 1) || (chunkLength == complete)) {
                                                                                        downloadQueue[queueId].tracksData[track.position].progress = percentage
                                                                                }
+                                                                               let chunkProgres = ((chunk.length / complete)) / downloadQueue[queueId].size * 100
+                                                                               downloadQueue[queueId].percentage += chunkProgres
+                                                                               io.sockets.emit("downloadProgress", {
+                                                                                       queueId: queueId,
+                                                                                       percentage: downloadQueue[queueId].percentage
+                                                                               })
                                                                        }catch(err){}
                                                                }
                                                        }