{"record":{"id":"fe3b0e56ecefa7aa","repo":"jackwener/OpenCLI","slug":"browser-session-required-for-bilibili-summary","errorCode":null,"errorMessage":"Browser session required for bilibili summary","messagePattern":"Browser session required for bilibili summary","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/bilibili/summary.js","lineNumber":142,"sourceCode":"        }\n    }\n    return rows;\n}\n\nvar command = cli({\n    site: 'bilibili',\n    name: 'summary',\n    access: 'read',\n    description: '获取 B站视频的官方 AI 总结（视频页「AI总结」同款，含分段大纲与时间戳）',\n    domain: 'www.bilibili.com',\n    strategy: Strategy.COOKIE,\n    args: [\n        { name: 'bvid', required: true, positional: true, help: 'Video BV ID / URL / b23.tv short link' },\n    ],\n    columns: ['time', 'content'],\n    func: async (page, kwargs) => {\n        if (!page) {\n            throw new CommandExecutionError('Browser session required for bilibili summary');\n        }\n        const bvid = await readBvid(kwargs.bvid);\n        const view = await apiGet(page, '/x/web-interface/view', { params: { bvid } });\n        const viewData = requireOkPayload(view, 'view');\n        const cid = viewData?.cid;\n        const upMid = viewData?.owner?.mid;\n        if (!cid || !upMid) {\n            throw new CommandExecutionError(`Bilibili view API did not return cid/up_mid for ${bvid}`);\n        }\n        const conclusion = await apiGet(page, '/x/web-interface/view/conclusion/get', {\n            params: { bvid, cid, up_mid: upMid },\n            signed: true,\n        });\n        const conclusionData = requireOkPayload(conclusion, 'conclusion');\n        return rowsFromModel(readModelResult(conclusionData, bvid));\n    },\n});\n","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/bilibili/summary.js#L124-L160","documentation":"The bilibili summary command requires an authenticated browser session (page) because it calls Bilibili web APIs with cookies and WBI signing via apiGet(page, ...). If page is null/falsy — the command was run without a logged-in browser session — this CommandExecutionError is thrown up front.","triggerScenarios":"Invoking `bilibili summary <bvid>` without starting the CLI's browser/login session, or calling the exported func directly with page=null (e.g. in tests or scripted use).","commonSituations":"Running the command in headless/CI environments without the browser login step; forgetting `--session`/login flow; calling the command's func programmatically without supplying a page object.","solutions":["Start the browser session and log in to Bilibili before running the summary command (the standard CLI login/init command).","Re-run the command inside the same session where cookies are stored.","If calling func directly, pass a real logged-in page object instead of null.","For headless automation, use the library's persistent browser context with saved cookies.","Check the CLI docs for the required session bootstrap step."],"exampleFix":"// before\nawait run('bilibili', 'summary', bvid); // no session started\n// after\nawait login(); // establish browser session with cookies\nawait run('bilibili', 'summary', bvid);","handlingStrategy":"validation","validationCode":"if (!page) {\n  throw new Error('Start a browser session (login) before calling bilibili summary');\n}","typeGuard":"function hasPage(p) {\n  return !!p && typeof p.goto === 'function';\n}","tryCatchPattern":"try {\n  const model = await readModelResult(page, bvid);\n} catch (e) {\n  if (String(e.message).includes('Browser session required')) {\n    await login();\n    return readModelResult(await getSessionPage(), bvid);\n  }\n  throw e;\n}","preventionTips":["Always run the CLI login/bootstrap step before session-dependent commands","In scripts, assert a live page exists before calling command funcs","Use a persistent browser context with saved cookies in CI/headless runs","Check session validity (cookies not expired) before long batch jobs"],"tags":["bilibili","browser-session","authentication","prerequisite"],"backgroundTag":"missing-browser-session","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}