feat: 优化影视源类型判断逻辑,支持更智能的API地址解析

This commit is contained in:
katelya
2025-09-04 13:18:29 +08:00
parent d6ea0a4748
commit 63d0942b66
+11 -2
View File
@@ -70,8 +70,17 @@ export async function GET(request: NextRequest) {
// 影视源配置
sites: sourceConfigs.map((source) => {
// 智能判断type如果api地址以.json结尾,则type为1,否则为0
const type = source.api.toLowerCase().endsWith('.json') ? 1 : 0;
// 智能type判断逻辑
// 1. 如果api地址包含 "/provide/vod" 且不包含 "at/xml",则认为是JSON类型 (type=1)
// 2. 如果api地址包含 "at/xml",则认为是XML类型 (type=0)
// 3. 如果api地址以 ".json" 结尾,则认为是JSON类型 (type=1)
// 4. 其他情况默认为JSON类型 (type=1),因为现在大部分都是JSON
let type = 1; // 默认为JSON类型
const apiLower = source.api.toLowerCase();
if (apiLower.includes('at/xml') || apiLower.endsWith('.xml')) {
type = 0; // XML类型
}
return {
key: source.key || source.name,