{"record":{"id":"f75188a37a6b603e","repo":"hmjz100/LinkSwift","slug":"url-f75188","errorCode":null,"errorMessage":"[百度网盘] 获取分享文件 URL 失败","messagePattern":"\\[百度网盘\\] 获取分享文件 URL 失败","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"（改）网盘直链下载助手.user.js","lineNumber":6118,"sourceCode":"\t\t\t\t$doc.find(\".loading-popup .loading-title\").html(`链接获取中`);\r\n\t\t\t\t$doc.find(\".loading-popup .swal2-html-container\").html(`<div>正在获取文件对应的下载链接~</div>`);\r\n\r\n\t\t\t\tfiles = await this.getFilesUrl(files, token).catch(e => {\r\n\t\t\t\t\tif (e instanceof Error) throw e;\r\n\t\t\t\t\tthrow new Error(e?.message || e || \"[百度网盘] 获取文件 URL 失败\");\r\n\t\t\t\t});\r\n\t\t\t} else if (temp.page === \"share\") {\r\n\t\t\t\tconst shareData = await this.getShareData();\r\n\r\n\t\t\t\tconst sign = await base.get(`${config.$baidu.api.getShareSign}&surl=1${shareData.share.url}$bdstoken=${shareData.baidu.token}&logid=${base.encodeBase(shareData.baidu.id)}`);\r\n\t\t\t\tif (sign?.data?.sign && sign?.data?.timestamp) {\r\n\t\t\t\t\tshareData.sign = sign.data.sign;\r\n\t\t\t\t\tshareData.timestamp = sign.data.timestamp;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tfiles = await this.getShareFilesUrl(files, shareData, token).catch(e => {\r\n\t\t\t\t\tif (e instanceof Error) throw e;\r\n\t\t\t\t\tthrow new Error(e?.message || e || \"[百度网盘] 获取分享文件 URL 失败\");\r\n\t\t\t\t});\r\n\t\t\t} else {\r\n\t\t\t\tthrow new Error(\"提示：<br/>页面错误~\");\r\n\t\t\t}\r\n\r\n\t\t\ttemp.links = [files, {\r\n\t\t\t\tisFolder: v => v.isdir === 1,\r\n\t\t\t\tgetFileName: v => (v.server_filename || v.filename),\r\n\t\t\t\tgetFileSize: v => v.size,\r\n\t\t\t\tgetFileLink: v => {\r\n\t\t\t\t\tif (!v.dlink || !v.dlink.startsWith(\"http\")) return v.dlink;\r\n\t\t\t\t\tconst url = new URL(v.dlink);\r\n\t\t\t\t\turl.searchParams.set(\"access_token\", token);\r\n\t\t\t\t\treturn url.href;\r\n\t\t\t\t},\r\n\t\t\t\tconvert: {\r\n\t\t\t\t\taria2: `--header \"User-Agent:${config.$baidu.api.ua.downloadLink}\"`,\r\n\t\t\t\t\tcurl: `-A \"${config.$baidu.api.ua.downloadLink}\"`,\r","sourceCodeStart":6100,"sourceCodeEnd":6136,"githubUrl":"https://github.com/hmjz100/LinkSwift/blob/417ea5e28a3e1a90339710e17356e9fd22b8a34b/（改）网盘直链下载助手.user.js#L6100-L6136","documentation":"Same fallback pattern as error 12 but for the share page: thrown when `this.getShareFilesUrl(files, shareData, token)` rejects with a non-Error value. Resolving download links for files inside a shared folder requires share sign/timestamp plus a logged-in BDNDS token; failure there is re-wrapped as this generic message.","triggerScenarios":"On a Baidu share page (`temp.page === 'share'`), getShareFilesUrl fails: shareData.sign/timestamp missing (getShareSign returned no data), share link expired or cancelled, or the transfer/download API rejects with a non-Error payload.","commonSituations":"Share link has expired or been cancelled by the owner; share requires a passcode the script didn't capture; user not logged in so quota-limited share cannot be resolved; Baidu changed the share-sign API parameters.","solutions":["Verify the share link is still valid and open it fresh before using the script.","Log into Baidu Netdisk so share downloads can be authorized.","Re-enter the share passcode if the share is protected.","Update the userscript; the getShareSign API signature may have changed."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if (!shareData || !shareData.sign || !shareData.timestamp) { alert('分享信息获取失败，请重新打开分享页'); return; }","typeGuard":"function hasShareSign(sd) { return !!(sd && sd.sign && sd.timestamp); }","tryCatchPattern":"try { await getShareLinks(); } catch (e) { console.error('share link resolve failed:', e); if (!shareData.sign) reopenSharePage(); }","preventionTips":["Confirm the share link is valid and not expired/cancelled before resolving","Log into Baidu Netdisk so share downloads can be authorized","Re-enter the share passcode for protected shares","Update the userscript when share APIs change"],"tags":["userscript","baidu-netdisk","share-link","api"],"backgroundTag":"share-link-resolution-failed","analyzedSha":"417ea5e28a3e1a90339710e17356e9fd22b8a34b","analyzedAt":"2026-09-02T18:13:32.837Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T21:17:11.164Z"}