koishi-plugin-bilibili-videolink-analysis 1.1.7 → 1.1.9

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.
Files changed (2) hide show
  1. package/lib/index.js +15 -18
  2. package/package.json +2 -2
package/lib/index.js CHANGED
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.apply = exports.usage = exports.Config = exports.name = exports.inject = void 0;
4
- const koishi_1 = require("koishi");
5
4
  const { Schema, Logger, h } = require("koishi");
6
5
  const logger = new Logger('bilibili-videolink-analysis');
7
6
  exports.name = 'bilibili-videolink-analysis';
@@ -73,10 +72,6 @@ exports.Config = Schema.intersect([
73
72
  Schema.const('4').description('返回视频和视频直链'),
74
73
  Schema.const('5').description('返回视频,仅在日志记录视频直链'),
75
74
  ]).role('radio').default('2').description("是否返回` 视频/视频直链 `"),
76
- //Video_ClarityPriority: Schema.union([
77
- // Schema.const('1').description('低清晰度优先(低清晰度的视频发得快一点)'),
78
- // Schema.const('2').description('高清晰度优先(清晰的还是去B站看吧)'),
79
- //]).role('radio').default('1').description("发送的视频清晰度优先策略"),
80
75
  BVnumberParsing: Schema.boolean().default(true).description("是否允许根据`独立的BV号`解析视频 `开启后,可以通过视频的BV号解析视频。` <br> [触发说明见README](https://www.npmjs.com/package/koishi-plugin-bilibili-videolink-analysis)"),
81
76
  Maximumduration: Schema.number().default(25).description("允许解析的视频最大时长(分钟)`超过这个时长 就不会发视频`").min(1),
82
77
  Maximumduration_tip: Schema.union([
@@ -94,14 +89,10 @@ exports.Config = Schema.intersect([
94
89
  Schema.const("bv").description("BV 号"),
95
90
  Schema.const("av").description("AV 号"),
96
91
  ]).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
92
  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${观看} --- ${弹幕}"),
93
+ .default("${标题} --- ${UP主}\n---\n${封面}\n---\n${简介}\n---\n${点赞} --- ${投币}\n${收藏} --- ${转发}\n${观看} --- ${弹幕}"),
104
94
  bVideoShowLink: Schema.boolean().default(false).description("在末尾显示视频的链接地址 `开启可能会导致其他bot循环解析`"),
95
+ bVideoShowIntroductionTofixed: Schema.number().default(50).description("视频的`简介`最大的字符长度<br>超出部分会使用 `...` 代替"),
105
96
  }).description("链接的图文解析设置"),
106
97
 
107
98
  Schema.object({
@@ -114,7 +105,6 @@ exports.Config = Schema.intersect([
114
105
  function apply(ctx, config) {
115
106
 
116
107
  ctx.middleware(async (session, next) => {
117
-
118
108
  let sessioncontent = session.content;
119
109
  // 如果允许解析 BV 号,则进行解析
120
110
  if (config.BVnumberParsing) {
@@ -132,6 +122,7 @@ function apply(ctx, config) {
132
122
  }
133
123
  return next();
134
124
  }, config.middleware);
125
+
135
126
  if (config.demand) {
136
127
  ctx.command('B站点播/退出登录', '退出B站账号')
137
128
  .action(async ({ session }) => {
@@ -349,14 +340,15 @@ display: none !important;
349
340
  }
350
341
 
351
342
  if (config.enable) { // 开启自动解析了
352
- session.content = `https://www.bilibili.com/video/${chosenVideo.id}`
353
- const ret = await extractLinks(session, config, ctx, lastProcessedUrls, logger); // 提取链接
343
+
344
+ const ret = await extractLinks(session, config, ctx, [{ type: 'Video', id: chosenVideo.id }], logger); // 提取链接
354
345
  if (ret && !isLinkProcessedRecently(ret, lastProcessedUrls, config, logger)) {
355
346
  await processVideoFromLink(session, config, ctx, lastProcessedUrls, logger, ret, options); // 解析视频并返回
356
347
  }
357
348
  }
358
349
  })
359
350
  }
351
+
360
352
  if (config.loggerinfo) {
361
353
  ctx.command('B站点播/调试点播 [keyword]', '调试时点播B站视频')
362
354
  .option('video', '-v 解析返回视频')
@@ -456,8 +448,8 @@ display: none !important;
456
448
 
457
449
  if (config.enable) {
458
450
  // 开启自动解析了
459
- session.content = `https://www.bilibili.com/video/${chosenVideo.id}`;
460
- const ret = await extractLinks(session, config, ctx, lastProcessedUrls, logger);
451
+
452
+ const ret = await extractLinks(session, config, ctx, [{ type: 'Video', id: chosenVideo.id }], logger);
461
453
  if (ret && !isLinkProcessedRecently(ret, lastProcessedUrls, config, logger)) {
462
454
  await processVideoFromLink(session, config, ctx, lastProcessedUrls, logger, ret, options);
463
455
  }
@@ -471,7 +463,6 @@ display: none !important;
471
463
  if (links.length === 0) {
472
464
  return false; // 如果没有找到链接,返回 false
473
465
  }
474
-
475
466
  return links; // 返回解析出的链接
476
467
  }
477
468
 
@@ -738,12 +729,18 @@ display: none !important;
738
729
  if (!info || !info["data"])
739
730
  return null;
740
731
 
732
+ let description = info["data"]["desc"];
733
+ // 根据配置处理简介
734
+ const maxLength = config.bVideoShowIntroductionTofixed;
735
+ if (description.length > maxLength) {
736
+ description = description.substring(0, maxLength) + '...';
737
+ }
741
738
  // 定义占位符对应的数据
742
739
  const placeholders = {
743
740
  '${标题}': info["data"]["title"],
744
741
  '${UP主}': info["data"]["owner"]["name"],
745
742
  '${封面}': `<img src="${info["data"]["pic"]}"/>`,
746
- '${简介}': info["data"]["desc"],
743
+ '${简介}': description, // 使用处理后的简介
747
744
  '${点赞}': `点赞:${(0, numeral)(info["data"]["stat"]["like"], this.config)}`,
748
745
  '${投币}': `投币:${(0, numeral)(info["data"]["stat"]["coin"], this.config)}`,
749
746
  '${收藏}': `收藏:${(0, numeral)(info["data"]["stat"]["favorite"], this.config)}`,
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.7",
5
+ "version": "1.1.9",
6
6
  "main": "lib/index.js",
7
7
  "typings": "lib/index.d.ts",
8
8
  "files": [
@@ -24,4 +24,4 @@
24
24
  "peerDependencies": {
25
25
  "koishi": "^4.16.8"
26
26
  }
27
- }
27
+ }