dsh-shlr-bilitoolkit 0.1.14 → 0.1.15
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/dist/dsh.js +77 -135
- package/package.json +1 -1
package/dist/dsh.js
CHANGED
|
@@ -141,31 +141,38 @@ export const TOOLS = [
|
|
|
141
141
|
},
|
|
142
142
|
{
|
|
143
143
|
id: "bili_video_subtitle",
|
|
144
|
-
description: "
|
|
144
|
+
description: "视频字幕:默认返回字幕纯文本(优先中文);list=true 时返回可用字幕轨列表。",
|
|
145
145
|
parameters: {
|
|
146
146
|
type: "object",
|
|
147
147
|
properties: {
|
|
148
148
|
bvid: { type: "string" },
|
|
149
149
|
lang: { type: "string", default: "zh" },
|
|
150
|
+
list: { type: "boolean", default: false, description: "true 则只列字幕轨,不取正文" },
|
|
150
151
|
},
|
|
151
152
|
required: ["bvid"],
|
|
152
153
|
},
|
|
153
154
|
handler: async (a) => {
|
|
154
155
|
const c = await getClient();
|
|
156
|
+
if (Boolean(a.list ?? false)) {
|
|
157
|
+
const subs = await c.video.subtitles(a.bvid);
|
|
158
|
+
return subs.map((s) => s.toDict());
|
|
159
|
+
}
|
|
155
160
|
return { text: await c.video.subtitleText(a.bvid, a.lang ?? "zh") };
|
|
156
161
|
},
|
|
157
162
|
},
|
|
158
163
|
{
|
|
159
|
-
id: "
|
|
160
|
-
description: "搜索 B
|
|
164
|
+
id: "bili_search",
|
|
165
|
+
description: "搜索 B 站视频或用户。",
|
|
161
166
|
parameters: {
|
|
162
167
|
type: "object",
|
|
163
168
|
properties: {
|
|
164
169
|
keyword: { type: "string" },
|
|
170
|
+
type: { type: "string", enum: ["video", "user"], default: "video" },
|
|
165
171
|
order: {
|
|
166
172
|
type: "string",
|
|
167
173
|
enum: ["totalrank", "click", "pubdate", "dm", "stow", "scores"],
|
|
168
174
|
default: "totalrank",
|
|
175
|
+
description: "排序(仅视频)",
|
|
169
176
|
},
|
|
170
177
|
pageSize: { type: "integer", default: 20 },
|
|
171
178
|
},
|
|
@@ -173,27 +180,15 @@ export const TOOLS = [
|
|
|
173
180
|
},
|
|
174
181
|
handler: async (a) => {
|
|
175
182
|
const c = await getClient();
|
|
176
|
-
const
|
|
183
|
+
const ps = Number(a.pageSize ?? 20);
|
|
184
|
+
if (String(a.type ?? "video") === "user") {
|
|
185
|
+
const [users, total] = await c.search.users(a.keyword, 1, ps);
|
|
186
|
+
return { total, users: users.map((u) => u.toDict()) };
|
|
187
|
+
}
|
|
188
|
+
const [videos, total] = await c.search.videos(a.keyword, 1, ps, a.order ?? "totalrank");
|
|
177
189
|
return { total, videos: videos.map((v) => v.toDict()) };
|
|
178
190
|
},
|
|
179
191
|
},
|
|
180
|
-
{
|
|
181
|
-
id: "bili_search_user",
|
|
182
|
-
description: "搜索 B 站用户。",
|
|
183
|
-
parameters: {
|
|
184
|
-
type: "object",
|
|
185
|
-
properties: {
|
|
186
|
-
keyword: { type: "string" },
|
|
187
|
-
pageSize: { type: "integer", default: 20 },
|
|
188
|
-
},
|
|
189
|
-
required: ["keyword"],
|
|
190
|
-
},
|
|
191
|
-
handler: async (a) => {
|
|
192
|
-
const c = await getClient();
|
|
193
|
-
const [users, total] = await c.search.users(a.keyword, 1, Number(a.pageSize ?? 20));
|
|
194
|
-
return { total, users: users.map((u) => u.toDict()) };
|
|
195
|
-
},
|
|
196
|
-
},
|
|
197
192
|
{
|
|
198
193
|
id: "bili_space_info",
|
|
199
194
|
description: "获取 B 站用户空间基本信息(昵称、等级、签名)。",
|
|
@@ -291,54 +286,50 @@ export const TOOLS = [
|
|
|
291
286
|
// ---- 评论 ----
|
|
292
287
|
{
|
|
293
288
|
id: "bili_comment_list",
|
|
294
|
-
description: "
|
|
289
|
+
description: "获取评论列表(视频 / 动态 / 专栏),返回评论列表。",
|
|
295
290
|
parameters: {
|
|
296
291
|
type: "object",
|
|
297
292
|
properties: {
|
|
298
|
-
|
|
293
|
+
target: { type: "string", enum: ["video", "dynamic", "article"], default: "video" },
|
|
294
|
+
id: { type: "string", description: "视频 bvid / 动态 id / 专栏 cv 号" },
|
|
299
295
|
sort: { type: "string", enum: ["time", "like", "reply"], default: "time" },
|
|
300
296
|
pageSize: { type: "integer", default: 20 },
|
|
301
297
|
},
|
|
302
|
-
required: ["
|
|
298
|
+
required: ["id"],
|
|
303
299
|
},
|
|
304
300
|
handler: async (a) => {
|
|
305
301
|
const c = await getClient();
|
|
306
|
-
const
|
|
307
|
-
|
|
302
|
+
const target = String(a.target ?? "video");
|
|
303
|
+
const ps = Number(a.pageSize ?? 20);
|
|
304
|
+
const sort = a.sort ?? "time";
|
|
305
|
+
let items;
|
|
306
|
+
if (target === "dynamic")
|
|
307
|
+
[items] = await c.comment.listDynamic(a.id, 1, ps, sort);
|
|
308
|
+
else if (target === "article")
|
|
309
|
+
[items] = await c.comment.listArticle(a.id, 1, ps, sort);
|
|
310
|
+
else
|
|
311
|
+
[items] = await c.comment.listVideo(a.id, 1, ps, sort);
|
|
312
|
+
return { comments: items.map((x) => x.toDict()) };
|
|
308
313
|
},
|
|
309
314
|
},
|
|
310
315
|
// ---- 关注关系 ----
|
|
311
316
|
{
|
|
312
|
-
id: "
|
|
313
|
-
description: "
|
|
314
|
-
parameters: {
|
|
315
|
-
type: "object",
|
|
316
|
-
properties: {
|
|
317
|
-
uid: { type: "integer" },
|
|
318
|
-
pageSize: { type: "integer", default: 20 },
|
|
319
|
-
},
|
|
320
|
-
required: ["uid"],
|
|
321
|
-
},
|
|
322
|
-
handler: async (a) => {
|
|
323
|
-
const c = await getClient();
|
|
324
|
-
const [users, total] = await c.relation.followings(Number(a.uid), 1, Number(a.pageSize ?? 20));
|
|
325
|
-
return { total, users: users.map((x) => x.toDict()) };
|
|
326
|
-
},
|
|
327
|
-
},
|
|
328
|
-
{
|
|
329
|
-
id: "bili_relation_followers",
|
|
330
|
-
description: "获取某用户的粉丝列表。",
|
|
317
|
+
id: "bili_relation_list",
|
|
318
|
+
description: "获取某用户的关注列表或粉丝列表。",
|
|
331
319
|
parameters: {
|
|
332
320
|
type: "object",
|
|
333
321
|
properties: {
|
|
334
322
|
uid: { type: "integer" },
|
|
323
|
+
type: { type: "string", enum: ["followings", "followers"], default: "followings" },
|
|
335
324
|
pageSize: { type: "integer", default: 20 },
|
|
336
325
|
},
|
|
337
326
|
required: ["uid"],
|
|
338
327
|
},
|
|
339
328
|
handler: async (a) => {
|
|
340
329
|
const c = await getClient();
|
|
341
|
-
const [users, total] =
|
|
330
|
+
const [users, total] = String(a.type ?? "followings") === "followers"
|
|
331
|
+
? await c.relation.followers(Number(a.uid), 1, Number(a.pageSize ?? 20))
|
|
332
|
+
: await c.relation.followings(Number(a.uid), 1, Number(a.pageSize ?? 20));
|
|
342
333
|
return { total, users: users.map((x) => x.toDict()) };
|
|
343
334
|
},
|
|
344
335
|
},
|
|
@@ -349,16 +340,6 @@ export const TOOLS = [
|
|
|
349
340
|
parameters: { type: "object", properties: {} },
|
|
350
341
|
handler: async () => (await getClient()).notify.unread(),
|
|
351
342
|
},
|
|
352
|
-
{
|
|
353
|
-
id: "bili_notify_replies",
|
|
354
|
-
description: "获取「回复我的」消息列表(需登录)。",
|
|
355
|
-
parameters: { type: "object", properties: {} },
|
|
356
|
-
handler: async () => {
|
|
357
|
-
const c = await getClient();
|
|
358
|
-
const [items, cursor, isEnd] = await c.notify.replies();
|
|
359
|
-
return { isEnd, cursor, notices: items.map((x) => x.toDict()) };
|
|
360
|
-
},
|
|
361
|
-
},
|
|
362
343
|
// ---- 收藏夹(读取) ----
|
|
363
344
|
{
|
|
364
345
|
id: "bili_fav_folders",
|
|
@@ -401,35 +382,24 @@ export const TOOLS = [
|
|
|
401
382
|
},
|
|
402
383
|
{
|
|
403
384
|
id: "bili_favorite",
|
|
404
|
-
description: "
|
|
385
|
+
description: "收藏或取消收藏视频到收藏夹(写操作,需登录)。",
|
|
405
386
|
parameters: {
|
|
406
387
|
type: "object",
|
|
407
388
|
properties: {
|
|
408
389
|
bvid: { type: "string" },
|
|
390
|
+
action: { type: "string", enum: ["add", "remove"], default: "add" },
|
|
409
391
|
folderName: { type: "string" },
|
|
410
392
|
},
|
|
411
393
|
required: ["bvid"],
|
|
412
394
|
},
|
|
413
|
-
handler: async (a) => {
|
|
414
|
-
const fid = await (await getClient()).interact.favorite(a.bvid, undefined, a.folderName);
|
|
415
|
-
return { folderId: fid };
|
|
416
|
-
},
|
|
417
|
-
},
|
|
418
|
-
{
|
|
419
|
-
id: "bili_send_comment",
|
|
420
|
-
description: "发表视频评论(写操作,需登录)。",
|
|
421
|
-
parameters: {
|
|
422
|
-
type: "object",
|
|
423
|
-
properties: {
|
|
424
|
-
bvid: { type: "string" },
|
|
425
|
-
message: { type: "string" },
|
|
426
|
-
},
|
|
427
|
-
required: ["bvid", "message"],
|
|
428
|
-
},
|
|
429
395
|
handler: async (a) => {
|
|
430
396
|
const c = await getClient();
|
|
431
|
-
|
|
432
|
-
|
|
397
|
+
if (String(a.action ?? "add") === "remove") {
|
|
398
|
+
const fid = await c.interact.unfavorite(a.bvid, undefined, a.folderName);
|
|
399
|
+
return { ok: true, folderId: fid };
|
|
400
|
+
}
|
|
401
|
+
const fid = await c.interact.favorite(a.bvid, undefined, a.folderName);
|
|
402
|
+
return { ok: true, folderId: fid };
|
|
433
403
|
},
|
|
434
404
|
},
|
|
435
405
|
{
|
|
@@ -522,19 +492,6 @@ export const TOOLS = [
|
|
|
522
492
|
return pages.map((p) => p.toDict());
|
|
523
493
|
},
|
|
524
494
|
},
|
|
525
|
-
{
|
|
526
|
-
id: "bili_video_subtitles",
|
|
527
|
-
description: "列出视频可用的字幕轨(语言 / 名称 / 链接),不含正文。",
|
|
528
|
-
parameters: {
|
|
529
|
-
type: "object",
|
|
530
|
-
properties: { bvid: { type: "string" } },
|
|
531
|
-
required: ["bvid"],
|
|
532
|
-
},
|
|
533
|
-
handler: async (a) => {
|
|
534
|
-
const subs = await (await getClient()).video.subtitles(a.bvid);
|
|
535
|
-
return subs.map((s) => s.toDict());
|
|
536
|
-
},
|
|
537
|
-
},
|
|
538
495
|
{
|
|
539
496
|
id: "bili_video_playurl",
|
|
540
497
|
description: "获取视频播放地址信息(清晰度、可用清晰度列表、durl 直链)。高清晰度可能需登录 / 大会员。",
|
|
@@ -668,22 +625,6 @@ export const TOOLS = [
|
|
|
668
625
|
return { ok: true };
|
|
669
626
|
},
|
|
670
627
|
},
|
|
671
|
-
{
|
|
672
|
-
id: "bili_unfavorite",
|
|
673
|
-
description: "把视频从收藏夹移除(写操作,需登录)。",
|
|
674
|
-
parameters: {
|
|
675
|
-
type: "object",
|
|
676
|
-
properties: {
|
|
677
|
-
bvid: { type: "string" },
|
|
678
|
-
folderName: { type: "string", description: "收藏夹名(可选,默认取默认收藏夹)" },
|
|
679
|
-
},
|
|
680
|
-
required: ["bvid"],
|
|
681
|
-
},
|
|
682
|
-
handler: async (a) => {
|
|
683
|
-
const fid = await (await getClient()).interact.unfavorite(a.bvid, undefined, a.folderName);
|
|
684
|
-
return { ok: true, folderId: fid };
|
|
685
|
-
},
|
|
686
|
-
},
|
|
687
628
|
{
|
|
688
629
|
id: "bili_user_following",
|
|
689
630
|
description: "查询我是否已关注某用户。",
|
|
@@ -885,21 +826,25 @@ export const TOOLS = [
|
|
|
885
826
|
},
|
|
886
827
|
// ---- 消息中心补充 ----
|
|
887
828
|
{
|
|
888
|
-
id: "
|
|
889
|
-
description: "
|
|
890
|
-
parameters: {
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
829
|
+
id: "bili_notify_list",
|
|
830
|
+
description: "消息中心列表:回复我的 / @我的 / 收到的赞(需登录)。",
|
|
831
|
+
parameters: {
|
|
832
|
+
type: "object",
|
|
833
|
+
properties: {
|
|
834
|
+
type: { type: "string", enum: ["replies", "ats", "likes"], default: "replies" },
|
|
835
|
+
},
|
|
894
836
|
},
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
837
|
+
handler: async (a) => {
|
|
838
|
+
const c = await getClient();
|
|
839
|
+
const t = String(a.type ?? "replies");
|
|
840
|
+
let items;
|
|
841
|
+
if (t === "ats")
|
|
842
|
+
[items] = await c.notify.ats();
|
|
843
|
+
else if (t === "likes")
|
|
844
|
+
[items] = await c.notify.likes();
|
|
845
|
+
else
|
|
846
|
+
[items] = await c.notify.replies();
|
|
847
|
+
return { notices: items.map((x) => x.toDict()) };
|
|
903
848
|
},
|
|
904
849
|
},
|
|
905
850
|
// ---- 私信补充 ----
|
|
@@ -959,39 +904,36 @@ export const TOOLS = [
|
|
|
959
904
|
parameters: { type: "object", properties: {} },
|
|
960
905
|
handler: async () => (await getClient()).profile.info(),
|
|
961
906
|
},
|
|
962
|
-
{
|
|
963
|
-
id: "bili_profile_update_sign",
|
|
964
|
-
description: "修改我的个性签名(写操作,需登录,会进入审核)。",
|
|
965
|
-
parameters: {
|
|
966
|
-
type: "object",
|
|
967
|
-
properties: { sign: { type: "string" } },
|
|
968
|
-
required: ["sign"],
|
|
969
|
-
},
|
|
970
|
-
handler: async (a) => {
|
|
971
|
-
await (await getClient()).profile.updateSign(String(a.sign ?? ""));
|
|
972
|
-
return { ok: true };
|
|
973
|
-
},
|
|
974
|
-
},
|
|
975
907
|
{
|
|
976
908
|
id: "bili_profile_update",
|
|
977
|
-
description: "修改我的昵称 / 性别 /
|
|
909
|
+
description: "修改我的昵称 / 性别 / 生日 / 签名(写操作,需登录,至少改一项)。",
|
|
978
910
|
parameters: {
|
|
979
911
|
type: "object",
|
|
980
912
|
properties: {
|
|
981
913
|
uname: { type: "string", description: "新昵称(1~20 字符)" },
|
|
982
914
|
sex: { type: "string", enum: ["男", "女", "保密"] },
|
|
983
915
|
birthday: { type: "string", description: "YYYY-MM-DD" },
|
|
916
|
+
sign: { type: "string", description: "个性签名(≤70 字)" },
|
|
984
917
|
},
|
|
985
918
|
},
|
|
986
919
|
handler: async (a) => {
|
|
987
|
-
|
|
920
|
+
const c = await getClient();
|
|
921
|
+
const hasProfile = a.uname != null || a.sex != null || a.birthday != null;
|
|
922
|
+
if (a.sign == null && !hasProfile) {
|
|
923
|
+
throw new Error("至少修改一项:uname / sex / birthday / sign");
|
|
924
|
+
}
|
|
925
|
+
if (a.sign != null)
|
|
926
|
+
await c.profile.updateSign(String(a.sign));
|
|
927
|
+
if (hasProfile) {
|
|
928
|
+
await c.profile.updateProfile(a.uname != null ? String(a.uname) : undefined, a.sex != null ? String(a.sex) : undefined, a.birthday != null ? String(a.birthday) : undefined);
|
|
929
|
+
}
|
|
988
930
|
return { ok: true };
|
|
989
931
|
},
|
|
990
932
|
},
|
|
991
933
|
// ---- 登录状态 ----
|
|
992
934
|
{
|
|
993
935
|
id: "bili_login_status",
|
|
994
|
-
description: "
|
|
936
|
+
description: "查登录态(返回用户名)。想登录或报未登录(-101)时先调本工具;未登录则必须立即调 bili_gen_qr 展示二维码图片。刚调过 bili_gen_qr 时本工具会顺带轮询,用户确认后自动保存 Cookie。",
|
|
995
937
|
parameters: { type: "object", properties: {} },
|
|
996
938
|
handler: async () => {
|
|
997
939
|
const c = await getClient();
|
|
@@ -1040,7 +982,7 @@ export const TOOLS = [
|
|
|
1040
982
|
},
|
|
1041
983
|
{
|
|
1042
984
|
id: "bili_gen_qr",
|
|
1043
|
-
description: "
|
|
985
|
+
description: "【登录唯一入口】生成扫码登录二维码。必须把返回的二维码图片展示给用户扫(用 qrDataUrl / qrImageUrl / qrImagePath 渲染成图片),不要只给链接。返回 url / qrcodeKey / qrDataUrl / qrImageUrl / qrImagePath。用户确认后调 bili_login_status 完成登录。",
|
|
1044
986
|
parameters: { type: "object", properties: {} },
|
|
1045
987
|
handler: async () => {
|
|
1046
988
|
const c = await getClient();
|