koishi-plugin-video-parser-all 1.0.5 → 1.0.6

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 +20 -30
  2. package/package.json +1 -1
  3. package/readme.md +0 -1
package/lib/index.js CHANGED
@@ -718,11 +718,28 @@ function apply(ctx, config) {
718
718
  debugLog('INFO', '没有成功解析的内容');
719
719
  return;
720
720
  }
721
+ // 先发送所有视频(单独发送,在合并转发之前)
722
+ for (const item of items) {
723
+ const p = item.parsed;
724
+ if (p.video && (p.type === 'video' || (p.type === 'live' && !p.live_photo?.length && !p.images?.length))) {
725
+ if (config.showVideoFile) {
726
+ try {
727
+ await sendVideoFile(session, p.video);
728
+ }
729
+ catch (e) {
730
+ debugLog('ERROR', `视频发送失败: ${getErrorMessage(e)}`);
731
+ }
732
+ }
733
+ else {
734
+ await sendWithTimeout(session, `视频链接:${p.video}`);
735
+ }
736
+ await delay(500);
737
+ }
738
+ }
721
739
  const enableForward = config.enableForward && session.platform === 'onebot';
722
740
  const botName = config.botName || '视频解析机器人';
723
741
  if (enableForward) {
724
742
  const forwardMessages = [];
725
- const videoItems = [];
726
743
  for (const item of items) {
727
744
  const p = item.parsed;
728
745
  const text = item.text;
@@ -738,12 +755,7 @@ function apply(ctx, config) {
738
755
  forwardMessages.push(buildForwardNode(session, koishi_1.h.image(imgUrl), botName));
739
756
  }
740
757
  }
741
- if (p.video) {
742
- forwardMessages.push(buildForwardNode(session, `视频链接:${p.video}`, botName));
743
- if (config.showVideoFile && (p.type === 'video' || (p.type === 'live' && !p.live_photo?.length && !p.images?.length))) {
744
- videoItems.push(p);
745
- }
746
- }
758
+ // 视频已单独发送,合并转发中不再添加
747
759
  }
748
760
  if (forwardMessages.length) {
749
761
  const forwardMsg = (0, koishi_1.h)('message', { forward: true }, forwardMessages.slice(0, 100));
@@ -759,17 +771,9 @@ function apply(ctx, config) {
759
771
  }
760
772
  }
761
773
  }
762
- for (const p of videoItems) {
763
- try {
764
- await sendVideoFile(session, p.video);
765
- }
766
- catch (err) {
767
- debugLog('ERROR', `视频发送失败: ${getErrorMessage(err)}`);
768
- }
769
- await delay(500);
770
- }
771
774
  }
772
775
  else {
776
+ // 非合并转发,只发送文字、封面、图片(视频已在之前发过)
773
777
  for (const item of items) {
774
778
  const p = item.parsed;
775
779
  const text = item.text;
@@ -781,20 +785,6 @@ function apply(ctx, config) {
781
785
  await sendWithTimeout(session, koishi_1.h.image(p.cover)).catch(() => { });
782
786
  await delay(300);
783
787
  }
784
- if (p.video && (p.type === 'video' || (p.type === 'live' && !p.live_photo?.length && !p.images?.length))) {
785
- if (config.showVideoFile) {
786
- try {
787
- await sendVideoFile(session, p.video);
788
- }
789
- catch (err) {
790
- debugLog('ERROR', `视频发送失败: ${getErrorMessage(err)}`);
791
- }
792
- }
793
- else {
794
- await sendWithTimeout(session, `视频链接:${p.video}`);
795
- }
796
- await delay(500);
797
- }
798
788
  if (p.type === 'image' || p.type === 'live_photo' || (p.type === 'live' && (p.live_photo?.length || p.images?.length))) {
799
789
  const imageUrls = p.images?.length ? p.images : (p.live_photo?.map(lp => lp.image) ?? []);
800
790
  for (const imgUrl of imageUrls) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-video-parser-all",
3
3
  "description": "Koishi 全平台视频解析插件,支持抖音/快手/B站/微博/小红书/剪映/YouTube/TikTok等20+平台",
4
- "version": "1.0.5",
4
+ "version": "1.0.6",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [
package/readme.md CHANGED
@@ -63,7 +63,6 @@ This is a **multi-platform video/image parsing plugin** developed for the Koishi
63
63
  | `tempDir` | string | `./temp_videos` | 临时视频存储目录 |
64
64
  | `maxVideoSize` | number | 0 | 最大下载视频大小(MB),0 为不限制大小 |
65
65
  | `forceDownloadVideo` | boolean | false | 强制下载视频后发送 |
66
- | `videoLoadWaitTime` | number | 180000 | 视频链接加载等待时间(毫秒),获取到视频链接后等待指定时间再发送,0为不等待 |
67
66
 
68
67
  ### 网络与 API 设置
69
68
  | 配置项 | 类型 | 默认值 | 说明 |