koishi-plugin-video-parser-all 1.4.5 → 1.4.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.
- package/lib/index.d.ts +1 -8
- package/lib/index.js +7 -28
- package/package.json +3 -3
- package/readme.md +1 -9
package/lib/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ declare module 'koishi' {
|
|
|
4
4
|
downloads?: {
|
|
5
5
|
download(url: string, dest: string, options?: Record<string, unknown>): Promise<string>;
|
|
6
6
|
};
|
|
7
|
+
aria2?: any;
|
|
7
8
|
}
|
|
8
9
|
}
|
|
9
10
|
export declare const name = "video-parser-all";
|
|
@@ -60,10 +61,6 @@ export declare const Config: Schema<{
|
|
|
60
61
|
mediaDownloadTimeout?: number | null | undefined;
|
|
61
62
|
maxMediaSize?: number | null | undefined;
|
|
62
63
|
downloadEngine?: "internal" | "aria2" | "downloads" | null | undefined;
|
|
63
|
-
aria2Host?: string | null | undefined;
|
|
64
|
-
aria2Port?: number | null | undefined;
|
|
65
|
-
aria2Secret?: string | null | undefined;
|
|
66
|
-
resumeDownload?: boolean | null | undefined;
|
|
67
64
|
} & {
|
|
68
65
|
timeout?: number | null | undefined;
|
|
69
66
|
videoSendTimeout?: number | null | undefined;
|
|
@@ -209,10 +206,6 @@ export declare const Config: Schema<{
|
|
|
209
206
|
mediaDownloadTimeout: number;
|
|
210
207
|
maxMediaSize: number;
|
|
211
208
|
downloadEngine: "internal" | "aria2" | "downloads";
|
|
212
|
-
aria2Host: string;
|
|
213
|
-
aria2Port: number;
|
|
214
|
-
aria2Secret: string;
|
|
215
|
-
resumeDownload: boolean;
|
|
216
209
|
} & {
|
|
217
210
|
timeout: number;
|
|
218
211
|
videoSendTimeout: number;
|
package/lib/index.js
CHANGED
|
@@ -127,13 +127,9 @@ exports.Config = koishi_1.Schema.intersect([
|
|
|
127
127
|
maxMediaSize: koishi_1.Schema.number().min(0).step(1).default(0).description('最大下载文件大小 (MB),0 为不限制'),
|
|
128
128
|
downloadEngine: koishi_1.Schema.union([
|
|
129
129
|
koishi_1.Schema.const('internal').description('内置下载'),
|
|
130
|
-
koishi_1.Schema.const('aria2').description('aria2
|
|
130
|
+
koishi_1.Schema.const('aria2').description('aria2 下载(需 koishi-plugin-aria2-plus)'),
|
|
131
131
|
koishi_1.Schema.const('downloads').description('downloads 服务下载'),
|
|
132
132
|
]).default('internal').description('下载引擎'),
|
|
133
|
-
aria2Host: koishi_1.Schema.string().default('127.0.0.1').description('aria2 RPC 地址'),
|
|
134
|
-
aria2Port: koishi_1.Schema.number().default(6800).description('aria2 RPC 端口'),
|
|
135
|
-
aria2Secret: koishi_1.Schema.string().default('').description('aria2 RPC 密钥'),
|
|
136
|
-
resumeDownload: koishi_1.Schema.boolean().default(true).description('启用断点续传(仅 aria2 模式)'),
|
|
137
133
|
}).description('性能与限制'),
|
|
138
134
|
koishi_1.Schema.object({
|
|
139
135
|
timeout: koishi_1.Schema.number().min(0).step(1).default(180000).description('API 请求超时 (ms)'),
|
|
@@ -740,23 +736,8 @@ function apply(ctx, config) {
|
|
|
740
736
|
const mediaDownloadTimeout = config.mediaDownloadTimeout ?? 120000;
|
|
741
737
|
const maxMediaSize = config.maxMediaSize ?? 0;
|
|
742
738
|
const downloadEngine = config.downloadEngine || 'internal';
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
try {
|
|
746
|
-
const Aria2 = require('aria2');
|
|
747
|
-
aria2 = new Aria2({
|
|
748
|
-
host: config.aria2Host || '127.0.0.1',
|
|
749
|
-
port: config.aria2Port || 6800,
|
|
750
|
-
secure: false,
|
|
751
|
-
secret: config.aria2Secret || '',
|
|
752
|
-
path: '/jsonrpc'
|
|
753
|
-
});
|
|
754
|
-
aria2.open();
|
|
755
|
-
logger.info('aria2 连接成功');
|
|
756
|
-
}
|
|
757
|
-
catch (e) {
|
|
758
|
-
logger.warn('aria2 连接失败,回退到内置下载');
|
|
759
|
-
}
|
|
739
|
+
if (downloadEngine === 'aria2' && !ctx.aria2) {
|
|
740
|
+
logger.warn('选择了 aria2 下载引擎,但未检测到 koishi-plugin-aria2-plus 服务,将回退到内置下载');
|
|
760
741
|
}
|
|
761
742
|
function getPlatformConfig(type) {
|
|
762
743
|
if (type.startsWith('custom_')) {
|
|
@@ -852,9 +833,9 @@ function apply(ctx, config) {
|
|
|
852
833
|
debugLog('ERROR', `downloads 服务下载失败,回退内置下载: ${getErrorMessage(e)}`);
|
|
853
834
|
}
|
|
854
835
|
}
|
|
855
|
-
else if (downloadEngine === 'aria2' && aria2
|
|
836
|
+
else if (downloadEngine === 'aria2' && ctx.aria2) {
|
|
856
837
|
try {
|
|
857
|
-
const gid = await
|
|
838
|
+
const gid = await ctx.aria2.addUri([url], {
|
|
858
839
|
dir: cacheDir,
|
|
859
840
|
out: fileName,
|
|
860
841
|
split: 4,
|
|
@@ -870,10 +851,10 @@ function apply(ctx, config) {
|
|
|
870
851
|
const ariaStartTime = Date.now();
|
|
871
852
|
while (!completed) {
|
|
872
853
|
if (Date.now() - ariaStartTime > timeout) {
|
|
873
|
-
await
|
|
854
|
+
await ctx.aria2.remove(gid).catch(() => { });
|
|
874
855
|
throw new Error('aria2下载超时');
|
|
875
856
|
}
|
|
876
|
-
const status = await
|
|
857
|
+
const status = await ctx.aria2.tellStatus(gid);
|
|
877
858
|
if (status.status === 'complete') {
|
|
878
859
|
completed = true;
|
|
879
860
|
}
|
|
@@ -1339,8 +1320,6 @@ function apply(ctx, config) {
|
|
|
1339
1320
|
}, 3600000);
|
|
1340
1321
|
ctx.on('dispose', () => {
|
|
1341
1322
|
clearInterval(tempCleanupInterval);
|
|
1342
|
-
if (aria2)
|
|
1343
|
-
aria2.close();
|
|
1344
1323
|
urlCacheLocal.clear();
|
|
1345
1324
|
dedupCache.clear();
|
|
1346
1325
|
debugLog('INFO', '插件已卸载');
|
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.4.
|
|
4
|
+
"version": "1.4.6",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
7
7
|
"files": [
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
"koishi-plugin-downloads": "^1.0.0",
|
|
102
102
|
"koishi-plugin-silk": "^1.0.0",
|
|
103
103
|
"koishi-plugin-ffmpeg": "^1.0.0",
|
|
104
|
-
"aria2": "^
|
|
104
|
+
"koishi-plugin-aria2-plus": "^1.0.0"
|
|
105
105
|
},
|
|
106
106
|
"peerDependenciesMeta": {
|
|
107
107
|
"koishi-plugin-downloads": {
|
|
@@ -113,7 +113,7 @@
|
|
|
113
113
|
"koishi-plugin-ffmpeg": {
|
|
114
114
|
"optional": true
|
|
115
115
|
},
|
|
116
|
-
"aria2": {
|
|
116
|
+
"koishi-plugin-aria2-plus": {
|
|
117
117
|
"optional": true
|
|
118
118
|
}
|
|
119
119
|
},
|
package/readme.md
CHANGED
|
@@ -61,10 +61,6 @@ This is a **multi-platform video/image parsing plugin** developed for the Koishi
|
|
|
61
61
|
| `mediaDownloadTimeout` | number | 120000 | 统一下载超时 (ms) |
|
|
62
62
|
| `maxMediaSize` | number | 0 | 最大下载文件大小 (MB),0 为不限制 |
|
|
63
63
|
| `downloadEngine` | string | internal | 下载引擎(internal / aria2 / downloads) |
|
|
64
|
-
| `aria2Host` | string | 127.0.0.1 | aria2 RPC 地址 |
|
|
65
|
-
| `aria2Port` | number | 6800 | aria2 RPC 端口 |
|
|
66
|
-
| `aria2Secret` | string | | aria2 RPC 密钥 |
|
|
67
|
-
| `resumeDownload` | boolean | true | 启用断点续传(仅 aria2) |
|
|
68
64
|
|
|
69
65
|
### 网络与请求
|
|
70
66
|
| 配置项 | 类型 | 默认值 | 说明 |
|
|
@@ -134,11 +130,7 @@ This is a **multi-platform video/image parsing plugin** developed for the Koishi
|
|
|
134
130
|
- `koishi-plugin-silk`:silk 编解码
|
|
135
131
|
- `koishi-plugin-ffmpeg`:音频重采样
|
|
136
132
|
### aria2 下载引擎(可选)
|
|
137
|
-
若启用 `downloadEngine: 'aria2'
|
|
138
|
-
- 安装 aria2 服务端:https://github.com/aria2/aria2
|
|
139
|
-
- 安装 npm 客户端:`npm install aria2`
|
|
140
|
-
- 启动 RPC:`aria2c --enable-rpc --rpc-listen-all=true --rpc-allow-origin-all`
|
|
141
|
-
未满足条件时自动降级为内置下载,不影响正常使用。
|
|
133
|
+
若启用 `downloadEngine: 'aria2'`,请安装可选依赖 `koishi-plugin-aria2-plus` 并配置该插件连接 aria2 服务。插件启动时会自动检测该服务,未安装或不可用时将降级为内置下载,不影响正常使用。
|
|
142
134
|
### downloads 服务(可选)
|
|
143
135
|
若启用 `downloadEngine: 'downloads'`,请安装可选依赖 `koishi-plugin-downloads`,失败时回退到内置下载。
|
|
144
136
|
|