{"record":{"id":"f844b7ba671368a0","repo":"hmjz100/LinkSwift","slug":"br","errorCode":null,"errorMessage":"提示：<br/>获取下载链接失败，刷新网页后再试试吧~","messagePattern":"提示：<br/>获取下载链接失败，刷新网页后再试试吧~","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"（改）网盘直链下载助手.user.js","lineNumber":5946,"sourceCode":"\t\t\t\tconst batch = pending.slice(i, i + size);\r\n\t\t\t\tconst fsids = JSON.stringify(batch.map(item => item.fs_id));\r\n\r\n\t\t\t\tconst url = new URL(config.$baidu.api.getLink);\r\n\t\t\t\turl.searchParams.set(\"fsids\", fsids);\r\n\t\t\t\turl.searchParams.set(\"access_token\", token);\r\n\r\n\t\t\t\tconst res = await base.get(url, { \"User-Agent\": config.$baidu.api.ua.downloadLink });\r\n\r\n\t\t\t\tif (!res || res.errno !== 0 || !res.list) {\r\n\t\t\t\t\tif (res.errno === 112) throw new Error(\"提示：<br/>页面已过期，请刷新后重试~<br/>代码：\" + res.errno);\r\n\t\t\t\t\tif (res.errno === 9019) {\r\n\t\t\t\t\t\tbase.delValue(\"baidu_access_token\");\r\n\t\t\t\t\t\tthrow new Error(\"提示：<br/>访问令牌已过期，再获取一次吧~<br/>代码：\" + res.errno);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tif (res.errno || res.errmsg) {\r\n\t\t\t\t\t\tbatch.forEach(item => item.dlink = `获取下载地址失败，${(res.errno || res.errmsg) ? \"服务器说：\" + (res.errno && res.errmsg ? res.errno + \" - \" + res.errmsg : (res.errmsg || res.errno)) + \"。\" : \"刷新后再试试吧~\"}`);\r\n\t\t\t\t\t} else {\r\n\t\t\t\t\t\tthrow new Error(\"提示：<br/>获取下载链接失败，刷新网页后再试试吧~\");\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\tbatch.forEach(_item => {\r\n\t\t\t\t\tconst item = res.list.find(li => li.fs_id == _item.fs_id);\r\n\t\t\t\t\tif (item) {\r\n\t\t\t\t\t\tObject.assign(_item, item);\r\n\t\t\t\t\t\ttemp.glinks.push({ id: _item.fs_id, expires: (Date.now() + 4 * 60 * 60 * 1000), data: item });\r\n\t\t\t\t\t}\r\n\t\t\t\t});\r\n\r\n\t\t\t\tproc += res.list.length;\r\n\t\t\t\t$doc.find(\".swal2-html-container\").html(`已获取 ${proc} / ${items.length} 个链接`);\r\n\r\n\t\t\t\t// 批次间休息\r\n\t\t\t\tif (i + size < pending.length) await base.sleep(1000);\r\n\t\t\t}\r\n\t\t\treturn base.clone(items);\r","sourceCodeStart":5928,"sourceCodeEnd":5964,"githubUrl":"https://github.com/hmjz100/LinkSwift/blob/417ea5e28a3e1a90339710e17356e9fd22b8a34b/（改）网盘直链下载助手.user.js#L5928-L5964","documentation":"Generic failure path of the Baidu download-link fetch (网盘直链下载助手.user.js:5946): the response was not a success (errno !== 0 or no `list`), and it carried neither a recognized errno nor errmsg, so no specific code-based error applies. The script throws this catch-all telling the user to refresh and retry. It means Baidu returned an unparseable/empty failure response rather than a documented error code.","triggerScenarios":"base.get to the Baidu fsids download API resolves with a body that is falsy or lacks `list`, and whose `errno` and `errmsg` are both absent — e.g. an empty/HTML error page parsed to nothing, a rate-limit or WAF interstitial the script could not parse, or a network layer returning an empty object.","commonSituations":"Baidu intermittently throttling or serving an anti-bot page; the response shape changing after a Baidu API update so errno fields no longer land where the script expects; transient network failure producing an empty response body.","solutions":["Refresh the Baidu Netdisk page and retry; these are often transient.","Retry later / reduce request frequency if Baidu is rate-limiting or showing risk-control interstitials.","Check whether Baidu changed the API response shape; update the userscript to a version matching the current API.","Log the raw response (res) at the failure point to see what Baidu actually returned before assuming a script bug.","Verify login state on pan.baidu.com; being logged out can produce non-JSON responses."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function isBaiduSuccess(res) { return !!res && res.errno === 0 && Array.isArray(res.list); }","tryCatchPattern":"try {\n  await fetchBaiduDownloadLinks(batch);\n} catch (e) {\n  if (String(e.message).includes(\"获取下载链接失败\")) {\n    // transient/unrecognized response: log raw res if possible, refresh page, back off and retry\n  } else throw e;\n}","preventionTips":["Retry with backoff — this catch-all is usually a transient throttle or anti-bot interstitial.","Stay logged in to pan.baidu.com and avoid aggressive batch sizes that trigger risk control.","Keep the userscript updated in case Baidu changed the API response shape.","Log the raw response at the failure point to distinguish throttling from shape changes."],"tags":["baidu","api-error","unparseable-response","network"],"backgroundTag":"unrecognized-api-response","analyzedSha":"417ea5e28a3e1a90339710e17356e9fd22b8a34b","analyzedAt":"2026-09-02T18:13:32.837Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T21:17:11.164Z"}