diff --git a/backend/subscriptions.js b/backend/subscriptions.js index c1bbefe..2d212ed 100644 --- a/backend/subscriptions.js +++ b/backend/subscriptions.js @@ -254,13 +254,13 @@ exports.getVideosForSub = async (sub, user_uid = null) => { } logger.verbose('Subscription: finished check for ' + sub.name); - const processed_output = utils.parseOutputJSON(output, err); - if (!processed_output) { + const parsed_output = utils.parseOutputJSON(output, err); + if (!parsed_output) { logger.error('Subscription check failed!'); resolve(null); return; } - const files_to_download = await handleOutputJSON(processed_output, sub, user_uid); + const files_to_download = await handleOutputJSON(parsed_output, sub, user_uid); resolve(files_to_download); return; }); diff --git a/backend/utils.js b/backend/utils.js index 8c6a1ae..837a063 100644 --- a/backend/utils.js +++ b/backend/utils.js @@ -545,7 +545,10 @@ exports.parseOutputJSON = (output, err) => { logger.error(e); return null; } - } else { + } else if (output.length === 0 || (output.length === 1 && output[0].length === 0)) { + // output is '' or [''] + return []; + } else { for (const output_item of output) { // we have to do this because sometimes there will be leading characters before the actual json const start_idx = output_item.indexOf('{"');