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.
- package/lib/index.js +12 -20
- package/package.json +1 -1
- 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
|
|
157
|
-
const
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
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
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 |
|
|
60
|
-
| `customApis` | array | [] | 自定义平台专属 API
|
|
59
|
+
| `useDedicatedApiFirst` | boolean | false | 全局默认值:是否优先使用平台专属 API,各平台可单独覆盖该行为 |
|
|
60
|
+
| `customApis` | array | [] | 自定义平台专属 API 列表。每项包含:`platform`(平台类型)、`apiUrl`(API 地址)、`useDedicatedFirst`(该平台是否优先使用此专属 API)。可覆盖内置默认专属 API,并独立控制专属 API 的优先策略 |
|
|
61
61
|
|
|
62
62
|
### 错误与重试设置
|
|
63
63
|
| 配置项 | 类型 | 默认值 | 说明 |
|