koishi-plugin-bilibili-videolink-analysis 1.1.0 → 1.1.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 +70 -33
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -458,8 +458,7 @@ display: none !important;
|
|
|
458
458
|
}
|
|
459
459
|
}
|
|
460
460
|
})
|
|
461
|
-
|
|
462
|
-
async function handleBilibiliMedia(config, session, lastretUrl) {
|
|
461
|
+
/*async function handleBilibiliMedia(config, session, lastretUrl) {
|
|
463
462
|
const fullAPIurl = `https://api.xingzhige.com/API/b_parse/?url=${encodeURIComponent(lastretUrl)}`;
|
|
464
463
|
|
|
465
464
|
try {
|
|
@@ -485,6 +484,7 @@ display: none !important;
|
|
|
485
484
|
// 视频时长超过最大限制,返回提示
|
|
486
485
|
if (config.Maximumduration_tip !== '不返回文字提示') {
|
|
487
486
|
await session.send(config.Maximumduration_tip)
|
|
487
|
+
return next()
|
|
488
488
|
} else {
|
|
489
489
|
return null; // 不返回提示信息
|
|
490
490
|
}
|
|
@@ -509,7 +509,7 @@ display: none !important;
|
|
|
509
509
|
logger.error("请求解析 API 失败或处理出错:", error);
|
|
510
510
|
return null;
|
|
511
511
|
}
|
|
512
|
-
}
|
|
512
|
+
}*/
|
|
513
513
|
|
|
514
514
|
|
|
515
515
|
//判断是否需要解析
|
|
@@ -589,42 +589,79 @@ display: none !important;
|
|
|
589
589
|
await session.send(retWithoutLastLink);
|
|
590
590
|
}
|
|
591
591
|
}
|
|
592
|
-
|
|
593
592
|
if (config.VideoParsing_ToLink) {
|
|
594
|
-
const
|
|
593
|
+
const fullAPIurl = `https://api.xingzhige.com/API/b_parse/?url=${encodeURIComponent(lastretUrl)}`;
|
|
595
594
|
|
|
596
|
-
|
|
597
|
-
await
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
595
|
+
try {
|
|
596
|
+
const responseData = await ctx.http.get(fullAPIurl);
|
|
597
|
+
|
|
598
|
+
if (responseData.code === 0 && responseData.msg === "video" && responseData.data) {
|
|
599
|
+
const { bvid, cid, video } = responseData.data;
|
|
600
|
+
const bilibiliUrl = `https://api.bilibili.com/x/player/playurl?fnval=80&cid=${cid}&bvid=${bvid}`;
|
|
601
|
+
const playData = await ctx.http.get(bilibiliUrl);
|
|
602
|
+
|
|
603
|
+
// ctx.logger.info(bilibiliUrl);
|
|
604
|
+
|
|
605
|
+
if (playData.code === 0 && playData.data && playData.data.dash.duration) {
|
|
606
|
+
const videoDurationSeconds = playData.data.dash.duration;
|
|
607
|
+
const videoDurationMinutes = videoDurationSeconds / 60;
|
|
608
|
+
|
|
609
|
+
if (videoDurationMinutes > config.Maximumduration) {
|
|
610
|
+
if (config.Maximumduration_tip !== '不返回文字提示') {
|
|
611
|
+
await session.send(config.Maximumduration_tip);
|
|
612
|
+
return;
|
|
613
|
+
} else {
|
|
614
|
+
return;
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
const videoUrl = video.url;
|
|
619
|
+
//ctx.logger.info(videoUrl);
|
|
620
|
+
|
|
621
|
+
if (videoUrl) {
|
|
622
|
+
if (options.link) {
|
|
623
|
+
await session.send(h.text(videoUrl));
|
|
624
|
+
return;
|
|
625
|
+
} else if (options.audio) {
|
|
626
|
+
await session.send(h.audio(videoUrl));
|
|
627
|
+
return;
|
|
628
|
+
} else {
|
|
629
|
+
switch (config.VideoParsing_ToLink) {
|
|
630
|
+
case '1':
|
|
631
|
+
break;
|
|
632
|
+
case '2':
|
|
633
|
+
await session.send(h.video(videoUrl));
|
|
634
|
+
break;
|
|
635
|
+
case '3':
|
|
636
|
+
await session.send(h.text(videoUrl));
|
|
637
|
+
break;
|
|
638
|
+
case '4':
|
|
639
|
+
await session.send(h.text(videoUrl));
|
|
640
|
+
await session.send(h.video(videoUrl));
|
|
641
|
+
break;
|
|
642
|
+
case '5':
|
|
643
|
+
logger.info(videoUrl);
|
|
644
|
+
await session.send(h.video(videoUrl));
|
|
645
|
+
break;
|
|
646
|
+
default:
|
|
647
|
+
break;
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
} else {
|
|
651
|
+
throw new Error("解析视频直链失败");
|
|
652
|
+
}
|
|
653
|
+
} else {
|
|
654
|
+
throw new Error("获取播放数据失败");
|
|
655
|
+
}
|
|
656
|
+
} else {
|
|
657
|
+
throw new Error("解析视频信息失败或非视频类型内容");
|
|
624
658
|
}
|
|
659
|
+
} catch (error) {
|
|
660
|
+
logger.error("请求解析 API 失败或处理出错:", error);
|
|
625
661
|
}
|
|
626
662
|
}
|
|
627
663
|
|
|
664
|
+
|
|
628
665
|
if (config.loggerinfo) {
|
|
629
666
|
//logger.info(`视频信息内容:\n ${JSON.stringify(mediaData)}`);
|
|
630
667
|
logger.info(`机器人发送完整消息为:\n ${ret}`);
|
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站链接(支持小程序卡片)支持搜索点播功能!灵感来自完美的 [bili-parser](/market?keyword=bili-parser) !",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "1.1.
|
|
5
|
+
"version": "1.1.1",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"typings": "lib/index.d.ts",
|
|
8
8
|
"files": [
|