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

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 +27 -64
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -414,7 +414,7 @@ function findValueInObject(obj, keys) {
414
414
  }
415
415
  function parseData(rawResponse, maxDescLength) {
416
416
  const root = rawResponse || {};
417
- const data = root.data || root.result || root || {};
417
+ const data = root.data || root;
418
418
  const stat = {};
419
419
  let totalImageCount = 0;
420
420
  Object.entries(VARIABLE_MAPPING).forEach(([varName, keys]) => {
@@ -456,83 +456,46 @@ function parseData(rawResponse, maxDescLength) {
456
456
  else if ((data.images && data.images.length > 1) || (root.images && root.images.length > 1) ||
457
457
  (data.imgurl && data.imgurl.length > 1) || (root.imgurl && root.imgurl.length > 1))
458
458
  type = '图集';
459
- const title = stat['标题'] || data.note_title || data.title || data.content_title || data.video?.title ||
460
- data.item?.title || root.title || data.live?.title || '无标题';
461
- let author = stat['作者'] || data.author?.name || data.nickname || data.user_name || data.owner?.name ||
462
- data.item?.author || root.author || data.user?.name || data.live?.author || '';
463
- if (typeof author === 'object') {
464
- author = '';
459
+ const title = data.title || '无标题';
460
+ let author = '';
461
+ if (data.author && typeof data.author === 'object') {
462
+ author = data.author.name || '';
465
463
  }
466
464
  else {
467
- author = author || '未知作者';
468
- }
469
- const rawDesc = stat['简介'] || data.note_desc || data.content || data.text || data.description ||
470
- data.video?.desc || data.item?.description || root.desc || root.description ||
471
- data.live?.desc || (title !== '无标题' ? title : '') || '暂无简介';
472
- const desc = rawDesc.length > 0 ? rawDesc.slice(0, maxDescLength) : '暂无简介';
473
- const cover = data.cover || data.video?.fm || data.imgurl || data.pic || data.thumbnail || data.cover_url ||
474
- data.item?.cover || root.cover || data.live?.cover || data.live?.keyframe ||
475
- (Array.isArray(data.images) && data.images[0]) ||
476
- (Array.isArray(root.images) && root.images[0]) ||
477
- (Array.isArray(data.imgurl) && data.imgurl[0]) || '';
478
- let images = [];
479
- const imgSources = [
480
- data.images, data.pics, data.pic_urls, data.image_list, data.imgurl,
481
- root.images, root.pics, root.pic_urls, root.image_list, root.imgurl,
482
- data.item?.images
483
- ];
484
- for (const source of imgSources) {
485
- if (Array.isArray(source) && source.length > 0) {
486
- images = source.filter(i => i && typeof i === 'string' && i !== cover);
487
- break;
488
- }
489
- }
490
- let video = data.video?.url || data.url || data.download_url || data.playUrl ||
491
- data.video_url || root.url || data.item?.url || data.live?.url ||
492
- (data.live?.url && Array.isArray(data.live.url) ? data.live.url[0] : '') || '';
493
- const durationValue = stat['视频时长'] || data.item?.duration || data.duration || 0;
465
+ author = data.author || '';
466
+ }
467
+ author = author || '未知作者';
468
+ const rawDesc = data.desc || data.content || '暂无简介';
469
+ const desc = rawDesc.slice(0, maxDescLength);
470
+ const cover = data.cover || '';
471
+ const images = Array.isArray(data.images) ? data.images : [];
472
+ const video = data.url || data.video_backup || '';
473
+ const durationValue = data.duration || 0;
494
474
  const duration = typeof durationValue === 'number' ? durationValue : parseInt(durationValue) || 0;
495
475
  const durationFormatted = formatDuration(durationValue);
496
- const pubTime = formatPublishTime(stat['发布时间']);
476
+ const pubTime = formatPublishTime(data.create_time || data.publish_time);
497
477
  if (pubTime)
498
478
  stat['发布时间'] = pubTime;
499
- else
500
- delete stat['发布时间'];
501
- if (durationFormatted !== '00:00:00') {
479
+ if (durationFormatted !== '00:00:00')
502
480
  stat['视频时长'] = durationFormatted;
503
- }
504
- else {
505
- delete stat['视频时长'];
506
- }
507
- if (stat['图片数量'] === 0) {
481
+ if (stat['图片数量'] === 0)
508
482
  delete stat['图片数量'];
509
- }
510
- const sizeVal = stat['文件大小'];
511
- if (sizeVal && !String(sizeVal).includes('MB')) {
512
- const num = Number(sizeVal);
513
- if (!isNaN(num) && num > 0)
514
- stat['文件大小'] = `${num.toFixed(2)} MB`;
515
- }
516
- const live_photo = data.live_photo || root.live_photo || [];
517
- const h_w = data.item?.h_w || root.h_w || [];
518
- const quality_urls = data.quality_urls || root.quality_urls || {};
519
- const default_quality = data.default_quality || root.default_quality || '';
520
- const download_url = data.download_url || video;
521
- const play_count = stat['播放数'] || data.play_count || root.play_count || '';
522
- const reposts_count = Number(stat['转发数']) || data.reposts_count || root.reposts_count || 0;
523
- const attitudes_count = Number(stat['点赞数']) || data.attitudes_count || root.attitudes_count || data.like || root.like || 0;
524
- const comments_count = Number(stat['评论数']) || data.comments_count || root.comments_count || 0;
483
+ const live_photo = data.live_photo || [];
484
+ const h_w = data.item?.h_w || [];
485
+ const quality_urls = data.quality_urls || {};
486
+ const default_quality = data.default_quality || '';
487
+ const download_url = video;
488
+ const play_count = stat['播放数'] || '';
489
+ const reposts_count = Number(stat['转发数']) || 0;
490
+ const attitudes_count = Number(stat['点赞数']) || 0;
491
+ const comments_count = Number(stat['评论数']) || 0;
525
492
  if (data.live) {
526
493
  stat['直播间地址'] = data.live.room_url || '';
527
494
  stat['直播间ID'] = data.live.room_id || '';
528
- stat['直播间状态'] = data.live.status === 1 ? '直播中' : (data.live.status === 0 ? '未开播' : data.live.status || '未知');
495
+ stat['直播间状态'] = data.live.status === 1 ? '直播中' : (data.live.status === 0 ? '未开播' : '未知');
529
496
  stat['在线人数'] = data.live.online || '';
530
497
  stat['关注数'] = data.live.attention || '';
531
498
  }
532
- if (data.followers_count)
533
- stat['粉丝数'] = data.followers_count;
534
- if (data.ip_info_str)
535
- stat['IP属地'] = data.ip_info_str;
536
499
  return {
537
500
  type: type,
538
501
  rawData: rawResponse,
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.3",
4
+ "version": "0.7.5",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [