{"record":{"id":"f45daad2b6fd2dc5","repo":"jackwener/OpenCLI","slug":"payload-message-payload-code-f45daa","errorCode":null,"errorMessage":"获取视频播放信息失败: ${payload.message} (${payload.code})","messagePattern":"获取视频播放信息失败: (.+?) \\((.+?)\\)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/bilibili/subtitle.js","lineNumber":56,"sourceCode":"        if (!cid) {\n            throw new CommandExecutionError(`无法从 view API 拿到 cid (bvid=${bvid})`);\n        }\n        // 2. 用带 Wbi 签名的 player/v2 拿字幕列表（之前 evaluate 里 fetch 因为没签名会 403）\n        let payload;\n        try {\n            payload = await apiGet(page, '/x/player/wbi/v2', {\n                params: { bvid, cid },\n                signed: true,\n            });\n        }\n        catch (err) {\n            throw new CommandExecutionError(`获取视频播放信息失败: ${err?.message || err}`);\n        }\n        if (!payload || typeof payload !== 'object' || Array.isArray(payload)) {\n            throw new CommandExecutionError('获取到的视频播放信息对象不符合预期格式');\n        }\n        if (payload.code !== 0) {\n            throw new CommandExecutionError(`获取视频播放信息失败: ${payload.message} (${payload.code})`);\n        }\n        const needLoginSubtitle = payload.data?.need_login_subtitle === true;\n        const subtitles = payload.data?.subtitle?.subtitles;\n        if (!Array.isArray(subtitles)) {\n            throw new CommandExecutionError('获取到的字幕列表对象不符合数组格式');\n        }\n        if (subtitles.length === 0) {\n            if (needLoginSubtitle) {\n                throw new AuthRequiredError('bilibili.com', 'Bilibili subtitles are hidden behind login for this video. Please log in to bilibili.com in Chrome and retry.');\n            }\n            throw new EmptyResultError('bilibili subtitle', '此视频没有发现外挂或智能字幕。');\n        }\n        // 3. 选择目标字幕语言\n        const target = kwargs.lang\n            ? subtitles.find((s) => s.lan === kwargs.lang) || subtitles[0]\n            : subtitles[0];\n        if (!target || typeof target !== 'object' || !Object.hasOwn(target, 'subtitle_url')) {\n            throw new CommandExecutionError('字幕条目缺少 subtitle_url 字段');","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/bilibili/subtitle.js#L38-L74","documentation":"The player/v2 API responded with a valid envelope but payload.code !== 0, i.e. Bilibili rejected the player-info request at the business level (the API's message and code are surfaced in the error). Common codes include -352 risk control and -404 not found. This mirrors error 433 but for the Wbi-signed player endpoint.","triggerScenarios":"After a successful signed apiGet('/x/player/wbi/v2') the payload.code is non-zero — typically -352 (risk control / gaea rejection), -404 (bad cid/bvid pair), or -412 rate limiting.","commonSituations":"Account flagged by Bilibili's anti-bot (gaea) system; expired/invalid Wbi signature producing rejection codes; requesting subtitles for a video whose cid doesn't match; burst of automated requests triggering throttling.","solutions":["Decode the code: -352 → risk control, slow down / use a warmed-up logged-in session; -404 → verify bvid+cid pair; -412 → back off and retry later","Log in to bilibili.com in the automation Chrome profile and retry — risk-control responses are far more common unauthenticated","Reduce request frequency / add delay between commands","Refresh the session so Wbi signature keys are current, then retry"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await run(['bilibili', 'subtitle', bvid]);\n} catch (e) {\n  const m = /获取视频播放信息失败: (.+) \\((-?\\d+)\\)/.exec(String(e.message));\n  if (m) {\n    const code = Number(m[2]);\n    if (code === -352 || code === -412) { /* risk control: back off, warm logged-in session */ }\n    else if (code === -404) { /* verify bvid+cid */ }\n  } else throw e;\n}","preventionTips":["Use a logged-in, warmed-up session to minimize -352 risk-control responses","Throttle batch requests to Bilibili APIs","Refresh the session periodically so Wbi signatures stay valid"],"tags":["api","bilibili","risk-control","wbi-signature"],"backgroundTag":"api-error-code","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}