修复请求renren失败直接不返回其他站点信息的问题
This commit is contained in:
1 parent
3133bdebcb
commit
9fdcd65233
2 files changed
+70
-65
No files matched your search
+37
-32
@@ -2206,40 +2206,45 @@ async function performNetworkSearch(
|
||||
minInterval = 500 // 默认节流间隔(毫秒)
|
||||
} = {}
|
||||
) {
|
||||
const url = `https://api.rrmj.plus/m-station/search/drama`;
|
||||
const params = { keywords: keyword, size: 20, order: "match", search_after: "", isExecuteVipActivity: true };
|
||||
try {
|
||||
const url = `https://api.rrmj.plus/m-station/search/drama`;
|
||||
const params = { keywords: keyword, size: 20, order: "match", search_after: "", isExecuteVipActivity: true };
|
||||
|
||||
// 🔒 锁逻辑(可选)
|
||||
if (lockRef) {
|
||||
while (lockRef.value) await new Promise(r => setTimeout(r, 50));
|
||||
lockRef.value = true;
|
||||
// 🔒 锁逻辑(可选)
|
||||
if (lockRef) {
|
||||
while (lockRef.value) await new Promise(r => setTimeout(r, 50));
|
||||
lockRef.value = true;
|
||||
}
|
||||
|
||||
// ⏱️ 节流逻辑(依赖 lastRequestTimeRef)
|
||||
const now = Date.now();
|
||||
const dt = now - lastRequestTimeRef.value;
|
||||
if (dt < minInterval) await new Promise(r => setTimeout(r, minInterval - dt));
|
||||
|
||||
const resp = await renrenRequest("GET", url, params);
|
||||
lastRequestTimeRef.value = Date.now(); // 更新引用
|
||||
|
||||
if (lockRef) lockRef.value = false;
|
||||
|
||||
if (!resp.data) return [];
|
||||
|
||||
const decoded = autoDecode(resp.data);
|
||||
const list = decoded?.data?.searchDramaList || [];
|
||||
return list.map((item, idx) => ({
|
||||
provider: "renren",
|
||||
mediaId: String(item.id),
|
||||
title: String(item.title || "").replace(/<[^>]+>/g, "").replace(/:/g, ":"),
|
||||
type: "tv_series",
|
||||
season: null,
|
||||
year: item.year,
|
||||
imageUrl: item.cover,
|
||||
episodeCount: item.episodeTotal,
|
||||
currentEpisodeIndex: episodeInfo?.episode ?? null,
|
||||
}));
|
||||
} catch (error) {
|
||||
log("error", `getRenrenAnimes error: ${error.message}`);
|
||||
return [];
|
||||
}
|
||||
|
||||
// ⏱️ 节流逻辑(依赖 lastRequestTimeRef)
|
||||
const now = Date.now();
|
||||
const dt = now - lastRequestTimeRef.value;
|
||||
if (dt < minInterval) await new Promise(r => setTimeout(r, minInterval - dt));
|
||||
|
||||
const resp = await renrenRequest("GET", url, params);
|
||||
lastRequestTimeRef.value = Date.now(); // 更新引用
|
||||
|
||||
if (lockRef) lockRef.value = false;
|
||||
|
||||
if (!resp.data) return [];
|
||||
|
||||
const decoded = autoDecode(resp.data);
|
||||
const list = decoded?.data?.searchDramaList || [];
|
||||
return list.map((item, idx) => ({
|
||||
provider: "renren",
|
||||
mediaId: String(item.id),
|
||||
title: String(item.title || "").replace(/<[^>]+>/g, "").replace(/:/g, ":"),
|
||||
type: "tv_series",
|
||||
season: null,
|
||||
year: item.year,
|
||||
imageUrl: item.cover,
|
||||
episodeCount: item.episodeTotal,
|
||||
currentEpisodeIndex: episodeInfo?.episode ?? null,
|
||||
}));
|
||||
}
|
||||
|
||||
// ---------------------
|
||||
|
||||
+33
-33
@@ -52,10 +52,10 @@ test('worker.js API endpoints', async (t) => {
|
||||
// assert(res.length > 2, `Expected res.length > 2, but got ${res.length}`);
|
||||
// });
|
||||
|
||||
await t.test('GET bilibili danmu', async () => {
|
||||
const res = await fetchBilibili("https://www.bilibili.com/bangumi/play/ep1231564");
|
||||
assert(res.length > 2, `Expected res.length > 2, but got ${res.length}`);
|
||||
});
|
||||
// await t.test('GET bilibili danmu', async () => {
|
||||
// const res = await fetchBilibili("https://www.bilibili.com/bangumi/play/ep1231564");
|
||||
// assert(res.length > 2, `Expected res.length > 2, but got ${res.length}`);
|
||||
// });
|
||||
|
||||
// await t.test('GET youku danmu', async () => {
|
||||
// const res = await fetchYouku("https://v.youku.com/v_show/id_XNjQ3ODMyNjU3Mg==.html");
|
||||
@@ -67,35 +67,35 @@ test('worker.js API endpoints', async (t) => {
|
||||
// assert(res.length > 2, `Expected res.length > 2, but got ${res.length}`);
|
||||
// });
|
||||
|
||||
// await t.test('GET realistic danmu', async () => {
|
||||
// // tencent
|
||||
// // const keyword = "子夜归";
|
||||
// // iqiyi
|
||||
// // const keyword = "赴山海";
|
||||
// // mango
|
||||
// // const keyword = "锦月如歌";
|
||||
// // bilibili
|
||||
// // const keyword = "国王排名";
|
||||
// // youku
|
||||
// // const keyword = "黑白局";
|
||||
// // renren
|
||||
// const keyword = "瑞克和莫蒂";
|
||||
//
|
||||
// const searchUrl = new URL(`${urlPrefix}/${token}/api/v2/search/anime?keyword=${keyword}`);
|
||||
// const searchRes = await searchAnime(searchUrl);
|
||||
// const searchData = await searchRes.json();
|
||||
// assert(searchData.animes.length > 0, `Expected searchData.animes.length > 0, but got ${searchData.animes.length}`);
|
||||
//
|
||||
// const bangumiUrl = new URL(`${urlPrefix}/${token}/api/v2/bangumi/${searchData.animes[0].animeId}`);
|
||||
// const bangumiRes = await getBangumi(bangumiUrl.pathname);
|
||||
// const bangumiData = await bangumiRes.json();
|
||||
// assert(bangumiData.bangumi.episodes.length > 0, `Expected bangumiData.bangumi.episodes.length > 0, but got ${bangumiData.bangumi.episodes.length}`);
|
||||
//
|
||||
// const commentUrl = new URL(`${urlPrefix}/${token}/api/v2/comment/${bangumiData.bangumi.episodes[0].episodeId}?withRelated=true&chConvert=1`);
|
||||
// const commentRes = await getComment(commentUrl.pathname);
|
||||
// const commentData = await commentRes.json();
|
||||
// assert(commentData.count > 0, `Expected commentData.count > 0, but got ${commentData.count}`);
|
||||
// });
|
||||
await t.test('GET realistic danmu', async () => {
|
||||
// tencent
|
||||
// const keyword = "子夜归";
|
||||
// iqiyi
|
||||
// const keyword = "赴山海";
|
||||
// mango
|
||||
// const keyword = "锦月如歌";
|
||||
// bilibili
|
||||
// const keyword = "国王排名";
|
||||
// youku
|
||||
// const keyword = "黑白局";
|
||||
// renren
|
||||
const keyword = "瑞克和莫蒂";
|
||||
|
||||
const searchUrl = new URL(`${urlPrefix}/${token}/api/v2/search/anime?keyword=${keyword}`);
|
||||
const searchRes = await searchAnime(searchUrl);
|
||||
const searchData = await searchRes.json();
|
||||
assert(searchData.animes.length > 0, `Expected searchData.animes.length > 0, but got ${searchData.animes.length}`);
|
||||
|
||||
const bangumiUrl = new URL(`${urlPrefix}/${token}/api/v2/bangumi/${searchData.animes[0].animeId}`);
|
||||
const bangumiRes = await getBangumi(bangumiUrl.pathname);
|
||||
const bangumiData = await bangumiRes.json();
|
||||
assert(bangumiData.bangumi.episodes.length > 0, `Expected bangumiData.bangumi.episodes.length > 0, but got ${bangumiData.bangumi.episodes.length}`);
|
||||
|
||||
const commentUrl = new URL(`${urlPrefix}/${token}/api/v2/comment/${bangumiData.bangumi.episodes[0].episodeId}?withRelated=true&chConvert=1`);
|
||||
const commentRes = await getComment(commentUrl.pathname);
|
||||
const commentData = await commentRes.json();
|
||||
assert(commentData.count > 0, `Expected commentData.count > 0, but got ${commentData.count}`);
|
||||
});
|
||||
|
||||
// // 测试 POST /api/v2/match 接口
|
||||
// await t.test('POST /api/v2/match for matching anime', async () => {
|
||||
|
||||
Reference in new issue
Block a user