feat: merge year handle into api

This commit is contained in:
shinya
2025-07-11 12:38:46 +08:00
parent 868ec2d5aa
commit 6817ada00a
5 changed files with 18 additions and 27 deletions

View File

@@ -84,7 +84,9 @@ export async function searchFromApi(
source: apiSite.key,
source_name: apiName,
class: item.vod_class,
year: item.vod_year ? item.vod_year.match(/\d{4}/)?.[0] || '' : '',
year: item.vod_year
? item.vod_year.match(/\d{4}/)?.[0] || ''
: 'unknown',
desc: cleanHtmlTags(item.vod_content || ''),
type_name: item.type_name,
douban_id: item.vod_douban_id,
@@ -154,7 +156,7 @@ export async function searchFromApi(
class: item.vod_class,
year: item.vod_year
? item.vod_year.match(/\d{4}/)?.[0] || ''
: '',
: 'unknown',
desc: cleanHtmlTags(item.vod_content || ''),
type_name: item.type_name,
douban_id: item.vod_douban_id,
@@ -261,7 +263,7 @@ export async function getDetailFromApi(
type: videoDetail.type_name,
year: videoDetail.vod_year
? videoDetail.vod_year.match(/\d{4}/)?.[0] || ''
: '',
: 'unknown',
area: videoDetail.vod_area,
director: videoDetail.vod_director,
actor: videoDetail.vod_actor,
@@ -330,7 +332,7 @@ async function handleSpecialSourceDetail(
// 提取年份
const yearMatch = html.match(/>(\d{4})</);
const yearText = yearMatch ? yearMatch[1] : '';
const yearText = yearMatch ? yearMatch[1] : 'unknown';
return {
code: 200,

View File

@@ -16,7 +16,6 @@ interface FetchVideoDetailOptions {
source: string;
id: string;
fallbackTitle?: string;
fallbackYear?: string;
}
/**
@@ -28,7 +27,6 @@ export async function fetchVideoDetail({
source,
id,
fallbackTitle = '',
fallbackYear = '',
}: FetchVideoDetailOptions): Promise<VideoDetail> {
// 优先通过搜索接口查找精确匹配
if (fallbackTitle) {
@@ -67,7 +65,7 @@ export async function fetchVideoDetail({
source: data?.videoInfo?.source || source,
source_name: data?.videoInfo?.source_name || '',
class: data?.videoInfo?.remarks || '',
year: data?.videoInfo?.year || fallbackYear || '',
year: data?.videoInfo?.year || 'unknown',
desc: data?.videoInfo?.desc || '',
type_name: data?.videoInfo?.type || '',
} as VideoDetail;