From 365c8291d46215e20d4921237cf160cac8b540d6 Mon Sep 17 00:00:00 2001 From: shinya Date: Thu, 26 Jun 2025 10:19:59 +0800 Subject: [PATCH] feat: optimize year match --- src/app/api/detail/route.ts | 4 +++- src/app/api/search/route.ts | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/app/api/detail/route.ts b/src/app/api/detail/route.ts index 9653b07..0c1d80b 100644 --- a/src/app/api/detail/route.ts +++ b/src/app/api/detail/route.ts @@ -144,7 +144,9 @@ async function getDetailFromApi( cover: videoDetail.vod_pic, desc: cleanHtmlTags(videoDetail.vod_content), type: videoDetail.type_name, - year: videoDetail.vod_year, + year: videoDetail.vod_year + ? videoDetail.vod_year.match(/\d{4}/)?.[0] || '' + : '', area: videoDetail.vod_area, director: videoDetail.vod_director, actor: videoDetail.vod_actor, diff --git a/src/app/api/search/route.ts b/src/app/api/search/route.ts index 5f70de2..9055092 100644 --- a/src/app/api/search/route.ts +++ b/src/app/api/search/route.ts @@ -95,7 +95,7 @@ async function searchFromApi( source: apiSite.key, source_name: apiName, class: item.vod_class, - year: item.vod_year, + year: item.vod_year ? item.vod_year.match(/\d{4}/)?.[0] || '' : '', desc: cleanHtmlTags(item.vod_content || ''), type_name: item.type_name, }; @@ -165,7 +165,9 @@ async function searchFromApi( source: apiSite.key, source_name: apiName, class: item.vod_class, - year: item.vod_year, + year: item.vod_year + ? item.vod_year.match(/\d{4}/)?.[0] || '' + : '', desc: cleanHtmlTags(item.vod_content || ''), type_name: item.type_name, };