jackwener/OpenCLI · error · CommandExecutionError

获取视频播放信息失败: ${payload.message} (${payload.code})

Error message

获取视频播放信息失败: ${payload.message} (${payload.code})

What it means

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.

Source

Thrown at clis/bilibili/subtitle.js:56

        if (!cid) {
            throw new CommandExecutionError(`无法从 view API 拿到 cid (bvid=${bvid})`);
        }
        // 2. 用带 Wbi 签名的 player/v2 拿字幕列表(之前 evaluate 里 fetch 因为没签名会 403)
        let payload;
        try {
            payload = await apiGet(page, '/x/player/wbi/v2', {
                params: { bvid, cid },
                signed: true,
            });
        }
        catch (err) {
            throw new CommandExecutionError(`获取视频播放信息失败: ${err?.message || err}`);
        }
        if (!payload || typeof payload !== 'object' || Array.isArray(payload)) {
            throw new CommandExecutionError('获取到的视频播放信息对象不符合预期格式');
        }
        if (payload.code !== 0) {
            throw new CommandExecutionError(`获取视频播放信息失败: ${payload.message} (${payload.code})`);
        }
        const needLoginSubtitle = payload.data?.need_login_subtitle === true;
        const subtitles = payload.data?.subtitle?.subtitles;
        if (!Array.isArray(subtitles)) {
            throw new CommandExecutionError('获取到的字幕列表对象不符合数组格式');
        }
        if (subtitles.length === 0) {
            if (needLoginSubtitle) {
                throw new AuthRequiredError('bilibili.com', 'Bilibili subtitles are hidden behind login for this video. Please log in to bilibili.com in Chrome and retry.');
            }
            throw new EmptyResultError('bilibili subtitle', '此视频没有发现外挂或智能字幕。');
        }
        // 3. 选择目标字幕语言
        const target = kwargs.lang
            ? subtitles.find((s) => s.lan === kwargs.lang) || subtitles[0]
            : subtitles[0];
        if (!target || typeof target !== 'object' || !Object.hasOwn(target, 'subtitle_url')) {
            throw new CommandExecutionError('字幕条目缺少 subtitle_url 字段');

View on GitHub (pinned to 49907e53dc)

Solutions

  1. 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
  2. Log in to bilibili.com in the automation Chrome profile and retry — risk-control responses are far more common unauthenticated
  3. Reduce request frequency / add delay between commands
  4. Refresh the session so Wbi signature keys are current, then retry
Defensive patterns

Strategy: try-catch

Try / catch

try {
  await run(['bilibili', 'subtitle', bvid]);
} catch (e) {
  const m = /获取视频播放信息失败: (.+) \((-?\d+)\)/.exec(String(e.message));
  if (m) {
    const code = Number(m[2]);
    if (code === -352 || code === -412) { /* risk control: back off, warm logged-in session */ }
    else if (code === -404) { /* verify bvid+cid */ }
  } else throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/f45daad2b6fd2dc5. Report an issue: GitHub.