mirror of
https://github.com/Tzahi12345/YoutubeDL-Material.git
synced 2026-04-19 02:41:29 +03:00
Fixed issue where sub check would crash server if no subs existed
This commit is contained in:
@@ -214,6 +214,7 @@ exports.watchSubscriptionsInterval = async () => {
|
|||||||
if (!change) return;
|
if (!change) return;
|
||||||
if (change['key'] === 'ytdl_subscriptions_check_interval' || change['key'] === 'ytdl_multi_user_mode') {
|
if (change['key'] === 'ytdl_subscriptions_check_interval' || change['key'] === 'ytdl_multi_user_mode') {
|
||||||
current_sub_index = 0; // TODO: start after the last sub check
|
current_sub_index = 0; // TODO: start after the last sub check
|
||||||
|
logger.verbose('Resetting sub check schedule due to config change');
|
||||||
clearInterval(parent_interval);
|
clearInterval(parent_interval);
|
||||||
const new_interval = config_api.getConfigItem('ytdl_subscriptions_check_interval');
|
const new_interval = config_api.getConfigItem('ytdl_subscriptions_check_interval');
|
||||||
parent_interval = setInterval(() => watchSubscriptions(), new_interval*1000);
|
parent_interval = setInterval(() => watchSubscriptions(), new_interval*1000);
|
||||||
@@ -224,6 +225,10 @@ exports.watchSubscriptionsInterval = async () => {
|
|||||||
|
|
||||||
async function watchSubscriptions() {
|
async function watchSubscriptions() {
|
||||||
const subscription_ids = await getValidSubscriptionsToCheck();
|
const subscription_ids = await getValidSubscriptionsToCheck();
|
||||||
|
if (subscription_ids.length === 0) {
|
||||||
|
logger.info('Skipping subscription check as no valid subscriptions exist.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
checkSubscription(subscription_ids[current_sub_index]);
|
checkSubscription(subscription_ids[current_sub_index]);
|
||||||
current_sub_index = (current_sub_index + 1) % subscription_ids.length;
|
current_sub_index = (current_sub_index + 1) % subscription_ids.length;
|
||||||
}
|
}
|
||||||
@@ -243,7 +248,6 @@ async function checkSubscription(sub_id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
await exports.getVideosForSub(sub.id);
|
await exports.getVideosForSub(sub.id);
|
||||||
// TODO: make sure if multi user mode changes we are also cancelling this
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getValidSubscriptionsToCheck() {
|
async function getValidSubscriptionsToCheck() {
|
||||||
|
|||||||
Reference in New Issue
Block a user