feat: fetch douban video info with year

This commit is contained in:
shinya
2025-07-18 22:32:48 +08:00
parent 29c6019462
commit 498010ba2e
7 changed files with 22 additions and 94 deletions

View File

@@ -8,6 +8,7 @@ interface DoubanCategoryApiResponse {
items: Array<{
id: string;
title: string;
card_subtitle: string;
pic: {
large: string;
normal: string;
@@ -106,6 +107,7 @@ export async function GET(request: Request) {
title: item.title,
poster: item.pic?.normal || item.pic?.large || '',
rate: item.rating?.value ? item.rating.value.toFixed(1) : '',
year: item.card_subtitle?.match(/(\d{4})/)?.[1] || '',
}));
const response: DoubanResult = {

View File

@@ -100,6 +100,7 @@ export async function GET(request: Request) {
title: item.title,
poster: item.cover,
rate: item.rate,
year: '',
}));
const response: DoubanResult = {
@@ -171,6 +172,7 @@ function handleTop250(pageStart: number) {
title: title,
poster: processedCover,
rate: rate,
year: '',
});
}

View File

@@ -294,6 +294,7 @@ function DoubanPageClient() {
poster={item.poster}
douban_id={item.id}
rate={item.rate}
year={item.year}
/>
</div>
))}

View File

@@ -13,7 +13,7 @@ import {
getAllPlayRecords,
subscribeToDataUpdates,
} from '@/lib/db.client';
import { getDoubanRecommends } from '@/lib/douban.client';
import { getDoubanCategories } from '@/lib/douban.client';
import { DoubanItem } from '@/lib/types';
import CapsuleSwitch from '@/components/CapsuleSwitch';
@@ -65,8 +65,12 @@ function HomeClient() {
// 并行获取热门电影和热门剧集
const [moviesData, tvShowsData] = await Promise.all([
getDoubanRecommends({ type: 'movie', tag: '热门' }),
getDoubanRecommends({ type: 'tv', tag: '热门' }),
getDoubanCategories({
kind: 'movie',
category: '热门',
type: '全部',
}),
getDoubanCategories({ kind: 'tv', category: 'tv', type: 'tv' }),
]);
if (moviesData.code === 200) {
@@ -242,6 +246,7 @@ function HomeClient() {
poster={movie.poster}
douban_id={movie.id}
rate={movie.rate}
year={movie.year}
/>
</div>
))}
@@ -288,6 +293,7 @@ function HomeClient() {
poster={show.poster}
douban_id={show.id}
rate={show.rate}
year={show.year}
/>
</div>
))}