feat: 相关推荐改本站片源按主演/导演/语言/地区/类型匹配 点击source+id直达片源 (fixed131)
Docker Build & Test / build (push) Canceled after 0s
Docker Build & Test / test (push) Canceled after 0s
Build & Push Docker image / build-and-push (linux/amd64) (push) Canceled after 0s
Build & Push Docker image / build-and-push (linux/arm/v7) (push) Canceled after 0s
Build & Push Docker image / build-and-push (linux/arm64) (push) Canceled after 0s
Build & Push Docker image / merge-images (push) Canceled after 0s
Release / release (push) Canceled after 0s
Release / docker (push) Canceled after 0s

This commit is contained in:
jinghui committed 2026-11-15 02:34:21 +08:00
1 parent dfc1d87a54
commit 4ba6bc2339
7 files changed
+439 -37

No files matched your search

+95 -33
View File
@@ -24,8 +24,11 @@ export default function VideoMetaExtra({
doubanId,
area,
lang,
genre,
isTv,
desc,
selfSource,
selfId,
}: {
title: string;
actor?: string;
@@ -36,13 +39,18 @@ export default function VideoMetaExtra({
doubanId?: number;
area?: string;
lang?: string;
genre?: string;
isTv?: boolean;
desc?: string;
/** 当前条目所属源与 id,用于相关推荐排除自己 */
selfSource?: string;
selfId?: string;
}) {
const [comments, setComments] = useState<DoubanComment[]>([]);
const [loading, setLoading] = useState(false);
const [dbDetail, setDbDetail] = useState<any>(null);
const [related, setRelated] = useState<any[]>([]);
const [relatedLoading, setRelatedLoading] = useState(false);
useEffect(() => {
if (!doubanId) return;
@@ -64,18 +72,47 @@ export default function VideoMetaExtra({
if (alive && d?.code === 1) setDbDetail(d);
})
.catch(() => {});
// 相关推荐
fetch(`/api/douban-related?id=${encodeURIComponent(String(doubanId))}&type=${isTv ? 'tv' : 'movie'}`)
.then((r) => r.json())
.then((d) => {
if (alive && d?.code === 1) setRelated(d.list || []);
})
.catch(() => {});
return () => {
alive = false;
};
}, [doubanId]);
// 相关推荐:本站片源,按 主演/导演/语言/地区/类型 匹配(不走豆瓣推荐接口)
useEffect(() => {
if (!title || (!actor && !director)) {
setRelated([]);
return;
}
let alive = true;
setRelatedLoading(true);
const params = new URLSearchParams({
title,
actor: actor || '',
director: director || '',
area: area || '',
lang: lang || '',
genre: genre || '',
doubanId: String(doubanId || ''),
selfSource: selfSource || '',
selfId: selfId || '',
});
if (isTv !== undefined) params.set('isTv', isTv ? '1' : '0');
fetch(`/api/related?${params.toString()}`)
.then((r) => r.json())
.then((d) => {
if (alive) setRelated(Array.isArray(d?.items) ? d.items : []);
})
.catch(() => {
if (alive) setRelated([]);
})
.finally(() => {
if (alive) setRelatedLoading(false);
});
return () => {
alive = false;
};
}, [title, actor, director, area, lang, genre, isTv, doubanId, selfSource, selfId]);
const actors = (actor || (dbDetail?.actors || []).join(','))
.split(/[,,、\/|]/)
.map((s: string) => s.trim())
@@ -208,35 +245,60 @@ export default function VideoMetaExtra({
))}
</div>
</div>
{related.length > 0 && (
{/* 相关推荐:本站片源按元数据匹配,点击直达该条片源 */}
{(related.length > 0 || relatedLoading) && (
<div className='mt-4'>
<div className='flex items-baseline gap-2 text-sm font-semibold mb-2 opacity-80'>
<div className='flex items-baseline gap-2 flex-wrap text-sm font-semibold mb-2 opacity-80'>
<span>相关推荐</span>
<span className='text-xs font-normal opacity-60'>豆瓣相似影片推荐 · 取前10</span>
</div>
<div className='grid grid-cols-5 gap-3'>
{related.map((r: any) => (
<a
key={r.id}
href={`/play?title=${encodeURIComponent(r.title)}`}
target='_self'
rel='noreferrer'
className='group block'
>
{r.poster ? (
<img
src={`/api/image-proxy?url=${encodeURIComponent(r.poster)}`}
alt={r.title}
className='w-full aspect-[2/3] object-cover rounded-md mb-1'
/>
) : null}
<div className='text-xs truncate group-hover:text-blue-500'>{r.title}</div>
{r.rating > 0 && (
<div className='text-xs text-amber-500'>{r.rating.toFixed(1)}</div>
)}
</a>
))}
<span className='text-[11px] font-normal opacity-60'>
按主演 / 导演 / 语言 / 地区 / 类型匹配 · 本站片源直达
</span>
</div>
{relatedLoading && related.length === 0 && (
<div className='grid grid-cols-5 gap-3'>
{[0, 1, 2, 3, 4].map((i) => (
<div
key={i}
className='animate-pulse aspect-[2/3] rounded-md bg-gray-200/70 dark:bg-gray-700/50'
/>
))}
</div>
)}
{related.length > 0 && (
<div className='grid grid-cols-5 gap-3'>
{related.map((r: any) => (
<a
key={`${r.source}-${r.id}`}
href={`/play?source=${encodeURIComponent(r.source)}&id=${encodeURIComponent(r.id)}&title=${encodeURIComponent(r.title)}${r.year ? `&year=${encodeURIComponent(r.year)}` : ''}`}
target='_self'
rel='noreferrer'
className='group block'
>
{r.poster ? (
<img
src={`/api/image-proxy?url=${encodeURIComponent(r.poster)}`}
alt={r.title}
className='w-full aspect-[2/3] object-cover rounded-md mb-1'
/>
) : null}
<div className='text-xs truncate group-hover:text-blue-500' title={r.title}>
{r.title}
</div>
<div className='text-[10px] opacity-50 truncate'>
{[r.year, r.source_name].filter(Boolean).join(' · ')}
</div>
{r.reasons?.length > 0 && (
<div
className='text-[10px] text-green-600/80 truncate'
title={r.reasons.join('、')}
>
{r.reasons.slice(0, 2).join(' · ')}
</div>
)}
</a>
))}
</div>
)}
</div>
)}
</div>