完善tmdb反代
This commit is contained in:
@@ -240,6 +240,7 @@ export async function POST(request: NextRequest) {
|
||||
// TMDB 配置
|
||||
tmdbApiKey: adminConfig.SiteConfig.TMDBApiKey,
|
||||
tmdbProxy: adminConfig.SiteConfig.TMDBProxy,
|
||||
tmdbReverseProxy: adminConfig.SiteConfig.TMDBReverseProxy,
|
||||
// 决策模型配置(固定使用自定义provider,复用主模型的API配置)
|
||||
enableDecisionModel: aiConfig.EnableDecisionModel,
|
||||
decisionProvider: 'custom',
|
||||
|
||||
@@ -179,7 +179,8 @@ export async function GET(request: NextRequest) {
|
||||
client,
|
||||
metadataPath,
|
||||
config.SiteConfig.TMDBApiKey,
|
||||
config.SiteConfig.TMDBProxy
|
||||
config.SiteConfig.TMDBProxy,
|
||||
config.SiteConfig.TMDBReverseProxy
|
||||
);
|
||||
|
||||
// 获取集数列表(使用目录路径或点击的文件路径)
|
||||
|
||||
@@ -32,6 +32,7 @@ export async function GET(request: NextRequest) {
|
||||
const config = await getConfig();
|
||||
const tmdbApiKey = config.SiteConfig.TMDBApiKey;
|
||||
const tmdbProxy = config.SiteConfig.TMDBProxy;
|
||||
const tmdbReverseProxy = config.SiteConfig.TMDBReverseProxy;
|
||||
|
||||
const actualKey = getNextApiKey(tmdbApiKey || '');
|
||||
if (!actualKey) {
|
||||
@@ -41,9 +42,11 @@ export async function GET(request: NextRequest) {
|
||||
);
|
||||
}
|
||||
|
||||
// 使用反代代理或默认 Base URL
|
||||
const baseUrl = tmdbReverseProxy || 'https://api.themoviedb.org';
|
||||
// 根据类型选择API端点
|
||||
const endpoint = type === 'movie' ? 'movie' : 'tv';
|
||||
const url = `https://api.themoviedb.org/3/${endpoint}/${id}?api_key=${actualKey}&language=zh-CN&append_to_response=credits`;
|
||||
const url = `${baseUrl}/3/${endpoint}/${id}?api_key=${actualKey}&language=zh-CN&append_to_response=credits`;
|
||||
|
||||
const fetchOptions: any = tmdbProxy
|
||||
? {
|
||||
|
||||
@@ -32,6 +32,7 @@ export async function GET(request: NextRequest) {
|
||||
const config = await getConfig();
|
||||
const tmdbApiKey = config.SiteConfig.TMDBApiKey;
|
||||
const tmdbProxy = config.SiteConfig.TMDBProxy;
|
||||
const tmdbReverseProxy = config.SiteConfig.TMDBReverseProxy;
|
||||
|
||||
if (!tmdbApiKey) {
|
||||
return NextResponse.json({ error: 'TMDB API Key 未配置' }, { status: 400 });
|
||||
@@ -42,7 +43,9 @@ export async function GET(request: NextRequest) {
|
||||
return NextResponse.json({ error: 'TMDB API Key 无效' }, { status: 400 });
|
||||
}
|
||||
|
||||
const url = `https://api.themoviedb.org/3/tv/${id}/season/${season}?api_key=${actualKey}&language=zh-CN`;
|
||||
// 使用反代代理或默认 Base URL
|
||||
const baseUrl = tmdbReverseProxy || 'https://api.themoviedb.org';
|
||||
const url = `${baseUrl}/3/tv/${id}/season/${season}?api_key=${actualKey}&language=zh-CN`;
|
||||
|
||||
const fetchOptions: any = tmdbProxy
|
||||
? {
|
||||
|
||||
@@ -31,6 +31,7 @@ export async function GET(request: NextRequest) {
|
||||
const config = await getConfig();
|
||||
const tmdbApiKey = config.SiteConfig.TMDBApiKey;
|
||||
const tmdbProxy = config.SiteConfig.TMDBProxy;
|
||||
const tmdbReverseProxy = config.SiteConfig.TMDBReverseProxy;
|
||||
|
||||
const actualKey = getNextApiKey(tmdbApiKey || '');
|
||||
if (!actualKey) {
|
||||
@@ -40,8 +41,10 @@ export async function GET(request: NextRequest) {
|
||||
);
|
||||
}
|
||||
|
||||
// 使用反代代理或默认 Base URL
|
||||
const baseUrl = tmdbReverseProxy || 'https://api.themoviedb.org';
|
||||
// 使用 multi search 同时搜索电影和电视剧
|
||||
const url = `https://api.themoviedb.org/3/search/multi?api_key=${actualKey}&language=zh-CN&query=${encodeURIComponent(query)}&page=1`;
|
||||
const url = `${baseUrl}/3/search/multi?api_key=${actualKey}&language=zh-CN&query=${encodeURIComponent(query)}&page=1`;
|
||||
|
||||
const fetchOptions: any = tmdbProxy
|
||||
? {
|
||||
|
||||
@@ -34,6 +34,7 @@ export async function GET(request: NextRequest) {
|
||||
const config = await getConfig();
|
||||
const tmdbApiKey = config.SiteConfig.TMDBApiKey;
|
||||
const tmdbProxy = config.SiteConfig.TMDBProxy;
|
||||
const tmdbReverseProxy = config.SiteConfig.TMDBReverseProxy;
|
||||
|
||||
if (!tmdbApiKey) {
|
||||
return NextResponse.json(
|
||||
@@ -42,7 +43,7 @@ export async function GET(request: NextRequest) {
|
||||
);
|
||||
}
|
||||
|
||||
const result = await getTVSeasons(tmdbApiKey, tvId, tmdbProxy);
|
||||
const result = await getTVSeasons(tmdbApiKey, tvId, tmdbProxy, tmdbReverseProxy);
|
||||
|
||||
if (result.code === 200 && result.seasons) {
|
||||
return NextResponse.json({
|
||||
|
||||
Reference in New Issue
Block a user