koishi-plugin-music-parser-all 0.0.4 → 0.0.5

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
@@ -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 = "music-parser-all";
package/lib/index.js CHANGED
@@ -506,19 +506,16 @@ function apply(ctx, config) {
506
506
  let aria2 = null;
507
507
  if (downloadEngine === 'aria2') {
508
508
  try {
509
- const Aria2 = require('aria2');
510
- aria2 = new Aria2({
511
- host: config.aria2Host || '127.0.0.1',
512
- port: config.aria2Port || 6800,
513
- secure: false,
514
- secret: config.aria2Secret || '',
515
- path: '/jsonrpc'
516
- });
517
- aria2.open();
518
- logger.info('aria2 连接成功');
509
+ aria2 = ctx.aria2;
510
+ if (aria2) {
511
+ logger.info('已获取 aria2 服务实例 (koishi-plugin-aria2-plus)');
512
+ }
513
+ else {
514
+ logger.warn('aria2 服务不可用,将回退到内置下载');
515
+ }
519
516
  }
520
517
  catch (e) {
521
- logger.warn('aria2 连接失败,回退到内置下载');
518
+ logger.warn('获取 aria2 服务失败,将回退到内置下载');
522
519
  }
523
520
  }
524
521
  const customPlatforms = (config.customPlatforms || []).map((p) => ({
@@ -629,7 +626,7 @@ function apply(ctx, config) {
629
626
  }
630
627
  else if (downloadEngine === 'aria2' && aria2 && config.resumeDownload) {
631
628
  try {
632
- const gid = await aria2.call('aria2.addUri', [url], {
629
+ const gid = await aria2.addUri([url], {
633
630
  dir: cacheDir,
634
631
  out: fileName,
635
632
  split: 4,
@@ -645,10 +642,10 @@ function apply(ctx, config) {
645
642
  const ariaStartTime = Date.now();
646
643
  while (!completed) {
647
644
  if (Date.now() - ariaStartTime > timeout) {
648
- await aria2.call('aria2.remove', gid).catch(() => { });
645
+ await aria2.remove(gid).catch(() => { });
649
646
  throw new Error('aria2下载超时');
650
647
  }
651
- const status = await aria2.call('aria2.tellStatus', gid);
648
+ const status = await aria2.tellStatus(gid);
652
649
  if (status.status === 'complete') {
653
650
  completed = true;
654
651
  }
@@ -1073,8 +1070,6 @@ function apply(ctx, config) {
1073
1070
  }, 3600000);
1074
1071
  ctx.on('dispose', () => {
1075
1072
  clearInterval(tempCleanupInterval);
1076
- if (aria2)
1077
- aria2.close();
1078
1073
  urlCacheLocal.clear();
1079
1074
  dedupCache.clear();
1080
1075
  debugLog('INFO', '音乐解析插件已卸载');
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.4",
4
+ "version": "0.0.5",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [
@@ -46,7 +46,7 @@
46
46
  "koishi-plugin-downloads": "^1.0.0",
47
47
  "koishi-plugin-silk": "^1.0.0",
48
48
  "koishi-plugin-ffmpeg": "^1.0.0",
49
- "aria2": "^4.1.2"
49
+ "koishi-plugin-aria2-plus": "^1.0.0"
50
50
  },
51
51
  "peerDependenciesMeta": {
52
52
  "koishi-plugin-downloads": {
@@ -58,7 +58,7 @@
58
58
  "koishi-plugin-ffmpeg": {
59
59
  "optional": true
60
60
  },
61
- "aria2": {
61
+ "koishi-plugin-aria2-plus": {
62
62
  "optional": true
63
63
  }
64
64
  },