koishi-plugin-music-parser-all 0.0.7 → 0.0.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 CHANGED
@@ -34,10 +34,6 @@ export declare const Config: Schema<{
34
34
  mediaDownloadTimeout?: number | null | undefined;
35
35
  maxMediaSize?: number | null | undefined;
36
36
  downloadEngine?: "internal" | "aria2" | "downloads" | null | undefined;
37
- aria2Host?: string | null | undefined;
38
- aria2Port?: number | null | undefined;
39
- aria2Secret?: string | null | undefined;
40
- resumeDownload?: boolean | null | undefined;
41
37
  } & {
42
38
  timeout?: number | null | undefined;
43
39
  videoSendTimeout?: number | null | undefined;
@@ -135,10 +131,6 @@ export declare const Config: Schema<{
135
131
  mediaDownloadTimeout: number;
136
132
  maxMediaSize: number;
137
133
  downloadEngine: "internal" | "aria2" | "downloads";
138
- aria2Host: string;
139
- aria2Port: number;
140
- aria2Secret: string;
141
- resumeDownload: boolean;
142
134
  } & {
143
135
  timeout: number;
144
136
  videoSendTimeout: number;
@@ -230,3 +222,6 @@ export declare const Config: Schema<{
230
222
  parseErrorItemFormat: string;
231
223
  }>;
232
224
  export declare function apply(ctx: Context, config: any): void;
225
+ export declare namespace apply {
226
+ var inject: string[];
227
+ }
package/lib/index.js CHANGED
@@ -99,13 +99,9 @@ exports.Config = koishi_1.Schema.intersect([
99
99
  maxMediaSize: koishi_1.Schema.number().min(0).step(1).default(0).description('最大下载文件大小 (MB),0 为不限制'),
100
100
  downloadEngine: koishi_1.Schema.union([
101
101
  koishi_1.Schema.const('internal').description('内置下载'),
102
- koishi_1.Schema.const('aria2').description('aria2 下载'),
102
+ koishi_1.Schema.const('aria2').description('aria2 下载(需 koishi-plugin-aria2-plus)'),
103
103
  koishi_1.Schema.const('downloads').description('downloads 服务下载'),
104
104
  ]).default('internal').description('下载引擎'),
105
- aria2Host: koishi_1.Schema.string().default('127.0.0.1').description('aria2 RPC 地址'),
106
- aria2Port: koishi_1.Schema.number().default(6800).description('aria2 RPC 端口'),
107
- aria2Secret: koishi_1.Schema.string().default('').description('aria2 RPC 密钥'),
108
- resumeDownload: koishi_1.Schema.boolean().default(true).description('启用断点续传(仅 aria2 模式)'),
109
105
  }).description('性能与限制'),
110
106
  koishi_1.Schema.object({
111
107
  timeout: koishi_1.Schema.number().min(0).step(1).default(180000).description('API 请求超时 (ms)'),
@@ -503,20 +499,8 @@ function apply(ctx, config) {
503
499
  const mediaDownloadTimeout = config.mediaDownloadTimeout ?? 120000;
504
500
  const maxMediaSize = config.maxMediaSize ?? 0;
505
501
  const downloadEngine = config.downloadEngine || 'internal';
506
- let aria2 = null;
507
- if (downloadEngine === 'aria2') {
508
- try {
509
- aria2 = ctx.aria2;
510
- if (aria2) {
511
- logger.info('已获取 aria2 服务实例 (koishi-plugin-aria2-plus)');
512
- }
513
- else {
514
- logger.warn('aria2 服务不可用,将回退到内置下载');
515
- }
516
- }
517
- catch (e) {
518
- logger.warn('获取 aria2 服务失败,将回退到内置下载');
519
- }
502
+ if (downloadEngine === 'aria2' && !ctx.aria2) {
503
+ logger.warn('选择了 aria2 下载引擎,但未检测到 koishi-plugin-aria2-plus 服务,将回退到内置下载');
520
504
  }
521
505
  const customPlatforms = (config.customPlatforms || []).map((p) => ({
522
506
  name: p.name,
@@ -624,9 +608,9 @@ function apply(ctx, config) {
624
608
  debugLog('ERROR', `downloads 下载失败,回退内置下载: ${getErrorMessage(e)}`);
625
609
  }
626
610
  }
627
- else if (downloadEngine === 'aria2' && aria2 && config.resumeDownload) {
611
+ else if (downloadEngine === 'aria2' && ctx.aria2) {
628
612
  try {
629
- const gid = await aria2.addUri([url], {
613
+ const gid = await ctx.aria2.addUri([url], {
630
614
  dir: cacheDir,
631
615
  out: fileName,
632
616
  split: 4,
@@ -642,10 +626,10 @@ function apply(ctx, config) {
642
626
  const ariaStartTime = Date.now();
643
627
  while (!completed) {
644
628
  if (Date.now() - ariaStartTime > timeout) {
645
- await aria2.remove(gid).catch(() => { });
629
+ await ctx.aria2.remove(gid).catch(() => { });
646
630
  throw new Error('aria2下载超时');
647
631
  }
648
- const status = await aria2.tellStatus(gid);
632
+ const status = await ctx.aria2.tellStatus(gid);
649
633
  if (status.status === 'complete') {
650
634
  completed = true;
651
635
  }
@@ -1091,3 +1075,4 @@ function apply(ctx, config) {
1091
1075
  });
1092
1076
  debugLog('INFO', '音乐解析插件初始化完成');
1093
1077
  }
1078
+ apply.inject = ['aria2', 'downloads'];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-music-parser-all",
3
3
  "description": "Koishi 全平台音乐解析插件,支持网易云音乐/酷我音乐/QQ音乐/汽水音乐等平台",
4
- "version": "0.0.7",
4
+ "version": "0.0.9",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [