jackwener/OpenCLI · error · CommandExecutionError
获取视频分P信息失败: ${error?.message || error}
Error message
获取视频分P信息失败: ${error?.message || error} What it means
loadSelectedPart wraps the /x/web-interface/view call used to resolve the requested 分P (part) number. If the transport/API call throws (network, timeout, HTTP error) or the response envelope is malformed/non-zero code, it is converted into a Chinese-language CommandExecutionError prefixed 获取视频分P信息失败 with the underlying reason appended.
Source
Thrown at clis/bilibili/download.js:88
catch {
// nav 查询失败按"无会员"保守处理,走下面的拦截
}
}
throw new CliError(
'PAID_CONTENT',
`该视频为付费内容(${PAYMENT_LABELS[paymentType]}),当前账号无观看权益,无法获取完整视频流`,
'若已购买/已充电/已开通会员,加 --force 跳过本检查直接下载',
EXIT_CODES.NOPERM,
);
}
async function loadSelectedPart(page, bvid, pageNum) {
let payload;
try {
payload = await apiGet(page, '/x/web-interface/view', { params: { bvid } });
}
catch (error) {
throw new CommandExecutionError(`获取视频分P信息失败: ${error?.message || error}`);
}
if (!isObject(payload) || payload.code !== 0) {
throw new CommandExecutionError(`获取视频分P信息失败: ${payload?.message ?? 'unknown'} (${payload?.code ?? 'malformed'})`);
}
return selectVideoPart(payload.data, pageNum);
}
cli({
site: 'bilibili',
name: 'download',
access: 'read',
description: '下载B站视频(需要 yt-dlp)',
domain: 'www.bilibili.com',
strategy: Strategy.COOKIE,
args: [
{ name: 'bvid', required: true, positional: true, help: 'Video BV ID (e.g., BV1xxx)' },
{ name: 'output', default: './bilibili-downloads', help: 'Output directory' },
{ name: 'quality', default: 'best', help: 'Video quality (best, 1080p, 720p, 480p)' },View on GitHub (pinned to 49907e53dc)
Solutions
- Retry after a short wait if it was a timeout or risk-control blip (-352); reduce request frequency.
- Verify the bvid/URL is correct and the video still exists (code -404 means deleted/invalid).
- Refresh Bilibili cookies / re-login if auth-related codes appear.
- Check network connectivity and proxy/VPN configuration before retrying.
Example fix
// caller-side retry around the CLI-level failure
try {
await download(bvid, { page: 2 });
} catch (e) {
if (String(e.message).startsWith('获取视频分P信息失败')) {
await new Promise(r => setTimeout(r, 2000));
await download(bvid, { page: 2 }); // retry once
}
} Defensive patterns
Strategy: retry
Try / catch
try {
await download(bvid, { page: n });
} catch (e) {
if (/获取视频分P信息失败/.test(e.message)) {
if (/-404/.test(e.message)) { /* video gone: don't retry */ }
else { /* transient (timeout/-352): wait and retry with backoff */ }
} else throw e;
} Prevention
- Validate bvid/URL and that the video still exists before batch downloads
- Throttle request rate to avoid -352 risk-control rejections
- Refresh cookies when auth-related failure codes appear
- Verify network/proxy connectivity before large download runs
When it happens
Trigger: Using --page on a multi-P video while /x/web-interface/view fails: network timeout/DNS failure, Bilibili returning code != 0 (e.g. -404 video not found, -352 risk control, -403), rate limiting, or invalid cookie session.
Common situations: Typo in bvid or URL resolving to a removed video; triggering anti-bot risk control (-352) after many requests; expired cookies; offline/proxy network issues; --page given for a video whose data can't be fetched.
Related errors
- 获取视频信息失败: ${err?.message || err}
- 获取视频播放信息失败: ${err?.message || err}
- ${label} returned HTTP ${resp.status}: ${summarizeApiError(p
- arXiv API HTTP ${resp.status}
- Cannot resolve aid for bvid: ${bvid}
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/47a40bbeedd49939.
Report an issue: GitHub.