koishi-plugin-video-parser-all 1.4.0 → 1.4.1
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 +32 -31
- package/package.json +1 -1
- package/readme.md +3 -5
package/lib/index.js
CHANGED
|
@@ -796,21 +796,6 @@ function apply(ctx, config) {
|
|
|
796
796
|
return { [customHeaderName]: apiKey };
|
|
797
797
|
return {};
|
|
798
798
|
}
|
|
799
|
-
async function resolveShortUrl(url) {
|
|
800
|
-
try {
|
|
801
|
-
const res = await http.get(url, {
|
|
802
|
-
timeout: 10000,
|
|
803
|
-
maxRedirects: 10,
|
|
804
|
-
headers: { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36', 'Referer': 'https://www.baidu.com/' },
|
|
805
|
-
validateStatus: (status) => status >= 200 && status < 400,
|
|
806
|
-
});
|
|
807
|
-
const finalUrl = res.request?.res?.responseUrl || url;
|
|
808
|
-
return cleanUrl(finalUrl);
|
|
809
|
-
}
|
|
810
|
-
catch {
|
|
811
|
-
return cleanUrl(url);
|
|
812
|
-
}
|
|
813
|
-
}
|
|
814
799
|
const extRegexCache = {};
|
|
815
800
|
async function downloadFile(url, timeout, maxSize, filePrefix, fileExts) {
|
|
816
801
|
if (!url)
|
|
@@ -1163,8 +1148,22 @@ function apply(ctx, config) {
|
|
|
1163
1148
|
catch (error) {
|
|
1164
1149
|
lastError = error instanceof Error ? error : new Error(String(error));
|
|
1165
1150
|
debugLog('ERROR', `${api.label} attempt ${attempt + 1} failed: ${lastError.message}`);
|
|
1166
|
-
if (
|
|
1167
|
-
|
|
1151
|
+
if (axios_1.default.isAxiosError(error)) {
|
|
1152
|
+
if (!error.response) {
|
|
1153
|
+
if (attempt < config.retryTimes) {
|
|
1154
|
+
await delay(config.retryInterval);
|
|
1155
|
+
continue;
|
|
1156
|
+
}
|
|
1157
|
+
}
|
|
1158
|
+
const status = error.response?.status;
|
|
1159
|
+
if (status && (status >= 500 || status === 429)) {
|
|
1160
|
+
if (attempt < config.retryTimes) {
|
|
1161
|
+
await delay(config.retryInterval);
|
|
1162
|
+
continue;
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1165
|
+
}
|
|
1166
|
+
break;
|
|
1168
1167
|
}
|
|
1169
1168
|
}
|
|
1170
1169
|
debugLog('WARN', `${api.label} all retries failed`);
|
|
@@ -1172,18 +1171,16 @@ function apply(ctx, config) {
|
|
|
1172
1171
|
throw lastError || new Error('所有API请求全部失败');
|
|
1173
1172
|
}
|
|
1174
1173
|
async function parseUrl(url, type, fieldMapping, platformConf) {
|
|
1175
|
-
const
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
}
|
|
1184
|
-
|
|
1185
|
-
debugLog('ERROR', `候选链接失败: ${candidate}`, getErrorMessage(error));
|
|
1186
|
-
}
|
|
1174
|
+
const cleanedUrl = cleanUrl(url);
|
|
1175
|
+
try {
|
|
1176
|
+
const info = await fetchApi(cleanedUrl, type, fieldMapping, platformConf);
|
|
1177
|
+
if (info.video || info.images.length > 0 || info.live_photo.length > 0)
|
|
1178
|
+
return { success: true, data: info };
|
|
1179
|
+
debugLog('WARN', `解析成功但无内容: ${cleanedUrl}`);
|
|
1180
|
+
}
|
|
1181
|
+
catch (error) {
|
|
1182
|
+
debugLog('ERROR', `解析失败: ${cleanedUrl}`, getErrorMessage(error));
|
|
1183
|
+
return { success: false, msg: getErrorMessage(error) };
|
|
1187
1184
|
}
|
|
1188
1185
|
return { success: false, msg: texts.unsupportedPlatformText };
|
|
1189
1186
|
}
|
|
@@ -1300,7 +1297,8 @@ function apply(ctx, config) {
|
|
|
1300
1297
|
}
|
|
1301
1298
|
}
|
|
1302
1299
|
catch (e) {
|
|
1303
|
-
|
|
1300
|
+
if (e?.code !== 'ENOENT')
|
|
1301
|
+
debugLog('WARN', '清理临时文件失败:', e);
|
|
1304
1302
|
}
|
|
1305
1303
|
}, 3600000);
|
|
1306
1304
|
ctx.on('dispose', () => {
|
|
@@ -1322,7 +1320,10 @@ function apply(ctx, config) {
|
|
|
1322
1320
|
}
|
|
1323
1321
|
}
|
|
1324
1322
|
}
|
|
1325
|
-
catch {
|
|
1323
|
+
catch (e) {
|
|
1324
|
+
if (e?.code !== 'ENOENT')
|
|
1325
|
+
debugLog('WARN', '退出清理临时文件失败:', e);
|
|
1326
|
+
}
|
|
1326
1327
|
});
|
|
1327
1328
|
debugLog('INFO', '插件初始化完成');
|
|
1328
1329
|
}
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -49,7 +49,7 @@ This is a **multi-platform video/image parsing plugin** developed for the Koishi
|
|
|
49
49
|
| 配置项 | 类型 | 默认值 | 说明 |
|
|
50
50
|
|--------|------|--------|------|
|
|
51
51
|
| `showMusicVoice` | boolean | false | 音乐链接以语音发送 |
|
|
52
|
-
| `showMusicVoiceFile` | boolean | true |
|
|
52
|
+
| `showMusicVoiceFile` | boolean | true | 音乐链接是否以语音形式发送(关闭则只发送链接) |
|
|
53
53
|
| `forceDownloadMusicVoice` | boolean | false | 强制下载音乐语音 |
|
|
54
54
|
|
|
55
55
|
### 性能与限制
|
|
@@ -60,7 +60,7 @@ This is a **multi-platform video/image parsing plugin** developed for the Koishi
|
|
|
60
60
|
| `downloadConcurrency` | number | 3 | 下载线程数 |
|
|
61
61
|
| `mediaDownloadTimeout` | number | 120000 | 统一下载超时 (ms) |
|
|
62
62
|
| `maxMediaSize` | number | 0 | 最大下载文件大小 (MB),0 为不限制 |
|
|
63
|
-
| `downloadEngine` | string | internal | 下载引擎(internal / aria2) |
|
|
63
|
+
| `downloadEngine` | string | internal | 下载引擎(internal / aria2 / downloads) |
|
|
64
64
|
| `aria2Host` | string | 127.0.0.1 | aria2 RPC 地址 |
|
|
65
65
|
| `aria2Port` | number | 6800 | aria2 RPC 端口 |
|
|
66
66
|
| `aria2Secret` | string | | aria2 RPC 密钥 |
|
|
@@ -93,8 +93,6 @@ This is a **multi-platform video/image parsing plugin** developed for the Koishi
|
|
|
93
93
|
### API 与平台
|
|
94
94
|
| 配置项 | 类型 | 默认值 | 说明 |
|
|
95
95
|
|--------|------|--------|------|
|
|
96
|
-
| `apiKeys` | array | [] | 多 API 密钥列表 |
|
|
97
|
-
| `rotationMode` | string | sequential | 密钥轮换模式(sequential / load_balance) |
|
|
98
96
|
| `platformDedicatedFirst` | object | 全关 | 优先专属 API |
|
|
99
97
|
| `customApis` | array | [] | 覆盖内置平台 API |
|
|
100
98
|
| `customPlatforms` | array | [] | 自定义新平台 |
|
|
@@ -142,7 +140,7 @@ This is a **multi-platform video/image parsing plugin** developed for the Koishi
|
|
|
142
140
|
- 启动 RPC:`aria2c --enable-rpc --rpc-listen-all=true --rpc-allow-origin-all`
|
|
143
141
|
未满足条件时自动降级为内置下载,不影响正常使用。
|
|
144
142
|
### downloads 服务(可选)
|
|
145
|
-
|
|
143
|
+
若启用 `downloadEngine: 'downloads'`,请安装可选依赖 `koishi-plugin-downloads`,失败时回退到内置下载。
|
|
146
144
|
|
|
147
145
|
## 支持的平台 (Supported Platforms)
|
|
148
146
|
| 平台名称 | 关键词识别 | 解析能力 |
|