dsh-shlr-bilitoolkit 0.1.24 → 0.1.26

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/AGENTS.md CHANGED
@@ -5,5 +5,9 @@
5
5
  **必须调用 bili_gen_qr,并把返回的二维码图片展示给用户扫码**——用 qrDataUrl 以 Markdown 图片 `![qr](<qrDataUrl>)` 渲染(或引用 qrImageUrl / qrImagePath)。
6
6
  禁止只给链接、用 ASCII、让用户自己跑命令。用户确认后调 bili_login_status 完成登录。
7
7
 
8
+ ## 多步查询
9
+ 需要多个 B 站数据时(如「视频详情 + 热评 + UP主资料」),尽量在一段代码里完成,不要连续调用多个工具:
10
+ - 独立的只读调用用 `Promise.all` 并发;写操作保持逐条 `await`。
11
+
8
12
  ## 其它
9
13
  写操作(点赞 / 收藏 / 投币 / 关注 / 评论 / 私信 / 三连 / 发动态 / 改资料)会真实修改账号状态,执行前先与用户确认。
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # dsh-shlr-bilitoolkit
2
2
 
3
- 0.1.15-0.1.19为工具懒加载版,
3
+ 0.1.15-0.1.19为工具懒加载版
4
4
 
5
5
  B 站(哔哩哔哩)接口封装的 **TypeScript** 移植版,作为 [dsh](https://dshmp.com)(DeepSeek Harness)插件提供「视频 / 搜索 / 空间」等读取能力。
6
6
 
@@ -64,7 +64,7 @@ await client.loadCookies();
64
64
  const videos = await client.video.recommend(2, 10);
65
65
  const detail = await client.video.detail("BV1xx411c7mD");
66
66
  const text = await client.video.subtitleText("BV1xx411c7mD"); // 字幕纯文本
67
- const [videos2, total] = await client.search.videos("孤独摇滚");
67
+ const [videos2, total] = await client.search.videos("偶像大师");
68
68
  const info = await client.space.info(574115689);
69
69
  const [ups, _] = await client.space.videos(574115689, 1, 10);
70
70
  ```
@@ -12,21 +12,30 @@ export class VideoAPI {
12
12
  }
13
13
  async *iterRecommend(pages = 1, pageSize = 10) {
14
14
  const seen = new Set();
15
+ // 推荐流里混有广告(goto=ad)、直播、OGV 等非普通视频项,会被过滤掉,
16
+ // 所以按上限多抓一些做补偿,尽量让「要几条给几条」。
17
+ // 注意:B 站对 ps 有上限(约 30),给大了会 -400。
18
+ const ps = 30;
15
19
  for (let page = 1; page <= pages; page++) {
16
20
  const payload = await this.client.get(endpoints.RCMD_FEED, {
17
21
  fresh_idx: page,
18
22
  fresh_idx_1h: page,
19
23
  feed_version: 1,
20
- ps: pageSize,
24
+ ps,
21
25
  });
22
26
  const items = payload?.data?.item ?? [];
23
27
  let added = 0;
24
28
  for (const item of items) {
29
+ // 只保留普通视频(goto=av):排除广告 / 直播 / OGV / 推广等
30
+ if (item?.goto && item.goto !== "av")
31
+ continue;
25
32
  const video = Video.fromFeedItem(item);
26
33
  if (video && !seen.has(video.bvid)) {
27
34
  seen.add(video.bvid);
28
35
  added += 1;
29
36
  yield video;
37
+ if (seen.size >= pageSize * pages)
38
+ return;
30
39
  }
31
40
  }
32
41
  if (!added)
package/dist/dsh.d.ts CHANGED
@@ -38,6 +38,14 @@ export declare const GROUPS: Record<string, {
38
38
  hint: string;
39
39
  ids: string[];
40
40
  }>;
41
+ /**
42
+ * 工具输出 schema。必须用 type:"json"(编译成无 type 的注解式 schema,任意 lossless
43
+ * JSON 都放行):我们的工具有的返回数组(recommend / pagelist / subtitles)、有的返回
44
+ * 对象、有的返回标量;若声明 type:"object",数组会被校验器拒("value" must be an object)。
45
+ */
46
+ export declare const OUTPUT_SCHEMA_SPEC: {
47
+ readonly type: "json";
48
+ };
41
49
  export declare function apply(ctx: any): void;
42
50
  export * from "./index.js";
43
51
  export { BiliClient, Video, User, Page, PlayInfo, Subtitle, Collection };
package/dist/dsh.js CHANGED
@@ -1190,10 +1190,16 @@ function closeGroup(group) {
1190
1190
  if (i >= 0)
1191
1191
  groupLru.splice(i, 1);
1192
1192
  }
1193
+ /**
1194
+ * 工具输出 schema。必须用 type:"json"(编译成无 type 的注解式 schema,任意 lossless
1195
+ * JSON 都放行):我们的工具有的返回数组(recommend / pagelist / subtitles)、有的返回
1196
+ * 对象、有的返回标量;若声明 type:"object",数组会被校验器拒("value" must be an object)。
1197
+ */
1198
+ export const OUTPUT_SCHEMA_SPEC = { type: "json" };
1193
1199
  /** 把一个内部 DshTool 编译成官方 defineTool 定义。 */
1194
1200
  function buildDef(tool) {
1195
1201
  const output = {
1196
- schema: { type: "object", additionalProperties: true },
1202
+ schema: OUTPUT_SCHEMA_SPEC,
1197
1203
  render: tool.render ??
1198
1204
  ((_args, value) => [{ type: "text", text: textOf(value) }]),
1199
1205
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-shlr-bilitoolkit",
3
- "version": "0.1.24",
3
+ "version": "0.1.26",
4
4
  "description": "深海猎人专用B站接口工具箱 dsh 插件。",
5
5
  "type": "module",
6
6
  "main": "dist/dsh.js",