koishi-plugin-video-parser-all 0.7.5 → 0.7.8

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 (3) hide show
  1. package/lib/index.js +37 -45
  2. package/package.json +2 -3
  3. package/readme.md +3 -4
package/lib/index.js CHANGED
@@ -31,18 +31,7 @@ exports.Config = koishi_1.Schema.intersect([
31
31
  收藏:${'${收藏数}'}
32
32
  转发:${'${转发数}'}
33
33
  播放:${'${播放数}'}
34
- 评论:${'${评论数}'}
35
- IP属地:${'${IP属地}'}
36
- 发布时间:${'${发布时间}'}
37
- 粉丝数:${'${粉丝数}'}
38
- 在线人数:${'${在线人数}'}
39
- 关注数:${'${关注数}'}
40
- 文件大小:${'${文件大小}'}
41
- 直播间地址:${'${直播间地址}'}
42
- 直播间ID:${'${直播间ID}'}
43
- 直播间状态:${'${直播间状态}'}
44
- 图片数量:${'${图片数量}'}
45
- 作者ID:${'${作者ID}'}`).description('统一消息格式'),
34
+ 评论:${'${评论数}'}`).description('统一消息格式'),
46
35
  }).description('统一消息格式'),
47
36
  koishi_1.Schema.object({
48
37
  showImageText: koishi_1.Schema.boolean().default(true).description('显示图文内容'),
@@ -80,7 +69,6 @@ const logger = new koishi_1.Logger(exports.name);
80
69
  const PLATFORM_KEYWORDS = {
81
70
  bilibili: ['bilibili', 'b23', 'B站', 'www.bilibili.com', 'm.bilibili.com', '哔哩哔哩', 'bilibili.com/opus', 'bilibili.com/video', 'b23.tv', 't.bilibili.com', 'bilibili.com/bangumi'],
82
71
  kuaishou: ['kuaishou', '快手', 'v.kuaishou.com', 'www.kuaishou.com', 'kwimgs.com', 'kuaishou.com/app'],
83
- xiaohongshu: ['xiaohongshu', '小红书', 'xhslink.com', 'xiaohongshu.com', 'xhscdn.com', 'xiaohongshu.com/explore', 'xhslink.com/', 'xiaohongshu.com/discovery/item'],
84
72
  weibo: ['weibo', '微博', 'weibo.com', 'video.weibo.com', 'm.weibo.cn', 'weibo.com/tv/show', 'weibo.com/feed'],
85
73
  toutiao: ['toutiao', '今日头条', 'm.toutiao.com', 'toutiao.com', 'ixigua.com', 'toutiao.com/video', 'ixigua.com/i'],
86
74
  pipigx: ['pipigx', '皮皮搞笑', 'h5.pipigx.com', 'ippzone.com', 'pipigx.com/share'],
@@ -92,7 +80,6 @@ const API_CONFIG = {
92
80
  bilibili: 'https://api.xingzhige.com/API/b_parse',
93
81
  douyin: 'https://api.xingzhige.com/API/douyin/',
94
82
  kuaishou: 'https://api.bugpk.com/api/ksjx',
95
- xiaohongshu: 'https://api.bugpk.com/api/xhsjx',
96
83
  weibo: 'https://api.bugpk.com/api/weibo',
97
84
  toutiao: 'https://api.bugpk.com/api/toutiao',
98
85
  pipigx: 'https://api.bugpk.com/api/pipigx',
@@ -264,8 +251,6 @@ function getPlatformType(url) {
264
251
  return 'bilibili';
265
252
  if (PLATFORM_KEYWORDS.kuaishou.some(k => lower.includes(k)))
266
253
  return 'kuaishou';
267
- if (PLATFORM_KEYWORDS.xiaohongshu.some(k => lower.includes(k)))
268
- return 'xiaohongshu';
269
254
  if (PLATFORM_KEYWORDS.weibo.some(k => lower.includes(k)))
270
255
  return 'weibo';
271
256
  if (PLATFORM_KEYWORDS.toutiao.some(k => lower.includes(k)))
@@ -284,9 +269,6 @@ function cleanUrl(url) {
284
269
  try {
285
270
  url = url.replace(/&/g, '&');
286
271
  const urlObj = new URL(url);
287
- if (urlObj.hostname.includes('xiaohongshu.com') || urlObj.hostname.includes('xhslink.com')) {
288
- return urlObj.href;
289
- }
290
272
  if (urlObj.hostname.includes('douyin.com') || urlObj.hostname.includes('v.douyin.com')) {
291
273
  urlObj.searchParams.delete('source');
292
274
  urlObj.searchParams.delete('share_type');
@@ -417,7 +399,20 @@ function parseData(rawResponse, maxDescLength) {
417
399
  const data = root.data || root;
418
400
  const stat = {};
419
401
  let totalImageCount = 0;
402
+ if (root.msg === 'live' && data.live) {
403
+ const liveData = data.live;
404
+ stat['标题'] = liveData.title || '';
405
+ stat['直播间地址'] = liveData.room_url || '';
406
+ stat['直播间ID'] = liveData.room_id || '';
407
+ stat['直播间状态'] = liveData.status === 1 ? '直播中' : (liveData.status === 0 ? '未开播' : '未知');
408
+ stat['在线人数'] = liveData.online || '';
409
+ stat['关注数'] = liveData.attention || '';
410
+ stat['发布时间'] = formatPublishTime(liveData.time);
411
+ stat['简介'] = liveData.desc || '';
412
+ }
420
413
  Object.entries(VARIABLE_MAPPING).forEach(([varName, keys]) => {
414
+ if (stat[varName] !== undefined)
415
+ return;
421
416
  let value = findValueInObject(data, keys) || findValueInObject(root, keys);
422
417
  if (varName === '图片数量' && value === undefined) {
423
418
  let imgCount = 0;
@@ -456,7 +451,7 @@ function parseData(rawResponse, maxDescLength) {
456
451
  else if ((data.images && data.images.length > 1) || (root.images && root.images.length > 1) ||
457
452
  (data.imgurl && data.imgurl.length > 1) || (root.imgurl && root.imgurl.length > 1))
458
453
  type = '图集';
459
- const title = data.title || '无标题';
454
+ const title = stat['标题'] || data.title || '无标题';
460
455
  let author = '';
461
456
  if (data.author && typeof data.author === 'object') {
462
457
  author = data.author.name || '';
@@ -464,16 +459,16 @@ function parseData(rawResponse, maxDescLength) {
464
459
  else {
465
460
  author = data.author || '';
466
461
  }
467
- author = author || '未知作者';
468
- const rawDesc = data.desc || data.content || '暂无简介';
462
+ author = author || stat['作者'] || '未知作者';
463
+ const rawDesc = data.desc || data.content || stat['简介'] || '暂无简介';
469
464
  const desc = rawDesc.slice(0, maxDescLength);
470
- const cover = data.cover || '';
465
+ const cover = data.cover || data.live?.cover || data.live?.keyframe || '';
471
466
  const images = Array.isArray(data.images) ? data.images : [];
472
- const video = data.url || data.video_backup || '';
467
+ const video = data.url || data.video_backup || (data.live?.url && Array.isArray(data.live.url) ? data.live.url[0] : '') || '';
473
468
  const durationValue = data.duration || 0;
474
469
  const duration = typeof durationValue === 'number' ? durationValue : parseInt(durationValue) || 0;
475
470
  const durationFormatted = formatDuration(durationValue);
476
- const pubTime = formatPublishTime(data.create_time || data.publish_time);
471
+ const pubTime = formatPublishTime(data.create_time || data.publish_time || data.live?.time);
477
472
  if (pubTime)
478
473
  stat['发布时间'] = pubTime;
479
474
  if (durationFormatted !== '00:00:00')
@@ -489,13 +484,6 @@ function parseData(rawResponse, maxDescLength) {
489
484
  const reposts_count = Number(stat['转发数']) || 0;
490
485
  const attitudes_count = Number(stat['点赞数']) || 0;
491
486
  const comments_count = Number(stat['评论数']) || 0;
492
- if (data.live) {
493
- stat['直播间地址'] = data.live.room_url || '';
494
- stat['直播间ID'] = data.live.room_id || '';
495
- stat['直播间状态'] = data.live.status === 1 ? '直播中' : (data.live.status === 0 ? '未开播' : '未知');
496
- stat['在线人数'] = data.live.online || '';
497
- stat['关注数'] = data.live.attention || '';
498
- }
499
487
  return {
500
488
  type: type,
501
489
  rawData: rawResponse,
@@ -601,18 +589,10 @@ function apply(ctx, config) {
601
589
  for (let i = 0; i <= retryTimes; i++) {
602
590
  try {
603
591
  const params = { url };
604
- let res;
605
- if (platform === 'xiaohongshu') {
606
- res = await http.post(API_CONFIG[platform], new URLSearchParams(params), {
607
- timeout: config.timeout
608
- });
609
- }
610
- else {
611
- res = await http.get(API_CONFIG[platform], {
612
- params,
613
- timeout: config.timeout
614
- });
615
- }
592
+ const res = await http.get(API_CONFIG[platform], {
593
+ params,
594
+ timeout: config.timeout
595
+ });
616
596
  return res.data;
617
597
  }
618
598
  catch (error) {
@@ -653,6 +633,18 @@ function apply(ctx, config) {
653
633
  }
654
634
  try {
655
635
  const parseResult = parseData(resData, config.maxDescLength);
636
+ const isAllDefault = parseResult.title === '无标题' &&
637
+ parseResult.author === '未知作者' &&
638
+ parseResult.desc === '暂无简介';
639
+ if (isAllDefault) {
640
+ // 【关键修改1】控制台日志改为更精准的提示
641
+ logger.warn(`解析结果均为默认值(可能暂不支持该链接): ${url}`);
642
+ return {
643
+ data: null,
644
+ success: false,
645
+ msg: '解析失败: 暂不支持解析该链接'
646
+ };
647
+ }
656
648
  logger.info(`解析成功: ${url}`);
657
649
  return {
658
650
  data: parseResult,
@@ -756,8 +748,8 @@ function apply(ctx, config) {
756
748
  await sendTimeout(session, errorMsg);
757
749
  await delay(500);
758
750
  }
751
+ // 已删除⚠ 未解析到有效内容提示
759
752
  if (items.length === 0) {
760
- await sendTimeout(session, '⚠ 未解析到有效内容');
761
753
  return;
762
754
  }
763
755
  const enableForward = config.enableForward && session.platform === 'onebot';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-video-parser-all",
3
- "description": "Koishi 全平台视频解析插件,支持抖音/快手/B站/小红书/微博/今日头条/皮皮搞笑/皮皮虾/最右视频链接解析",
4
- "version": "0.7.5",
3
+ "description": "Koishi 全平台视频解析插件,支持抖音/快手/B站/微博/今日头条/皮皮搞笑/皮皮虾/最右视频链接解析",
4
+ "version": "0.7.8",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [
@@ -26,7 +26,6 @@
26
26
  "bv",
27
27
  "douyin",
28
28
  "kuaishou",
29
- "xiaohongshu",
30
29
  "weibo",
31
30
  "toutiao",
32
31
  "pipigx",
package/readme.md CHANGED
@@ -3,7 +3,7 @@
3
3
  ## 项目介绍 (Project Introduction)
4
4
 
5
5
  ### 中文
6
- 这是一个为 Koishi 机器人框架开发的**多平台视频/图集解析插件**,支持自动识别并解析抖音、快手、B站、小红书、微博、今日头条、皮皮搞笑、皮皮虾、最右等主流平台的短视频/图集链接。核心特性:
6
+ 这是一个为 Koishi 机器人框架开发的**多平台视频/图集解析插件**,支持自动识别并解析抖音、快手、B站、微博、今日头条、皮皮搞笑、皮皮虾、最右等主流平台的短视频/图集链接。核心特性:
7
7
  - 🚀 自动识别多平台链接,无需手动指定平台
8
8
  - 🎨 自定义解析结果格式,支持丰富的变量替换
9
9
  - ⚡ 内置防重复解析、接口重试、自动缓存清理等实用功能
@@ -116,10 +116,9 @@ This is a **multi-platform video/image parsing plugin** developed for the Koishi
116
116
  ## 支持的平台 (Supported Platforms)
117
117
  | 平台名称 | 关键词识别 | 解析能力 |
118
118
  |----------|------------|----------|
119
- | 哔哩哔哩 (B站) | bilibili、b23、B站 | 视频、番剧、直播、图集 |
120
- | 抖音 | douyin、v.douyin.com | 短视频、图集、直播 |
119
+ | 哔哩哔哩 (B站) | bilibili、b23、B站 | 视频、直播 |
120
+ | 抖音 | douyin、v.douyin.com | 短视频、图集 |
121
121
  | 快手 | kuaishou、v.kuaishou.com | 短视频、图集 |
122
- | 小红书 | xiaohongshu、xhslink.com | 笔记、图集、视频 |
123
122
  | 微博 | weibo、video.weibo.com | 视频、图集 |
124
123
  | 今日头条 | toutiao、ixigua.com | 短视频 |
125
124
  | 皮皮搞笑 | pipigx、h5.pipigx.com | 短视频 |