优化定时任务自动刷新收藏
This commit is contained in:
@@ -2,6 +2,7 @@ import { getAvailableApiSites } from '@/lib/config';
|
||||
import { SearchResult } from '@/lib/types';
|
||||
|
||||
import { getDetailFromApi, searchFromApi } from './downstream';
|
||||
import { getSpecialSourceDetail, isSpecialSource } from './special-sources-detail';
|
||||
|
||||
interface FetchVideoDetailOptions {
|
||||
source: string;
|
||||
@@ -11,14 +12,24 @@ interface FetchVideoDetailOptions {
|
||||
|
||||
/**
|
||||
* 根据 source 与 id 获取视频详情。
|
||||
* 1. 若传入 fallbackTitle,则先调用 /api/search 搜索精确匹配。
|
||||
* 2. 若搜索未命中或未提供 fallbackTitle,则直接调用 /api/detail。
|
||||
* 1. 如果是特殊源(emby、openlist、xiaoya),直接调用对应的获取函数。
|
||||
* 2. 若传入 fallbackTitle,则先调用 /api/search 搜索精确匹配。
|
||||
* 3. 若搜索未命中或未提供 fallbackTitle,则直接调用 /api/detail。
|
||||
*/
|
||||
export async function fetchVideoDetail({
|
||||
source,
|
||||
id,
|
||||
fallbackTitle = '',
|
||||
}: FetchVideoDetailOptions): Promise<SearchResult> {
|
||||
// 检查是否是特殊源(emby、openlist、xiaoya)
|
||||
if (isSpecialSource(source)) {
|
||||
const detail = await getSpecialSourceDetail(source, id);
|
||||
if (detail) {
|
||||
return detail;
|
||||
}
|
||||
// 如果特殊源返回 null,继续使用标准流程
|
||||
}
|
||||
|
||||
// 优先通过搜索接口查找精确匹配
|
||||
const apiSites = await getAvailableApiSites();
|
||||
const apiSite = apiSites.find((site) => site.key === source);
|
||||
|
||||
Reference in New Issue
Block a user