|
|
|
@ -241,31 +241,32 @@ async function getVideosForSub(sub, user_uid = null) {
|
|
|
|
|
logger.verbose('Subscription: finished check for ' + sub.name);
|
|
|
|
|
if (err && !output) {
|
|
|
|
|
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.')
|
|
|
|
|
try {
|
|
|
|
|
// TODO: reimplement
|
|
|
|
|
|
|
|
|
|
// const outputs = err.stdout.split(/\r\n|\r|\n/);
|
|
|
|
|
// 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']);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
const outputs = err.stdout.split(/\r\n|\r|\n/); // .map(jsonStr => JSON.parse(jsonStr));
|
|
|
|
|
const files_to_download = await handleOutputJSON(outputs, sub, user_uid);
|
|
|
|
|
resolve(files_to_download);
|
|
|
|
|
} catch(e) {
|
|
|
|
|
logger.error('Backup method failed. See error below:');
|
|
|
|
|
logger.error(e);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
logger.error('Subscription check failed!');
|
|
|
|
|
}
|
|
|
|
|
resolve(false);
|
|
|
|
|
} 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')) {
|
|
|
|
|
await setFreshUploads(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] === '')) {
|
|
|
|
|
logger.verbose('No additional videos to download for ' + sub.name);
|
|
|
|
|
resolve(true);
|
|
|
|
|
return;
|
|
|
|
|
return [];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resolve(files_to_download);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}, err => {
|
|
|
|
|
logger.error(err);
|
|
|
|
|
updateSubscriptionProperty(sub, {downloading: false}, user_uid);
|
|
|
|
|
});
|
|
|
|
|
return files_to_download;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function generateOptionsForSubscriptionDownload(sub, user_uid) {
|
|
|
|
|