Temporary debugging+1
This commit is contained in:
1 parent
c68aaba5ad
commit
b5fa793296
1 file changed
+10
-8
+10
-8
@@ -274,44 +274,46 @@ function parseJavdb(html, queryId) {
|
||||
|
||||
// ─── 主入口:依次尝试三个数据源 ─────────────────────────
|
||||
export async function search(id) {
|
||||
// 保持连字符格式去搜索
|
||||
// 用户输入连字符 031926-100,搜索时转成下划线 031926_100
|
||||
let searchId = id;
|
||||
if (/^\d{5,6}-\d+$/.test(id)) {
|
||||
searchId = id.replace('-', '_');
|
||||
console.log(chalk.gray(` 识别为FC2番号: ${id}`));
|
||||
}
|
||||
|
||||
const cached = getCache(id);
|
||||
if (cached) return cached;
|
||||
|
||||
// 最多自动重试 2 次,每次间隔 1 秒
|
||||
const MAX_RETRY = 2;
|
||||
// 最多自动重试 3 次,每次间隔 1 秒
|
||||
const MAX_RETRY = 3;
|
||||
|
||||
for (let attempt = 1; attempt <= MAX_RETRY; attempt++) {
|
||||
let result = null;
|
||||
|
||||
// 第一优先:JAVBUS
|
||||
result = searchJavbus(id);
|
||||
result = searchJavbus(searchId);
|
||||
if (result) {
|
||||
setCache(id, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
// 第二优先:JavLibrary
|
||||
result = searchJavlibrary(id);
|
||||
result = searchJavlibrary(searchId);
|
||||
if (result) {
|
||||
setCache(id, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
// 第三优先:JAVDB
|
||||
result = await searchJavdb(id);
|
||||
result = await searchJavdb(searchId);
|
||||
if (result) {
|
||||
setCache(id, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
// 本次没找到,如果还有重试机会就等 1 秒再试
|
||||
// 本次没找到,如果还有重试机会就等待
|
||||
if (attempt < MAX_RETRY) {
|
||||
await new Promise(resolve => setTimeout(resolve, 1000));
|
||||
await new Promise(resolve => setTimeout(resolve, 2000)); // 改成 2 秒
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user