koishi-plugin-bilibili-videolink-analysis 0.4.12 → 0.5.1
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/lib/index.js +50 -19
- package/package.json +1 -1
- package/readme.md +65 -42
package/lib/index.js
CHANGED
|
@@ -20,6 +20,7 @@ exports.usage = `
|
|
|
20
20
|
---
|
|
21
21
|
|
|
22
22
|
#### ⚠️ **如果你使用不了本项目,请优先检查:** ⚠️
|
|
23
|
+
#### 视频内容是否为B站的大会员专属视频/付费视频/充电专属视频
|
|
23
24
|
#### 是否正确配置并启动了[bilibili-login插件](/market?keyword=bilibili-login) (启动即可,不是必须登录)
|
|
24
25
|
#### 接入方法是否支持获取网址链接/小程序卡片消息
|
|
25
26
|
#### 接入方法是否支持视频元素的发送
|
|
@@ -54,20 +55,25 @@ exports.Config = koishi_1.Schema.intersect([
|
|
|
54
55
|
koishi_1.Schema.const('4').description('返回视频和视频直链'),
|
|
55
56
|
koishi_1.Schema.const('5').description('返回视频,仅在日志记录视频直链'),
|
|
56
57
|
]).role('radio').default('2').description("是否返回` 视频/视频直链 `"),
|
|
58
|
+
Video_ClarityPriority: koishi_1.Schema.union([
|
|
59
|
+
koishi_1.Schema.const('1').description('低清晰度优先(低清晰度的视频发得快一点)'),
|
|
60
|
+
koishi_1.Schema.const('2').description('高清晰度优先(清晰的还是去B站看吧)'),
|
|
61
|
+
]).role('radio').default('1').description("发送的视频清晰度优先策略"),
|
|
57
62
|
|
|
58
63
|
BVnumberParsing: koishi_1.Schema.boolean().default(true).description("是否允许根据`独立的BV号`解析视频 `开启后,可以通过视频的BV号解析视频。` <br> [触发说明见README](https://www.npmjs.com/package/koishi-plugin-bilibili-videolink-analysis)"),
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
+
Maximumduration: koishi_1.Schema.number().default(25).description("允许解析的视频最大时长(分钟)`超过这个时长 就不会发视频`").min(1),
|
|
65
|
+
Maximumduration_tip: koishi_1.Schema.union([
|
|
66
|
+
koishi_1.Schema.const('不返回文字提示').description('不返回文字提示'),
|
|
67
|
+
koishi_1.Schema.string().description('返回文字提示(请在右侧填写文字内容)').default('视频太长啦!还是去B站看吧~'),
|
|
68
|
+
]).description("对过长视频的文字提示内容").default('视频太长啦!还是去B站看吧~'),
|
|
69
|
+
MinimumTimeInterval: koishi_1.Schema.number().default(180).description("若干`秒`内 不再处理相同链接 `防止多bot互相触发 导致的刷屏/性能浪费`").min(1),
|
|
64
70
|
}).description("基础设置"),
|
|
65
71
|
|
|
66
72
|
koishi_1.Schema.object({
|
|
67
73
|
parseLimit: koishi_1.Schema.number().default(3).description("单对话多链接解析上限").hidden(),
|
|
68
74
|
useNumeral: koishi_1.Schema.boolean().default(true).description("使用格式化数字").hidden(),
|
|
69
75
|
showError: koishi_1.Schema.boolean().default(false).description("当链接不正确时提醒发送者").hidden(),
|
|
70
|
-
|
|
76
|
+
|
|
71
77
|
bVideoIDPreference: koishi_1.Schema.union([
|
|
72
78
|
koishi_1.Schema.const("bv").description("BV 号"),
|
|
73
79
|
koishi_1.Schema.const("av").description("AV 号"),
|
|
@@ -78,11 +84,13 @@ exports.Config = koishi_1.Schema.intersect([
|
|
|
78
84
|
bVideoStat: koishi_1.Schema.boolean().default(true).description("显示状态(*三连数据*)"),
|
|
79
85
|
bVideoExtraStat: koishi_1.Schema.boolean().default(true).description("显示额外状态(*弹幕&观看*)"),
|
|
80
86
|
bVideoShowLink: koishi_1.Schema.boolean().default(false).description("显示视频链接`开启可能会导致其他bot循环解析`"),
|
|
87
|
+
|
|
81
88
|
}).description("链接的图文解析设置"),
|
|
82
89
|
|
|
83
90
|
koishi_1.Schema.object({
|
|
91
|
+
userAgent: koishi_1.Schema.string().description("所有 API 请求所用的 User-Agent").default("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36"),
|
|
84
92
|
loggerinfo: koishi_1.Schema.boolean().default(false).description("日志调试输出 `日常使用无需开启`"),
|
|
85
|
-
}).description("
|
|
93
|
+
}).description("调试设置"),
|
|
86
94
|
]);
|
|
87
95
|
|
|
88
96
|
function apply(ctx, config) {
|
|
@@ -157,10 +165,20 @@ function apply(ctx, config) {
|
|
|
157
165
|
}
|
|
158
166
|
}
|
|
159
167
|
let bilibilimediaDataURL = '';
|
|
168
|
+
let mediaData = '';
|
|
160
169
|
if (config.VideoParsing_ToLink) {
|
|
161
170
|
const mediaDataString = JSON.stringify(await handleBilibiliMedia(bilibiliVideo, lastretUrl, config));
|
|
162
|
-
|
|
171
|
+
mediaData = JSON.parse(mediaDataString);
|
|
163
172
|
bilibilimediaDataURL = mediaData[0].url
|
|
173
|
+
const videoDuration = mediaData[0].duration; // 提取视频时长,单位为秒
|
|
174
|
+
|
|
175
|
+
if (videoDuration > config.Maximumduration * 60) {
|
|
176
|
+
// 如果视频时长超过配置的最大值
|
|
177
|
+
if (config.Maximumduration_tip) {
|
|
178
|
+
await session.send(config.Maximumduration_tip);
|
|
179
|
+
}
|
|
180
|
+
return next();
|
|
181
|
+
}
|
|
164
182
|
// 根据配置的值来决定发送的内容
|
|
165
183
|
/*
|
|
166
184
|
* VideoParsing_ToLink: koishi_1.Schema.union([
|
|
@@ -191,15 +209,17 @@ function apply(ctx, config) {
|
|
|
191
209
|
await session.send(koishi_1.h.video(bilibilimediaDataURL)); // 发送视频
|
|
192
210
|
break;
|
|
193
211
|
default:
|
|
194
|
-
// 处理默认情况或者错误配置
|
|
212
|
+
// 处理默认情况或者错误配置
|
|
213
|
+
// 目前默认 不返回视频/视频直链
|
|
195
214
|
break;
|
|
196
215
|
}
|
|
197
216
|
}
|
|
198
217
|
|
|
199
218
|
if (config.loggerinfo) {
|
|
200
219
|
//logger.info(`userAgent为\n ${config.userAgent}`);
|
|
201
|
-
//logger.info(`提取到的链接为\n ${JSON.stringify(links)}`);
|
|
202
|
-
logger.info(
|
|
220
|
+
//logger.info(`提取到的链接为\n ${JSON.stringify(links)}`);
|
|
221
|
+
logger.info(`视频信息内容:\n ${JSON.stringify(mediaData)}`);
|
|
222
|
+
logger.info(`机器人发送完整消息为:\n ${ret}`);
|
|
203
223
|
}
|
|
204
224
|
|
|
205
225
|
}
|
|
@@ -522,7 +542,7 @@ function apply(ctx, config) {
|
|
|
522
542
|
!pcvideoStream.data.accept_quality ||
|
|
523
543
|
!h5videoStream.data.accept_format ||
|
|
524
544
|
!pcvideoStream.data.accept_format)
|
|
525
|
-
throw new Error('无法获取清晰度信息,
|
|
545
|
+
throw new Error('无法获取清晰度信息, 可能该视频为大会员专享或者该视频为付费视频/充电专属视频!或者账号被风控。');
|
|
526
546
|
const h5Quality = h5videoStream.data.accept_quality;
|
|
527
547
|
const pcQuality = pcvideoStream.data.accept_quality;
|
|
528
548
|
if (config.loggerinfo) {
|
|
@@ -552,7 +572,18 @@ function apply(ctx, config) {
|
|
|
552
572
|
}
|
|
553
573
|
}
|
|
554
574
|
else {
|
|
555
|
-
|
|
575
|
+
// 根据配置决定排序顺序
|
|
576
|
+
switch (config.Video_ClarityPriority) {
|
|
577
|
+
case '1':
|
|
578
|
+
//logger.info(`低清晰度优先排序,a[1]: ${a[1]}, b[1]: ${b[1]}`);
|
|
579
|
+
return a[1] - b[1]; // 从低到高排序(低清晰度优先)
|
|
580
|
+
case '2':
|
|
581
|
+
//logger.info(`高清晰度优先排序,a[1]: ${a[1]}, b[1]: ${b[1]}`);
|
|
582
|
+
return b[1] - a[1]; // 从高到低排序(高清晰度优先)
|
|
583
|
+
default:
|
|
584
|
+
//logger.warn(`未知的视频清晰度优先级配置: ${config.Video_ClarityPriority}`);
|
|
585
|
+
return 0; // 默认保持原顺序
|
|
586
|
+
}
|
|
556
587
|
}
|
|
557
588
|
});
|
|
558
589
|
outerLoop: for (const [index, item] of CombinedQualityInfo.entries()) {
|
|
@@ -630,8 +661,6 @@ function apply(ctx, config) {
|
|
|
630
661
|
return returnErrorMediaData(['无法获取videoStream信息']);
|
|
631
662
|
bitRate.push(videoStream.data.quality);
|
|
632
663
|
url.push(videoStream.data.durl[0].url);
|
|
633
|
-
|
|
634
|
-
|
|
635
664
|
/*
|
|
636
665
|
for (const cid of cids) {
|
|
637
666
|
videoStream = await GetVideoStream(h5videoStream, pcvideoStream, cid);
|
|
@@ -699,12 +728,14 @@ function apply(ctx, config) {
|
|
|
699
728
|
comment: commentList?.[i] || undefined,
|
|
700
729
|
error: null,
|
|
701
730
|
};
|
|
702
|
-
|
|
703
|
-
if (config.loggerinfo) {
|
|
704
|
-
logger.info(mediaData)
|
|
705
|
-
}
|
|
731
|
+
|
|
706
732
|
mediaDataArray.push(mediaData);
|
|
707
733
|
}
|
|
734
|
+
/*
|
|
735
|
+
if (config.loggerinfo) {
|
|
736
|
+
logger.info(mediaDataArray)
|
|
737
|
+
}
|
|
738
|
+
*/
|
|
708
739
|
return mediaDataArray;
|
|
709
740
|
}
|
|
710
741
|
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "koishi-plugin-bilibili-videolink-analysis",
|
|
3
3
|
"description": "[<ruby>Bilibili视频解析<rp>(</rp><rt>点我查看食用方法</rt><rp>)</rp></ruby>](https://www.npmjs.com/package/koishi-plugin-bilibili-videolink-analysis)有了这个就可以方便地给群友分享B站的视频了哦(就不需要进QQ小程序了)!灵感来自强大的 [iirose-media-request](/market?keyword=iirose-media-request) 以及完美的 [bili-parser](/market?keyword=bili-parser) ,十分感谢这两个优秀的项目!",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.5.1",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"typings": "lib/index.d.ts",
|
|
8
8
|
"files": [
|
package/readme.md
CHANGED
|
@@ -24,36 +24,50 @@ email:1919892171@qq.com
|
|
|
24
24
|
|
|
25
25
|
---
|
|
26
26
|
|
|
27
|
+
**特别提醒**
|
|
28
|
+
|
|
29
|
+
请注意,对于B站的大会员专属视频和付费视频/充电专属视频,本插件暂不支持使用登录账号的cookie来获取视频内容。
|
|
30
|
+
|
|
31
|
+
这意味着,本插件目前无法解析或提供此类视频的观看服务。
|
|
32
|
+
|
|
33
|
+
如果您尝试解析这类视频,会收到错误提示或无法获取视频信息。
|
|
34
|
+
|
|
35
|
+
我们建议您直接在B站官网来观看这些视频。
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
27
39
|
## 📌 链接信息解析设置
|
|
28
40
|
|
|
29
41
|
### 基础设置
|
|
30
|
-
| 设置项
|
|
31
|
-
|
|
32
|
-
|
|
|
33
|
-
|
|
|
34
|
-
|
|
|
35
|
-
|
|
|
36
|
-
|
|
|
37
|
-
|
|
42
|
+
| 设置项 | 描述 | 默认值 |
|
|
43
|
+
| --- | --- | --- |
|
|
44
|
+
| `waitTip_Switch` | 是否返回等待提示语句。开启后,会发送自定义的等待提示语。 | 不返回文字提示 |
|
|
45
|
+
| `linktextParsing` | 是否返回视频图文数据。开启后,发送视频数据的图文解析。 | `true` |
|
|
46
|
+
| `VideoParsing_ToLink` | 是否返回视频/视频直链。可以选择不同的返回策略。 | 仅返回视频 |
|
|
47
|
+
| `Video_ClarityPriority` | 发送视频时清晰度的优先策略。 | 低清晰度优先 |
|
|
48
|
+
| `BVnumberParsing` | 是否允许根据独立的BV号解析视频。开启后,可以通过视频的BV号解析视频。 | `true` |
|
|
49
|
+
| `Maximumduration` | 允许解析的视频最大时长(分钟)。超过此时长则不会发送视频。 | `25` |
|
|
50
|
+
| `Maximumduration_tip` | 对过长视频的文字提示内容。 | 视频太长啦!还是去B站看吧~ |
|
|
51
|
+
| `MinimumTimeInterval` | 若干秒内不再处理相同链接,防止多bot互相触发导致的刷屏/性能浪费。 | `180`秒 |
|
|
38
52
|
### 链接的图文解析设置
|
|
39
|
-
| 设置项
|
|
40
|
-
|
|
41
|
-
|
|
|
42
|
-
|
|
|
43
|
-
|
|
|
44
|
-
|
|
|
45
|
-
|
|
|
46
|
-
|
|
|
47
|
-
|
|
|
48
|
-
|
|
|
49
|
-
|
|
|
50
|
-
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
| 设置项 | 描述 | 默认值 |
|
|
54
|
+
| --- | --- | --- |
|
|
55
|
+
| `parseLimit` | 单对话多链接解析上限。 | `3` |
|
|
56
|
+
| `useNumeral` | 是否使用格式化数字。 | `true` |
|
|
57
|
+
| `showError` | 当链接不正确时提醒发送者。 | `false` |
|
|
58
|
+
| `bVideoIDPreference` | ID偏好,选择视频ID类型,BV号或AV号。 | `"bv"` |
|
|
59
|
+
| `bVideoImage` | 是否显示视频封面。 | `true` |
|
|
60
|
+
| `bVideoOwner` | 是否显示视频UP主信息。 | `true` |
|
|
61
|
+
| `bVideoDesc` | 是否显示视频简介。 | `false` |
|
|
62
|
+
| `bVideoStat` | 是否显示视频状态(如三连数据)。 | `true` |
|
|
63
|
+
| `bVideoExtraStat` | 是否显示额外状态(如弹幕和观看人数)。 | `true` |
|
|
64
|
+
| `bVideoShowLink` | 是否显示视频链接。开启可能会导致其他bot循环解析。 | `false` |
|
|
65
|
+
### 调试设置
|
|
66
|
+
| 设置项 | 描述 | 默认值 |
|
|
67
|
+
| --- | --- | --- |
|
|
68
|
+
| `userAgent` | 所有API请求所用的User-Agent。 | 默认的User-Agent字符串 |
|
|
69
|
+
| `loggerinfo` | 是否开启日志调试输出。日常使用无需开启。 | `false` |
|
|
70
|
+
---
|
|
57
71
|
|
|
58
72
|
|
|
59
73
|
## 交互示例
|
|
@@ -69,13 +83,13 @@ email:1919892171@qq.com
|
|
|
69
83
|
```
|
|
70
84
|
|
|
71
85
|
```
|
|
72
|
-
|
|
86
|
+
机器人:(如果有开启相关配置项)
|
|
73
87
|
|
|
74
88
|
等待提示的文字
|
|
75
89
|
```
|
|
76
90
|
|
|
77
91
|
```
|
|
78
|
-
机器人:
|
|
92
|
+
机器人: (如果有开启相关配置项)
|
|
79
93
|
|
|
80
94
|
UP主: 我王小桃要上一档
|
|
81
95
|
金钱焊机纯享版:BV1T142197Ai
|
|
@@ -89,7 +103,7 @@ https://www.bilibili.com/video/BV1ii421Q7oj
|
|
|
89
103
|
|
|
90
104
|
|
|
91
105
|
```
|
|
92
|
-
|
|
106
|
+
机器人:(如果有开启相关配置项)
|
|
93
107
|
|
|
94
108
|
视频内容
|
|
95
109
|
```
|
|
@@ -164,28 +178,37 @@ https://www.bilibili.com/video/BV1ii421Q7oj
|
|
|
164
178
|
<details>
|
|
165
179
|
<summary>点击此处 可查看更新日志</summary>
|
|
166
180
|
|
|
181
|
+
- **0.5.1**
|
|
182
|
+
- 调整配置项`Maximumduration`的默认值为`25`分钟
|
|
183
|
+
- 优化对于`B站的大会员专属视频和付费视频/充电专属视频`的说明
|
|
184
|
+
- 优化对`无法获取清晰度信息`情况的报错的问题描述
|
|
185
|
+
|
|
186
|
+
- **0.5.0**
|
|
187
|
+
- 新增配置项`Maximumduration`和`Maximumduration_tip`,允许用户配置可以解析的最长的视频时长
|
|
188
|
+
- 新增配置项`Video_ClarityPriority`,允许用户配置视频清晰度发送策略
|
|
189
|
+
|
|
167
190
|
- **0.4.12** 更改配置项`VideoParsing_ToLink`默认值为`2`(才发现以前一直都是3)
|
|
168
191
|
|
|
169
192
|
- **0.4.11**
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
193
|
+
- 优化对于合集BV视频(合集内均为同一个BV号的视频)的解析
|
|
194
|
+
- 修改`MinimumTimeInterval`默认值为`180`,即3分钟
|
|
195
|
+
- 优化调试模式的日志输出
|
|
173
196
|
|
|
174
197
|
- **0.4.9** 优化控制台超链接
|
|
175
|
-
|
|
176
|
-
|
|
198
|
+
- 让插件超链接仅在本窗口打开,详细说明的超链接在新窗口打开
|
|
199
|
+
- `hidden()`掉部分原先插件的配置项
|
|
177
200
|
|
|
178
201
|
- **0.4.8**
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
202
|
+
- 优化插件说明
|
|
203
|
+
- 优化调试模式的日志输出
|
|
204
|
+
- 新增`VideoParsing_ToLink`的选项5,允许实现`返回视频,仅在日志记录视频直链`
|
|
205
|
+
- 修复`waitTip_Switch`提示文字失效
|
|
183
206
|
|
|
184
207
|
- **0.4.7**
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
208
|
+
- 移除`axios`,改用基于fetch的ctx.http
|
|
209
|
+
- 优化配置项`VideoParsing_ToLink`,由`必须`状态改为有默认值的状态,可以开箱即用
|
|
210
|
+
- 优化部分说明文字内容
|
|
211
|
+
- 移除依赖`BiliBiliMovie`
|
|
189
212
|
|
|
190
213
|
- **0.4.6**
|
|
191
214
|
- 继续优化对于BV号的提取
|