Fixed issue where errored single videos in playlist/sub downloads in yt-dlp would cause the entire sub check to fail (#493)

pull/657/head
Isaac Abadi 3 years ago
parent a4a0045475
commit d225e84a03

@ -241,31 +241,32 @@ 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) {
const files_to_download = await handleOutputJSON(output, sub, user_uid);
resolve(files_to_download);
}
});
}, err => {
logger.error(err);
updateSubscriptionProperty(sub, {downloading: false}, user_uid);
});
}
async function handleOutputJSON(output, sub, user_uid) {
if (config_api.getConfigItem('ytdl_subscriptions_redownload_fresh_uploads')) { if (config_api.getConfigItem('ytdl_subscriptions_redownload_fresh_uploads')) {
await setFreshUploads(sub, user_uid); await setFreshUploads(sub, user_uid);
checkVideosForFreshUploads(sub, user_uid); checkVideosForFreshUploads(sub, user_uid);
@ -273,8 +274,7 @@ async function getVideosForSub(sub, user_uid = null) {
if (output.length === 0 || (output.length === 1 && output[0] === '')) { if (output.length === 0 || (output.length === 1 && output[0] === '')) {
logger.verbose('No additional videos to download for ' + sub.name); logger.verbose('No additional videos to download for ' + sub.name);
resolve(true); return [];
return;
} }
const output_jsons = []; const output_jsons = [];
@ -300,13 +300,7 @@ async function getVideosForSub(sub, user_uid = null) {
await downloader_api.createDownload(file_to_download['webpage_url'], sub.type || 'video', base_download_options, user_uid, sub.id, sub.name, file_to_download); 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); return files_to_download;
}
});
}, err => {
logger.error(err);
updateSubscriptionProperty(sub, {downloading: false}, user_uid);
});
} }
function generateOptionsForSubscriptionDownload(sub, user_uid) { function generateOptionsForSubscriptionDownload(sub, user_uid) {

Loading…
Cancel
Save