{"record":{"id":"75581819878b7697","repo":"jackwener/OpenCLI","slug":"error-755818","errorCode":null,"errorMessage":"此视频没有发现外挂或智能字幕。","messagePattern":"此视频没有发现外挂或智能字幕。","errorType":"exception","errorClass":"EmptyResultError","httpStatus":null,"severity":"info","filePath":"clis/bilibili/subtitle.js","lineNumber":67,"sourceCode":"        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        }\n        // 4. 解析并拉取 CDN 的 JSON 文件\n        const fetchJs = `","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/bilibili/subtitle.js#L49-L85","documentation":"This is an EmptyResultError thrown by the bilibili subtitle command when the Bilibili player API returns a subtitle list that is an empty array. The library uses it to distinguish 'video genuinely has no subtitles' from an authentication problem: if subtitles are hidden behind login it throws AuthRequiredError instead. It means the request succeeded but no external (外挂) or AI-generated (智能) subtitle tracks exist for this video.","triggerScenarios":"Calling the bilibili subtitle CLI for a video whose /player/wbi/v2 API returns subtitles: [] — i.e. the uploader added no CC subtitles and Bilibili generated no AI subtitles.","commonSituations":"Fetching subtitles for fan-uploaded videos without CC tracks; videos where the uploader disabled subtitles; regional restriction where AI subtitle generation is unavailable; recently uploaded videos where AI subtitles have not been generated yet.","solutions":["Confirm the video actually has subtitles by checking manually in the web player (CC button / 字幕 menu).","Try a different video or different cid (e.g. multi-P videos need the right page).","If subtitles should exist, log in to bilibili.com in Chrome and retry — some subtitle data is only returned to logged-in sessions.","Handle EmptyResultError in your wrapper and treat it as 'no subtitles available' rather than a failure."],"exampleFix":"// before\nawait run('bilibili subtitle', { url });\n// after\ntry {\n  await run('bilibili subtitle', { url });\n} catch (e) {\n  if (e instanceof EmptyResultError) return null; // video has no subtitles\n  throw e;\n}","handlingStrategy":"try-catch","validationCode":"// No pre-call validation possible; check the video has a CC button in the web player first.","typeGuard":null,"tryCatchPattern":"try {\n  const subs = await run('bilibili subtitle', { url });\n} catch (e) {\n  if (e.name === 'EmptyResultError') return null; // no subtitles for this video\n  throw e;\n}","preventionTips":["Check the video's CC/字幕 menu manually before automating.","Log in to bilibili.com in Chrome so login-gated subtitles are returned.","Treat EmptyResultError as a normal 'no data' outcome, not a crash.","For multi-P videos, ensure the correct page/cid is targeted."],"tags":["bilibili","subtitle","empty-result"],"backgroundTag":"empty-result-set","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}