koishi-plugin-video-parser-all 1.3.3 → 1.3.4

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.
package/lib/index.d.ts CHANGED
@@ -10,6 +10,7 @@ export declare const Config: Schema<{
10
10
  } & {
11
11
  showImageText?: boolean | null | undefined;
12
12
  showCoverImage?: boolean | null | undefined;
13
+ showMusicCover?: boolean | null | undefined;
13
14
  showImageFile?: boolean | null | undefined;
14
15
  forceDownloadImage?: boolean | null | undefined;
15
16
  imageDownloadTimeout?: number | null | undefined;
@@ -99,6 +100,7 @@ export declare const Config: Schema<{
99
100
  } & {
100
101
  showImageText: boolean;
101
102
  showCoverImage: boolean;
103
+ showMusicCover: boolean;
102
104
  showImageFile: boolean;
103
105
  forceDownloadImage: boolean;
104
106
  imageDownloadTimeout: number;
package/lib/index.js CHANGED
@@ -76,11 +76,12 @@ exports.Config = koishi_1.Schema.intersect([
76
76
  debug: koishi_1.Schema.boolean().default(false).description('开启调试模式,在控制台输出详细日志'),
77
77
  }).description('基础设置'),
78
78
  koishi_1.Schema.object({
79
- unifiedMessageFormat: koishi_1.Schema.string().role('textarea').default('标题:${标题}\n作者:${作者}\n简介:${简介}\n音乐标题:${音乐标题}\n音乐作者:${音乐作者}\n音乐封面:${音乐封面}\n音乐链接:${音乐链接}\n点赞:${点赞数}\n收藏:${收藏数}\n转发:${转发数}\n播放:${播放数}\n评论:${评论数}\n图片数量:${图片数量}').description('文字消息格式,支持变量。某行所有变量为空时自动隐藏。封面及媒体文件由独立开关控制,默认不包含在文字中'),
79
+ unifiedMessageFormat: koishi_1.Schema.string().role('textarea').default('标题:${标题}\n作者:${作者}\n简介:${简介}\n音乐标题:${音乐标题}\n音乐作者:${音乐作者}\n音乐链接:${音乐链接}\n点赞:${点赞数}\n收藏:${收藏数}\n转发:${转发数}\n播放:${播放数}\n评论:${评论数}\n图片数量:${图片数量}').description('文字消息格式,支持变量。某行所有变量为空时自动隐藏。封面及媒体文件由独立开关控制,默认不包含在文字中'),
80
80
  }).description('消息格式设置'),
81
81
  koishi_1.Schema.object({
82
82
  showImageText: koishi_1.Schema.boolean().default(true).description('是否发送文字内容'),
83
- showCoverImage: koishi_1.Schema.boolean().default(true).description('是否发送封面图片'),
83
+ showCoverImage: koishi_1.Schema.boolean().default(true).description('是否发送封面图片(视频/图集封面)'),
84
+ showMusicCover: koishi_1.Schema.boolean().default(true).description('是否发送音乐封面图片'),
84
85
  showImageFile: koishi_1.Schema.boolean().default(true).description('封面/图片是否以文件形式发送(关闭则只发送链接)'),
85
86
  forceDownloadImage: koishi_1.Schema.boolean().default(false).description('强制下载封面/图片后发送'),
86
87
  imageDownloadTimeout: koishi_1.Schema.number().min(0).step(1).default(60000).description('图片下载超时(毫秒)'),
@@ -809,6 +810,45 @@ function apply(ctx, config) {
809
810
  }
810
811
  }
811
812
  }
813
+ async function sendMusicCover(session, imageUrl) {
814
+ if (!config.showMusicCover)
815
+ return;
816
+ const sendLink = async () => { await sendWithTimeout(session, `图片链接:${imageUrl}`).catch(() => { }); };
817
+ if (config.forceDownloadImage) {
818
+ try {
819
+ const localPath = await downloadImageFile(imageUrl);
820
+ await sendWithTimeout(session, koishi_1.h.image(`file://${localPath}`));
821
+ return;
822
+ }
823
+ catch (e) {
824
+ debugLog('ERROR', '强制下载音乐封面失败,尝试URL发送:', getErrorMessage(e));
825
+ try {
826
+ await sendWithTimeout(session, koishi_1.h.image(imageUrl));
827
+ return;
828
+ }
829
+ catch {
830
+ await sendLink();
831
+ }
832
+ }
833
+ return;
834
+ }
835
+ if (!config.showImageFile) {
836
+ await sendLink();
837
+ return;
838
+ }
839
+ try {
840
+ await sendWithTimeout(session, koishi_1.h.image(imageUrl));
841
+ }
842
+ catch {
843
+ try {
844
+ const localPath = await downloadImageFile(imageUrl);
845
+ await sendWithTimeout(session, koishi_1.h.image(`file://${localPath}`));
846
+ }
847
+ catch {
848
+ await sendLink();
849
+ }
850
+ }
851
+ }
812
852
  async function sendVideoFile(session, videoUrl) {
813
853
  if (!videoUrl)
814
854
  return;
@@ -894,9 +934,12 @@ function apply(ctx, config) {
894
934
  const text = item.text;
895
935
  if (text && config.showImageText)
896
936
  forwardMessages.push(buildForwardNode(session, text, botName));
897
- if (p.cover && p.type !== 'live_photo' && !(p.type === 'live' && (p.live_photo?.length || p.images?.length))) {
937
+ if (p.cover && config.showCoverImage && p.type !== 'live_photo' && !(p.type === 'live' && (p.live_photo?.length || p.images?.length))) {
898
938
  forwardMessages.push(buildForwardNode(session, koishi_1.h.image(p.cover), botName));
899
939
  }
940
+ if (config.showMusicCover && p.music.cover) {
941
+ forwardMessages.push(buildForwardNode(session, koishi_1.h.image(p.music.cover), botName));
942
+ }
900
943
  if (p.type === 'image' || p.type === 'live_photo' || (p.type === 'live' && (p.live_photo?.length || p.images?.length))) {
901
944
  const imageUrls = p.images?.length ? p.images : (p.live_photo?.map(lp => lp.image) ?? []);
902
945
  for (const imgUrl of imageUrls)
@@ -926,10 +969,14 @@ function apply(ctx, config) {
926
969
  await sendWithTimeout(session, text);
927
970
  await delay(300);
928
971
  }
929
- if (p.cover && p.type !== 'live_photo' && !(p.type === 'live' && (p.live_photo?.length || p.images?.length))) {
972
+ if (p.cover && config.showCoverImage && p.type !== 'live_photo' && !(p.type === 'live' && (p.live_photo?.length || p.images?.length))) {
930
973
  await sendImage(session, p.cover).catch(() => { });
931
974
  await delay(300);
932
975
  }
976
+ if (config.showMusicCover && p.music.cover) {
977
+ await sendMusicCover(session, p.music.cover).catch(() => { });
978
+ await delay(300);
979
+ }
933
980
  if (p.video && (p.type === 'video' || (p.type === 'live' && !p.live_photo?.length && !p.images?.length))) {
934
981
  await sendVideoFile(session, p.video);
935
982
  await delay(500);
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.3.3",
4
+ "version": "1.3.4",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [
package/readme.md CHANGED
@@ -31,13 +31,14 @@ This is a **multi-platform video/image parsing plugin** developed for the Koishi
31
31
  ### 统一消息格式 (Unified Message Format)
32
32
  | 配置项 | 类型 | 默认值 | 说明 |
33
33
  |--------|------|--------|------|
34
- | `unifiedMessageFormat` | string | `标题:${标题}\n作者:${作者}\n简介:${简介}\n音乐标题:${音乐标题}\n音乐作者:${音乐作者}\n音乐封面:${音乐封面}\n音乐链接:${音乐链接}\n点赞:${点赞数}\n收藏:${收藏数}\n转发:${转发数}\n播放:${播放数}\n评论:${评论数}\n图片数量:${图片数量}` | 文字消息格式,支持变量替换。空行自动隐藏。封面及媒体由独立开关控制,默认不包含在文字中 |
34
+ | `unifiedMessageFormat` | string | `标题:${标题}\n作者:${作者}\n简介:${简介}\n音乐标题:${音乐标题}\n音乐作者:${音乐作者}\n音乐链接:${音乐链接}\n点赞:${点赞数}\n收藏:${收藏数}\n转发:${转发数}\n播放:${播放数}\n评论:${评论数}\n图片数量:${图片数量}` | 文字消息格式,支持变量替换。空行自动隐藏。封面及媒体由独立开关控制,默认不包含在文字中 |
35
35
 
36
36
  ### 内容显示设置 (Content Display Settings)
37
37
  | 配置项 | 类型 | 默认值 | 说明 |
38
38
  |--------|------|--------|------|
39
39
  | `showImageText` | boolean | true | 是否发送文字内容 |
40
- | `showCoverImage` | boolean | true | 是否发送封面图片 |
40
+ | `showCoverImage` | boolean | true | 是否发送封面图片(视频/图集封面) |
41
+ | `showMusicCover` | boolean | true | 是否发送音乐封面图片 |
41
42
  | `showImageFile` | boolean | true | 封面/图片是否以文件形式发送(关闭则只发链接) |
42
43
  | `forceDownloadImage` | boolean | false | 强制下载封面/图片后发送 |
43
44
  | `imageDownloadTimeout` | number | 60000 | 图片下载超时(毫秒) |
@@ -116,10 +117,9 @@ This is a **multi-platform video/image parsing plugin** developed for the Koishi
116
117
  | `${视频链接}` | 视频原始链接 |
117
118
  | `${音乐标题}` | 音乐标题 |
118
119
  | `${音乐作者}` | 音乐作者 |
119
- | `${音乐封面}` | 音乐封面图片地址 |
120
120
  | `${音乐链接}` | 音乐原始链接 |
121
121
 
122
- > 注:封面图片由独立开关控制,不会出现在文字消息中。
122
+ > 注:音乐封面已转为独立图片发送,不再作为文字变量。其余封面图片均通过对应开关控制。
123
123
 
124
124
  ## 支持的平台 (Supported Platforms)
125
125
  | 平台名称 | 关键词识别 | 解析能力 |
@@ -157,11 +157,11 @@ This is a **multi-platform video/image parsing plugin** developed for the Koishi
157
157
 
158
158
  | 贡献者 (Contributor) | 贡献内容 (Contribution) |
159
159
  |----------------------|-------------------------|
160
- | Minecraft-1314 | 插件完整开发 |
161
- | ShiraiKuroko003 | 修复消息格式问题 |
162
- | cyavb | 自定义API KEY认证 |
163
- | Keep785 | 无法关闭发送封面 |
164
- | dzt2008 + Apricityx | 误解析修复 |
160
+ | Minecraft-1314 | 插件完整开发 (Complete plugin development) |
161
+ | ShiraiKuroko003 | 修复消息格式设置问题并且PR-1.2.5版本已修复 |
162
+ | cyavb | 提交功能建议-给自定义API添加KEY认证-已修复 |
163
+ | Keep785 | 提交Bug-无法正常关闭发送封面-已修复 |
164
+ | dzt2008 + Apricityx | 提交Bug-会对非支持视频平台URL进行误解析-已修复 |
165
165
  | JH-Ahua | BugPk-Api 支持 |
166
166
  | shangxue | 灵感来源 |
167
167