mirror of
https://github.com/Tzahi12345/YoutubeDL-Material.git
synced 2026-03-12 07:40:57 +03:00
Compare commits
2 Commits
rebuild-da
...
fix-playli
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
004a234b02 | ||
|
|
daca715d1b |
@@ -1159,7 +1159,12 @@ async function downloadFileByURL_exec(url, type, options, sessionID = null) {
|
|||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
// store info in download for future use
|
// 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']);
|
||||||
|
} else {
|
||||||
|
download['_filename'] = info['_filename'];
|
||||||
|
}
|
||||||
download['filesize'] = utils.getExpectedFileSize(info);
|
download['filesize'] = utils.getExpectedFileSize(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1613,12 +1618,15 @@ function checkDownloadPercent(download) {
|
|||||||
Any file that starts with <video title> will be counted as part of the "bytes downloaded", which will
|
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."
|
be divided by the "total expected bytes."
|
||||||
*/
|
*/
|
||||||
const file_id = download['file_id'];
|
// assume it's a playlist for logic reasons
|
||||||
const filename = path.format(path.parse(download['_filename'].substring(0, download['_filename'].length-4)));
|
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'];
|
const resulting_file_size = download['filesize'];
|
||||||
|
let sum_size = 0;
|
||||||
glob(`${filename}*`, (err, files) => {
|
let glob_str = '';
|
||||||
let sum_size = 0;
|
glob(`{${fileNames.join(',')}, }*`, (err, files) => {
|
||||||
files.forEach(file => {
|
files.forEach(file => {
|
||||||
try {
|
try {
|
||||||
const file_stats = fs.statSync(file);
|
const file_stats = fs.statSync(file);
|
||||||
|
|||||||
@@ -105,19 +105,27 @@ function getDownloadedThumbnail(name, type, customPath = null) {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getExpectedFileSize(info_json) {
|
function getExpectedFileSize(input_info_jsons) {
|
||||||
if (info_json['filesize']) {
|
// treat single videos as arrays to have the file sizes checked/added to. makes the code cleaner
|
||||||
return info_json['filesize'];
|
const info_jsons = Array.isArray(input_info_jsons) ? input_info_jsons : [input_info_jsons];
|
||||||
}
|
|
||||||
|
|
||||||
const formats = info_json['format_id'].split('+');
|
|
||||||
let expected_filesize = 0;
|
let expected_filesize = 0;
|
||||||
formats.forEach(format_id => {
|
|
||||||
info_json.formats.forEach(available_format => {
|
info_jsons.forEach(info_json => {
|
||||||
if (available_format.format_id === format_id && available_format.filesize) {
|
if (info_json['filesize']) {
|
||||||
expected_filesize += available_format.filesize;
|
expected_filesize += info_json['filesize'];
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
const formats = info_json['format_id'].split('+');
|
||||||
|
let individual_expected_filesize = 0;
|
||||||
|
formats.forEach(format_id => {
|
||||||
|
info_json.formats.forEach(available_format => {
|
||||||
|
if (available_format.format_id === format_id && available_format.filesize) {
|
||||||
|
individual_expected_filesize += available_format.filesize;
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
expected_filesize += individual_expected_filesize;
|
||||||
});
|
});
|
||||||
|
|
||||||
return expected_filesize;
|
return expected_filesize;
|
||||||
|
|||||||
Reference in New Issue
Block a user