feat: implement iptv

This commit is contained in:
shinya
2025-08-24 00:26:48 +08:00
parent 179e74bf45
commit b4e81d94eb
22 changed files with 2399 additions and 12 deletions

View File

@@ -6,6 +6,7 @@ import { NextRequest, NextResponse } from 'next/server';
import { getConfig, refineConfig } from '@/lib/config';
import { db } from '@/lib/db';
import { fetchVideoDetail } from '@/lib/fetchVideoDetail';
import { refreshLiveChannels } from '@/lib/live';
import { SearchResult } from '@/lib/types';
export const runtime = 'nodejs';
@@ -358,9 +359,25 @@ async function cronJob() {
// 执行其他定时任务
await refreshConfig();
await refreshAllLiveChannels();
await refreshRecordAndFavorites();
}
async function refreshAllLiveChannels() {
const config = await getConfig();
for (const liveInfo of config.LiveConfig || []) {
if (liveInfo.disabled) {
continue;
}
try {
const nums = await refreshLiveChannels(liveInfo);
liveInfo.channelNumber = nums;
} catch (error) {
console.error('刷新直播源失败:', error);
}
}
}
async function refreshConfig() {
let config = await getConfig();
if (config && config.ConfigSubscribtion && config.ConfigSubscribtion.URL && config.ConfigSubscribtion.AutoUpdate) {