From 63d0942b66a944e62078dde3655908c837a707ba Mon Sep 17 00:00:00 2001 From: katelya Date: Thu, 4 Sep 2025 13:18:29 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E5=BD=B1=E8=A7=86?= =?UTF-8?q?=E6=BA=90=E7=B1=BB=E5=9E=8B=E5=88=A4=E6=96=AD=E9=80=BB=E8=BE=91?= =?UTF-8?q?=EF=BC=8C=E6=94=AF=E6=8C=81=E6=9B=B4=E6=99=BA=E8=83=BD=E7=9A=84?= =?UTF-8?q?API=E5=9C=B0=E5=9D=80=E8=A7=A3=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/api/tvbox/route.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/app/api/tvbox/route.ts b/src/app/api/tvbox/route.ts index c90b7a5..ebab6d0 100644 --- a/src/app/api/tvbox/route.ts +++ b/src/app/api/tvbox/route.ts @@ -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,