koishi-plugin-bilibili-videolink-analysis 0.4.12 → 0.5.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/lib/index.js +48 -18
- package/package.json +1 -1
- package/readme.md +15 -11
package/lib/index.js
CHANGED
|
@@ -54,20 +54,25 @@ exports.Config = koishi_1.Schema.intersect([
|
|
|
54
54
|
koishi_1.Schema.const('4').description('返回视频和视频直链'),
|
|
55
55
|
koishi_1.Schema.const('5').description('返回视频,仅在日志记录视频直链'),
|
|
56
56
|
]).role('radio').default('2').description("是否返回` 视频/视频直链 `"),
|
|
57
|
+
Video_ClarityPriority: koishi_1.Schema.union([
|
|
58
|
+
koishi_1.Schema.const('1').description('低清晰度优先(低清晰度的视频发得快一点)'),
|
|
59
|
+
koishi_1.Schema.const('2').description('高清晰度优先(清晰的还是去B站看吧)'),
|
|
60
|
+
]).role('radio').default('1').description("发送的视频清晰度优先策略"),
|
|
57
61
|
|
|
58
62
|
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
|
-
|
|
63
|
+
Maximumduration: koishi_1.Schema.number().default(45).description("允许解析的视频最大时长(分钟)`超过这个时长 就不会发视频`").min(1),
|
|
64
|
+
Maximumduration_tip: koishi_1.Schema.union([
|
|
65
|
+
koishi_1.Schema.const('不返回文字提示').description('不返回文字提示'),
|
|
66
|
+
koishi_1.Schema.string().description('返回文字提示(请在右侧填写文字内容)').default('视频太长啦!还是去B站看吧~'),
|
|
67
|
+
]).description("对过长视频的文字提示内容").default('视频太长啦!还是去B站看吧~'),
|
|
68
|
+
MinimumTimeInterval: koishi_1.Schema.number().default(180).description("若干`秒`内 不再处理相同链接 `防止多bot互相触发 导致的刷屏/性能浪费`").min(1),
|
|
64
69
|
}).description("基础设置"),
|
|
65
70
|
|
|
66
71
|
koishi_1.Schema.object({
|
|
67
72
|
parseLimit: koishi_1.Schema.number().default(3).description("单对话多链接解析上限").hidden(),
|
|
68
73
|
useNumeral: koishi_1.Schema.boolean().default(true).description("使用格式化数字").hidden(),
|
|
69
74
|
showError: koishi_1.Schema.boolean().default(false).description("当链接不正确时提醒发送者").hidden(),
|
|
70
|
-
|
|
75
|
+
|
|
71
76
|
bVideoIDPreference: koishi_1.Schema.union([
|
|
72
77
|
koishi_1.Schema.const("bv").description("BV 号"),
|
|
73
78
|
koishi_1.Schema.const("av").description("AV 号"),
|
|
@@ -78,11 +83,13 @@ exports.Config = koishi_1.Schema.intersect([
|
|
|
78
83
|
bVideoStat: koishi_1.Schema.boolean().default(true).description("显示状态(*三连数据*)"),
|
|
79
84
|
bVideoExtraStat: koishi_1.Schema.boolean().default(true).description("显示额外状态(*弹幕&观看*)"),
|
|
80
85
|
bVideoShowLink: koishi_1.Schema.boolean().default(false).description("显示视频链接`开启可能会导致其他bot循环解析`"),
|
|
86
|
+
|
|
81
87
|
}).description("链接的图文解析设置"),
|
|
82
88
|
|
|
83
89
|
koishi_1.Schema.object({
|
|
90
|
+
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
91
|
loggerinfo: koishi_1.Schema.boolean().default(false).description("日志调试输出 `日常使用无需开启`"),
|
|
85
|
-
}).description("
|
|
92
|
+
}).description("调试设置"),
|
|
86
93
|
]);
|
|
87
94
|
|
|
88
95
|
function apply(ctx, config) {
|
|
@@ -157,10 +164,20 @@ function apply(ctx, config) {
|
|
|
157
164
|
}
|
|
158
165
|
}
|
|
159
166
|
let bilibilimediaDataURL = '';
|
|
167
|
+
let mediaData = '';
|
|
160
168
|
if (config.VideoParsing_ToLink) {
|
|
161
169
|
const mediaDataString = JSON.stringify(await handleBilibiliMedia(bilibiliVideo, lastretUrl, config));
|
|
162
|
-
|
|
170
|
+
mediaData = JSON.parse(mediaDataString);
|
|
163
171
|
bilibilimediaDataURL = mediaData[0].url
|
|
172
|
+
const videoDuration = mediaData[0].duration; // 提取视频时长,单位为秒
|
|
173
|
+
|
|
174
|
+
if (videoDuration > config.Maximumduration * 60) {
|
|
175
|
+
// 如果视频时长超过配置的最大值
|
|
176
|
+
if (config.Maximumduration_tip) {
|
|
177
|
+
await session.send(config.Maximumduration_tip);
|
|
178
|
+
}
|
|
179
|
+
return next();
|
|
180
|
+
}
|
|
164
181
|
// 根据配置的值来决定发送的内容
|
|
165
182
|
/*
|
|
166
183
|
* VideoParsing_ToLink: koishi_1.Schema.union([
|
|
@@ -191,15 +208,17 @@ function apply(ctx, config) {
|
|
|
191
208
|
await session.send(koishi_1.h.video(bilibilimediaDataURL)); // 发送视频
|
|
192
209
|
break;
|
|
193
210
|
default:
|
|
194
|
-
// 处理默认情况或者错误配置
|
|
211
|
+
// 处理默认情况或者错误配置
|
|
212
|
+
// 目前默认 不返回视频/视频直链
|
|
195
213
|
break;
|
|
196
214
|
}
|
|
197
215
|
}
|
|
198
216
|
|
|
199
217
|
if (config.loggerinfo) {
|
|
200
218
|
//logger.info(`userAgent为\n ${config.userAgent}`);
|
|
201
|
-
//logger.info(`提取到的链接为\n ${JSON.stringify(links)}`);
|
|
202
|
-
logger.info(
|
|
219
|
+
//logger.info(`提取到的链接为\n ${JSON.stringify(links)}`);
|
|
220
|
+
logger.info(`视频信息内容:\n ${JSON.stringify(mediaData)}`);
|
|
221
|
+
logger.info(`机器人发送完整消息为:\n ${ret}`);
|
|
203
222
|
}
|
|
204
223
|
|
|
205
224
|
}
|
|
@@ -552,7 +571,18 @@ function apply(ctx, config) {
|
|
|
552
571
|
}
|
|
553
572
|
}
|
|
554
573
|
else {
|
|
555
|
-
|
|
574
|
+
// 根据配置决定排序顺序
|
|
575
|
+
switch (config.Video_ClarityPriority) {
|
|
576
|
+
case '1':
|
|
577
|
+
//logger.info(`低清晰度优先排序,a[1]: ${a[1]}, b[1]: ${b[1]}`);
|
|
578
|
+
return a[1] - b[1]; // 从低到高排序(低清晰度优先)
|
|
579
|
+
case '2':
|
|
580
|
+
//logger.info(`高清晰度优先排序,a[1]: ${a[1]}, b[1]: ${b[1]}`);
|
|
581
|
+
return b[1] - a[1]; // 从高到低排序(高清晰度优先)
|
|
582
|
+
default:
|
|
583
|
+
//logger.warn(`未知的视频清晰度优先级配置: ${config.Video_ClarityPriority}`);
|
|
584
|
+
return 0; // 默认保持原顺序
|
|
585
|
+
}
|
|
556
586
|
}
|
|
557
587
|
});
|
|
558
588
|
outerLoop: for (const [index, item] of CombinedQualityInfo.entries()) {
|
|
@@ -630,8 +660,6 @@ function apply(ctx, config) {
|
|
|
630
660
|
return returnErrorMediaData(['无法获取videoStream信息']);
|
|
631
661
|
bitRate.push(videoStream.data.quality);
|
|
632
662
|
url.push(videoStream.data.durl[0].url);
|
|
633
|
-
|
|
634
|
-
|
|
635
663
|
/*
|
|
636
664
|
for (const cid of cids) {
|
|
637
665
|
videoStream = await GetVideoStream(h5videoStream, pcvideoStream, cid);
|
|
@@ -699,12 +727,14 @@ function apply(ctx, config) {
|
|
|
699
727
|
comment: commentList?.[i] || undefined,
|
|
700
728
|
error: null,
|
|
701
729
|
};
|
|
702
|
-
|
|
703
|
-
if (config.loggerinfo) {
|
|
704
|
-
logger.info(mediaData)
|
|
705
|
-
}
|
|
730
|
+
|
|
706
731
|
mediaDataArray.push(mediaData);
|
|
707
732
|
}
|
|
733
|
+
/*
|
|
734
|
+
if (config.loggerinfo) {
|
|
735
|
+
logger.info(mediaDataArray)
|
|
736
|
+
}
|
|
737
|
+
*/
|
|
708
738
|
return mediaDataArray;
|
|
709
739
|
}
|
|
710
740
|
|
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.0",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"typings": "lib/index.d.ts",
|
|
8
8
|
"files": [
|
package/readme.md
CHANGED
|
@@ -164,28 +164,32 @@ https://www.bilibili.com/video/BV1ii421Q7oj
|
|
|
164
164
|
<details>
|
|
165
165
|
<summary>点击此处 可查看更新日志</summary>
|
|
166
166
|
|
|
167
|
+
- **0.5.0**
|
|
168
|
+
- 新增配置项`Maximumduration`和`Maximumduration_tip`,允许用户配置可以解析的最长的视频时长
|
|
169
|
+
- 新增配置项`Video_ClarityPriority`,允许用户配置视频清晰度发送策略
|
|
170
|
+
|
|
167
171
|
- **0.4.12** 更改配置项`VideoParsing_ToLink`默认值为`2`(才发现以前一直都是3)
|
|
168
172
|
|
|
169
173
|
- **0.4.11**
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
174
|
+
- 优化对于合集BV视频(合集内均为同一个BV号的视频)的解析
|
|
175
|
+
- 修改`MinimumTimeInterval`默认值为`180`,即3分钟
|
|
176
|
+
- 优化调试模式的日志输出
|
|
173
177
|
|
|
174
178
|
- **0.4.9** 优化控制台超链接
|
|
175
179
|
- 让插件超链接仅在本窗口打开,详细说明的超链接在新窗口打开
|
|
176
180
|
- `hidden()`掉部分原先插件的配置项
|
|
177
181
|
|
|
178
182
|
- **0.4.8**
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
+
- 优化插件说明
|
|
184
|
+
- 优化调试模式的日志输出
|
|
185
|
+
- 新增`VideoParsing_ToLink`的选项5,允许实现`返回视频,仅在日志记录视频直链`
|
|
186
|
+
- 修复`waitTip_Switch`提示文字失效
|
|
183
187
|
|
|
184
188
|
- **0.4.7**
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
+
- 移除`axios`,改用基于fetch的ctx.http
|
|
190
|
+
- 优化配置项`VideoParsing_ToLink`,由`必须`状态改为有默认值的状态,可以开箱即用
|
|
191
|
+
- 优化部分说明文字内容
|
|
192
|
+
- 移除依赖`BiliBiliMovie`
|
|
189
193
|
|
|
190
194
|
- **0.4.6**
|
|
191
195
|
- 继续优化对于BV号的提取
|