koishi-plugin-video-parser-all 1.0.9 → 1.1.0

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 +12 -20
  2. package/package.json +1 -1
  3. package/readme.md +2 -2
package/lib/index.js CHANGED
@@ -153,16 +153,12 @@ function linkTypeParser(content) {
153
153
  }
154
154
  function extractAllUrlsFromMessage(session) {
155
155
  const content = session.content?.trim() || '';
156
- const rawUrls = [];
157
- const textMatch = content.match(/https?:\/\/[^\s<>"'(){}[\]]+/gi);
158
- if (textMatch)
159
- rawUrls.push(...textMatch);
156
+ const matchedLinks = linkTypeParser(content);
157
+ const cardsContent = [];
160
158
  if (session.elements) {
161
159
  for (const elem of session.elements) {
162
160
  if (elem.type === 'xml' && elem.data) {
163
- const matches = elem.data.match(/https?:\/\/[^\s<>"'(){}[\]]+/gi);
164
- if (matches)
165
- rawUrls.push(...matches);
161
+ cardsContent.push(elem.data);
166
162
  }
167
163
  else if (elem.type === 'json' && elem.data) {
168
164
  try {
@@ -172,9 +168,7 @@ function extractAllUrlsFromMessage(session) {
172
168
  return;
173
169
  for (const val of Object.values(obj)) {
174
170
  if (typeof val === 'string') {
175
- const matches = val.match(/https?:\/\/[^\s<>"'(){}[\]]+/gi);
176
- if (matches)
177
- rawUrls.push(...matches);
171
+ cardsContent.push(val);
178
172
  }
179
173
  else if (typeof val === 'object')
180
174
  extract(val);
@@ -186,18 +180,16 @@ function extractAllUrlsFromMessage(session) {
186
180
  }
187
181
  }
188
182
  }
183
+ for (const cardContent of cardsContent) {
184
+ const cardLinks = linkTypeParser(cardContent);
185
+ matchedLinks.push(...cardLinks);
186
+ }
189
187
  const seen = new Set();
190
188
  const result = [];
191
- for (const rawUrl of rawUrls) {
192
- const cleanedUrl = rawUrl.replace(/&amp;/g, '&').replace(/[.,;:!?)]+$/, '');
193
- if (seen.has(cleanedUrl))
194
- continue;
195
- const matches = linkTypeParser(cleanedUrl);
196
- for (const match of matches) {
197
- if (!seen.has(match.url)) {
198
- seen.add(match.url);
199
- result.push(match);
200
- }
189
+ for (const link of matchedLinks) {
190
+ if (!seen.has(link.url)) {
191
+ seen.add(link.url);
192
+ result.push(link);
201
193
  }
202
194
  }
203
195
  return result;
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.9",
4
+ "version": "1.1.0",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [
package/readme.md CHANGED
@@ -56,8 +56,8 @@ This is a **multi-platform video/image parsing plugin** developed for the Koishi
56
56
  |--------|------|--------|------|
57
57
  | `primaryApiUrl` | string | `https://api.bugpk.com/api/short_videos` | 主 API 地址,解析时优先使用 |
58
58
  | `backupApiUrl` | string | `https://api.bugpk.com/api/svparse` | 备用主 API 地址,仅支持抖音、小红书、Instagram、即梦平台解析 |
59
- | `useDedicatedApiFirst` | boolean | false | 是否优先使用平台专属 API,失败后依次回退到主 API、备用主 API |
60
- | `customApis` | array | [] | 自定义平台专属 API 列表,每项需选择平台并填写 API 地址,可覆盖内置的默认专属 API |
59
+ | `useDedicatedApiFirst` | boolean | false | 全局默认值:是否优先使用平台专属 API,各平台可单独覆盖该行为 |
60
+ | `customApis` | array | [] | 自定义平台专属 API 列表。每项包含:`platform`(平台类型)、`apiUrl`(API 地址)、`useDedicatedFirst`(该平台是否优先使用此专属 API)。可覆盖内置默认专属 API,并独立控制专属 API 的优先策略 |
61
61
 
62
62
  ### 错误与重试设置
63
63
  | 配置项 | 类型 | 默认值 | 说明 |