mirror of
https://github.com/Tzahi12345/YoutubeDL-Material.git
synced 2026-03-07 12:00:01 +03:00
Improved download fail backup method
This commit is contained in:
@@ -521,6 +521,8 @@ exports.generateArgs = async (url, type, options, user_uid = null, simulated = f
|
||||
downloadConfig.push('--write-thumbnail');
|
||||
}
|
||||
|
||||
downloadConfig.push('-i');
|
||||
|
||||
if (globalArgs && globalArgs !== '') {
|
||||
// adds global args
|
||||
if (downloadConfig.indexOf('-o') !== -1 && globalArgs.split(',,').indexOf('-o') !== -1) {
|
||||
@@ -571,8 +573,8 @@ exports.getVideoInfoByURL = async (url, args = [], download_uid = null) => {
|
||||
let {callback} = await youtubedl_api.runYoutubeDL(url, new_args);
|
||||
const {parsed_output, err} = await callback;
|
||||
if (!parsed_output || parsed_output.length === 0) {
|
||||
let error_message = `Error while retrieving info on video with URL ${url} with the following message: ${err}`;
|
||||
if (err.stderr) error_message += `\n\n${err.stderr}`;
|
||||
let error_message = `Error while retrieving info on video with URL ${url}`;
|
||||
if (err.stderr) error_message += ` with the following message: \n${err.stderr}`;
|
||||
logger.error(error_message);
|
||||
if (download_uid) {
|
||||
await handleDownloadError(download_uid, error_message, 'info_retrieve_failed');
|
||||
|
||||
@@ -529,7 +529,9 @@ exports.parseOutputJSON = (output, err) => {
|
||||
let split_output = [];
|
||||
// const output_jsons = [];
|
||||
if (err && !output) {
|
||||
if (!err.stderr.includes('This video is unavailable') && !err.stderr.includes('Private video')) {
|
||||
const attempt_backup_errs = ['This video is unavailable', 'Private video', 'unavailable video'];
|
||||
const attempt_backup = err.stderr ? attempt_backup_errs.some(err_msg => err.stderr.includes(err_msg)) : false;
|
||||
if (!attempt_backup) {
|
||||
return null;
|
||||
}
|
||||
logger.info('An error was encountered with at least one video, backup method will be used.')
|
||||
|
||||
@@ -67,7 +67,9 @@ const runYoutubeDLProcess = async (url, args, youtubedl_fork = config_api.getCon
|
||||
const parsed_output = utils.parseOutputJSON(stdout.trim().split(/\r?\n/), stderr);
|
||||
resolve({parsed_output, err: stderr});
|
||||
} catch (e) {
|
||||
resolve({parsed_output: null, err: e})
|
||||
// Attempt to not fail
|
||||
const parsed_output = utils.parseOutputJSON(e && e.stdout && e.stdout.trim().split(/\r?\n/), e && e.stderr);
|
||||
resolve({parsed_output: parsed_output, err: parsed_output ? null : e});
|
||||
}
|
||||
});
|
||||
return {child_process, callback}
|
||||
|
||||
Reference in New Issue
Block a user