koishi-plugin-video-parser-all 0.7.0 → 0.7.2

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 +11 -19
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -284,9 +284,8 @@ 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
- urlObj.searchParams.forEach((_, key) => urlObj.searchParams.delete(key));
289
- return urlObj.origin + urlObj.pathname;
287
+ if (urlObj.hostname.includes('xiaohongshu.com') || urlObj.hostname.includes('xhslink.com')) {
288
+ return urlObj.href;
290
289
  }
291
290
  if (urlObj.hostname.includes('douyin.com') || urlObj.hostname.includes('v.douyin.com')) {
292
291
  urlObj.searchParams.delete('source');
@@ -301,15 +300,17 @@ function cleanUrl(url) {
301
300
  }
302
301
  async function resolveShortUrl(url) {
303
302
  try {
304
- const res = await axios_1.default.head(url, {
303
+ const res = await axios_1.default.get(url, {
305
304
  timeout: 10000,
306
305
  maxRedirects: 10,
307
306
  headers: {
308
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',
309
308
  'Referer': 'https://www.baidu.com/',
310
- }
309
+ },
310
+ validateStatus: status => true
311
311
  });
312
- return cleanUrl(res.request.res?.responseUrl || url);
312
+ const finalUrl = res.request.res?.responseUrl || url;
313
+ return cleanUrl(finalUrl);
313
314
  }
314
315
  catch (e) {
315
316
  return cleanUrl(url);
@@ -634,26 +635,17 @@ function apply(ctx, config) {
634
635
  let lastError = null;
635
636
  for (let i = 0; i <= retryTimes; i++) {
636
637
  try {
637
- const params = { url, proxyurl: '' };
638
+ const params = { url };
638
639
  let res;
639
640
  if (platform === 'xiaohongshu') {
640
641
  res = await http.post(API_CONFIG[platform], new URLSearchParams(params), {
641
- timeout: config.timeout,
642
- headers: {
643
- 'X-Requested-With': 'XMLHttpRequest',
644
- 'Origin': 'https://api.bugpk.com',
645
- 'Content-Type': 'application/x-www-form-urlencoded'
646
- }
642
+ timeout: config.timeout
647
643
  });
648
644
  }
649
645
  else {
650
646
  res = await http.get(API_CONFIG[platform], {
651
647
  params,
652
- timeout: config.timeout,
653
- headers: {
654
- 'X-Requested-With': 'XMLHttpRequest',
655
- 'Origin': 'https://www.baidu.com'
656
- }
648
+ timeout: config.timeout
657
649
  });
658
650
  }
659
651
  return res.data;
@@ -723,7 +715,7 @@ function apply(ctx, config) {
723
715
  }
724
716
  }
725
717
  async function processSingleUrl(session, url) {
726
- const hash = crypto_1.default.createHash('md5').update(url).digest('hex');
718
+ const hash = crypto_1.default.createHash('md5').update(url + Date.now().toString()).digest('hex');
727
719
  const now = Date.now();
728
720
  if (processed.get(hash) && now - processed.get(hash) < config.sameLinkInterval * 1000) {
729
721
  logger.warn(`相同链接重复解析: ${url}`);
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.0",
4
+ "version": "0.7.2",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [