feat: implement iptv

This commit is contained in:
shinya
2025-08-24 00:26:48 +08:00
parent eadd93fde6
commit 0a8c255279
22 changed files with 2399 additions and 12 deletions
+30
View File
@@ -0,0 +1,30 @@
import { NextRequest, NextResponse } from 'next/server';
import { getCachedLiveChannels } from '@/lib/live';
export async function GET(request: NextRequest) {
try {
const { searchParams } = new URL(request.url);
const sourceKey = searchParams.get('source');
if (!sourceKey) {
return NextResponse.json({ error: '缺少直播源参数' }, { status: 400 });
}
const channelData = await getCachedLiveChannels(sourceKey);
if (!channelData) {
return NextResponse.json({ error: '频道信息未找到' }, { status: 404 });
}
return NextResponse.json({
success: true,
data: channelData.channels
});
} catch (error) {
return NextResponse.json(
{ error: '获取频道信息失败' },
{ status: 500 }
);
}
}
+30
View File
@@ -0,0 +1,30 @@
/* eslint-disable no-console */
import { NextRequest, NextResponse } from 'next/server';
import { getConfig } from '@/lib/config';
export async function GET(request: NextRequest) {
console.log(request.url)
try {
const config = await getConfig();
if (!config) {
return NextResponse.json({ error: '配置未找到' }, { status: 404 });
}
// 过滤出所有非 disabled 的直播源
const liveSources = (config.LiveConfig || []).filter(source => !source.disabled);
return NextResponse.json({
success: true,
data: liveSources
});
} catch (error) {
console.error('获取直播源失败:', error);
return NextResponse.json(
{ error: '获取直播源失败' },
{ status: 500 }
);
}
}