diff --git a/lib/fetcher.js b/lib/fetcher.js index c127cdd..f3489a1 100644 --- a/lib/fetcher.js +++ b/lib/fetcher.js @@ -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 秒 } }