fixed79: 豆瓣详情兜底评分/演员/导演 + 新增 douban-detail 路由
Docker Build & Test / build (push) Canceled after 0s
Docker Build & Test / test (push) Canceled after 0s
Build & Push Docker image / build-and-push (linux/amd64) (push) Canceled after 0s
Build & Push Docker image / build-and-push (linux/arm/v7) (push) Canceled after 0s
Build & Push Docker image / build-and-push (linux/arm64) (push) Canceled after 0s
Build & Push Docker image / merge-images (push) Canceled after 0s

This commit is contained in:
3970260761 committed 2026-11-08 15:06:53 +08:00
1 parent 428b4b73d0
commit 574fa99fb4
3 files changed
+64 -9

No files matched your search

+45
View File
@@ -0,0 +1,45 @@
import { NextRequest, NextResponse } from 'next/server';
export const dynamic = 'force-dynamic';
// 从豆瓣 rexxar 获取条目详情(评分/演员/导演等)
export async function GET(req: NextRequest) {
const { searchParams } = new URL(req.url);
const id = (searchParams.get('id') || '').trim();
if (!id) return NextResponse.json({ code: 0, msg: '缺少豆瓣ID' });
const ua =
'Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.0 Mobile/15E148 Safari/604.1';
for (const kind of ['movie', 'tv']) {
try {
const r = await fetch(`https://m.douban.com/rexxar/api/v2/${kind}/${id}`, {
headers: { 'User-Agent': ua, Referer: `https://m.douban.com/${kind}/subject/${id}/`, Accept: 'application/json' },
signal: AbortSignal.timeout(15000),
});
if (!r.ok) continue;
const d: any = await r.json();
if (!d || !d.id) continue;
const actors = (Array.isArray(d.actors) ? d.actors : [])
.map((a: any) => a?.name || a?.title)
.filter(Boolean);
const directors = (Array.isArray(d.directors) ? d.directors : [])
.map((a: any) => a?.name || a?.title)
.filter(Boolean);
return NextResponse.json({
code: 1,
msg: 'ok',
title: d.title || '',
rating: Number(d?.rating?.value || 0),
ratingCount: Number(d?.rating?.count || 0),
actors,
directors,
area: Array.isArray(d.regions) ? d.regions.join(' / ') : d.regions || '',
year: d.year || '',
});
} catch {
continue;
}
}
return NextResponse.json({ code: 0, msg: '未找到', rating: 0, actors: [], directors: [] });
}