jackwener/OpenCLI · error · AuthRequiredError
Bilibili subtitles are hidden behind login for this video. P
Error message
Bilibili subtitles are hidden behind login for this video. Please log in to bilibili.com in Chrome and retry.
What it means
The subtitle list came back empty AND the API flagged need_login_subtitle === true, meaning Bilibili hid the video's subtitles behind authentication (or AI subtitles require login). The library raises AuthRequiredError instead of CommandExecutionError because the remedy is user login, not a code fix. The message instructs logging into bilibili.com in the attached Chrome profile.
Source
Thrown at clis/bilibili/subtitle.js:65
});
}
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 字段');
}
const targetSubUrl = typeof target.subtitle_url === 'string' ? target.subtitle_url.trim() : '';
if (!targetSubUrl) {
throw new AuthRequiredError('bilibili.com', '[风控拦截/未登录] 获取到的 subtitle_url 为空!请确保 CLI 已成功登录且风控未封锁此账号。');
}
const finalUrl = targetSubUrl.startsWith('//') ? 'https:' + targetSubUrl : targetSubUrl;
if (!/^https?:\/\//i.test(finalUrl)) {
throw new CommandExecutionError(`字幕 URL 非法: ${finalUrl}`);
}View on GitHub (pinned to 49907e53dc)
Solutions
- Log in to bilibili.com in the Chrome profile the CLI attaches to, then re-run the command
- Verify the session is still valid (cookies not expired) — re-login if needed
- If AI subtitles aren't essential, target a video with uploader-provided CC subtitles, which are often available unauthenticated
Defensive patterns
Strategy: fallback
Try / catch
try {
const rows = await run(['bilibili', 'subtitle', bvid]);
} catch (e) {
if (e instanceof AuthRequiredError || String(e.message).includes('hidden behind login')) {
// prompt user to log into bilibili.com, or fall back to videos with public CC subtitles
} else throw e;
} Prevention
- Always run bilibili commands with a logged-in Chrome profile
- Re-login when cookies expire to keep the session anonymous-free
- Prefer videos with uploader-provided CC subtitles for unauthenticated workflows
When it happens
Trigger: payload.data.subtitle.subtitles.length === 0 while payload.data.need_login_subtitle is true — usually AI-generated (智能) subtitles on a video, fetched without a logged-in session.
Common situations: Fetching AI subtitles for a video while logged out; using a fresh/clean Chrome profile with no bilibili.com cookies; cookie expired so the session is effectively anonymous; videos where only login-gated AI subtitles exist.
Related errors
- Bilibili creator-center login is required: ${message}
- Bilibili creator-center login is required: ${detail}
- Browser session required for bilibili subtitle
- 获取到的字幕列表对象不符合数组格式
- Bilibili ${label} API requires login or permission: ${messag
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/683a1b7af6099328.
Report an issue: GitHub.