{"record":{"id":"683a1b7af6099328","repo":"jackwener/OpenCLI","slug":"bilibili-subtitles-are-hidden-behind-login-for-thi","errorCode":null,"errorMessage":"Bilibili subtitles are hidden behind login for this video. Please log in to bilibili.com in Chrome and retry.","messagePattern":"Bilibili subtitles are hidden behind login for this video\\. Please log in to bilibili\\.com in Chrome and retry\\.","errorType":"exception","errorClass":"AuthRequiredError","httpStatus":null,"severity":"error","filePath":"clis/bilibili/subtitle.js","lineNumber":65,"sourceCode":"            });\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 字段');\n        }\n        const targetSubUrl = typeof target.subtitle_url === 'string' ? target.subtitle_url.trim() : '';\n        if (!targetSubUrl) {\n            throw new AuthRequiredError('bilibili.com', '[风控拦截/未登录] 获取到的 subtitle_url 为空！请确保 CLI 已成功登录且风控未封锁此账号。');\n        }\n        const finalUrl = targetSubUrl.startsWith('//') ? 'https:' + targetSubUrl : targetSubUrl;\n        if (!/^https?:\\/\\//i.test(finalUrl)) {\n            throw new CommandExecutionError(`字幕 URL 非法: ${finalUrl}`);\n        }","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/bilibili/subtitle.js#L47-L83","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const rows = await run(['bilibili', 'subtitle', bvid]);\n} catch (e) {\n  if (e instanceof AuthRequiredError || String(e.message).includes('hidden behind login')) {\n    // prompt user to log into bilibili.com, or fall back to videos with public CC subtitles\n  } else throw e;\n}","preventionTips":["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"],"tags":["authentication","bilibili","subtitles","login-required"],"backgroundTag":"login-required","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}