mirror of
https://github.com/MoonTechLab/LunaTV.git
synced 2026-02-28 01:13:15 +08:00
feat: concurrent refresh in cron
This commit is contained in:
@@ -365,17 +365,24 @@ async function cronJob() {
|
|||||||
|
|
||||||
async function refreshAllLiveChannels() {
|
async function refreshAllLiveChannels() {
|
||||||
const config = await getConfig();
|
const config = await getConfig();
|
||||||
for (const liveInfo of config.LiveConfig || []) {
|
|
||||||
if (liveInfo.disabled) {
|
// 并发刷新所有启用的直播源
|
||||||
continue;
|
const refreshPromises = (config.LiveConfig || [])
|
||||||
}
|
.filter(liveInfo => !liveInfo.disabled)
|
||||||
try {
|
.map(async (liveInfo) => {
|
||||||
const nums = await refreshLiveChannels(liveInfo);
|
try {
|
||||||
liveInfo.channelNumber = nums;
|
const nums = await refreshLiveChannels(liveInfo);
|
||||||
} catch (error) {
|
liveInfo.channelNumber = nums;
|
||||||
console.error('刷新直播源失败:', error);
|
} catch (error) {
|
||||||
}
|
console.error(`刷新直播源失败 [${liveInfo.name || liveInfo.key}]:`, error);
|
||||||
}
|
liveInfo.channelNumber = 0;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 等待所有刷新任务完成
|
||||||
|
await Promise.all(refreshPromises);
|
||||||
|
|
||||||
|
// 保存配置
|
||||||
await db.saveAdminConfig(config);
|
await db.saveAdminConfig(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user