mirror of
https://github.com/Tzahi12345/YoutubeDL-Material.git
synced 2026-04-18 20:31:30 +03:00
Fixed issue where errored single videos in playlist/sub downloads in yt-dlp would cause the entire sub check to fail (#493)
This commit is contained in:
@@ -241,65 +241,22 @@ async function getVideosForSub(sub, user_uid = null) {
|
|||||||
logger.verbose('Subscription: finished check for ' + sub.name);
|
logger.verbose('Subscription: finished check for ' + sub.name);
|
||||||
if (err && !output) {
|
if (err && !output) {
|
||||||
logger.error(err.stderr ? err.stderr : err.message);
|
logger.error(err.stderr ? err.stderr : err.message);
|
||||||
if (err.stderr.includes('This video is unavailable')) {
|
if (err.stderr.includes('This video is unavailable') || err.stderr.includes('Private video')) {
|
||||||
logger.info('An error was encountered with at least one video, backup method will be used.')
|
logger.info('An error was encountered with at least one video, backup method will be used.')
|
||||||
try {
|
try {
|
||||||
// TODO: reimplement
|
const outputs = err.stdout.split(/\r\n|\r|\n/); // .map(jsonStr => JSON.parse(jsonStr));
|
||||||
|
const files_to_download = await handleOutputJSON(outputs, sub, user_uid);
|
||||||
// const outputs = err.stdout.split(/\r\n|\r|\n/);
|
resolve(files_to_download);
|
||||||
// for (let i = 0; i < outputs.length; i++) {
|
|
||||||
// const output = JSON.parse(outputs[i]);
|
|
||||||
// await handleOutputJSON(sub, output, i === 0, multiUserMode)
|
|
||||||
// if (err.stderr.includes(output['id']) && archive_path) {
|
|
||||||
// // we found a video that errored! add it to the archive to prevent future errors
|
|
||||||
// if (sub.archive) {
|
|
||||||
// archive_dir = sub.archive;
|
|
||||||
// archive_path = path.join(archive_dir, 'archive.txt')
|
|
||||||
// fs.appendFileSync(archive_path, output['id']);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
logger.error('Backup method failed. See error below:');
|
logger.error('Backup method failed. See error below:');
|
||||||
logger.error(e);
|
logger.error(e);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
logger.error('Subscription check failed!');
|
||||||
}
|
}
|
||||||
resolve(false);
|
resolve(false);
|
||||||
} else if (output) {
|
} else if (output) {
|
||||||
if (config_api.getConfigItem('ytdl_subscriptions_redownload_fresh_uploads')) {
|
const files_to_download = await handleOutputJSON(output, sub, user_uid);
|
||||||
await setFreshUploads(sub, user_uid);
|
|
||||||
checkVideosForFreshUploads(sub, user_uid);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (output.length === 0 || (output.length === 1 && output[0] === '')) {
|
|
||||||
logger.verbose('No additional videos to download for ' + sub.name);
|
|
||||||
resolve(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const output_jsons = [];
|
|
||||||
for (let i = 0; i < output.length; i++) {
|
|
||||||
let output_json = null;
|
|
||||||
try {
|
|
||||||
output_json = JSON.parse(output[i]);
|
|
||||||
output_jsons.push(output_json);
|
|
||||||
} catch(e) {
|
|
||||||
output_json = null;
|
|
||||||
}
|
|
||||||
if (!output_json) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const files_to_download = await getFilesToDownload(sub, output_jsons);
|
|
||||||
const base_download_options = generateOptionsForSubscriptionDownload(sub, user_uid);
|
|
||||||
|
|
||||||
for (let j = 0; j < files_to_download.length; j++) {
|
|
||||||
const file_to_download = files_to_download[j];
|
|
||||||
file_to_download['formats'] = utils.stripPropertiesFromObject(file_to_download['formats'], ['format_id', 'filesize', 'filesize_approx']); // prevent download object from blowing up in size
|
|
||||||
await downloader_api.createDownload(file_to_download['webpage_url'], sub.type || 'video', base_download_options, user_uid, sub.id, sub.name, file_to_download);
|
|
||||||
}
|
|
||||||
|
|
||||||
resolve(files_to_download);
|
resolve(files_to_download);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -309,6 +266,43 @@ async function getVideosForSub(sub, user_uid = null) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function handleOutputJSON(output, sub, user_uid) {
|
||||||
|
if (config_api.getConfigItem('ytdl_subscriptions_redownload_fresh_uploads')) {
|
||||||
|
await setFreshUploads(sub, user_uid);
|
||||||
|
checkVideosForFreshUploads(sub, user_uid);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (output.length === 0 || (output.length === 1 && output[0] === '')) {
|
||||||
|
logger.verbose('No additional videos to download for ' + sub.name);
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
const output_jsons = [];
|
||||||
|
for (let i = 0; i < output.length; i++) {
|
||||||
|
let output_json = null;
|
||||||
|
try {
|
||||||
|
output_json = JSON.parse(output[i]);
|
||||||
|
output_jsons.push(output_json);
|
||||||
|
} catch(e) {
|
||||||
|
output_json = null;
|
||||||
|
}
|
||||||
|
if (!output_json) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const files_to_download = await getFilesToDownload(sub, output_jsons);
|
||||||
|
const base_download_options = generateOptionsForSubscriptionDownload(sub, user_uid);
|
||||||
|
|
||||||
|
for (let j = 0; j < files_to_download.length; j++) {
|
||||||
|
const file_to_download = files_to_download[j];
|
||||||
|
file_to_download['formats'] = utils.stripPropertiesFromObject(file_to_download['formats'], ['format_id', 'filesize', 'filesize_approx']); // prevent download object from blowing up in size
|
||||||
|
await downloader_api.createDownload(file_to_download['webpage_url'], sub.type || 'video', base_download_options, user_uid, sub.id, sub.name, file_to_download);
|
||||||
|
}
|
||||||
|
|
||||||
|
return files_to_download;
|
||||||
|
}
|
||||||
|
|
||||||
function generateOptionsForSubscriptionDownload(sub, user_uid) {
|
function generateOptionsForSubscriptionDownload(sub, user_uid) {
|
||||||
let basePath = null;
|
let basePath = null;
|
||||||
if (user_uid)
|
if (user_uid)
|
||||||
|
|||||||
Reference in New Issue
Block a user