koishi-plugin-video-parser-all 0.3.9 → 0.4.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.
Files changed (2) hide show
  1. package/lib/index.js +59 -59
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -12,77 +12,74 @@ const fs_1 = __importDefault(require("fs"));
12
12
  const path_1 = __importDefault(require("path"));
13
13
  const promises_1 = require("stream/promises");
14
14
  const worker_threads_1 = require("worker_threads");
15
- const __filename = typeof __dirname !== 'undefined'
16
- ? path_1.default.join(__dirname, 'index.js')
17
- : process.cwd() + '/index.js';
18
15
  exports.name = 'video-parser-all';
19
16
  exports.Config = koishi_1.Schema.intersect([
20
17
  koishi_1.Schema.object({
21
- enable: koishi_1.Schema.boolean().default(true),
22
- botName: koishi_1.Schema.string().default('视频解析机器人'),
23
- showWaitingTip: koishi_1.Schema.boolean().default(true),
24
- waitingTipText: koishi_1.Schema.string().default('正在解析视频,请稍候...'),
25
- sameLinkInterval: koishi_1.Schema.number().min(0).default(180),
26
- maxVideoSize: koishi_1.Schema.number().min(0).default(50),
27
- downloadThreads: koishi_1.Schema.number().min(0).default(4),
28
- }),
18
+ enable: koishi_1.Schema.boolean().default(true).description('是否启用视频解析插件'),
19
+ botName: koishi_1.Schema.string().default('视频解析机器人').description('机器人显示名称'),
20
+ showWaitingTip: koishi_1.Schema.boolean().default(true).description('解析时显示等待提示'),
21
+ waitingTipText: koishi_1.Schema.string().default('正在解析视频,请稍候...').description('等待提示文本内容'),
22
+ sameLinkInterval: koishi_1.Schema.number().min(0).default(180).description('相同链接重复解析间隔(秒)'),
23
+ maxVideoSize: koishi_1.Schema.number().min(0).default(50).description('允许发送的最大视频大小(MB)'),
24
+ downloadThreads: koishi_1.Schema.number().min(0).default(4).description('视频下载线程数'),
25
+ }).description('基础设置'),
29
26
  koishi_1.Schema.object({
30
27
  platformEnable: koishi_1.Schema.object({
31
- bilibili: koishi_1.Schema.boolean().default(true),
32
- douyin: koishi_1.Schema.boolean().default(true),
33
- kuaishou: koishi_1.Schema.boolean().default(true),
34
- xigua: koishi_1.Schema.boolean().default(true),
35
- xiaohongshu: koishi_1.Schema.boolean().default(true),
36
- weibo: koishi_1.Schema.boolean().default(true),
37
- toutiao: koishi_1.Schema.boolean().default(true),
38
- pipigx: koishi_1.Schema.boolean().default(true),
39
- pipixia: koishi_1.Schema.boolean().default(true),
40
- zuiyou: koishi_1.Schema.boolean().default(true),
41
- })
42
- }),
28
+ bilibili: koishi_1.Schema.boolean().default(true).description('B站'),
29
+ douyin: koishi_1.Schema.boolean().default(true).description('抖音'),
30
+ kuaishou: koishi_1.Schema.boolean().default(true).description('快手'),
31
+ xigua: koishi_1.Schema.boolean().default(true).description('西瓜视频'),
32
+ xiaohongshu: koishi_1.Schema.boolean().default(true).description('小红书'),
33
+ weibo: koishi_1.Schema.boolean().default(true).description('微博'),
34
+ toutiao: koishi_1.Schema.boolean().default(true).description('今日头条'),
35
+ pipigx: koishi_1.Schema.boolean().default(true).description('皮皮搞笑'),
36
+ pipixia: koishi_1.Schema.boolean().default(true).description('皮皮虾'),
37
+ zuiyou: koishi_1.Schema.boolean().default(true).description('最右'),
38
+ }).description('启用平台(勾选即开启对应平台解析)')
39
+ }).description('平台开关'),
43
40
  koishi_1.Schema.object({
44
41
  platformFormat: koishi_1.Schema.object({
45
- bilibili: koishi_1.Schema.string().role('textarea').default('标题:${标题}\nUP主:${作者}\n简介:${简介}\n时长:${视频时长}\n点赞:${点赞数}\n投币:${投币数}\n收藏:${收藏数}\n转发:${转发数}'),
46
- douyin: koishi_1.Schema.string().role('textarea').default('标题:${标题}\n作者:${作者}\n点赞:${点赞数}\n收藏:${收藏数}\n转发:${转发数}'),
47
- kuaishou: koishi_1.Schema.string().role('textarea').default('标题:${标题}\n作者:${作者}\n点赞:${点赞数}\n播放:${播放数}\n转发:${转发数}'),
48
- xigua: koishi_1.Schema.string().role('textarea').default('标题:${标题}\n播放:${播放数}\n点赞:${点赞数}\n视频大小:${视频大小}MB'),
49
- xiaohongshu: koishi_1.Schema.string().role('textarea').default('标题:${标题}\n作者:${作者}\n简介:${简介}'),
50
- weibo: koishi_1.Schema.string().role('textarea').default('标题:${标题}\n作者:${作者}\n简介:${简介}'),
51
- toutiao: koishi_1.Schema.string().role('textarea').default('标题:${标题}\n作者:${作者}\n简介:${简介}'),
52
- pipigx: koishi_1.Schema.string().role('textarea').default('标题:${标题}\n作者:${作者}\n简介:${简介}'),
53
- pipixia: koishi_1.Schema.string().role('textarea').default('标题:${标题}\n作者:${作者}\n简介:${简介}'),
54
- zuiyou: koishi_1.Schema.string().role('textarea').default('标题:${标题}\n作者:${作者}\n简介:${简介}'),
55
- })
56
- }),
42
+ bilibili: koishi_1.Schema.string().role('textarea').default('标题:${标题}\nUP主:${作者}\n简介:${简介}\n时长:${视频时长}\n点赞:${点赞数}\n投币:${投币数}\n收藏:${收藏数}\n转发:${转发数}').description('B站消息格式'),
43
+ douyin: koishi_1.Schema.string().role('textarea').default('标题:${标题}\n作者:${作者}\n点赞:${点赞数}\n收藏:${收藏数}\n转发:${转发数}').description('抖音消息格式'),
44
+ kuaishou: koishi_1.Schema.string().role('textarea').default('标题:${标题}\n作者:${作者}\n点赞:${点赞数}\n播放:${播放数}\n转发:${转发数}').description('快手消息格式'),
45
+ xigua: koishi_1.Schema.string().role('textarea').default('标题:${标题}\n播放:${播放数}\n点赞:${点赞数}\n视频大小:${视频大小}MB').description('西瓜视频消息格式'),
46
+ xiaohongshu: koishi_1.Schema.string().role('textarea').default('标题:${标题}\n作者:${作者}\n简介:${简介}').description('小红书消息格式'),
47
+ weibo: koishi_1.Schema.string().role('textarea').default('标题:${标题}\n作者:${作者}\n简介:${简介}').description('微博消息格式'),
48
+ toutiao: koishi_1.Schema.string().role('textarea').default('标题:${标题}\n作者:${作者}\n简介:${简介}').description('今日头条消息格式'),
49
+ pipigx: koishi_1.Schema.string().role('textarea').default('标题:${标题}\n作者:${作者}\n简介:${简介}').description('皮皮搞笑消息格式'),
50
+ pipixia: koishi_1.Schema.string().role('textarea').default('标题:${标题}\n作者:${作者}\n简介:${简介}').description('皮皮虾消息格式'),
51
+ zuiyou: koishi_1.Schema.string().role('textarea').default('标题:${标题}\n作者:${作者}\n简介:${简介}').description('最右消息格式'),
52
+ }).description('各平台消息输出格式(支持${变量}占位符)')
53
+ }).description('消息格式'),
57
54
  koishi_1.Schema.object({
58
- showImageText: koishi_1.Schema.boolean().default(true),
59
- showVideoUrl: koishi_1.Schema.boolean().default(false),
60
- showVideoFile: koishi_1.Schema.boolean().default(true),
61
- }),
55
+ showImageText: koishi_1.Schema.boolean().default(true).description('显示图文内容'),
56
+ showVideoUrl: koishi_1.Schema.boolean().default(false).description('显示视频无水印链接'),
57
+ showVideoFile: koishi_1.Schema.boolean().default(true).description('发送视频文件(关闭则只发链接)'),
58
+ }).description('内容显示设置'),
62
59
  koishi_1.Schema.object({
63
- maxDescLength: koishi_1.Schema.number().default(200),
64
- }),
60
+ maxDescLength: koishi_1.Schema.number().default(200).description('简介内容最大长度(字符)'),
61
+ }).description('内容长度限制'),
65
62
  koishi_1.Schema.object({
66
- timeout: koishi_1.Schema.number().min(0).default(180000),
67
- videoSendTimeout: koishi_1.Schema.number().min(0).default(0),
68
- userAgent: koishi_1.Schema.string().default('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36'),
69
- bilibiliAccessKey: koishi_1.Schema.string().default(''),
70
- }),
63
+ timeout: koishi_1.Schema.number().min(0).default(180000).description('API请求超时时间(毫秒)'),
64
+ videoSendTimeout: koishi_1.Schema.number().min(0).default(0).description('视频发送超时时间(毫秒,0为不限制)'),
65
+ userAgent: koishi_1.Schema.string().default('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36').description('请求UA标识'),
66
+ bilibiliAccessKey: koishi_1.Schema.string().default('').description('B站AccessKey(可选,用于高级解析)'),
67
+ }).description('网络与API设置'),
71
68
  koishi_1.Schema.object({
72
- ignoreSendError: koishi_1.Schema.boolean().default(true),
73
- retryTimes: koishi_1.Schema.number().min(0).default(0),
74
- retryInterval: koishi_1.Schema.number().min(0).default(0),
75
- }),
69
+ ignoreSendError: koishi_1.Schema.boolean().default(true).description('忽略发送失败错误'),
70
+ retryTimes: koishi_1.Schema.number().min(0).default(0).description('API请求重试次数'),
71
+ retryInterval: koishi_1.Schema.number().min(0).default(0).description('重试间隔时间(毫秒)'),
72
+ }).description('错误与重试设置'),
76
73
  koishi_1.Schema.object({
77
- enableForward: koishi_1.Schema.boolean().default(false),
78
- downloadVideoBeforeSend: koishi_1.Schema.boolean().default(false),
79
- }),
74
+ enableForward: koishi_1.Schema.boolean().default(false).description('启用合并转发(仅OneBot平台)'),
75
+ downloadVideoBeforeSend: koishi_1.Schema.boolean().default(false).description('发送前先下载视频(避免链接失效)'),
76
+ }).description('发送方式设置'),
80
77
  koishi_1.Schema.object({
81
- messageBufferDelay: koishi_1.Schema.number().min(0).default(0),
82
- }),
78
+ messageBufferDelay: koishi_1.Schema.number().min(0).default(0).description('消息缓冲延迟(毫秒,批量处理链接)'),
79
+ }).description('消息处理设置'),
83
80
  koishi_1.Schema.object({
84
- autoClearCacheInterval: koishi_1.Schema.number().min(0).default(0),
85
- }),
81
+ autoClearCacheInterval: koishi_1.Schema.number().min(0).default(0).description('自动清理缓存间隔(分钟,0为关闭)'),
82
+ }).description('缓存清理设置'),
86
83
  ]);
87
84
  if (!worker_threads_1.isMainThread) {
88
85
  const workerDataTyped = worker_threads_1.workerData;
@@ -801,7 +798,6 @@ function apply(ctx, config) {
801
798
  }
802
799
  return { data: null, msg: '西瓜视频解析失败' };
803
800
  }
804
- // 修复:确保 currentPlatform 不为 null
805
801
  const currentPlatform = platform;
806
802
  const nonKuaishouPlatforms = ['xiaohongshu', 'weibo', 'toutiao', 'pipigx', 'pipixia', 'zuiyou'];
807
803
  if (nonKuaishouPlatforms.includes(currentPlatform)) {
@@ -809,7 +805,6 @@ function apply(ctx, config) {
809
805
  try {
810
806
  const res = await http.get(API_CONFIG.universal, { params: { url: realUrl } });
811
807
  if ((res.data.code === 200 || res.data.code === 0) && res.data.data) {
812
- // currentPlatform 已经被断言为非 null,安全传递给 parseData
813
808
  const parseResult = parseData(res.data.data, config.maxDescLength, currentPlatform);
814
809
  return { data: parseResult, msg: '解析成功' };
815
810
  }
@@ -1130,3 +1125,8 @@ function apply(ctx, config) {
1130
1125
  process.on('exit', clearAllCache);
1131
1126
  ctx.logger.info('视频解析插件已加载');
1132
1127
  }
1128
+ module.exports = {
1129
+ name: exports.name,
1130
+ Config: exports.Config,
1131
+ apply,
1132
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-video-parser-all",
3
3
  "description": "Koishi 全平台视频解析插件,支持抖音/快手/B站/小红书/微博/今日头条/皮皮搞笑/皮皮虾/西瓜视频/最右视频链接解析",
4
- "version": "0.3.9",
4
+ "version": "0.4.1",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [