koishi-plugin-video-parser-all 0.7.6 → 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 +32 -14
  2. package/package.json +1 -1
  3. package/readme.md +2 -2
package/lib/index.js CHANGED
@@ -399,7 +399,20 @@ function parseData(rawResponse, maxDescLength) {
399
399
  const data = root.data || root;
400
400
  const stat = {};
401
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
+ }
402
413
  Object.entries(VARIABLE_MAPPING).forEach(([varName, keys]) => {
414
+ if (stat[varName] !== undefined)
415
+ return;
403
416
  let value = findValueInObject(data, keys) || findValueInObject(root, keys);
404
417
  if (varName === '图片数量' && value === undefined) {
405
418
  let imgCount = 0;
@@ -438,7 +451,7 @@ function parseData(rawResponse, maxDescLength) {
438
451
  else if ((data.images && data.images.length > 1) || (root.images && root.images.length > 1) ||
439
452
  (data.imgurl && data.imgurl.length > 1) || (root.imgurl && root.imgurl.length > 1))
440
453
  type = '图集';
441
- const title = data.title || '无标题';
454
+ const title = stat['标题'] || data.title || '无标题';
442
455
  let author = '';
443
456
  if (data.author && typeof data.author === 'object') {
444
457
  author = data.author.name || '';
@@ -446,16 +459,16 @@ function parseData(rawResponse, maxDescLength) {
446
459
  else {
447
460
  author = data.author || '';
448
461
  }
449
- author = author || '未知作者';
450
- const rawDesc = data.desc || data.content || '暂无简介';
462
+ author = author || stat['作者'] || '未知作者';
463
+ const rawDesc = data.desc || data.content || stat['简介'] || '暂无简介';
451
464
  const desc = rawDesc.slice(0, maxDescLength);
452
- const cover = data.cover || '';
465
+ const cover = data.cover || data.live?.cover || data.live?.keyframe || '';
453
466
  const images = Array.isArray(data.images) ? data.images : [];
454
- 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] : '') || '';
455
468
  const durationValue = data.duration || 0;
456
469
  const duration = typeof durationValue === 'number' ? durationValue : parseInt(durationValue) || 0;
457
470
  const durationFormatted = formatDuration(durationValue);
458
- const pubTime = formatPublishTime(data.create_time || data.publish_time);
471
+ const pubTime = formatPublishTime(data.create_time || data.publish_time || data.live?.time);
459
472
  if (pubTime)
460
473
  stat['发布时间'] = pubTime;
461
474
  if (durationFormatted !== '00:00:00')
@@ -471,13 +484,6 @@ function parseData(rawResponse, maxDescLength) {
471
484
  const reposts_count = Number(stat['转发数']) || 0;
472
485
  const attitudes_count = Number(stat['点赞数']) || 0;
473
486
  const comments_count = Number(stat['评论数']) || 0;
474
- if (data.live) {
475
- stat['直播间地址'] = data.live.room_url || '';
476
- stat['直播间ID'] = data.live.room_id || '';
477
- stat['直播间状态'] = data.live.status === 1 ? '直播中' : (data.live.status === 0 ? '未开播' : '未知');
478
- stat['在线人数'] = data.live.online || '';
479
- stat['关注数'] = data.live.attention || '';
480
- }
481
487
  return {
482
488
  type: type,
483
489
  rawData: rawResponse,
@@ -627,6 +633,18 @@ function apply(ctx, config) {
627
633
  }
628
634
  try {
629
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
+ }
630
648
  logger.info(`解析成功: ${url}`);
631
649
  return {
632
650
  data: parseResult,
@@ -730,8 +748,8 @@ function apply(ctx, config) {
730
748
  await sendTimeout(session, errorMsg);
731
749
  await delay(500);
732
750
  }
751
+ // 已删除⚠ 未解析到有效内容提示
733
752
  if (items.length === 0) {
734
- await sendTimeout(session, '⚠ 未解析到有效内容');
735
753
  return;
736
754
  }
737
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
3
  "description": "Koishi 全平台视频解析插件,支持抖音/快手/B站/微博/今日头条/皮皮搞笑/皮皮虾/最右视频链接解析",
4
- "version": "0.7.6",
4
+ "version": "0.7.8",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [
package/readme.md CHANGED
@@ -116,8 +116,8 @@ 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
122
  | 微博 | weibo、video.weibo.com | 视频、图集 |
123
123
  | 今日头条 | toutiao、ixigua.com | 短视频 |