@xzxzzx/bilibili-mcp 1.3.7 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +63 -4
- package/README_EN.md +63 -4
- package/dist/bilibili/client.d.ts +3 -73
- package/dist/bilibili/client.d.ts.map +1 -1
- package/dist/bilibili/client.js +4 -581
- package/dist/bilibili/client.js.map +1 -1
- package/dist/bilibili/comments-api.d.ts +6 -0
- package/dist/bilibili/comments-api.d.ts.map +1 -0
- package/dist/bilibili/comments-api.js +126 -0
- package/dist/bilibili/comments-api.js.map +1 -0
- package/dist/bilibili/comments.d.ts +10 -3
- package/dist/bilibili/comments.d.ts.map +1 -1
- package/dist/bilibili/comments.js +30 -7
- package/dist/bilibili/comments.js.map +1 -1
- package/dist/bilibili/fingerprint.d.ts +10 -0
- package/dist/bilibili/fingerprint.d.ts.map +1 -0
- package/dist/bilibili/fingerprint.js +50 -0
- package/dist/bilibili/fingerprint.js.map +1 -0
- package/dist/bilibili/http.d.ts +24 -0
- package/dist/bilibili/http.d.ts.map +1 -0
- package/dist/bilibili/http.js +259 -0
- package/dist/bilibili/http.js.map +1 -0
- package/dist/bilibili/metadata.d.ts +6 -0
- package/dist/bilibili/metadata.d.ts.map +1 -0
- package/dist/bilibili/metadata.js +36 -0
- package/dist/bilibili/metadata.js.map +1 -0
- package/dist/bilibili/subtitle.d.ts +9 -0
- package/dist/bilibili/subtitle.d.ts.map +1 -1
- package/dist/bilibili/subtitle.js +99 -8
- package/dist/bilibili/subtitle.js.map +1 -1
- package/dist/bilibili/types.d.ts +33 -0
- package/dist/bilibili/types.d.ts.map +1 -1
- package/dist/bilibili/video-api.d.ts +57 -0
- package/dist/bilibili/video-api.d.ts.map +1 -0
- package/dist/bilibili/video-api.js +81 -0
- package/dist/bilibili/video-api.js.map +1 -0
- package/dist/bilibili/wbi.d.ts +13 -0
- package/dist/bilibili/wbi.d.ts.map +1 -0
- package/dist/bilibili/wbi.js +120 -0
- package/dist/bilibili/wbi.js.map +1 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +164 -5
- package/dist/server.js.map +1 -1
- package/dist/utils/validation.d.ts +8 -0
- package/dist/utils/validation.d.ts.map +1 -1
- package/dist/utils/validation.js +23 -0
- package/dist/utils/validation.js.map +1 -1
- package/package.json +11 -9
- package/dist/smithery-test.d.ts +0 -4
- package/dist/smithery-test.d.ts.map +0 -1
- package/dist/smithery-test.js +0 -11
- package/dist/smithery-test.js.map +0 -1
- package/src/index.ts +0 -37
package/README.md
CHANGED
|
@@ -28,7 +28,9 @@
|
|
|
28
28
|
- [🌟 功能特性](#-功能特性)
|
|
29
29
|
- [1. 视频总结 (`get_video_info`)](#1-视频总结-get_video_info)
|
|
30
30
|
- [2. 评论总结 (`get_video_comments`)](#2-评论总结-get_video_comments)
|
|
31
|
-
- [3.
|
|
31
|
+
- [3. 视频转录 (`get_video_transcript`)](#3-视频转录-get_video_transcript)
|
|
32
|
+
- [4. 视频元数据 (`get_video_metadata`)](#4-视频元数据-get_video_metadata)
|
|
33
|
+
- [5. 行为说明与错误处理](#5-行为说明与错误处理)
|
|
32
34
|
- [📋 环境要求](#-环境要求)
|
|
33
35
|
- [🚀 安装方式](#-安装方式)
|
|
34
36
|
- [🖱️ Cursor](#️-cursor)
|
|
@@ -85,12 +87,51 @@
|
|
|
85
87
|
- 优先保留包含时间戳的评论(如 `05:20`),方便定位高能片段
|
|
86
88
|
- 支持两种详细程度:
|
|
87
89
|
- `brief`: 10 条热门评论速览
|
|
88
|
-
- `detailed`:
|
|
90
|
+
- `detailed`: 20 条热门评论 + 高赞连带回复
|
|
91
|
+
- 可选参数:
|
|
92
|
+
- `limit`: 显式评论数量 `1-50`,覆盖 `detail_level` 的默认数量
|
|
93
|
+
- `sort`: 排序方式 `"hot"`(按热度,默认)或 `"time"`(按时间)
|
|
94
|
+
- `include_replies`: 是否包含高赞回复(默认 `true`)
|
|
95
|
+
|
|
96
|
+
### 3. 视频转录 (`get_video_transcript`)
|
|
97
|
+
- 返回纯字幕文本,按行合并
|
|
98
|
+
- 支持指定偏好语言(默认按 `zh-Hans` > `ai-zh` > `zh-CN` > `zh-Hant` > `en` 优先级选择)
|
|
99
|
+
- 可选参数:
|
|
100
|
+
- `preferred_lang`: 偏好字幕语言代码
|
|
101
|
+
- `fallback_to_description`: 字幕不可用时是否降级为视频描述(默认 `false`)
|
|
102
|
+
- 默认不降级:无字幕时返回 `SUBTITLE_UNAVAILABLE` 错误
|
|
103
|
+
- Cookie 失效时始终返回 `COOKIE_EXPIRED`,不静默降级
|
|
104
|
+
|
|
105
|
+
### 4. 视频元数据 (`get_video_metadata`)
|
|
106
|
+
- 返回视频标题、作者、时长、发布时间、描述、标签、播放/点赞/投币等统计信息
|
|
107
|
+
- 不获取字幕或评论
|
|
108
|
+
- 仅需 `bvid_or_url` 参数
|
|
109
|
+
|
|
110
|
+
### 5. 行为说明与错误处理
|
|
89
111
|
|
|
90
|
-
### 3. 🛡️ 稳健性增强
|
|
91
112
|
- **Cookie 过期智能检测**:当字幕获取为空时自动验证登录状态,区分“无字幕视频”与“凭证失效”,并抛出明确的 `COOKIE_EXPIRED` 错误,避免静默降级。
|
|
92
113
|
|
|
93
|
-
|
|
114
|
+
#### 无 Cookie 行为
|
|
115
|
+
|
|
116
|
+
- 部分公开视频元数据(`get_video_metadata`)可能在未登录状态下工作。
|
|
117
|
+
- 字幕(`get_video_info`、`get_video_transcript`)在未登录时可能无法获取、不完整或返回空结果。
|
|
118
|
+
- 评论(`get_video_comments`)在未登录时可能不完整、被限流或返回空列表。
|
|
119
|
+
- 不建议依赖无 Cookie 模式获取字幕或评论。
|
|
120
|
+
|
|
121
|
+
#### Cookie 凭据来源
|
|
122
|
+
|
|
123
|
+
- Cookie 凭据应通过 `.env` 文件、环境变量或凭据管理工具提供。
|
|
124
|
+
- 支持的环境变量:`BILIBILI_SESSDATA`、`BILIBILI_BILI_JCT`、`BILIBILI_DEDEUSERID`。
|
|
125
|
+
- **切勿**在源码、脚本、文档、测试、日志或示例中硬编码 Cookie 值。
|
|
126
|
+
- 如果 Cookie 值曾出现在仓库历史中,应尽快到 Bilibili 账号设置中轮换/失效旧 Cookie。
|
|
127
|
+
|
|
128
|
+
#### 预期错误码
|
|
129
|
+
|
|
130
|
+
| 错误码 | 含义 | 调用方建议 |
|
|
131
|
+
|--------|------|-----------|
|
|
132
|
+
| `VALIDATION_ERROR` | 输入参数不合法 | 检查并修正 `bvid_or_url` 或其他参数 |
|
|
133
|
+
| `COOKIE_EXPIRED` | Cookie 已失效或未登录 | 用户应更新/轮换 Bilibili 凭据 |
|
|
134
|
+
| `SUBTITLE_UNAVAILABLE` | 视频无可用的字幕 | 对 `get_video_transcript` 可重试并设置 `fallback_to_description: true` |
|
|
94
135
|
|
|
95
136
|
## 📋 环境要求
|
|
96
137
|
|
|
@@ -405,6 +446,24 @@ bilibili-mcp config
|
|
|
405
446
|
"name": "get_video_comments",
|
|
406
447
|
"arguments": { "bvid_or_url": "BV1xx4x1x7xx", "detail_level": "brief" }
|
|
407
448
|
}
|
|
449
|
+
|
|
450
|
+
// 获取纯字幕文本(无字幕时返回错误)
|
|
451
|
+
{
|
|
452
|
+
"name": "get_video_transcript",
|
|
453
|
+
"arguments": { "bvid_or_url": "BV1xx4x1x7xx" }
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
// 获取视频元数据
|
|
457
|
+
{
|
|
458
|
+
"name": "get_video_metadata",
|
|
459
|
+
"arguments": { "bvid_or_url": "BV1xx4x1x7xx" }
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
// 获取评论(自定义数量+排序)
|
|
463
|
+
{
|
|
464
|
+
"name": "get_video_comments",
|
|
465
|
+
"arguments": { "bvid_or_url": "BV1xx4x1x7xx", "limit": 5, "sort": "time", "include_replies": false }
|
|
466
|
+
}
|
|
408
467
|
```
|
|
409
468
|
|
|
410
469
|
---
|
package/README_EN.md
CHANGED
|
@@ -23,7 +23,9 @@ View this document in [简体中文](./README.md)
|
|
|
23
23
|
- [🌟 Features](#-features)
|
|
24
24
|
- [1. Video Summarization (`get_video_info`)](#1-video-summarization-get_video_info)
|
|
25
25
|
- [2. Comment Summarization (`get_video_comments`)](#2-comment-summarization-get_video_comments)
|
|
26
|
-
- [3.
|
|
26
|
+
- [3. Video Transcript (`get_video_transcript`)](#3-video-transcript-get_video_transcript)
|
|
27
|
+
- [4. Video Metadata (`get_video_metadata`)](#4-video-metadata-get_video_metadata)
|
|
28
|
+
- [5. Behavior and Error Handling](#5-behavior-and-error-handling)
|
|
27
29
|
- [📋 Requirements](#-requirements)
|
|
28
30
|
- [🚀 Installation](#-installation)
|
|
29
31
|
- [🖱️ Cursor](#️-cursor)
|
|
@@ -80,12 +82,51 @@ Before proceeding with installation, please ensure you are familiar with [How to
|
|
|
80
82
|
- Prioritizes comments with timestamps (e.g., `05:20`) for quick highlight location.
|
|
81
83
|
- Supports two levels of detail:
|
|
82
84
|
- `brief`: 10 popular comments summary.
|
|
83
|
-
- `detailed`:
|
|
85
|
+
- `detailed`: 20 popular comments + high-quality replies.
|
|
86
|
+
- Optional parameters:
|
|
87
|
+
- `limit`: Explicit comment count `1-50`, overrides `detail_level` default.
|
|
88
|
+
- `sort`: Sort order `"hot"` (default) or `"time"`.
|
|
89
|
+
- `include_replies`: Whether to include top replies (default `true`).
|
|
90
|
+
|
|
91
|
+
### 3. Video Transcript (`get_video_transcript`)
|
|
92
|
+
- Returns clean subtitle text, joined by newlines.
|
|
93
|
+
- Supports preferred language selection (defaults to `zh-Hans` > `ai-zh` > `zh-CN` > `zh-Hant` > `en` priority).
|
|
94
|
+
- Optional parameters:
|
|
95
|
+
- `preferred_lang`: Preferred subtitle language code.
|
|
96
|
+
- `fallback_to_description`: Fall back to video description if subtitles unavailable (default `false`).
|
|
97
|
+
- By default, returns `SUBTITLE_UNAVAILABLE` error when no subtitles exist.
|
|
98
|
+
- Cookie expiration always returns `COOKIE_EXPIRED`, never silently falls back.
|
|
99
|
+
|
|
100
|
+
### 4. Video Metadata (`get_video_metadata`)
|
|
101
|
+
- Returns video title, author, duration, publish date, description, tags, and stats (views, likes, coins, etc.).
|
|
102
|
+
- Does not fetch subtitles or comments.
|
|
103
|
+
- Only requires the `bvid_or_url` parameter.
|
|
104
|
+
|
|
105
|
+
### 5. Behavior and Error Handling
|
|
84
106
|
|
|
85
|
-
### 3. 🛡️ Robustness Enhancement
|
|
86
107
|
- **Intelligent Cookie Expiration Detection**: Automatically verifies login status when subtitles are empty, distinguishing between "videos without subtitles" and "invalid credentials," and throwing a clear `COOKIE_EXPIRED` error to prevent silent degradation.
|
|
87
108
|
|
|
88
|
-
|
|
109
|
+
#### Without Cookie
|
|
110
|
+
|
|
111
|
+
- Some public video metadata (`get_video_metadata`) may work without authentication.
|
|
112
|
+
- Subtitles (`get_video_info`, `get_video_transcript`) may be unavailable, incomplete, or fail without authentication.
|
|
113
|
+
- Comments (`get_video_comments`) may be incomplete, empty, or rate-limited without authentication.
|
|
114
|
+
- Do not rely on cookie-less mode for reliable subtitle or comment access.
|
|
115
|
+
|
|
116
|
+
#### Credential Sources
|
|
117
|
+
|
|
118
|
+
- Credentials should be supplied via `.env` file, environment variables, or the credential helper.
|
|
119
|
+
- Supported environment variables: `BILIBILI_SESSDATA`, `BILIBILI_BILI_JCT`, `BILIBILI_DEDEUSERID`.
|
|
120
|
+
- **Never** hard-code Cookie values in source code, scripts, docs, tests, logs, or examples.
|
|
121
|
+
- If Cookie values were previously exposed in repository history, rotate them immediately via Bilibili account settings.
|
|
122
|
+
|
|
123
|
+
#### Expected Error Codes
|
|
124
|
+
|
|
125
|
+
| Code | Meaning | Caller Action |
|
|
126
|
+
|------|---------|---------------|
|
|
127
|
+
| `VALIDATION_ERROR` | Invalid input parameter | Fix the `bvid_or_url` or other parameter |
|
|
128
|
+
| `COOKIE_EXPIRED` | Cookie expired or not logged in | User should refresh/rotate Bilibili credentials |
|
|
129
|
+
| `SUBTITLE_UNAVAILABLE` | No subtitles available for this video | For `get_video_transcript`, retry with `fallback_to_description: true` |
|
|
89
130
|
|
|
90
131
|
## 📋 Requirements
|
|
91
132
|
|
|
@@ -389,6 +430,24 @@ AI assistants will call these tools using JSON:
|
|
|
389
430
|
"name": "get_video_comments",
|
|
390
431
|
"arguments": { "bvid_or_url": "BV1xx4x1x7xx", "detail_level": "brief" }
|
|
391
432
|
}
|
|
433
|
+
|
|
434
|
+
// Transcript-only text (returns error if no subtitles)
|
|
435
|
+
{
|
|
436
|
+
"name": "get_video_transcript",
|
|
437
|
+
"arguments": { "bvid_or_url": "BV1xx4x1x7xx" }
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
// Video metadata
|
|
441
|
+
{
|
|
442
|
+
"name": "get_video_metadata",
|
|
443
|
+
"arguments": { "bvid_or_url": "BV1xx4x1x7xx" }
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
// Comments with custom limit + sort
|
|
447
|
+
{
|
|
448
|
+
"name": "get_video_comments",
|
|
449
|
+
"arguments": { "bvid_or_url": "BV1xx4x1x7xx", "limit": 5, "sort": "time", "include_replies": false }
|
|
450
|
+
}
|
|
392
451
|
```
|
|
393
452
|
|
|
394
453
|
---
|
|
@@ -1,74 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* 该函数不会在日志或错误信息中输出任何 Cookie 内容。
|
|
5
|
-
*/
|
|
6
|
-
export declare function checkLoginStatus(): Promise<{
|
|
7
|
-
isLogin: boolean;
|
|
8
|
-
}>;
|
|
9
|
-
/**
|
|
10
|
-
* 带有 WBI 签名的 GET 请求
|
|
11
|
-
*/
|
|
12
|
-
export declare function fetchWithWBI(path: string, params: Record<string, string | number>, additionalHeaders?: Record<string, string>): Promise<unknown>;
|
|
13
|
-
/**
|
|
14
|
-
* 普通的 GET 请求(不需要 WBI 签名)
|
|
15
|
-
*/
|
|
16
|
-
export declare function fetchWithoutWBI(path: string, params?: Record<string, string | number>, additionalHeaders?: Record<string, string>): Promise<unknown>;
|
|
17
|
-
/**
|
|
18
|
-
* 获取视频基本信息
|
|
19
|
-
*/
|
|
20
|
-
export declare function getVideoInfo(bvid: string): Promise<{
|
|
21
|
-
title: string;
|
|
22
|
-
desc: string;
|
|
23
|
-
pic?: string;
|
|
24
|
-
owner: {
|
|
25
|
-
name: string;
|
|
26
|
-
face: string;
|
|
27
|
-
};
|
|
28
|
-
stat: {
|
|
29
|
-
view: number;
|
|
30
|
-
danmaku: number;
|
|
31
|
-
reply: number;
|
|
32
|
-
favorite: number;
|
|
33
|
-
coin: number;
|
|
34
|
-
share: number;
|
|
35
|
-
like: number;
|
|
36
|
-
};
|
|
37
|
-
cid: number;
|
|
38
|
-
aid: number;
|
|
39
|
-
duration: number;
|
|
40
|
-
pubdate: number;
|
|
41
|
-
tag?: {
|
|
42
|
-
tag_name: string;
|
|
43
|
-
}[];
|
|
44
|
-
}>;
|
|
45
|
-
/**
|
|
46
|
-
* 获取视频字幕信息
|
|
47
|
-
*/
|
|
48
|
-
export declare function getVideoSubtitle(bvid: string, cid: number): Promise<{
|
|
49
|
-
subtitle: {
|
|
50
|
-
subtitles: Array<{
|
|
51
|
-
id: number;
|
|
52
|
-
lan: string;
|
|
53
|
-
lan_doc: string;
|
|
54
|
-
subtitle_url: string;
|
|
55
|
-
}>;
|
|
56
|
-
};
|
|
57
|
-
}>;
|
|
58
|
-
/**
|
|
59
|
-
* 获取字幕内容
|
|
60
|
-
*/
|
|
61
|
-
export declare function getSubtitleContent(url: string): Promise<{
|
|
62
|
-
body: Array<{
|
|
63
|
-
from: number;
|
|
64
|
-
to: number;
|
|
65
|
-
location: number;
|
|
66
|
-
content: string;
|
|
67
|
-
}>;
|
|
68
|
-
}>;
|
|
69
|
-
/**
|
|
70
|
-
* 获取视频评论
|
|
71
|
-
*/
|
|
72
|
-
export declare function getVideoComments(videoUrlOrBvid: string, page?: number, pageSize?: number, sort?: number, // 0按时间,1按热度
|
|
73
|
-
includeReplies?: boolean): Promise<any>;
|
|
1
|
+
export { checkLoginStatus, fetchWithWBI, fetchWithoutWBI } from "./http.js";
|
|
2
|
+
export { getSubtitleContent, getVideoInfo, getVideoSubtitle, } from "./video-api.js";
|
|
3
|
+
export { getVideoComments } from "./comments-api.js";
|
|
74
4
|
//# sourceMappingURL=client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/bilibili/client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/bilibili/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5E,OAAO,EACL,kBAAkB,EAClB,YAAY,EACZ,gBAAgB,GACjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC"}
|