fixed80: 相关推荐10部(豆瓣) + 中间件白名单
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:32:27 +08:00
1 parent 574fa99fb4
commit 7a99890425
3 files changed
+78 -1

No files matched your search

+38
View File
@@ -0,0 +1,38 @@
import { NextRequest, NextResponse } from 'next/server';
export const dynamic = 'force-dynamic';
export async function GET(req: NextRequest) {
const { searchParams } = new URL(req.url);
const id = (searchParams.get('id') || '').trim();
const type = (searchParams.get('type') || 'movie').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';
const kind = type === 'tv' ? 'tv' : 'movie';
try {
const r = await fetch(
`https://m.douban.com/rexxar/api/v2/${kind}/${id}/recommendations?count=10&start=0`,
{
headers: { 'User-Agent': ua, Referer: `https://m.douban.com/${kind}/subject/${id}/`, Accept: 'application/json' },
signal: AbortSignal.timeout(15000),
}
);
if (!r.ok) return NextResponse.json({ code: 0, msg: '请求失败' });
const arr: any = await r.json();
if (!Array.isArray(arr)) return NextResponse.json({ code: 0, msg: '无数据' });
const list = arr.slice(0, 10).map((x: any) => ({
id: String(x.id || ''),
title: x.title || '',
poster: x?.pic?.large || x?.pic?.normal || '',
rating: Number(x?.rating?.value || 0),
subtitle: x.card_subtitle || '',
url: x.url || '',
}));
return NextResponse.json({ code: 1, msg: 'ok', list });
} catch (e: any) {
return NextResponse.json({ code: 0, msg: e?.message || 'error' });
}
}