增加电视直播刷新间隔配置

This commit is contained in:
mtvpls
2026-05-06 09:57:31 +08:00
parent 6d9e092448
commit cb47150eb2
5 changed files with 119 additions and 7 deletions
+20 -2
View File
@@ -8,12 +8,17 @@ import { db, getStorage } from '@/lib/db';
import { EmailService } from '@/lib/email.service';
import {
FavoriteUpdate,
MangaShelfUpdate,
getBatchFavoriteUpdateEmailTemplate,
getBatchMangaUpdateEmailTemplate,
MangaShelfUpdate,
} from '@/lib/email.templates';
import { fetchVideoDetail } from '@/lib/fetchVideoDetail';
import { refreshLiveChannels } from '@/lib/live';
import {
getLastGlobalLiveRefreshTime,
getLiveRefreshIntervalHours,
refreshLiveChannels,
setLastGlobalLiveRefreshTime,
} from '@/lib/live';
import { MangaChapter, MangaShelfItem } from '@/lib/manga.types';
import { startOpenListRefresh } from '@/lib/openlist-refresh';
import { getSuwayomiConfig, loginWithSimpleAuth, SuwayomiClient } from '@/lib/suwayomi.client';
@@ -236,6 +241,17 @@ async function cronJob() {
async function refreshAllLiveChannels() {
const config = await getConfig();
const refreshIntervalHours = getLiveRefreshIntervalHours(config.LiveRefreshIntervalHours);
const lastRefreshTime = getLastGlobalLiveRefreshTime();
const now = Date.now();
const intervalMs = refreshIntervalHours * 60 * 60 * 1000;
const timeSinceLastRefresh = now - lastRefreshTime;
if (lastRefreshTime > 0 && timeSinceLastRefresh < intervalMs) {
const remainingHours = Math.ceil((intervalMs - timeSinceLastRefresh) / (60 * 60 * 1000));
console.log(`跳过刷新电视直播:距离上次刷新仅 ${Math.floor(timeSinceLastRefresh / (60 * 60 * 1000))} 小时,还需等待 ${remainingHours} 小时`);
return;
}
// 并发刷新所有启用的直播源
const refreshPromises = (config.LiveConfig || [])
@@ -253,6 +269,8 @@ async function refreshAllLiveChannels() {
// 等待所有刷新任务完成
await Promise.all(refreshPromises);
setLastGlobalLiveRefreshTime(Date.now());
// 保存配置
await db.saveAdminConfig(config);
}