mirror of
https://github.com/Tzahi12345/YoutubeDL-Material.git
synced 2026-04-08 23:21:28 +03:00
Fixes bug where playlists could not have download progress tracked
- downloads are now treated as playlists for cleaner logic
This commit is contained in:
@@ -1159,7 +1159,10 @@ async function downloadFileByURL_exec(url, type, options, sessionID = null) {
|
||||
return;
|
||||
} else {
|
||||
// store info in download for future use
|
||||
download['_filename'] = info['_filename'];
|
||||
if (Array.isArray(info)) {
|
||||
download['fileNames'] = [];
|
||||
for (let info_obj of info) download['fileNames'].push(info_obj['_filename']);
|
||||
}
|
||||
download['filesize'] = utils.getExpectedFileSize(info);
|
||||
}
|
||||
|
||||
@@ -1613,12 +1616,15 @@ function checkDownloadPercent(download) {
|
||||
Any file that starts with <video title> will be counted as part of the "bytes downloaded", which will
|
||||
be divided by the "total expected bytes."
|
||||
*/
|
||||
const file_id = download['file_id'];
|
||||
const filename = path.format(path.parse(download['_filename'].substring(0, download['_filename'].length-4)));
|
||||
// assume it's a playlist for logic reasons
|
||||
const fileNames = Array.isArray(download['fileNames']) ? download['fileNames']
|
||||
: [path.format(path.parse(download['_filename'].substring(0, download['_filename'].length-4)))];
|
||||
|
||||
|
||||
const resulting_file_size = download['filesize'];
|
||||
|
||||
glob(`${filename}*`, (err, files) => {
|
||||
let sum_size = 0;
|
||||
let sum_size = 0;
|
||||
let glob_str = '';
|
||||
glob(`{${fileNames.join(',')}, }*`, (err, files) => {
|
||||
files.forEach(file => {
|
||||
try {
|
||||
const file_stats = fs.statSync(file);
|
||||
|
||||
Reference in New Issue
Block a user