koishi-plugin-bilibili-videolink-analysis 1.1.6 → 1.1.7
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 +39 -29
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -94,12 +94,14 @@ exports.Config = Schema.intersect([
|
|
|
94
94
|
Schema.const("bv").description("BV 号"),
|
|
95
95
|
Schema.const("av").description("AV 号"),
|
|
96
96
|
]).default("bv").description("ID 偏好").hidden(),
|
|
97
|
-
bVideoImage: Schema.boolean().default(true).description("显示封面"),
|
|
98
|
-
bVideoOwner: Schema.boolean().default(true).description("显示 UP 主"),
|
|
99
|
-
bVideoDesc: Schema.boolean().default(false).description("显示简介`有的简介真的很长`"),
|
|
100
|
-
bVideoStat: Schema.boolean().default(true).description("显示状态(*三连数据*)"),
|
|
101
|
-
bVideoExtraStat: Schema.boolean().default(true).description("显示额外状态(*弹幕&观看*)"),
|
|
102
|
-
|
|
97
|
+
//bVideoImage: Schema.boolean().default(true).description("显示封面"),
|
|
98
|
+
//bVideoOwner: Schema.boolean().default(true).description("显示 UP 主"),
|
|
99
|
+
//bVideoDesc: Schema.boolean().default(false).description("显示简介`有的简介真的很长`"),
|
|
100
|
+
//bVideoStat: Schema.boolean().default(true).description("显示状态(*三连数据*)"),
|
|
101
|
+
//bVideoExtraStat: Schema.boolean().default(true).description("显示额外状态(*弹幕&观看*)"),
|
|
102
|
+
bVideo_area: Schema.string().role('textarea', { rows: [8, 16] }).description("图文解析的返回格式<br>注意变量格式,以及变量名称<br>比如 `${标题}` 不可以变成`${标题123}`,你可以直接删掉但是不能修改变量名称哦<br>当然变量也不能无中生有,下面的默认值内容 就是所有变量了,你仅可以删去变量 或者修改变量之外的格式。")
|
|
103
|
+
.default("${标题} --- ${UP主}\n---\n${封面}\n---\n${简介}\n---\n${点赞} --- ${投币}\n${收藏} --- ${转发}\n${观看} --- ${弹幕}"),
|
|
104
|
+
bVideoShowLink: Schema.boolean().default(false).description("在末尾显示视频的链接地址 `开启可能会导致其他bot循环解析`"),
|
|
103
105
|
}).description("链接的图文解析设置"),
|
|
104
106
|
|
|
105
107
|
Schema.object({
|
|
@@ -727,43 +729,51 @@ display: none !important;
|
|
|
727
729
|
return ret;
|
|
728
730
|
}
|
|
729
731
|
/**
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
732
|
+
* 生成视频信息
|
|
733
|
+
* @param id 视频 ID
|
|
734
|
+
* @returns 文字视频信息
|
|
735
|
+
*/
|
|
734
736
|
async gen_context(id) {
|
|
735
737
|
const info = await this.fetch_video_info(id);
|
|
736
738
|
if (!info || !info["data"])
|
|
737
739
|
return null;
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
:
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
:
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
:
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
740
|
+
|
|
741
|
+
// 定义占位符对应的数据
|
|
742
|
+
const placeholders = {
|
|
743
|
+
'${标题}': info["data"]["title"],
|
|
744
|
+
'${UP主}': info["data"]["owner"]["name"],
|
|
745
|
+
'${封面}': `<img src="${info["data"]["pic"]}"/>`,
|
|
746
|
+
'${简介}': info["data"]["desc"],
|
|
747
|
+
'${点赞}': `点赞:${(0, numeral)(info["data"]["stat"]["like"], this.config)}`,
|
|
748
|
+
'${投币}': `投币:${(0, numeral)(info["data"]["stat"]["coin"], this.config)}`,
|
|
749
|
+
'${收藏}': `收藏:${(0, numeral)(info["data"]["stat"]["favorite"], this.config)}`,
|
|
750
|
+
'${转发}': `转发:${(0, numeral)(info["data"]["stat"]["share"], this.config)}`,
|
|
751
|
+
'${观看}': `观看:${(0, numeral)(info["data"]["stat"]["view"], this.config)}`,
|
|
752
|
+
'${弹幕}': `弹幕:${(0, numeral)(info["data"]["stat"]["danmaku"], this.config)}`,
|
|
753
|
+
};
|
|
754
|
+
|
|
755
|
+
// 根据配置项中的格式替换占位符
|
|
756
|
+
let ret = this.config.bVideo_area;
|
|
757
|
+
for (const [placeholder, value] of Object.entries(placeholders)) {
|
|
758
|
+
ret = ret.replace(new RegExp(placeholder.replace(/\$/g, '\\$'), 'g'), value);
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
// 根据 ID 偏好添加视频链接
|
|
755
762
|
switch (this.config.bVideoIDPreference) {
|
|
756
763
|
case "bv":
|
|
757
|
-
ret +=
|
|
764
|
+
ret += `\nhttps://www.bilibili.com/video/${info["data"]["bvid"]}`;
|
|
758
765
|
break;
|
|
759
766
|
case "av":
|
|
760
|
-
ret +=
|
|
767
|
+
ret += `\nhttps://www.bilibili.com/video/av${info["data"]["aid"]}`;
|
|
761
768
|
break;
|
|
762
769
|
default:
|
|
763
770
|
break;
|
|
764
771
|
}
|
|
772
|
+
|
|
765
773
|
return ret;
|
|
766
774
|
}
|
|
775
|
+
|
|
776
|
+
|
|
767
777
|
}
|
|
768
778
|
|
|
769
779
|
/**
|
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.7",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"typings": "lib/index.d.ts",
|
|
8
8
|
"files": [
|