mirror of
https://github.com/Tzahi12345/YoutubeDL-Material.git
synced 2026-04-23 03:33:20 +03:00
Updated methodology of calculating download progress to rely on fs.readdir instead of glob
This commit is contained in:
@@ -3,7 +3,6 @@ const { uuid } = require('uuidv4');
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
const mergeFiles = require('merge-files');
|
const mergeFiles = require('merge-files');
|
||||||
const NodeID3 = require('node-id3')
|
const NodeID3 = require('node-id3')
|
||||||
const glob = require('glob')
|
|
||||||
const Mutex = require('async-mutex').Mutex;
|
const Mutex = require('async-mutex').Mutex;
|
||||||
|
|
||||||
const youtubedl = require('youtube-dl');
|
const youtubedl = require('youtube-dl');
|
||||||
@@ -583,20 +582,26 @@ async function checkDownloadPercent(download_uid) {
|
|||||||
if (!resulting_file_size) return;
|
if (!resulting_file_size) return;
|
||||||
|
|
||||||
let sum_size = 0;
|
let sum_size = 0;
|
||||||
glob(`{${files_to_check_for_progress.join(',')}, }*`, async (err, files) => {
|
for (let i = 0; i < files_to_check_for_progress.length; i++) {
|
||||||
files.forEach(async file => {
|
const file_to_check_for_progress = files_to_check_for_progress[i];
|
||||||
try {
|
const dir = path.dirname(file_to_check_for_progress);
|
||||||
const file_stats = fs.statSync(file);
|
if (!fs.existsSync(dir)) continue;
|
||||||
if (file_stats && file_stats.size) {
|
fs.readdir(dir, async (err, files) => {
|
||||||
sum_size += file_stats.size;
|
for (let j = 0; j < files.length; j++) {
|
||||||
}
|
const file = files[j];
|
||||||
} catch (e) {
|
if (!file.includes(path.basename(file_to_check_for_progress))) continue;
|
||||||
|
try {
|
||||||
|
const file_stats = fs.statSync(path.join(dir, file));
|
||||||
|
if (file_stats && file_stats.size) {
|
||||||
|
sum_size += file_stats.size;
|
||||||
|
}
|
||||||
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const percent_complete = (sum_size/resulting_file_size * 100).toFixed(2);
|
||||||
|
await db_api.updateRecord('download_queue', {uid: download_uid}, {percent_complete: percent_complete});
|
||||||
});
|
});
|
||||||
const percent_complete = (sum_size/resulting_file_size * 100).toFixed(2);
|
}
|
||||||
await db_api.updateRecord('download_queue', {uid: download_uid}, {percent_complete: percent_complete});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.generateNFOFile = (info, output_path) => {
|
exports.generateNFOFile = (info, output_path) => {
|
||||||
|
|||||||
@@ -40,7 +40,6 @@
|
|||||||
"express": "^4.17.3",
|
"express": "^4.17.3",
|
||||||
"fluent-ffmpeg": "^2.1.2",
|
"fluent-ffmpeg": "^2.1.2",
|
||||||
"fs-extra": "^9.0.0",
|
"fs-extra": "^9.0.0",
|
||||||
"glob": "^7.1.6",
|
|
||||||
"jsonwebtoken": "^8.5.1",
|
"jsonwebtoken": "^8.5.1",
|
||||||
"lowdb": "^1.0.0",
|
"lowdb": "^1.0.0",
|
||||||
"md5": "^2.2.1",
|
"md5": "^2.2.1",
|
||||||
|
|||||||
Reference in New Issue
Block a user