hmjz100/LinkSwift · error · Error
提示:<br/>获取下载链接失败,刷新网页后再试试吧~
Error message
提示:<br/>获取下载链接失败,刷新网页后再试试吧~
What it means
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.
Source
Thrown at (改)网盘直链下载助手.user.js:5946
const batch = pending.slice(i, i + size);
const fsids = JSON.stringify(batch.map(item => item.fs_id));
const url = new URL(config.$baidu.api.getLink);
url.searchParams.set("fsids", fsids);
url.searchParams.set("access_token", token);
const res = await base.get(url, { "User-Agent": config.$baidu.api.ua.downloadLink });
if (!res || res.errno !== 0 || !res.list) {
if (res.errno === 112) throw new Error("提示:<br/>页面已过期,请刷新后重试~<br/>代码:" + res.errno);
if (res.errno === 9019) {
base.delValue("baidu_access_token");
throw new Error("提示:<br/>访问令牌已过期,再获取一次吧~<br/>代码:" + res.errno);
}
if (res.errno || res.errmsg) {
batch.forEach(item => item.dlink = `获取下载地址失败,${(res.errno || res.errmsg) ? "服务器说:" + (res.errno && res.errmsg ? res.errno + " - " + res.errmsg : (res.errmsg || res.errno)) + "。" : "刷新后再试试吧~"}`);
} else {
throw new Error("提示:<br/>获取下载链接失败,刷新网页后再试试吧~");
}
}
batch.forEach(_item => {
const item = res.list.find(li => li.fs_id == _item.fs_id);
if (item) {
Object.assign(_item, item);
temp.glinks.push({ id: _item.fs_id, expires: (Date.now() + 4 * 60 * 60 * 1000), data: item });
}
});
proc += res.list.length;
$doc.find(".swal2-html-container").html(`已获取 ${proc} / ${items.length} 个链接`);
// 批次间休息
if (i + size < pending.length) await base.sleep(1000);
}
return base.clone(items);
View on GitHub (pinned to 417ea5e28a)
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.
Defensive patterns
Strategy: try-catch
Type guard
function isBaiduSuccess(res) { return !!res && res.errno === 0 && Array.isArray(res.list); } Try / catch
try {
await fetchBaiduDownloadLinks(batch);
} catch (e) {
if (String(e.message).includes("获取下载链接失败")) {
// transient/unrecognized response: log raw res if possible, refresh page, back off and retry
} else throw e;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
AI-assisted analysis of hmjz100/LinkSwift@417ea5e28a (2026-09-02).
Data as JSON: /api/errors/f844b7ba671368a0.
Report an issue: GitHub.