tmdb支持设置baseurl

This commit is contained in:
mtvpls
2026-01-17 18:04:58 +08:00
parent 9b7eb719a2
commit be8373de40
9 changed files with 95 additions and 31 deletions

View File

@@ -7384,7 +7384,7 @@ const SiteConfigComponent = ({
{/* TMDB Proxy */}
<div>
<label className='block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2'>
TMDB
TMDB
</label>
<input
type='text'
@@ -7402,6 +7402,28 @@ const SiteConfigComponent = ({
访 TMDB API
</p>
</div>
{/* TMDB Reverse Proxy */}
<div>
<label className='block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2'>
TMDB
</label>
<input
type='text'
placeholder='请输入反代 Base URL可选'
value={siteSettings.TMDBReverseProxy}
onChange={(e) =>
setSiteSettings((prev) => ({
...prev,
TMDBReverseProxy: e.target.value,
}))
}
className='w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 focus:ring-2 focus:ring-green-500 focus:border-transparent'
/>
<p className='mt-1 text-xs text-gray-500 dark:text-gray-400'>
TMDB Base URL
</p>
</div>
</div>
{/* Pansou 配置 */}

View File

@@ -43,6 +43,7 @@ export async function POST(request: NextRequest) {
DanmakuApiToken,
TMDBApiKey,
TMDBProxy,
TMDBReverseProxy,
BannerDataSource,
RecommendationDataSource,
PansouApiUrl,
@@ -124,6 +125,7 @@ export async function POST(request: NextRequest) {
typeof DanmakuApiToken !== 'string' ||
(TMDBApiKey !== undefined && typeof TMDBApiKey !== 'string') ||
(TMDBProxy !== undefined && typeof TMDBProxy !== 'string') ||
(TMDBReverseProxy !== undefined && typeof TMDBReverseProxy !== 'string') ||
(BannerDataSource !== undefined && typeof BannerDataSource !== 'string') ||
(RecommendationDataSource !== undefined && typeof RecommendationDataSource !== 'string') ||
typeof EnableComments !== 'boolean' ||
@@ -175,6 +177,7 @@ export async function POST(request: NextRequest) {
DanmakuApiToken,
TMDBApiKey,
TMDBProxy,
TMDBReverseProxy,
BannerDataSource,
RecommendationDataSource,
PansouApiUrl,

View File

@@ -61,6 +61,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(
@@ -94,7 +95,8 @@ export async function GET(request: NextRequest) {
const searchResult = await searchTMDBMulti(
tmdbApiKey,
cleanedTitle,
tmdbProxy
tmdbProxy,
tmdbReverseProxy
);
if (searchResult.code !== 200 || !searchResult.results.length) {
@@ -134,9 +136,9 @@ export async function GET(request: NextRequest) {
// 获取详情
let detailsResult;
if (mediaType === 'movie') {
detailsResult = await getTMDBMovieDetails(tmdbApiKey, tmdbId, tmdbProxy);
detailsResult = await getTMDBMovieDetails(tmdbApiKey, tmdbId, tmdbProxy, tmdbReverseProxy);
} else {
detailsResult = await getTMDBTVDetails(tmdbApiKey, tmdbId, tmdbProxy);
detailsResult = await getTMDBTVDetails(tmdbApiKey, tmdbId, tmdbProxy, tmdbReverseProxy);
}
if (detailsResult.code !== 200 || !detailsResult.details) {

View File

@@ -62,6 +62,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(
@@ -90,7 +91,7 @@ export async function GET(request: NextRequest) {
mediaType = cached.data.mediaType;
} else {
// 搜索TMDB
const searchResult = await searchTMDBMulti(tmdbApiKey, cleanedTitle, tmdbProxy);
const searchResult = await searchTMDBMulti(tmdbApiKey, cleanedTitle, tmdbProxy, tmdbReverseProxy);
if (searchResult.code !== 200 || !searchResult.results.length) {
return NextResponse.json(
@@ -145,8 +146,8 @@ export async function GET(request: NextRequest) {
// 获取推荐
const recommendationsResult =
mediaType === 'movie'
? await getTMDBMovieRecommendations(tmdbApiKey, tmdbId, tmdbProxy)
: await getTMDBTVRecommendations(tmdbApiKey, tmdbId, tmdbProxy);
? await getTMDBMovieRecommendations(tmdbApiKey, tmdbId, tmdbProxy, tmdbReverseProxy)
: await getTMDBTVRecommendations(tmdbApiKey, tmdbId, tmdbProxy, tmdbReverseProxy);
if (recommendationsResult.code !== 200) {
return NextResponse.json(

View File

@@ -56,6 +56,7 @@ export async function GET() {
// 使用TMDB数据源默认
const apiKey = config.SiteConfig?.TMDBApiKey;
const proxy = config.SiteConfig?.TMDBProxy;
const reverseProxy = config.SiteConfig?.TMDBReverseProxy;
if (!apiKey) {
return NextResponse.json(
@@ -65,13 +66,13 @@ export async function GET() {
}
// 获取热门内容
result = await getTMDBTrendingContent(apiKey, proxy);
result = await getTMDBTrendingContent(apiKey, proxy, reverseProxy);
// 为每个项目获取视频数据
if (result.code === 200 && result.list) {
const itemsWithVideos = await Promise.all(
result.list.map(async (item: any) => {
const videoKey = await getTMDBVideos(apiKey, item.media_type, item.id, proxy);
const videoKey = await getTMDBVideos(apiKey, item.media_type, item.id, proxy, reverseProxy);
return { ...item, video_key: videoKey };
})
);

View File

@@ -28,6 +28,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(
@@ -37,7 +38,7 @@ export async function GET(request: NextRequest) {
}
// 调用TMDB API获取数据
const result = await getTMDBUpcomingContent(tmdbApiKey, tmdbProxy);
const result = await getTMDBUpcomingContent(tmdbApiKey, tmdbProxy, tmdbReverseProxy);
if (result.code !== 200) {
return NextResponse.json(