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

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 +34 -45
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -100,27 +100,27 @@ const API_CONFIG = {
100
100
  zuiyou: 'https://api.bugpk.com/api/zuiyou'
101
101
  };
102
102
  const VARIABLE_MAPPING = {
103
- '标题': ['title', 'note_title', 'content_title', 'item.title', 'data.title', 'video.title', 'live.title', 'data.item.title', 'data.live.title'],
104
- '作者': ['author', 'author.name', 'name', 'nickname', 'user_name', 'owner.name', 'data.author', 'item.author', 'user.name', 'live.author', 'data.user.name', 'data.author.name'],
105
- '简介': ['desc', 'description', 'content', 'note_desc', 'text', 'data.desc', 'item.description', 'live.desc', 'data.item.description'],
106
- '视频时长': ['duration', 'time', 'video_duration', 'item.duration', 'stat.duration', 'data.item.duration'],
107
- '点赞数': ['like', 'attitudes_count', 'digg_count', 'praise', 'stat.like', 'liked_count', 'data.like', 'data.attitudes_count', 'item.attitudes_count', 'data.item.attitudes_count'],
108
- '投币数': ['coin', 'bi', 'stat.coin', 'stast.coin'],
109
- '收藏数': ['collect', 'favorite', 'star', 'stat.collect', 'collected_count', 'stast.favorite', 'data.favorite'],
110
- '转发数': ['share', 'forward', 'repost', 'stat.share', 'reposts_count', 'shared_count', 'stast.share', 'data.reposts_count', 'data.item.reposts_count'],
111
- '播放数': ['view', 'play_count', 'play', 'stat.view', 'play_times', 'stast.view', 'data.play_count', 'item.play_count', 'data.item.play_count'],
112
- '评论数': ['comment', 'comments_count', 'comment_count', 'discuss', 'stat.comment', 'stast.reply', 'data.comments_count', 'item.comments_count', 'data.item.comments_count', 'stat.reply'],
113
- 'IP属地': ['ip_info_str', 'data.ip_info_str', 'item.ip_info', 'data.item.ip_info_str'],
114
- '发布时间': ['date', 'time', 'publish_time', 'data.date', 'item.publish_time', 'live.time', 'stast.publish_time', 'stat.time', 'data.time.publish_time', 'data.live.time', 'stat.ctime'],
115
- '粉丝数': ['followers_count', 'data.followers_count', 'item.followers', 'author.fans', 'data.item.followers_count'],
116
- '在线人数': ['online', 'data.online', 'live.online', 'room.online', 'data.live.online'],
117
- '关注数': ['attention', 'data.attention', 'live.attention', 'stast.attention', 'data.live.attention'],
118
- '文件大小': ['size', 'size_str', 'item.size', 'item.size_str', 'data.size', 'data.item.size_str'],
119
- '直播间地址': ['room_url', 'live.room_url', 'data.room_url', 'live.url', 'data.live.room_url'],
120
- '直播间ID': ['room_id', 'live.room_id', 'data.room_id', 'live.room_id', 'data.live.room_id'],
121
- '直播间状态': ['status', 'live.status', 'data.status', 'room.status', 'data.live.status'],
122
- '图片数量': ['count', 'data.count', 'item.count', 'images.length', 'data.images.length', 'data.item.count'],
123
- '作者ID': ['userId', 'userID', 'author_id', 'data.userId', 'item.userID', 'author.mid', 'user.mid', 'data.item.userID', 'data.author_id', 'data.user.mid', 'author.id', 'uid', 'short_id', 'data.author.id']
103
+ '标题': ['title', 'note_title', 'content_title', 'item.title', 'data.title', 'video.title', 'live.title', 'data.item.title', 'data.live.title', 'data.note.title', 'data.video_info.title', 'data.aweme_info.title', 'data.video_data.title', 'data.post_title', 'data.article_title', 'data.video_title', 'data.work_title', 'data.media_title', 'data.caption'],
104
+ '作者': ['author', 'author.name', 'name', 'nickname', 'user_name', 'owner.name', 'data.author', 'item.author', 'user.name', 'live.author', 'data.user.name', 'data.author.name', 'data.note.author', 'data.user', 'data.user_info', 'data.owner_info', 'data.creator', 'data.username', 'data.author_name', 'data.user_nickname', 'data.publisher', 'data.uploader'],
105
+ '简介': ['desc', 'description', 'content', 'note_desc', 'text', 'data.desc', 'item.description', 'live.desc', 'data.item.description', 'data.note.desc', 'data.caption', 'data.detail', 'data.intro', 'data.introduce', 'data.summary', 'data.video_desc', 'data.post_content', 'data.article_content'],
106
+ '视频时长': ['duration', 'time', 'video_duration', 'item.duration', 'stat.duration', 'data.item.duration', 'data.video_duration', 'data.video_time', 'data.play_time', 'data.length', 'data.video_length'],
107
+ '点赞数': ['like', 'attitudes_count', 'digg_count', 'praise', 'stat.like', 'liked_count', 'data.like', 'data.attitudes_count', 'item.attitudes_count', 'data.item.attitudes_count', 'data.like_count', 'data.likes', 'data.praise_count', 'data.digg', 'data.favorited_count', 'data.love_count', 'data.up_count', 'data.zan'],
108
+ '投币数': ['coin', 'bi', 'stat.coin', 'stast.coin', 'data.coin', 'data.coin_num', 'data.coin_count'],
109
+ '收藏数': ['collect', 'favorite', 'star', 'stat.collect', 'collected_count', 'stast.favorite', 'data.favorite', 'data.collect_count', 'data.collection_count', 'data.star_count', 'data.bookmark_count', 'data.fav_count', 'data.save_count'],
110
+ '转发数': ['share', 'forward', 'repost', 'stat.share', 'reposts_count', 'shared_count', 'stast.share', 'data.reposts_count', 'data.item.reposts_count', 'data.share_count', 'data.forward_count', 'data.repost_count'],
111
+ '播放数': ['view', 'play_count', 'play', 'stat.view', 'play_times', 'stast.view', 'data.play_count', 'item.play_count', 'data.item.play_count', 'data.view_count', 'data.views', 'data.play_num', 'data.watch_count', 'data.video_play_count'],
112
+ '评论数': ['comment', 'comments_count', 'comment_count', 'discuss', 'stat.comment', 'stast.reply', 'data.comments_count', 'item.comments_count', 'data.item.comments_count', 'stat.reply', 'data.comment_num', 'data.reply_count', 'data.review_count'],
113
+ 'IP属地': ['ip', 'ip_info', 'ip_location', 'ip_info_str', 'data.ip_info_str', 'item.ip', 'item.ip_info', 'data.item.ip_info_str', 'data.user_ip', 'data.location', 'data.region', 'data.area', 'data.addr'],
114
+ '发布时间': ['date', 'time', 'publish_time', 'create_time', 'ctime', 'pubdate', 'data.date', 'item.publish_time', 'live.time', 'stast.publish_time', 'stat.time', 'data.time.publish_time', 'data.live.time', 'stat.ctime', 'data.upload_time', 'data.post_time', 'data.create_date', 'data.pub_time', 'data.timestamp'],
115
+ '粉丝数': ['fans', 'fans_count', 'follower', 'followers', 'follower_count', 'followers_count', 'data.followers_count', 'item.followers', 'author.fans', 'data.item.followers_count', 'data.user_fans', 'data.fan_num'],
116
+ '在线人数': ['online', 'online_count', 'data.online', 'live.online', 'room.online', 'data.live.online', 'data.watching', 'data.viewer_count', 'data.audience_count'],
117
+ '关注数': ['follow', 'follow_count', 'attention', 'data.attention', 'live.attention', 'stast.attention', 'data.live.attention', 'data.following_count', 'data.follow_num'],
118
+ '文件大小': ['size', 'size_str', 'item.size', 'item.size_str', 'data.size', 'data.item.size_str', 'data.file_size', 'data.video_size', 'data.vid_size'],
119
+ '直播间地址': ['room_url', 'live.room_url', 'data.room_url', 'live.url', 'data.live.room_url', 'data.room_link', 'data.live_url', 'data.stream_url'],
120
+ '直播间ID': ['room_id', 'live.room_id', 'data.room_id', 'live.room_id', 'data.live.room_id', 'data.live_id', 'data.stream_id'],
121
+ '直播间状态': ['status', 'live_status', 'live.status', 'data.status', 'room.status', 'data.live.status', 'data.stream_status', 'data.room_status'],
122
+ '图片数量': ['count', 'img_count', 'image_count', 'pic_count', 'data.count', 'item.count', 'images.length', 'data.images.length', 'data.item.count', 'data.pic_num', 'data.img_num'],
123
+ '作者ID': ['uid', 'userid', 'user_id', 'userId', 'userID', 'author_id', 'data.userId', 'item.userID', 'author.mid', 'user.mid', 'data.item.userID', 'data.author_id', 'data.user.mid', 'author.id', 'short_id', 'data.author.id', 'data.uid', 'data.mid', 'data.open_id', 'data.account_id']
124
124
  };
125
125
  function getErrorMessage(error) {
126
126
  if (error instanceof Error)
@@ -284,10 +284,7 @@ function cleanUrl(url) {
284
284
  try {
285
285
  url = url.replace(/&/g, '&');
286
286
  const urlObj = new URL(url);
287
- if (urlObj.hostname.includes('xiaohongshu.com')) {
288
- const pathname = urlObj.pathname;
289
- urlObj.searchParams.forEach((_, key) => urlObj.searchParams.delete(key));
290
- urlObj.pathname = pathname;
287
+ if (urlObj.hostname.includes('xiaohongshu.com') || urlObj.hostname.includes('xhslink.com')) {
291
288
  return urlObj.href;
292
289
  }
293
290
  if (urlObj.hostname.includes('douyin.com') || urlObj.hostname.includes('v.douyin.com')) {
@@ -303,16 +300,17 @@ function cleanUrl(url) {
303
300
  }
304
301
  async function resolveShortUrl(url) {
305
302
  try {
306
- const res = await axios_1.default.head(url, {
307
- timeout: 15000,
308
- maxRedirects: 15,
303
+ const res = await axios_1.default.get(url, {
304
+ timeout: 10000,
305
+ maxRedirects: 10,
309
306
  headers: {
310
307
  'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
311
308
  'Referer': 'https://www.baidu.com/',
312
309
  },
313
- validateStatus: (status) => status >= 200 && status < 400
310
+ validateStatus: status => true
314
311
  });
315
- return cleanUrl(res.request.res?.responseUrl || url);
312
+ const finalUrl = res.request.res?.responseUrl || url;
313
+ return cleanUrl(finalUrl);
316
314
  }
317
315
  catch (e) {
318
316
  return cleanUrl(url);
@@ -587,7 +585,9 @@ function generateFormattedText(parseData, config) {
587
585
  result = result.replace(varMatch, String(value));
588
586
  }
589
587
  });
590
- return result.trim() || `标题:${parseData.title}\n作者:${parseData.author}\n简介:${parseData.desc}`;
588
+ return result.trim() || `标题:${parseData.title}
589
+ 作者:${parseData.author}
590
+ 简介:${parseData.desc}`;
591
591
  }
592
592
  function clearAllCache() {
593
593
  processed.clear();
@@ -637,28 +637,17 @@ function apply(ctx, config) {
637
637
  let lastError = null;
638
638
  for (let i = 0; i <= retryTimes; i++) {
639
639
  try {
640
- const params = { url, proxyurl: '' };
640
+ const params = { url };
641
641
  let res;
642
642
  if (platform === 'xiaohongshu') {
643
643
  res = await http.post(API_CONFIG[platform], new URLSearchParams(params), {
644
- timeout: config.timeout,
645
- headers: {
646
- 'X-Requested-With': 'XMLHttpRequest',
647
- 'Origin': 'https://api.bugpk.com',
648
- 'Content-Type': 'application/x-www-form-urlencoded',
649
- 'Cache-Control': 'no-cache',
650
- 'Pragma': 'no-cache'
651
- }
644
+ timeout: config.timeout
652
645
  });
653
646
  }
654
647
  else {
655
648
  res = await http.get(API_CONFIG[platform], {
656
649
  params,
657
- timeout: config.timeout,
658
- headers: {
659
- 'X-Requested-With': 'XMLHttpRequest',
660
- 'Origin': 'https://www.baidu.com'
661
- }
650
+ timeout: config.timeout
662
651
  });
663
652
  }
664
653
  return res.data;
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.1",
4
+ "version": "0.7.3",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [