koishi-plugin-video-parser-all 1.3.7 → 1.3.9
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 +2 -2
- package/lib/index.js +6 -5
- package/package.json +5 -1
package/lib/index.d.ts
CHANGED
|
@@ -58,7 +58,7 @@ export declare const Config: Schema<{
|
|
|
58
58
|
downloadConcurrency?: number | null | undefined;
|
|
59
59
|
mediaDownloadTimeout?: number | null | undefined;
|
|
60
60
|
maxMediaSize?: number | null | undefined;
|
|
61
|
-
downloadEngine?: "internal" | "aria2" | null | undefined;
|
|
61
|
+
downloadEngine?: "internal" | "aria2" | "downloads" | null | undefined;
|
|
62
62
|
aria2Host?: string | null | undefined;
|
|
63
63
|
aria2Port?: number | null | undefined;
|
|
64
64
|
aria2Secret?: string | null | undefined;
|
|
@@ -205,7 +205,7 @@ export declare const Config: Schema<{
|
|
|
205
205
|
downloadConcurrency: number;
|
|
206
206
|
mediaDownloadTimeout: number;
|
|
207
207
|
maxMediaSize: number;
|
|
208
|
-
downloadEngine: "internal" | "aria2";
|
|
208
|
+
downloadEngine: "internal" | "aria2" | "downloads";
|
|
209
209
|
aria2Host: string;
|
|
210
210
|
aria2Port: number;
|
|
211
211
|
aria2Secret: string;
|
package/lib/index.js
CHANGED
|
@@ -115,7 +115,7 @@ exports.Config = koishi_1.Schema.intersect([
|
|
|
115
115
|
}).description('媒体发送'),
|
|
116
116
|
koishi_1.Schema.object({
|
|
117
117
|
showMusicVoice: koishi_1.Schema.boolean().default(false).description('音乐链接以语音形式发送'),
|
|
118
|
-
showMusicVoiceFile: koishi_1.Schema.boolean().default(true).description('
|
|
118
|
+
showMusicVoiceFile: koishi_1.Schema.boolean().default(true).description('音乐链接是否以语音形式发送(关闭则只发送链接)'),
|
|
119
119
|
forceDownloadMusicVoice: koishi_1.Schema.boolean().default(false).description('强制下载音乐语音'),
|
|
120
120
|
}).description('音乐语音(需 silk 和 ffmpeg)'),
|
|
121
121
|
koishi_1.Schema.object({
|
|
@@ -127,6 +127,7 @@ exports.Config = koishi_1.Schema.intersect([
|
|
|
127
127
|
downloadEngine: koishi_1.Schema.union([
|
|
128
128
|
koishi_1.Schema.const('internal').description('内置下载'),
|
|
129
129
|
koishi_1.Schema.const('aria2').description('aria2 下载'),
|
|
130
|
+
koishi_1.Schema.const('downloads').description('downloads 服务下载'),
|
|
130
131
|
]).default('internal').description('下载引擎'),
|
|
131
132
|
aria2Host: koishi_1.Schema.string().default('127.0.0.1').description('aria2 RPC 地址'),
|
|
132
133
|
aria2Port: koishi_1.Schema.number().default(6800).description('aria2 RPC 端口'),
|
|
@@ -810,18 +811,18 @@ function apply(ctx, config) {
|
|
|
810
811
|
return cleanUrl(url);
|
|
811
812
|
}
|
|
812
813
|
}
|
|
814
|
+
const extRegexCache = {};
|
|
813
815
|
async function downloadFile(url, timeout, maxSize, filePrefix, fileExts) {
|
|
814
816
|
if (!url)
|
|
815
817
|
throw new Error('链接为空');
|
|
816
818
|
await promises_1.default.mkdir(cacheDir, { recursive: true });
|
|
817
|
-
const extRegexCache = {};
|
|
818
819
|
const ext = fileExts.find(e => {
|
|
819
820
|
const r = extRegexCache[e] || (extRegexCache[e] = new RegExp('\\.' + e + '(\\?|$)', 'i'));
|
|
820
821
|
return r.test(url);
|
|
821
822
|
}) || fileExts[0];
|
|
822
823
|
const fileName = `${filePrefix}_${Date.now()}_${(0, crypto_1.randomBytes)(4).toString('hex')}.${ext}`;
|
|
823
824
|
const filePath = path_1.default.resolve(cacheDir, fileName);
|
|
824
|
-
if (ctx.downloads) {
|
|
825
|
+
if (downloadEngine === 'downloads' && ctx.downloads) {
|
|
825
826
|
try {
|
|
826
827
|
const dest = await ctx.downloads.download(url, path_1.default.join(cacheDir, fileName), {
|
|
827
828
|
headers: { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36' },
|
|
@@ -835,10 +836,10 @@ function apply(ctx, config) {
|
|
|
835
836
|
return dest;
|
|
836
837
|
}
|
|
837
838
|
catch (e) {
|
|
838
|
-
debugLog('ERROR', `downloads
|
|
839
|
+
debugLog('ERROR', `downloads 服务下载失败,回退内置下载: ${getErrorMessage(e)}`);
|
|
839
840
|
}
|
|
840
841
|
}
|
|
841
|
-
if (aria2 && config.resumeDownload) {
|
|
842
|
+
else if (downloadEngine === 'aria2' && aria2 && config.resumeDownload) {
|
|
842
843
|
try {
|
|
843
844
|
const gid = await aria2.call('aria2.addUri', [url], {
|
|
844
845
|
dir: cacheDir,
|
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.
|
|
4
|
+
"version": "1.3.9",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
7
7
|
"files": [
|
|
@@ -98,11 +98,15 @@
|
|
|
98
98
|
"peerDependencies": {
|
|
99
99
|
"@koishijs/plugin-console": "^5.30.4",
|
|
100
100
|
"koishi": "^4.18.7",
|
|
101
|
+
"koishi-plugin-downloads": "^1.0.0",
|
|
101
102
|
"koishi-plugin-silk": "^1.0.0",
|
|
102
103
|
"koishi-plugin-ffmpeg": "^1.0.0",
|
|
103
104
|
"aria2": "^4.1.2"
|
|
104
105
|
},
|
|
105
106
|
"peerDependenciesMeta": {
|
|
107
|
+
"koishi-plugin-downloads": {
|
|
108
|
+
"optional": true
|
|
109
|
+
},
|
|
106
110
|
"koishi-plugin-silk": {
|
|
107
111
|
"optional": true
|
|
108
112
|
},
|