bililive-cli 3.19.0 → 3.21.0

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.
@@ -1,40 +1,40 @@
1
1
  'use strict';
2
2
 
3
3
  var path$3 = require('node:path');
4
- var require$$2$1 = require('node:http');
5
- var require$$0$4 = require('node:url');
6
- var a$1 = require('node:https');
7
- var index$1 = require('./index-CApcEp1I.cjs');
8
- var require$$0$6 = require('tty');
9
- var require$$1$3 = require('util');
10
- var require$$0$c = require('assert');
11
- var require$$0$8 = require('path');
12
- var require$$0$7 = require('buffer');
13
- var require$$0$5 = require('events');
14
- var require$$0$9 = require('fs');
15
- var require$$0$a = require('stream');
4
+ var http$4 = require('node:http');
5
+ var urlLib = require('node:url');
6
+ var https = require('node:https');
7
+ var index$1 = require('./index-BC-o_4nM.cjs');
8
+ var require$$0$5 = require('tty');
9
+ var require$$1$4 = require('util');
10
+ var require$$0$b = require('assert');
11
+ var require$$0$7 = require('path');
12
+ var require$$0$6 = require('buffer');
13
+ var require$$0$4 = require('events');
14
+ var require$$0$8 = require('fs');
15
+ var require$$0$9 = require('stream');
16
16
  var zlib$1 = require('zlib');
17
- var require$$0$b = require('url');
18
- var require$$1$2 = require('crypto');
19
- var require$$3$1 = require('http');
20
- var require$$0$d = require('net');
17
+ var require$$0$a = require('url');
18
+ var require$$1$3 = require('crypto');
19
+ var require$$1$2 = require('http');
20
+ var require$$4$1 = require('net');
21
21
  var require$$5$1 = require('querystring');
22
22
  var require$$17 = require('async_hooks');
23
- var require$$1$4 = require('string_decoder');
23
+ var require$$1$5 = require('string_decoder');
24
24
  var os$1 = require('node:os');
25
- var require$$1$5 = require('os');
25
+ var require$$1$6 = require('os');
26
26
  var require$$1$1 = require('node:child_process');
27
27
  var crypto$3 = require('node:crypto');
28
28
  var fs$6 = require('node:fs');
29
+ require('node:module');
29
30
  var EventEmitter$4 = require('node:events');
30
- require('ntsuspend');
31
31
  require('node:readline');
32
32
  require('@napi-rs/canvas');
33
33
  require('better-sqlite3');
34
34
  var musicSegmentDetector = require('music-segment-detector');
35
- var require$$0$e = require('child_process');
36
- var require$$1$6 = require('https');
37
- var require$$0$f = require('node:stream');
35
+ var require$$0$c = require('child_process');
36
+ var require$$1$7 = require('https');
37
+ var require$$0$d = require('node:stream');
38
38
  var web = require('node:stream/web');
39
39
  var shazamioCore = require('shazamio-core');
40
40
 
@@ -1183,8 +1183,8 @@ class Alist extends index$1.TypedEmitter {
1183
1183
  this.emit("canceled", "上传已取消");
1184
1184
  },
1185
1185
  };
1186
- const url = new require$$0$4.URL(combineURLs(this.server, "/api/fs/put"));
1187
- const httpModule = url.protocol === "https:" ? a$1 : require$$2$1;
1186
+ const url = new urlLib.URL(combineURLs(this.server, "/api/fs/put"));
1187
+ const httpModule = url.protocol === "https:" ? https : http$4;
1188
1188
  try {
1189
1189
  await new Promise((resolve, reject) => {
1190
1190
  req = httpModule.request({
@@ -1542,9 +1542,9 @@ var subprotocol$1 = { parse: parse$h };
1542
1542
 
1543
1543
  /* eslint no-unused-vars: ["error", { "varsIgnorePattern": "^Duplex$", "caughtErrors": "none" }] */
1544
1544
 
1545
- const EventEmitter$3 = require$$0$5;
1546
- const http$3 = require$$3$1;
1547
- const { createHash } = require$$1$2;
1545
+ const EventEmitter$3 = require$$0$4;
1546
+ const http$3 = require$$1$2;
1547
+ const { createHash } = require$$1$3;
1548
1548
 
1549
1549
  const extension = index$1.extension;
1550
1550
  const PerMessageDeflate = index$1.permessageDeflate;
@@ -2698,8 +2698,8 @@ function requireNode$1 () {
2698
2698
  if (hasRequiredNode$1) return node$1.exports;
2699
2699
  hasRequiredNode$1 = 1;
2700
2700
  (function (module, exports) {
2701
- const tty = require$$0$6;
2702
- const util = require$$1$3;
2701
+ const tty = require$$0$5;
2702
+ const util = require$$1$4;
2703
2703
 
2704
2704
  /**
2705
2705
  * This is the Node.js implementation of `debug()`.
@@ -3315,7 +3315,7 @@ var safeBuffer = {exports: {}};
3315
3315
 
3316
3316
  (function (module, exports) {
3317
3317
  /* eslint-disable node/no-deprecated-api */
3318
- var buffer = require$$0$7;
3318
+ var buffer = require$$0$6;
3319
3319
  var Buffer = buffer.Buffer;
3320
3320
 
3321
3321
  // alternative to using Object.keys for old browsers
@@ -3401,7 +3401,7 @@ contentDisposition$1.exports.parse = parse$g;
3401
3401
  * @private
3402
3402
  */
3403
3403
 
3404
- var basename$2 = require$$0$8.basename;
3404
+ var basename$2 = require$$0$7.basename;
3405
3405
  var Buffer$2 = safeBufferExports.Buffer;
3406
3406
 
3407
3407
  /**
@@ -4776,9 +4776,9 @@ function status$1 (code) {
4776
4776
  * @private
4777
4777
  */
4778
4778
 
4779
- var EventEmitter$2 = require$$0$5.EventEmitter;
4780
- var ReadStream = require$$0$9.ReadStream;
4781
- var Stream$3 = require$$0$a;
4779
+ var EventEmitter$2 = require$$0$4.EventEmitter;
4780
+ var ReadStream = require$$0$8.ReadStream;
4781
+ var Stream$3 = require$$0$9;
4782
4782
  var Zlib = zlib$1;
4783
4783
 
4784
4784
  /**
@@ -5206,14 +5206,14 @@ function encodeUrl (url) {
5206
5206
  const typeis = typeIsExports.is;
5207
5207
  const statuses = statuses$2;
5208
5208
  const destroy = destroy_1$2;
5209
- const assert = require$$0$c;
5210
- const extname = require$$0$8.extname;
5209
+ const assert = require$$0$b;
5210
+ const extname = require$$0$7.extname;
5211
5211
  const vary = varyExports;
5212
5212
  const only = only$1;
5213
- const util = require$$1$3;
5213
+ const util = require$$1$4;
5214
5214
  const encodeUrl = encodeurl;
5215
- const Stream = require$$0$a;
5216
- const URL = require$$0$b.URL;
5215
+ const Stream = require$$0$9;
5216
+ const URL = require$$0$a.URL;
5217
5217
 
5218
5218
  /**
5219
5219
  * Prototype.
@@ -5996,7 +5996,7 @@ function requireEventListenerCount () {
5996
5996
  * @private
5997
5997
  */
5998
5998
 
5999
- var EventEmitter = require$$0$5.EventEmitter;
5999
+ var EventEmitter = require$$0$4.EventEmitter;
6000
6000
 
6001
6001
  /**
6002
6002
  * Module exports.
@@ -6078,7 +6078,7 @@ var compatExports = compat.exports;
6078
6078
 
6079
6079
  var callSiteToString = compatExports.callSiteToString;
6080
6080
  var eventListenerCount = compatExports.eventListenerCount;
6081
- var relative$1 = require$$0$8.relative;
6081
+ var relative$1 = require$$0$7.relative;
6082
6082
 
6083
6083
  /**
6084
6084
  * Module exports.
@@ -7252,7 +7252,7 @@ Delegator.prototype.fluent = function (name) {
7252
7252
  * Module dependencies.
7253
7253
  */
7254
7254
 
7255
- var relative = require$$0$8.relative;
7255
+ var relative = require$$0$7.relative;
7256
7256
 
7257
7257
  /**
7258
7258
  * Module exports.
@@ -7787,7 +7787,7 @@ function DeprecationError (namespace, message, stack) {
7787
7787
  // https://github.com/nodejs/node/issues/3043
7788
7788
  // https://github.com/nodejs/node/pull/3073
7789
7789
 
7790
- var crypto$2 = require$$1$2;
7790
+ var crypto$2 = require$$1$3;
7791
7791
 
7792
7792
  function bufferEqual(a, b) {
7793
7793
  if (a.length !== b.length) {
@@ -7825,7 +7825,7 @@ var lib$8 = timeSafeCompare;
7825
7825
  */
7826
7826
 
7827
7827
  var compare$c = lib$8;
7828
- var crypto$1 = require$$1$2;
7828
+ var crypto$1 = require$$1$3;
7829
7829
 
7830
7830
  function Keygrip$1(keys, algorithm, encoding) {
7831
7831
  if (!algorithm) algorithm = "sha1";
@@ -7877,7 +7877,7 @@ var keygrip = Keygrip$1;
7877
7877
 
7878
7878
  var deprecate$2 = depd_1('cookies');
7879
7879
  var Keygrip = keygrip;
7880
- var http$2 = require$$3$1;
7880
+ var http$2 = require$$1$2;
7881
7881
 
7882
7882
  /**
7883
7883
  * RegExp to match field-content in RFC 7230 sec 3.2
@@ -8163,7 +8163,7 @@ var cookies = Cookies;
8163
8163
  * Module dependencies.
8164
8164
  */
8165
8165
 
8166
- const util = require$$1$3;
8166
+ const util = require$$1$4;
8167
8167
  const createError = httpErrorsExports$1;
8168
8168
  const httpAssert$1 = httpAssert;
8169
8169
  const delegate = delegates;
@@ -9811,7 +9811,7 @@ var parseurl$1 = {exports: {}};
9811
9811
  * @private
9812
9812
  */
9813
9813
 
9814
- var url = require$$0$b;
9814
+ var url = require$$0$a;
9815
9815
  var parse$c = url.parse;
9816
9816
  var Url = url.Url;
9817
9817
 
@@ -10098,17 +10098,17 @@ function parseTokenList (str) {
10098
10098
  * Module dependencies.
10099
10099
  */
10100
10100
 
10101
- const URL = require$$0$b.URL;
10102
- const net = require$$0$d;
10101
+ const URL = require$$0$a.URL;
10102
+ const net = require$$4$1;
10103
10103
  const accepts$1 = accepts;
10104
10104
  const contentType$1 = contentType;
10105
- const stringify = require$$0$b.format;
10105
+ const stringify = require$$0$a.format;
10106
10106
  const parse = parseurlExports;
10107
10107
  const qs = require$$5$1;
10108
10108
  const typeis = typeIsExports;
10109
10109
  const fresh = fresh_1;
10110
10110
  const only = only$1;
10111
- const util = require$$1$3;
10111
+ const util = require$$1$4;
10112
10112
 
10113
10113
  const IP = Symbol('context#ip');
10114
10114
 
@@ -11169,16 +11169,16 @@ convert$1.back = function (mw) {
11169
11169
  const isGeneratorFunction = isGeneratorFunction$2;
11170
11170
  const debug$5 = srcExports('koa:application');
11171
11171
  const onFinished = onFinishedExports;
11172
- const assert = require$$0$c;
11172
+ const assert = require$$0$b;
11173
11173
  const response = responseExports;
11174
11174
  const compose$1 = koaCompose;
11175
11175
  const context = contextExports;
11176
11176
  const request = requestExports;
11177
11177
  const statuses$1 = statuses$2;
11178
- const Emitter = require$$0$5;
11179
- const util$3 = require$$1$3;
11180
- const Stream$2 = require$$0$a;
11181
- const http$1 = require$$3$1;
11178
+ const Emitter = require$$0$4;
11179
+ const util$3 = require$$1$4;
11180
+ const Stream$2 = require$$0$9;
11181
+ const http$1 = require$$1$2;
11182
11182
  const only = only$1;
11183
11183
  const convert = koaConvert;
11184
11184
  const deprecate$1 = depd_1('koa');
@@ -12393,7 +12393,7 @@ function isNextNameSafe(token) {
12393
12393
  return !ID_CONTINUE.test(token.value[0]);
12394
12394
  }
12395
12395
 
12396
- const { parse: parseUrl, format: formatUrl } = require$$0$4;
12396
+ const { parse: parseUrl, format: formatUrl } = urlLib;
12397
12397
 
12398
12398
  const { pathToRegexp: pathToRegexp$1, compile, parse: parse$a } = dist$1;
12399
12399
 
@@ -12663,7 +12663,7 @@ function safeDecodeURIComponent(text) {
12663
12663
  * @link https://github.com/alexmingoia/koa-router
12664
12664
  */
12665
12665
 
12666
- const http = require$$2$1;
12666
+ const http = http$4;
12667
12667
 
12668
12668
  const debug$4 = index$1.srcExports('koa-router');
12669
12669
 
@@ -13844,7 +13844,7 @@ var lib$7 = {exports: {}};
13844
13844
 
13845
13845
  /* eslint-disable node/no-deprecated-api */
13846
13846
 
13847
- var buffer$1 = require$$0$7;
13847
+ var buffer$1 = require$$0$6;
13848
13848
  var Buffer$1 = buffer$1.Buffer;
13849
13849
 
13850
13850
  var safer = {};
@@ -14025,7 +14025,7 @@ function requireInternal () {
14025
14025
  //------------------------------------------------------------------------------
14026
14026
 
14027
14027
  // We use node.js internal decoder. Its signature is the same as ours.
14028
- var StringDecoder = require$$1$4.StringDecoder;
14028
+ var StringDecoder = require$$1$5.StringDecoder;
14029
14029
 
14030
14030
  if (!StringDecoder.prototype.end) // Node v0.8 doesn't have this method.
14031
14031
  StringDecoder.prototype.end = function() {};
@@ -24426,8 +24426,8 @@ function requireStreams () {
24426
24426
  if (hasRequiredStreams) return streams;
24427
24427
  hasRequiredStreams = 1;
24428
24428
 
24429
- var Buffer = require$$0$7.Buffer,
24430
- Transform = require$$0$a.Transform;
24429
+ var Buffer = require$$0$6.Buffer,
24430
+ Transform = require$$0$9.Transform;
24431
24431
 
24432
24432
 
24433
24433
  // == Exports ==================================================================
@@ -24553,7 +24553,7 @@ var hasRequiredExtendNode;
24553
24553
  function requireExtendNode () {
24554
24554
  if (hasRequiredExtendNode) return extendNode;
24555
24555
  hasRequiredExtendNode = 1;
24556
- var Buffer = require$$0$7.Buffer;
24556
+ var Buffer = require$$0$6.Buffer;
24557
24557
  // Note: not polyfilled with safer-buffer on a purpose, as overrides Buffer
24558
24558
 
24559
24559
  // == Extend Node primitives to use iconv-lite =================================
@@ -24586,7 +24586,7 @@ function requireExtendNode () {
24586
24586
  };
24587
24587
 
24588
24588
  // -- SlowBuffer -----------------------------------------------------------
24589
- var SlowBuffer = require$$0$7.SlowBuffer;
24589
+ var SlowBuffer = require$$0$6.SlowBuffer;
24590
24590
 
24591
24591
  original.SlowBufferToString = SlowBuffer.prototype.toString;
24592
24592
  SlowBuffer.prototype.toString = function(encoding, start, end) {
@@ -24726,7 +24726,7 @@ function requireExtendNode () {
24726
24726
 
24727
24727
  // -- Readable -------------------------------------------------------------
24728
24728
  if (iconv.supportsStreams) {
24729
- var Readable = require$$0$a.Readable;
24729
+ var Readable = require$$0$9.Readable;
24730
24730
 
24731
24731
  original.ReadableSetEncoding = Readable.prototype.setEncoding;
24732
24732
  Readable.prototype.setEncoding = function setEncoding(enc, options) {
@@ -24749,7 +24749,7 @@ function requireExtendNode () {
24749
24749
 
24750
24750
  delete Buffer.isNativeEncoding;
24751
24751
 
24752
- var SlowBuffer = require$$0$7.SlowBuffer;
24752
+ var SlowBuffer = require$$0$6.SlowBuffer;
24753
24753
 
24754
24754
  SlowBuffer.prototype.toString = original.SlowBufferToString;
24755
24755
  SlowBuffer.prototype.write = original.SlowBufferWrite;
@@ -24760,7 +24760,7 @@ function requireExtendNode () {
24760
24760
  Buffer.prototype.write = original.BufferWrite;
24761
24761
 
24762
24762
  if (iconv.supportsStreams) {
24763
- var Readable = require$$0$a.Readable;
24763
+ var Readable = require$$0$9.Readable;
24764
24764
 
24765
24765
  Readable.prototype.setEncoding = original.ReadableSetEncoding;
24766
24766
  delete Readable.prototype.collect;
@@ -25707,7 +25707,7 @@ var callBound$1 = function callBoundIntrinsic(name, allowMissing) {
25707
25707
  return intrinsic;
25708
25708
  };
25709
25709
 
25710
- var util_inspect = require$$1$3.inspect;
25710
+ var util_inspect = require$$1$4.inspect;
25711
25711
 
25712
25712
  var hasMap = typeof Map === 'function' && Map.prototype;
25713
25713
  var mapSizeDescriptor = Object.getOwnPropertyDescriptor && hasMap ? Object.getOwnPropertyDescriptor(Map.prototype, 'size') : null;
@@ -29914,6 +29914,36 @@ async function batchResolveChannel(urls) {
29914
29914
  failedCount,
29915
29915
  };
29916
29916
  }
29917
+ async function getStreamUrl(id) {
29918
+ const recorderManager = container.resolve("recorderManager");
29919
+ const recorder = recorderManager.manager.recorders.find((item) => item.id === id);
29920
+ if (!recorder)
29921
+ throw new Error("未找到录制器");
29922
+ let url;
29923
+ if (recorder.recordHandle) {
29924
+ if (recorder.providerId === "DouYin") {
29925
+ url = recorder.recordHandle.url;
29926
+ }
29927
+ }
29928
+ if (!url) {
29929
+ // B站的fmp4流不需要referer验证
29930
+ let formatName;
29931
+ let formatPriorities;
29932
+ if (recorder.providerId === "Bilibili") {
29933
+ formatName = "fmp4";
29934
+ }
29935
+ else if (recorder.providerId === "TikTok") {
29936
+ formatName = "hls";
29937
+ formatPriorities = ["hls", "flv"];
29938
+ }
29939
+ const data = await recorder.getStream({
29940
+ formatName: formatName,
29941
+ formatPriorities: formatPriorities,
29942
+ });
29943
+ url = data.url;
29944
+ }
29945
+ return { url };
29946
+ }
29917
29947
  async function getLiveInfo(ids) {
29918
29948
  const recorderManager = container.resolve("recorderManager");
29919
29949
  const recorders = recorderManager.manager.recorders;
@@ -29992,6 +30022,7 @@ var recorderService = {
29992
30022
  batchResolveChannel,
29993
30023
  getBiliStream,
29994
30024
  resolve,
30025
+ getStreamUrl,
29995
30026
  };
29996
30027
 
29997
30028
  const router$h = new Router$1();
@@ -30010,8 +30041,11 @@ router$h.post("/webhook/bililiverecorder", async (ctx) => {
30010
30041
  return;
30011
30042
  }
30012
30043
  const roomId = event.EventData.RoomId;
30013
- // 如果是docker,那么将recoderFolder参数修改为 /app/video路径
30014
- const recoderFolder = isDocker ? "/app/video" : config.webhook.recoderFolder;
30044
+ let recoderFolder = config.webhook.recoderFolder;
30045
+ if (isDocker && !config.webhook.recoderFolder) {
30046
+ // 如果是docker,且不存在recoderFolder参数,那么修改默认值
30047
+ recoderFolder = "/app/video";
30048
+ }
30015
30049
  const filePath = path$3.join(recoderFolder, event.EventData.RelativePath);
30016
30050
  index$1.logObj.info("录播姬文件路径:", filePath, recoderFolder);
30017
30051
  handler.handle({
@@ -30299,7 +30333,7 @@ var hasRequiredStream$1;
30299
30333
  function requireStream$1 () {
30300
30334
  if (hasRequiredStream$1) return stream$3;
30301
30335
  hasRequiredStream$1 = 1;
30302
- stream$3 = require$$0$a;
30336
+ stream$3 = require$$0$9;
30303
30337
  return stream$3;
30304
30338
  }
30305
30339
 
@@ -30412,7 +30446,7 @@ function requireUtil () {
30412
30446
  }
30413
30447
  util$2.isPrimitive = isPrimitive;
30414
30448
 
30415
- util$2.isBuffer = require$$0$7.Buffer.isBuffer;
30449
+ util$2.isBuffer = require$$0$6.Buffer.isBuffer;
30416
30450
 
30417
30451
  function objectToString(o) {
30418
30452
  return Object.prototype.toString.call(o);
@@ -30432,7 +30466,7 @@ function requireBufferList () {
30432
30466
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
30433
30467
 
30434
30468
  var Buffer = index$1.safeBufferExports.Buffer;
30435
- var util = require$$1$3;
30469
+ var util = require$$1$4;
30436
30470
 
30437
30471
  function copyBuffer(src, target, offset) {
30438
30472
  src.copy(target, offset);
@@ -30611,7 +30645,7 @@ function requireNode () {
30611
30645
  * For Node.js, simply re-export the core `util.deprecate` function.
30612
30646
  */
30613
30647
 
30614
- node = require$$1$3.deprecate;
30648
+ node = require$$1$4.deprecate;
30615
30649
  return node;
30616
30650
  }
30617
30651
 
@@ -31696,7 +31730,7 @@ function require_stream_readable$1 () {
31696
31730
  Readable.ReadableState = ReadableState;
31697
31731
 
31698
31732
  /*<replacement>*/
31699
- require$$0$5.EventEmitter;
31733
+ require$$0$4.EventEmitter;
31700
31734
 
31701
31735
  var EElistenerCount = function (emitter, type) {
31702
31736
  return emitter.listeners(type).length;
@@ -31726,7 +31760,7 @@ function require_stream_readable$1 () {
31726
31760
  /*</replacement>*/
31727
31761
 
31728
31762
  /*<replacement>*/
31729
- var debugUtil = require$$1$3;
31763
+ var debugUtil = require$$1$4;
31730
31764
  var debug = void 0;
31731
31765
  if (debugUtil && debugUtil.debuglog) {
31732
31766
  debug = debugUtil.debuglog('stream');
@@ -32872,7 +32906,7 @@ function requireReadable () {
32872
32906
  if (hasRequiredReadable) return readable$1.exports;
32873
32907
  hasRequiredReadable = 1;
32874
32908
  (function (module, exports) {
32875
- var Stream = require$$0$a;
32909
+ var Stream = require$$0$9;
32876
32910
  if (process.env.READABLE_STREAM === 'disable' && Stream) {
32877
32911
  module.exports = Stream;
32878
32912
  exports = module.exports = Stream.Readable;
@@ -45248,7 +45282,7 @@ function matchNeedle(self, data, pos, len) {
45248
45282
 
45249
45283
  var sbmh = SBMH;
45250
45284
 
45251
- const { Readable: Readable$1, Writable: Writable$2 } = require$$0$a;
45285
+ const { Readable: Readable$1, Writable: Writable$2 } = require$$0$9;
45252
45286
 
45253
45287
  const StreamSearch = sbmh;
45254
45288
 
@@ -45898,7 +45932,7 @@ const FIELD_VCHAR = [
45898
45932
 
45899
45933
  var multipart = Multipart;
45900
45934
 
45901
- const { Writable: Writable$1 } = require$$0$a;
45935
+ const { Writable: Writable$1 } = require$$0$9;
45902
45936
 
45903
45937
  const { getDecoder } = utils;
45904
45938
 
@@ -46455,7 +46489,7 @@ function appendField$1 (store, key, value) {
46455
46489
 
46456
46490
  var appendField_1 = appendField$1;
46457
46491
 
46458
- var EventEmitter$1 = require$$0$5.EventEmitter;
46492
+ var EventEmitter$1 = require$$0$4.EventEmitter;
46459
46493
 
46460
46494
  function Counter$1 () {
46461
46495
  EventEmitter$1.call(this);
@@ -46484,7 +46518,7 @@ Counter$1.prototype.onceZero = function onceZero (fn) {
46484
46518
 
46485
46519
  var counter = Counter$1;
46486
46520
 
46487
- var util$1 = require$$1$3;
46521
+ var util$1 = require$$1$4;
46488
46522
 
46489
46523
  var errorMessages = {
46490
46524
  LIMIT_PART_COUNT: 'Too many parts',
@@ -46869,8 +46903,8 @@ function makeMiddleware$1 (setup) {
46869
46903
 
46870
46904
  var makeMiddleware_1 = makeMiddleware$1;
46871
46905
 
46872
- var path$2 = require$$0$8;
46873
- var fs$5 = require$$0$9;
46906
+ var path$2 = require$$0$7;
46907
+ var fs$5 = require$$0$8;
46874
46908
  var _0777 = parseInt('0777', 8);
46875
46909
 
46876
46910
  var mkdirp$1 = mkdirP.mkdirp = mkdirP.mkdirP = mkdirP;
@@ -46972,10 +47006,10 @@ mkdirP.sync = function sync (p, opts, made) {
46972
47006
  return made;
46973
47007
  };
46974
47008
 
46975
- var fs$4 = require$$0$9;
46976
- var os = require$$1$5;
46977
- var path$1 = require$$0$8;
46978
- var crypto = require$$1$2;
47009
+ var fs$4 = require$$0$8;
47010
+ var os = require$$1$6;
47011
+ var path$1 = require$$0$7;
47012
+ var crypto = require$$1$3;
46979
47013
  var mkdirp = mkdirp$1;
46980
47014
 
46981
47015
  function getFilename (req, file, cb) {
@@ -49394,8 +49428,8 @@ class Ollama extends Ollama$1 {
49394
49428
  return Buffer.from(image).toString("base64");
49395
49429
  }
49396
49430
  try {
49397
- if (require$$0$9.existsSync(image)) {
49398
- const fileBuffer = await require$$0$9.promises.readFile(require$$0$8.resolve(image));
49431
+ if (require$$0$8.existsSync(image)) {
49432
+ const fileBuffer = await require$$0$8.promises.readFile(require$$0$7.resolve(image));
49399
49433
  return Buffer.from(fileBuffer).toString("base64");
49400
49434
  }
49401
49435
  } catch {
@@ -49434,9 +49468,9 @@ class Ollama extends Ollama$1 {
49434
49468
  */
49435
49469
  resolvePath(inputPath, mfDir) {
49436
49470
  if (inputPath.startsWith("~")) {
49437
- return require$$0$8.join(require$$1$5.homedir(), inputPath.slice(1));
49471
+ return require$$0$7.join(require$$1$6.homedir(), inputPath.slice(1));
49438
49472
  }
49439
- return require$$0$8.resolve(mfDir, inputPath);
49473
+ return require$$0$7.resolve(mfDir, inputPath);
49440
49474
  }
49441
49475
  /**
49442
49476
  * checks if a file exists
@@ -49446,7 +49480,7 @@ class Ollama extends Ollama$1 {
49446
49480
  */
49447
49481
  async fileExists(path) {
49448
49482
  try {
49449
- await require$$0$9.promises.access(path);
49483
+ await require$$0$8.promises.access(path);
49450
49484
  return true;
49451
49485
  } catch {
49452
49486
  return false;
@@ -49456,9 +49490,9 @@ class Ollama extends Ollama$1 {
49456
49490
  if (typeof ReadableStream === "undefined") {
49457
49491
  throw new Error("Streaming uploads are not supported in this environment.");
49458
49492
  }
49459
- const fileStream = require$$0$9.createReadStream(path);
49493
+ const fileStream = require$$0$8.createReadStream(path);
49460
49494
  const sha256sum = await new Promise((resolve2, reject) => {
49461
- const hash = require$$1$2.createHash("sha256");
49495
+ const hash = require$$1$3.createHash("sha256");
49462
49496
  fileStream.on("data", (data) => hash.update(data));
49463
49497
  fileStream.on("end", () => resolve2(hash.digest("hex")));
49464
49498
  fileStream.on("error", reject);
@@ -49495,10 +49529,10 @@ class Ollama extends Ollama$1 {
49495
49529
  async create(request) {
49496
49530
  let modelfileContent = "";
49497
49531
  if (request.path) {
49498
- modelfileContent = await require$$0$9.promises.readFile(request.path, { encoding: "utf8" });
49532
+ modelfileContent = await require$$0$8.promises.readFile(request.path, { encoding: "utf8" });
49499
49533
  modelfileContent = await this.parseModelfile(
49500
49534
  modelfileContent,
49501
- require$$0$8.dirname(request.path)
49535
+ require$$0$7.dirname(request.path)
49502
49536
  );
49503
49537
  } else if (request.modelfile) {
49504
49538
  modelfileContent = await this.parseModelfile(request.modelfile);
@@ -49627,7 +49661,7 @@ var hasRequiredStream;
49627
49661
  function requireStream () {
49628
49662
  if (hasRequiredStream) return stream$1;
49629
49663
  hasRequiredStream = 1;
49630
- stream$1 = require$$0$a;
49664
+ stream$1 = require$$0$9;
49631
49665
  return stream$1;
49632
49666
  }
49633
49667
 
@@ -49646,9 +49680,9 @@ function requireBuffer_list () {
49646
49680
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
49647
49681
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
49648
49682
  function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
49649
- var _require = require$$0$7,
49683
+ var _require = require$$0$6,
49650
49684
  Buffer = _require.Buffer;
49651
- var _require2 = require$$1$3,
49685
+ var _require2 = require$$1$4,
49652
49686
  inspect = _require2.inspect;
49653
49687
  var custom = inspect && inspect.custom || 'inspect';
49654
49688
  function copyBuffer(src, target, offset) {
@@ -50118,7 +50152,7 @@ function require_stream_writable () {
50118
50152
  var Stream = requireStream();
50119
50153
  /*</replacement>*/
50120
50154
 
50121
- var Buffer = require$$0$7.Buffer;
50155
+ var Buffer = require$$0$6.Buffer;
50122
50156
  var OurUint8Array = (typeof index$1.commonjsGlobal !== 'undefined' ? index$1.commonjsGlobal : typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : {}).Uint8Array || function () {};
50123
50157
  function _uint8ArrayToBuffer(chunk) {
50124
50158
  return Buffer.from(chunk);
@@ -51443,7 +51477,7 @@ function require_stream_readable () {
51443
51477
  Readable.ReadableState = ReadableState;
51444
51478
 
51445
51479
  /*<replacement>*/
51446
- require$$0$5.EventEmitter;
51480
+ require$$0$4.EventEmitter;
51447
51481
  var EElistenerCount = function EElistenerCount(emitter, type) {
51448
51482
  return emitter.listeners(type).length;
51449
51483
  };
@@ -51453,7 +51487,7 @@ function require_stream_readable () {
51453
51487
  var Stream = requireStream();
51454
51488
  /*</replacement>*/
51455
51489
 
51456
- var Buffer = require$$0$7.Buffer;
51490
+ var Buffer = require$$0$6.Buffer;
51457
51491
  var OurUint8Array = (typeof index$1.commonjsGlobal !== 'undefined' ? index$1.commonjsGlobal : typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : {}).Uint8Array || function () {};
51458
51492
  function _uint8ArrayToBuffer(chunk) {
51459
51493
  return Buffer.from(chunk);
@@ -51463,7 +51497,7 @@ function require_stream_readable () {
51463
51497
  }
51464
51498
 
51465
51499
  /*<replacement>*/
51466
- var debugUtil = require$$1$3;
51500
+ var debugUtil = require$$1$4;
51467
51501
  var debug;
51468
51502
  if (debugUtil && debugUtil.debuglog) {
51469
51503
  debug = debugUtil.debuglog('stream');
@@ -52688,7 +52722,7 @@ function requirePipeline () {
52688
52722
  }
52689
52723
 
52690
52724
  (function (module, exports) {
52691
- var Stream = require$$0$a;
52725
+ var Stream = require$$0$9;
52692
52726
  if (process.env.READABLE_STREAM === 'disable' && Stream) {
52693
52727
  module.exports = Stream.Readable;
52694
52728
  Object.assign(module.exports, Stream);
@@ -54076,56 +54110,47 @@ const coerce$1 = (version, options) => {
54076
54110
  };
54077
54111
  var coerce_1 = coerce$1;
54078
54112
 
54079
- var lrucache;
54080
- var hasRequiredLrucache;
54081
-
54082
- function requireLrucache () {
54083
- if (hasRequiredLrucache) return lrucache;
54084
- hasRequiredLrucache = 1;
54085
-
54086
- class LRUCache {
54087
- constructor () {
54088
- this.max = 1000;
54089
- this.map = new Map();
54090
- }
54091
-
54092
- get (key) {
54093
- const value = this.map.get(key);
54094
- if (value === undefined) {
54095
- return undefined
54096
- } else {
54097
- // Remove the key from the map and add it to the end
54098
- this.map.delete(key);
54099
- this.map.set(key, value);
54100
- return value
54101
- }
54102
- }
54113
+ class LRUCache {
54114
+ constructor () {
54115
+ this.max = 1000;
54116
+ this.map = new Map();
54117
+ }
54103
54118
 
54104
- delete (key) {
54105
- return this.map.delete(key)
54106
- }
54119
+ get (key) {
54120
+ const value = this.map.get(key);
54121
+ if (value === undefined) {
54122
+ return undefined
54123
+ } else {
54124
+ // Remove the key from the map and add it to the end
54125
+ this.map.delete(key);
54126
+ this.map.set(key, value);
54127
+ return value
54128
+ }
54129
+ }
54107
54130
 
54108
- set (key, value) {
54109
- const deleted = this.delete(key);
54131
+ delete (key) {
54132
+ return this.map.delete(key)
54133
+ }
54110
54134
 
54111
- if (!deleted && value !== undefined) {
54112
- // If cache is full, delete the least recently used item
54113
- if (this.map.size >= this.max) {
54114
- const firstKey = this.map.keys().next().value;
54115
- this.delete(firstKey);
54116
- }
54135
+ set (key, value) {
54136
+ const deleted = this.delete(key);
54117
54137
 
54118
- this.map.set(key, value);
54119
- }
54138
+ if (!deleted && value !== undefined) {
54139
+ // If cache is full, delete the least recently used item
54140
+ if (this.map.size >= this.max) {
54141
+ const firstKey = this.map.keys().next().value;
54142
+ this.delete(firstKey);
54143
+ }
54120
54144
 
54121
- return this
54122
- }
54123
- }
54145
+ this.map.set(key, value);
54146
+ }
54124
54147
 
54125
- lrucache = LRUCache;
54126
- return lrucache;
54148
+ return this
54149
+ }
54127
54150
  }
54128
54151
 
54152
+ var lrucache = LRUCache;
54153
+
54129
54154
  var range;
54130
54155
  var hasRequiredRange;
54131
54156
 
@@ -54347,7 +54372,7 @@ function requireRange () {
54347
54372
 
54348
54373
  range = Range;
54349
54374
 
54350
- const LRU = requireLrucache();
54375
+ const LRU = lrucache;
54351
54376
  const cache = new LRU();
54352
54377
 
54353
54378
  const parseOptions = parseOptions_1;
@@ -56090,7 +56115,7 @@ router$d.post("/get_cookie", async (ctx) => {
56090
56115
  return;
56091
56116
  }
56092
56117
  const secret = "r96gkr8ahc34fsrewr34";
56093
- const hash = require$$1$2.createHmac("sha256", secret).update(`${uid}${timestamp}`).digest("hex");
56118
+ const hash = require$$1$3.createHmac("sha256", secret).update(`${uid}${timestamp}`).digest("hex");
56094
56119
  if (hash !== signature) {
56095
56120
  ctx.status = 400;
56096
56121
  ctx.body = "签名无效";
@@ -56266,10 +56291,10 @@ router$c.put("/subtitle-style/:id", async (ctx) => {
56266
56291
 
56267
56292
  var chokidar = {};
56268
56293
 
56269
- const fs$3 = require$$0$9;
56270
- const { Readable } = require$$0$a;
56271
- const sysPath$3 = require$$0$8;
56272
- const { promisify: promisify$3 } = require$$1$3;
56294
+ const fs$3 = require$$0$8;
56295
+ const { Readable } = require$$0$9;
56296
+ const sysPath$3 = require$$0$7;
56297
+ const { promisify: promisify$3 } = require$$1$4;
56273
56298
  const picomatch$1 = index$1.picomatch;
56274
56299
 
56275
56300
  const readdir$1 = promisify$3(fs$3.readdir);
@@ -56963,7 +56988,7 @@ var require$$0 = [
56963
56988
 
56964
56989
  var binaryExtensions$1 = require$$0;
56965
56990
 
56966
- const path = require$$0$8;
56991
+ const path = require$$0$7;
56967
56992
  const binaryExtensions = binaryExtensions$1;
56968
56993
 
56969
56994
  const extensions = new Set(binaryExtensions);
@@ -56974,9 +56999,9 @@ var constants$1 = {};
56974
56999
 
56975
57000
  (function (exports) {
56976
57001
 
56977
- const {sep} = require$$0$8;
57002
+ const {sep} = require$$0$7;
56978
57003
  const {platform} = process;
56979
- const os = require$$1$5;
57004
+ const os = require$$1$6;
56980
57005
 
56981
57006
  exports.EV_ALL = 'all';
56982
57007
  exports.EV_READY = 'ready';
@@ -57040,9 +57065,9 @@ var constants$1 = {};
57040
57065
  exports.isIBMi = os.type() === 'OS400';
57041
57066
  } (constants$1));
57042
57067
 
57043
- const fs$2 = require$$0$9;
57044
- const sysPath$2 = require$$0$8;
57045
- const { promisify: promisify$2 } = require$$1$3;
57068
+ const fs$2 = require$$0$8;
57069
+ const sysPath$2 = require$$0$7;
57070
+ const { promisify: promisify$2 } = require$$1$4;
57046
57071
  const isBinaryPath = isBinaryPath$1;
57047
57072
  const {
57048
57073
  isWindows: isWindows$1,
@@ -57691,9 +57716,9 @@ var nodefsHandler = NodeFsHandler$1;
57691
57716
 
57692
57717
  var fseventsHandler = {exports: {}};
57693
57718
 
57694
- const fs$1 = require$$0$9;
57695
- const sysPath$1 = require$$0$8;
57696
- const { promisify: promisify$1 } = require$$1$3;
57719
+ const fs$1 = require$$0$8;
57720
+ const sysPath$1 = require$$0$7;
57721
+ const { promisify: promisify$1 } = require$$1$4;
57697
57722
 
57698
57723
  let fsevents;
57699
57724
  try {
@@ -58218,10 +58243,10 @@ fseventsHandler.exports.canUse = canUse;
58218
58243
 
58219
58244
  var fseventsHandlerExports = fseventsHandler.exports;
58220
58245
 
58221
- const { EventEmitter } = require$$0$5;
58222
- const fs = require$$0$9;
58223
- const sysPath = require$$0$8;
58224
- const { promisify } = require$$1$3;
58246
+ const { EventEmitter } = require$$0$4;
58247
+ const fs = require$$0$8;
58248
+ const sysPath = require$$0$7;
58249
+ const { promisify } = require$$1$4;
58225
58250
  const readdirp = readdirp_1;
58226
58251
  const anymatch = anymatchExports.default;
58227
58252
  const globParent = index$1.globParent;
@@ -59190,7 +59215,7 @@ const watch = (paths, options) => {
59190
59215
 
59191
59216
  chokidar.watch = watch;
59192
59217
 
59193
- const stream = require$$0$a;
59218
+ const stream = require$$0$9;
59194
59219
  const Transform = stream.Transform;
59195
59220
 
59196
59221
 
@@ -59310,7 +59335,7 @@ SSETransform.defOpts = {
59310
59335
  var sse$1 = SSETransform;
59311
59336
 
59312
59337
  const SSE = sse$1;
59313
- const Stream$1 = require$$0$a;
59338
+ const Stream$1 = require$$0$9;
59314
59339
  const DEFAULT_OPTS = {
59315
59340
  maxClients: 10000,
59316
59341
  pingInterval: 60000,
@@ -59766,10 +59791,10 @@ class FFmpegWhisperASR {
59766
59791
  throw new Error(`音频文件不存在: ${filePath}`);
59767
59792
  }
59768
59793
  // 创建临时目录存放结果
59769
- const tempDir = require$$0$8.join(require$$1$5.tmpdir(), "whisper-asr");
59794
+ const tempDir = require$$0$7.join(require$$1$6.tmpdir(), "whisper-asr");
59770
59795
  await index$1.fs.ensureDir(tempDir);
59771
59796
  // 生成唯一的输出文件名
59772
- const outputFile = require$$0$8.join(tempDir, `${v4()}.json`);
59797
+ const outputFile = require$$0$7.join(tempDir, `${v4()}.json`);
59773
59798
  try {
59774
59799
  // 执行 ffmpeg 命令
59775
59800
  await this.executeFFmpeg(filePath, outputFile);
@@ -59828,7 +59853,7 @@ class FFmpegWhisperASR {
59828
59853
  ];
59829
59854
  this.options.logger.info(`执行 FFmpeg Whisper 命令: ${this.options.ffmpegPath} ${args.join(" ")}`);
59830
59855
  // 使用 spawn 执行命令
59831
- const process = require$$0$e.spawn(this.options.ffmpegPath, args);
59856
+ const process = require$$0$c.spawn(this.options.ffmpegPath, args);
59832
59857
  let stderr = "";
59833
59858
  // 收集标准错误输出(ffmpeg 的日志)
59834
59859
  process.stderr.on("data", (data) => {
@@ -60784,7 +60809,7 @@ const isFile = (value) => value instanceof File;
60784
60809
 
60785
60810
  const isBlob = (value) => value instanceof Blob$1;
60786
60811
 
60787
- const deprecateConstructorEntries = require$$1$3.deprecate(() => { }, "Constructor \"entries\" argument is not spec-compliant "
60812
+ const deprecateConstructorEntries = require$$1$4.deprecate(() => { }, "Constructor \"entries\" argument is not spec-compliant "
60788
60813
  + "and will be removed in next major release.");
60789
60814
 
60790
60815
  var __classPrivateFieldGet$8 = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
@@ -60921,7 +60946,7 @@ let FormData$1 = class FormData {
60921
60946
  get [Symbol.toStringTag]() {
60922
60947
  return "FormData";
60923
60948
  }
60924
- [require$$1$3.inspect.custom]() {
60949
+ [require$$1$4.inspect.custom]() {
60925
60950
  return this[Symbol.toStringTag];
60926
60951
  }
60927
60952
  };
@@ -60938,7 +60963,7 @@ var agentkeepalive = {exports: {}};
60938
60963
  * Module dependencies.
60939
60964
  */
60940
60965
 
60941
- var util = require$$1$3;
60966
+ var util = require$$1$4;
60942
60967
  var ms$1 = index$1.requireMs();
60943
60968
 
60944
60969
  var humanizeMs = function (t) {
@@ -60964,9 +60989,9 @@ var constants = {
60964
60989
  SOCKET_REQUEST_FINISHED_COUNT: Symbol('agentkeepalive#socketRequestFinishedCount'),
60965
60990
  };
60966
60991
 
60967
- const OriginalAgent = require$$3$1.Agent;
60992
+ const OriginalAgent = require$$1$2.Agent;
60968
60993
  const ms = humanizeMs;
60969
- const debug$1 = require$$1$3.debuglog('agentkeepalive');
60994
+ const debug$1 = require$$1$4.debuglog('agentkeepalive');
60970
60995
  const {
60971
60996
  INIT_SOCKET: INIT_SOCKET$1,
60972
60997
  CURRENT_ID,
@@ -61365,7 +61390,7 @@ function inspect(obj) {
61365
61390
  return res;
61366
61391
  }
61367
61392
 
61368
- const OriginalHttpsAgent = require$$1$6.Agent;
61393
+ const OriginalHttpsAgent = require$$1$7.Agent;
61369
61394
  const HttpAgent$1 = agent;
61370
61395
  const {
61371
61396
  INIT_SOCKET,
@@ -62581,7 +62606,7 @@ class MultipartBody {
62581
62606
  let fileFromPathWarned = false;
62582
62607
  async function fileFromPath(path, ...args) {
62583
62608
  // this import fails in environments that don't handle export maps correctly, like old versions of Jest
62584
- const { fileFromPath: _fileFromPath } = await Promise.resolve().then(function () { return require('./fileFromPath-DdVRxbmq.cjs'); });
62609
+ const { fileFromPath: _fileFromPath } = await Promise.resolve().then(function () { return require('./fileFromPath-CXG-E0Z1.cjs'); });
62585
62610
  if (!fileFromPathWarned) {
62586
62611
  console.warn(`fileFromPath is deprecated; use fs.createReadStream(${JSON.stringify(path)}) instead`);
62587
62612
  fileFromPathWarned = true;
@@ -62593,7 +62618,7 @@ const defaultHttpAgent = new KeepAliveAgent({ keepAlive: true, timeout: 5 * 60 *
62593
62618
  const defaultHttpsAgent = new KeepAliveAgent.HttpsAgent({ keepAlive: true, timeout: 5 * 60 * 1000 });
62594
62619
  async function getMultipartRequestOptions(form, opts) {
62595
62620
  const encoder = new FormDataEncoder(form);
62596
- const readable = require$$0$f.Readable.from(encoder);
62621
+ const readable = require$$0$d.Readable.from(encoder);
62597
62622
  const body = new MultipartBody(readable);
62598
62623
  const headers = {
62599
62624
  ...opts.headers,
@@ -68748,7 +68773,7 @@ class QwenLLM {
68748
68773
  this.client = new OpenAI({
68749
68774
  apiKey: config.apiKey,
68750
68775
  baseURL: config.baseURL || "https://dashscope.aliyuncs.com/compatible-mode/v1",
68751
- timeout: config.timeout || 60000,
68776
+ timeout: config.timeout || 300000,
68752
68777
  });
68753
68778
  this.model = config.model || "qwen-plus";
68754
68779
  }
@@ -68998,7 +69023,7 @@ class DecodedMessage {
68998
69023
  if (!uri.startsWith(DATA_URI_PREFIX)) {
68999
69024
  throw new Error('assert 4');
69000
69025
  }
69001
- return this.decodeFromBinary(require$$0$7.Buffer.from(uri.replace(DATA_URI_PREFIX, ''), 'base64'));
69026
+ return this.decodeFromBinary(require$$0$6.Buffer.from(uri.replace(DATA_URI_PREFIX, ''), 'base64'));
69002
69027
  }
69003
69028
  encodeToBinary() {
69004
69029
  const header = {
@@ -69049,7 +69074,7 @@ class DecodedMessage {
69049
69074
  }
69050
69075
  encodeToUri() {
69051
69076
  const bin = this.encodeToBinary();
69052
- return DATA_URI_PREFIX + require$$0$7.Buffer.from(bin).toString('base64');
69077
+ return DATA_URI_PREFIX + require$$0$6.Buffer.from(bin).toString('base64');
69053
69078
  }
69054
69079
  }
69055
69080
 
@@ -69889,7 +69914,7 @@ class Shazam {
69889
69914
  * @returns {ShazamRoot | null}
69890
69915
  */
69891
69916
  async recognise(path, language = "en-US", minimal = false) {
69892
- const signatures = shazamioCore.recognizeBytes(require$$0$9.readFileSync(path), 0, Number.MAX_SAFE_INTEGER);
69917
+ const signatures = shazamioCore.recognizeBytes(require$$0$8.readFileSync(path), 0, Number.MAX_SAFE_INTEGER);
69893
69918
  try {
69894
69919
  let response;
69895
69920
  for (let i = Math.floor(signatures.length / 2); i < signatures.length; i += 4) {
@@ -73181,7 +73206,13 @@ async function recognize(file, lyricOptimize) {
73181
73206
  // console.log("Shazam 识别结果:", JSON.stringify(result, null, 2));
73182
73207
  if (!result)
73183
73208
  return null;
73184
- const info = await shazamQueryInfo(result.trackId);
73209
+ let info = null;
73210
+ try {
73211
+ info = await shazamQueryInfo(result.trackId);
73212
+ }
73213
+ catch (error) {
73214
+ console.error("Shazam 查询信息失败:", error);
73215
+ }
73185
73216
  const appleMusicId = result.appleMusicId || info?.appleMusicId;
73186
73217
  const title = info?.title || result.title;
73187
73218
  const subtitle = info?.subtitle || "";
@@ -73357,6 +73388,7 @@ async function optimizeLyrics(asrData, lyrics, offset) {
73357
73388
  temperature: 0.5,
73358
73389
  enableSearch: false,
73359
73390
  responseFormat: enableStructuredOutput ? { type: "json_object" } : undefined,
73391
+ enableThinking: false,
73360
73392
  });
73361
73393
  index$1.logObj.info("优化结果:", response);
73362
73394
  if (!response.content) {
@@ -73449,6 +73481,7 @@ async function recognizeSongNameWithLLM(asrText, vendorId, options) {
73449
73481
  enableSearch: options.enableSearch,
73450
73482
  responseFormat: options.enableStructuredOutput ? { type: "json_object" } : undefined,
73451
73483
  temperature: 0.6,
73484
+ enableThinking: false,
73452
73485
  searchOptions: {
73453
73486
  forcedSearch: options.enableSearch,
73454
73487
  search_strategy: "max",
@@ -74013,7 +74046,7 @@ router$a.get("/ws/danma-test", async (ctx) => {
74013
74046
  };
74014
74047
  });
74015
74048
  router$a.post("/add", async (ctx) => {
74016
- const args = index$1.pick((ctx.request.body ?? {}), "providerId", "channelId", "remarks", "disableAutoCheck", "quality", "streamPriorities", "sourcePriorities", "extra", "noGlobalFollowFields", "line", "disableProvideCommentsWhenRecording", "saveGiftDanma", "saveSCDanma", "segment", "sendToWebhook", "uid", "saveCover", "convert2Mp4", "qualityRetry", "formatName", "useM3U8Proxy", "customHost", "codecName", "titleKeywords", "liveStartNotification", "chargeLiveNotification", "liveEndNotification", "weight", "source", "videoFormat", "recorderType", "cookie", "doubleScreen", "onlyAudio", "useServerTimestamp", "handleTime", "debugLevel", "api");
74049
+ const args = index$1.pick((ctx.request.body ?? {}), "providerId", "channelId", "remarks", "disableAutoCheck", "quality", "streamPriorities", "sourcePriorities", "extra", "noGlobalFollowFields", "line", "disableProvideCommentsWhenRecording", "saveGiftDanma", "saveSCDanma", "segment", "sendToWebhook", "uid", "saveCover", "convert2Mp4", "qualityRetry", "formatName", "useM3U8Proxy", "customHost", "codecName", "titleKeywords", "segmentOnTitleChange", "liveStartNotification", "chargeLiveNotification", "liveEndNotification", "weight", "source", "videoFormat", "recorderType", "cookie", "doubleScreen", "onlyAudio", "useServerTimestamp", "handleTime", "debugLevel", "api");
74017
74050
  const data = await recorderService.addRecorder(args);
74018
74051
  ctx.body = { payload: data };
74019
74052
  });
@@ -74027,9 +74060,22 @@ router$a.get("/:id", (ctx) => {
74027
74060
  const { id } = ctx.params;
74028
74061
  ctx.body = { payload: recorderService.getRecorder({ id }) };
74029
74062
  });
74063
+ /**
74064
+ * 获取直播播放列表
74065
+ * @route GET /recorder/:recorderId/stream
74066
+ * @param recorderId 录制器 ID
74067
+ * @returns 重写分片地址后的 HLS 播放列表
74068
+ */
74069
+ router$a.post("/:id/stream", async (ctx) => {
74070
+ const { id } = ctx.params;
74071
+ const data = await recorderService.getStreamUrl(id);
74072
+ ctx.body = {
74073
+ payload: data,
74074
+ };
74075
+ });
74030
74076
  router$a.put("/:id", (ctx) => {
74031
74077
  const { id } = ctx.params;
74032
- const patch = index$1.pick(ctx.request.body, "remarks", "disableAutoCheck", "quality", "streamPriorities", "sourcePriorities", "noGlobalFollowFields", "line", "disableProvideCommentsWhenRecording", "saveGiftDanma", "saveSCDanma", "saveCover", "segment", "sendToWebhook", "uid", "qualityRetry", "formatName", "useM3U8Proxy", "customHost", "codecName", "titleKeywords", "liveStartNotification", "chargeLiveNotification", "liveEndNotification", "weight", "source", "videoFormat", "recorderType", "cookie", "doubleScreen", "onlyAudio", "useServerTimestamp", "handleTime", "debugLevel", "convert2Mp4", "api");
74078
+ const patch = index$1.pick(ctx.request.body, "remarks", "disableAutoCheck", "quality", "streamPriorities", "sourcePriorities", "noGlobalFollowFields", "line", "disableProvideCommentsWhenRecording", "saveGiftDanma", "saveSCDanma", "saveCover", "segment", "sendToWebhook", "uid", "qualityRetry", "formatName", "useM3U8Proxy", "customHost", "codecName", "titleKeywords", "segmentOnTitleChange", "liveStartNotification", "chargeLiveNotification", "liveEndNotification", "weight", "source", "videoFormat", "recorderType", "cookie", "doubleScreen", "onlyAudio", "useServerTimestamp", "handleTime", "debugLevel", "convert2Mp4", "api");
74033
74079
  ctx.body = { payload: recorderService.updateRecorder({ id, ...patch }) };
74034
74080
  });
74035
74081
  /**
@@ -74315,6 +74361,11 @@ router$9.get("/seasons", async (ctx) => {
74315
74361
  const data = await index$1.biliApi.getSeasonList(uid);
74316
74362
  ctx.body = data;
74317
74363
  });
74364
+ router$9.get("/reserveList", async (ctx) => {
74365
+ const { uid } = ctx.request.query;
74366
+ const data = await index$1.biliApi.getReserveList(uid);
74367
+ ctx.body = data;
74368
+ });
74318
74369
  router$9.get("/season/:aid", async (ctx) => {
74319
74370
  const { uid } = ctx.request.query;
74320
74371
  const { aid } = ctx.params;
@@ -75243,8 +75294,8 @@ async function download$1(output, url, options) {
75243
75294
  const mp4Output = index$1.replaceExtName(output, ".mp4");
75244
75295
  if ((await index$1.fs.pathExists(mp4Output)) && !options.override)
75245
75296
  throw new Error(`${mp4Output}已存在`);
75246
- const { dir, name } = require$$0$8.parse(output);
75247
- const tsOutput = require$$0$8.join(dir, `${name}.ts`);
75297
+ const { dir, name } = require$$0$7.parse(output);
75298
+ const tsOutput = require$$0$7.join(dir, `${name}.ts`);
75248
75299
  if (await index$1.fs.pathExists(tsOutput)) {
75249
75300
  throw new Error(`${tsOutput}已存在,您可以直接执行转封装命令,或者删除后重新下载`);
75250
75301
  }
@@ -75252,10 +75303,10 @@ async function download$1(output, url, options) {
75252
75303
  const downloader = new index$1.M3U8Downloader(url, tsOutput, {
75253
75304
  convert2Mp4: false,
75254
75305
  ffmpegPath: ffmpegPath,
75255
- segmentsDir: require$$0$8.join(index$1.getTempPath(), index$1.uuid()),
75306
+ segmentsDir: require$$0$7.join(index$1.getTempPath(), index$1.uuid()),
75256
75307
  });
75257
75308
  const task = new index$1.KuaishouDownloadVideoTask(downloader, {
75258
- name: `下载任务:${require$$0$8.parse(output).name}`,
75309
+ name: `下载任务:${require$$0$7.parse(output).name}`,
75259
75310
  }, {
75260
75311
  onEnd: async () => {
75261
75312
  const outputName = `${name}.mp4`;
@@ -75298,7 +75349,7 @@ var kuaishou = {
75298
75349
  var dist = {};
75299
75350
 
75300
75351
  (function (exports) {
75301
- Object.defineProperty(exports,'__esModule',{value:!0}),exports.DownloaderHelper=exports.DH_STATES=void 0;var _typeof='function'==typeof Symbol&&'symbol'==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&'function'==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?'symbol':typeof a},_createClass=function(){function a(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,'value'in c&&(c.writable=!0),Object.defineProperty(a,c.key,c);}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}(),_fs=require$$0$9,fs=_interopRequireWildcard(_fs),_url=require$$0$b,_path=require$$0$8,path=_interopRequireWildcard(_path),_http=require$$3$1,http=_interopRequireWildcard(_http),_https=require$$1$6,https=_interopRequireWildcard(_https),_events=require$$0$5;function _interopRequireWildcard(a){if(a&&a.__esModule)return a;var b={};if(null!=a)for(var c in a)Object.prototype.hasOwnProperty.call(a,c)&&(b[c]=a[c]);return b.default=a,b}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError('Cannot call a class as a function')}function _possibleConstructorReturn(a,b){if(!a)throw new ReferenceError('this hasn\'t been initialised - super() hasn\'t been called');return b&&('object'==typeof b||'function'==typeof b)?b:a}function _inherits(a,b){if('function'!=typeof b&&null!==b)throw new TypeError('Super expression must either be null or a function, not '+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b);}var DH_STATES=exports.DH_STATES={IDLE:'IDLE',SKIPPED:'SKIPPED',STARTED:'STARTED',DOWNLOADING:'DOWNLOADING',RETRY:'RETRY',PAUSED:'PAUSED',RESUMED:'RESUMED',STOPPED:'STOPPED',FINISHED:'FINISHED',FAILED:'FAILED'};exports.DownloaderHelper=function(a){function b(a,c){var d=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};_classCallCheck(this,b);var e=_possibleConstructorReturn(this,(b.__proto__||Object.getPrototypeOf(b)).call(this,{captureRejections:!0}));return e.__validate(a,c)?(e.url=e.requestURL=a.trim(),e.state=DH_STATES.IDLE,e.__defaultOpts={body:null,retry:!1,method:'GET',headers:{},fileName:'',timeout:-1,metadata:null,override:!1,forceResume:!1,removeOnStop:!0,removeOnFail:!0,progressThrottle:1e3,httpRequestOptions:{},httpsRequestOptions:{},resumeOnIncomplete:!0,resumeIfFileExists:!1,resumeOnIncompleteMaxRetry:5},e.__opts=Object.assign({},e.__defaultOpts),e.__pipes=[],e.__total=0,e.__downloaded=0,e.__progress=0,e.__retryCount=0,e.__retryTimeout=null,e.__resumeRetryCount=0,e.__states=DH_STATES,e.__promise=null,e.__request=null,e.__response=null,e.__isAborted=!1,e.__isResumed=!1,e.__isResumable=!1,e.__isRedirected=!1,e.__destFolder=c,e.__statsEstimate={time:0,bytes:0,prevBytes:0,throttleTime:0},e.__fileName='',e.__filePath='',e.updateOptions(d),e):_possibleConstructorReturn(e)}return _inherits(b,a),_createClass(b,[{key:'start',value:function c(){var a=this,b=function(){return new Promise(function(b,c){a.__promise={resolve:b,reject:c},a.__start();})};return this.__opts.resumeIfFileExists&&this.state!==this.__states.RESUMED?this.getTotalSize().then(function(c){var d=c.name,e=c.total,f=a.__opts.override;if(a.__opts.override=!0,a.__filePath=a.__getFilePath(d),a.__opts.override=f,a.__filePath&&fs.existsSync(a.__filePath)){var g=a.__getFilesizeInBytes(a.__filePath);return g===e?b():a.resumeFromFile(a.__filePath,{total:e,fileName:d})}return b()}):b()}},{key:'pause',value:function b(){var a=this;return this.state===this.__states.STOPPED?Promise.resolve(!0):(this.__response&&(this.__response.unpipe(),this.__pipes.forEach(function(a){return a.stream.unpipe()})),this.__fileStream&&this.__fileStream.removeAllListeners(),this.__requestAbort(),this.__closeFileStream().then(function(){return a.__setState(a.__states.PAUSED),a.emit('pause'),!0}))}},{key:'resume',value:function a(){return this.__promise?this.state===this.__states.STOPPED?Promise.resolve(!1):(this.__setState(this.__states.RESUMED),this.__isResumable&&(this.__isResumed=!0,this.__reqOptions.headers.range='bytes='+this.__downloaded+'-'),this.emit('resume',this.__isResumed),this.__start()):this.start()}},{key:'stop',value:function c(){var a=this;if(this.state===this.__states.STOPPED)return Promise.resolve(!0);var b=function(){return new Promise(function(b,c){fs.access(a.__filePath,function(d){return d?(a.__emitStop(),b(!0)):void fs.unlink(a.__filePath,function(d){return d?(a.__setState(a.__states.FAILED),a.emit('error',d),c(d)):void(a.__emitStop(),b(!0))})});})};return this.__requestAbort(),this.__closeFileStream().then(function(){return a.__opts.removeOnStop?b():(a.__emitStop(),Promise.resolve(!0))})}},{key:'pipe',value:function c(a){var b=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null;return this.__pipes.push({stream:a,options:b}),a}},{key:'unpipe',value:function d(){var a=this,b=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null,c=function(b){return a.__response?a.__response.unpipe(b):b.unpipe()};if(b){var e=this.__pipes.find(function(a){return a.stream===b});return void(e&&(c(b),this.__pipes=this.__pipes.filter(function(a){return a.stream!==b})))}this.__pipes.forEach(function(a){return c(a.stream)}),this.__pipes=[];}},{key:'getDownloadPath',value:function a(){return this.__filePath}},{key:'isResumable',value:function a(){return this.__isResumable}},{key:'updateOptions',value:function c(a){var b=1<arguments.length&&void 0!==arguments[1]?arguments[1]:'';this.__opts=Object.assign({},this.__opts,a),this.__headers=this.__opts.headers,-1<this.__opts.timeout&&(this.__opts.httpRequestOptions.timeout=this.__opts.timeout,this.__opts.httpsRequestOptions.timeout=this.__opts.timeout),('number'!=typeof this.__opts.progressThrottle||0>this.__opts.progressThrottle)&&(this.__opts.progressThrottle=this.__defaultOpts.progressThrottle),this.url=b||this.url,this.__reqOptions=this.__getReqOptions(this.__opts.method,this.url,this.__opts.headers),this.__initProtocol(this.url);}},{key:'getOptions',value:function a(){return this.__opts}},{key:'getMetadata',value:function a(){return this.__opts.metadata}},{key:'getStats',value:function a(){return {total:this.__total,name:this.__fileName,downloaded:this.__downloaded,progress:this.__progress,speed:this.__statsEstimate.bytes}}},{key:'getTotalSize',value:function b(){var a=this;return new Promise(function(b,c){var d=function(b){a.__initProtocol(b);var c=Object.assign({},a.__headers);c.hasOwnProperty('range')&&delete c.range;var d=a.__getReqOptions('HEAD',b,c);return Object.assign({},a.__reqOptions,d)},e=0,f=null,g=function(b,c){if(!a.__opts.retry||'object'!==_typeof(a.__opts.retry))return Promise.reject(b||new Error('wrong retry options'));f&&(clearTimeout(f),f=null);var g=a.__opts.retry,i=g.delay,j=void 0===i?0:i,k=g.maxRetries,l=void 0===k?999:k;return e>=l?Promise.reject(b||new Error('reached the maximum retries')):(e++,a.__setState(a.__states.RETRY),a.emit('retry',e,a.__opts.retry,b),new Promise(function(b){f=setTimeout(function(){a.__setState(a.__states.IDLE),h(c,d(c)),b();},j);}))},h=function(e,i){f&&(clearTimeout(f),f=null);var j=a.__protocol.request(i,function(f){if(a.__isRequireRedirect(f)){var i=/^https?:\/\//.test(f.headers.location)?f.headers.location:new _url.URL(f.headers.location,e).href;return a.emit('redirected',i,e),h(i,d(i))}if(200>f.statusCode||400<=f.statusCode){var j=new Error('Response status was '+f.statusCode);return a.__opts.retry&&500<=f.statusCode&&600>f.statusCode?g(j,e).catch(c):c(j)}b({name:a.__getFileNameFromHeaders(f.headers,f),total:parseInt(f.headers['content-length'])||null});});j.on('error',function(b){return a.__opts.retry?g(b,e).catch(c):void c(b)}),j.on('timeout',function(){return a.__opts.retry?g(new Error('timeout'),e).catch(c):void c(new Error('timeout'))}),j.on('uncaughtException',function(b){return a.__opts.retry?g(b,e).catch(c):void c(b)}),j.end();};h(a.url,d(a.url));})}},{key:'getResumeState',value:function a(){return {downloaded:this.__downloaded,filePath:this.__filePath,fileName:this.__fileName,total:this.__total}}},{key:'resumeFromFile',value:function d(a){var b=this,c=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};return this.__opts.override=!0,this.__filePath=a,(c.total&&c.fileName?Promise.resolve({name:c.fileName,total:c.total}):this.getTotalSize()).then(function(a){var d=a.name,e=a.total;return b.__total=c.total||e,b.__fileName=c.fileName||d,b.__downloaded=c.downloaded||b.__getFilesizeInBytes(b.__filePath),b.__reqOptions.headers.range='bytes='+b.__downloaded+'-',b.__isResumed=!0,b.__isResumable=!0,b.__setState(b.__states.RESUMED),b.emit('resume',b.__isResumed),new Promise(function(a,c){b.__promise={resolve:a,reject:c},b.__start();})})}},{key:'__start',value:function a(){this.__isRedirected||this.state===this.__states.RESUMED||(this.emit('start'),this.__setState(this.__states.STARTED),this.__initProtocol(this.url)),this.__response=null,this.__isAborted=!1,this.__request&&!this.__request.destroyed&&this.__request.destroy(),this.__retryTimeout&&(clearTimeout(this.__retryTimeout),this.__retryTimeout=null),this.__request=this.__downloadRequest(this.__promise.resolve,this.__promise.reject),this.__request.on('error',this.__onError(this.__promise.resolve,this.__promise.reject)),this.__request.on('timeout',this.__onTimeout(this.__promise.resolve,this.__promise.reject)),this.__request.on('uncaughtException',this.__onError(this.__promise.resolve,this.__promise.reject,!0)),this.__opts.body&&this.__request.write(this.__opts.body),this.__request.end();}},{key:'__resolvePending',value:function b(){if(this.__promise){var a=this.__promise.resolve;return this.__promise=null,a(!0)}}},{key:'__downloadRequest',value:function d(a,b){var c=this;return this.__protocol.request(this.__reqOptions,function(d){if(c.__response=d,c.__isResumed||(c.__total=parseInt(d.headers['content-length'])||null,c.__resetStats()),c.__isRequireRedirect(d)){var e=/^https?:\/\//.test(d.headers.location)?d.headers.location:new _url.URL(d.headers.location,c.url).href;return c.__isRedirected=!0,c.__initProtocol(e),c.emit('redirected',e,c.url),c.__start()}if(200>d.statusCode||400<=d.statusCode){var f=new Error('Response status was '+d.statusCode);return (f.status=d.statusCode||0,f.body=d.body||'',500<=d.statusCode&&600>d.statusCode)?c.__onError(a,b)(f):(c.__setState(c.__states.FAILED),c.emit('error',f),b(f))}c.__opts.forceResume?c.__isResumable=!0:d.headers.hasOwnProperty('accept-ranges')&&'none'!==d.headers['accept-ranges']&&(c.__isResumable=!0),c.__startDownload(d,a,b);})}},{key:'__startDownload',value:function h(a,b,c){var d=this,e=a;if(!this.__isResumed){var i=this.__getFileNameFromHeaders(a.headers);if(this.__filePath=this.__getFilePath(i),this.__fileName=this.__filePath.split(path.sep).pop(),fs.existsSync(this.__filePath)){var f=this.__getFilesizeInBytes(this.__filePath),g=this.__total?this.__total:0;if('object'===_typeof(this.__opts.override)&&this.__opts.override.skip&&(this.__opts.override.skipSmaller||f>=g))return this.emit('skip',{totalSize:this.__total,fileName:this.__fileName,filePath:this.__filePath,downloadedSize:f}),this.__setState(this.__states.SKIPPED),b(!0)}this.__fileStream=fs.createWriteStream(this.__filePath,{});}else this.__fileStream=fs.createWriteStream(this.__filePath,{flags:'a'});this.emit('download',{fileName:this.__fileName,filePath:this.__filePath,totalSize:this.__total,isResumed:this.__isResumed,downloadedSize:this.__downloaded}),this.__retryCount=0,this.__isResumed=!1,this.__isRedirected=!1,this.__setState(this.__states.DOWNLOADING),this.__statsEstimate.time=new Date,this.__statsEstimate.throttleTime=new Date,e.on('data',function(a){return d.__calculateStats(a.length)}),this.__pipes.forEach(function(a){e.pipe(a.stream,a.options),e=a.stream;}),e.pipe(this.__fileStream),e.on('error',this.__onError(b,c)),this.__fileStream.on('finish',this.__onFinished(b,c)),this.__fileStream.on('error',this.__onError(b,c));}},{key:'__hasFinished',value:function a(){return !this.__isAborted&&-1===[this.__states.PAUSED,this.__states.STOPPED,this.__states.RETRY,this.__states.FAILED,this.__states.RESUMED].indexOf(this.state)}},{key:'__isRequireRedirect',value:function b(a){return 300<a.statusCode&&400>a.statusCode&&a.headers.hasOwnProperty('location')&&a.headers.location}},{key:'__onFinished',value:function d(a,b){var c=this;return function(){c.__fileStream.close(function(d){if(d)return b(d);if(c.__hasFinished()){var e=!!c.__total&&c.__downloaded!==c.__total;if(e&&c.__isResumable&&c.__opts.resumeOnIncomplete&&c.__resumeRetryCount<=c.__opts.resumeOnIncompleteMaxRetry)return c.__resumeRetryCount++,c.emit('warning',new Error('uncomplete download, retrying')),c.resume();c.__setState(c.__states.FINISHED),c.__pipes=[],c.emit('end',{fileName:c.__fileName,filePath:c.__filePath,totalSize:c.__total,incomplete:e,onDiskSize:c.__getFilesizeInBytes(c.__filePath),downloadedSize:c.__downloaded});}return a(c.__downloaded===c.__total)});}}},{key:'__closeFileStream',value:function b(){var a=this;return this.__fileStream?new Promise(function(b,c){a.__fileStream.close(function(a){return a?c(a):b(!0)});}):Promise.resolve(!0)}},{key:'__onError',value:function e(a,b){var c=this,d=!!(2<arguments.length&&void 0!==arguments[2])&&arguments[2];return function(a){return c.__pipes=[],d&&c.__requestAbort(),c.state===c.__states.STOPPED||c.state===c.__states.FAILED?void 0:c.__opts.retry?c.__retry(a).catch(function(d){c.__removeFile().finally(function(){c.__setState(c.__states.FAILED),c.emit('error',d?d:a),b(d?d:a);});}):c.__removeFile().finally(function(){c.__setState(c.__states.FAILED),c.emit('error',a),b(a);})}}},{key:'__retry',value:function h(){var a=this,b=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null;if(!this.__opts.retry||'object'!==_typeof(this.__opts.retry))return Promise.reject(b||new Error('wrong retry options'));var c=this.__opts.retry,d=c.delay,e=void 0===d?0:d,f=c.maxRetries,g=void 0===f?999:f;return this.__retryCount>=g?Promise.reject(b||new Error('reached the maximum retries')):(this.__retryCount++,this.__setState(this.__states.RETRY),this.emit('retry',this.__retryCount,this.__opts.retry,b),this.__response&&(this.__response.unpipe(),this.__pipes.forEach(function(a){return a.stream.unpipe()})),this.__fileStream&&this.__fileStream.removeAllListeners(),this.__requestAbort(),this.__closeFileStream().then(function(){return new Promise(function(b){return a.__retryTimeout=setTimeout(function(){return b(0<a.__downloaded?a.resume():a.__start())},e)})}))}},{key:'__onTimeout',value:function d(a,b){var c=this;return function(){return c.__requestAbort(),c.__opts.retry?c.__retry(new Error('timeout')).catch(function(a){c.__removeFile().finally(function(){c.__setState(c.__states.FAILED),a?b(a):(c.emit('timeout'),b(new Error('timeout')));});}):c.__removeFile().finally(function(){c.__setState(c.__states.FAILED),c.emit('timeout'),b(new Error('timeout'));})}}},{key:'__resetStats',value:function a(){this.__retryCount=0,this.__downloaded=0,this.__progress=0,this.__resumeRetryCount=0,this.__statsEstimate={time:0,bytes:0,prevBytes:0,throttleTime:0};}},{key:'__getFileNameFromHeaders',value:function k(a,b){var c='',d=/.*filename\*=.*?'.*?'([^"].+?[^"])(?:(?:;)|$)/i,e=/.*filename="(.*?)";?/i,f=/.*filename=([^"].+?[^"])(?:(?:;)|$)/i,g=a.hasOwnProperty('content-disposition'),h=g?a['content-disposition'].match(d):null,i=!g||h?null:a['content-disposition'].match(e),j=!g||h||i?null:a['content-disposition'].match(f);return g&&(h||i||j)?(c=a['content-disposition'],c=c.trim(),h?c=h[1]:i?c=i[1]:j&&(c=j[1]),c=c.replace(/[/\\]/g,'')):0<path.basename(new _url.URL(this.requestURL).pathname).length?c=path.basename(new _url.URL(this.requestURL).pathname):c=new _url.URL(this.requestURL).hostname+'.html',this.__opts.fileName?this.__getFileNameFromOpts(c,b):c.replace(/\.*$/,'')}},{key:'__getFilePath',value:function d(a){var b=path.join(this.__destFolder,a),c=b;return this.__opts.override||this.state===this.__states.RESUMED||(c=this.__uniqFileNameSync(c),b!==c&&this.emit('renamed',{path:c,fileName:c.split(path.sep).pop(),prevPath:b,prevFileName:b.split(path.sep).pop()})),c}},{key:'__getFileNameFromOpts',value:function g(a,b){if(!this.__opts.fileName)return a;if('string'==typeof this.__opts.fileName)return this.__opts.fileName;if('function'==typeof this.__opts.fileName){var h=path.join(this.__destFolder,a);return b&&b.headers||this.__response&&this.__response.headers?this.__opts.fileName(a,h,(b?b:this.__response).headers['content-type']):this.__opts.fileName(a,h)}if('object'===_typeof(this.__opts.fileName)){var c=this.__opts.fileName,d=c.name,e=!!c.hasOwnProperty('ext')&&c.ext;if('string'==typeof e)return d+'.'+e;if('boolean'==typeof e){if(e)return d;var f=a.includes('.')?a.split('.').pop():'';return ''===f?d:d+'.'+f}}return a}},{key:'__calculateStats',value:function f(a){var b=new Date,c=b-this.__statsEstimate.time,d=b-this.__statsEstimate.throttleTime,e=this.__total||0;a&&(this.__downloaded+=a,this.__progress=0===e?0:100*(this.__downloaded/e),(this.__downloaded===e||1e3<c)&&(this.__statsEstimate.time=b,this.__statsEstimate.bytes=this.__downloaded-this.__statsEstimate.prevBytes,this.__statsEstimate.prevBytes=this.__downloaded),(this.__downloaded===e||d>this.__opts.progressThrottle)&&(this.__statsEstimate.throttleTime=b,this.emit('progress.throttled',this.getStats())),this.emit('progress',this.getStats()));}},{key:'__setState',value:function b(a){this.state=a,this.emit('stateChanged',this.state);}},{key:'__getReqOptions',value:function f(a,b){var c=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},d=new _url.URL(b),e={protocol:d.protocol,host:d.hostname,port:d.port,path:d.pathname+d.search,method:a};return c&&(e.headers=c),e}},{key:'__getFilesizeInBytes',value:function d(a){try{var b=fs.statSync(a,{throwIfNoEntry:!1}),c=b.size||0;return c}catch(a){this.emit('warning',a);}return 0}},{key:'__validate',value:function d(a,b){if('string'!=typeof a)throw new Error('URL should be an string');if(''===a.trim())throw new Error('URL couldn\'t be empty');if('string'!=typeof b)throw new Error('Destination Folder should be an string');if(''===b.trim())throw new Error('Destination Folder couldn\'t be empty');if(!fs.existsSync(b))throw new Error('Destination Folder must exist');var c=fs.statSync(b);if(!c.isDirectory())throw new Error('Destination Folder must be a directory');try{fs.accessSync(b,fs.constants.W_OK);}catch(a){throw new Error('Destination Folder must be writable')}return !0}},{key:'__initProtocol',value:function c(a){var b=this.__getReqOptions(this.__opts.method,a,this.__headers);this.requestURL=a,-1<a.indexOf('https://')?(this.__protocol=https,b.agent=new https.Agent({keepAlive:!1}),this.__reqOptions=Object.assign({},b,this.__opts.httpsRequestOptions)):(this.__protocol=http,b.agent=new http.Agent({keepAlive:!1}),this.__reqOptions=Object.assign({},b,this.__opts.httpRequestOptions));}},{key:'__uniqFileNameSync',value:function f(a){if('string'!=typeof a||''===a)return a;try{fs.accessSync(a,fs.F_OK);var b=a.match(/(.*)(\([0-9]+\))(\..*)$/),c=b?b[1].trim():a,d=b?parseInt(b[2].replace(/\(|\)/,'')):0,e=a.split('.').pop();return e!==a&&0<e.length?(e='.'+e,c=c.replace(e,'')):e='',this.__uniqFileNameSync(c+' ('+ ++d+')'+e)}catch(b){return a}}},{key:'__removeFile',value:function b(){var a=this;return new Promise(function(b){return a.__fileStream?void a.__fileStream.close(function(c){return c&&a.emit('warning',c),a.__opts.removeOnFail?fs.access(a.__filePath,function(d){return d?b():void fs.unlink(a.__filePath,function(d){d&&a.emit('warning',c),b();})}):void b()}):b()})}},{key:'__requestAbort',value:function a(){this.__isAborted=!0,this.__retryTimeout&&(clearTimeout(this.__retryTimeout),this.__retryTimeout=null),this.__response&&this.__response.destroy(),this.__request&&(this.__request.destroy?this.__request.destroy():this.__request.abort());}},{key:'__emitStop',value:function a(){this.__resolvePending(),this.__setState(this.__states.STOPPED),this.emit('stop');}}]),b}(_events.EventEmitter);
75352
+ Object.defineProperty(exports,'__esModule',{value:!0}),exports.DownloaderHelper=exports.DH_STATES=void 0;var _typeof='function'==typeof Symbol&&'symbol'==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&'function'==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?'symbol':typeof a},_createClass=function(){function a(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,'value'in c&&(c.writable=!0),Object.defineProperty(a,c.key,c);}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}(),_fs=require$$0$8,fs=_interopRequireWildcard(_fs),_url=require$$0$a,_path=require$$0$7,path=_interopRequireWildcard(_path),_http=require$$1$2,http=_interopRequireWildcard(_http),_https=require$$1$7,https=_interopRequireWildcard(_https),_events=require$$0$4;function _interopRequireWildcard(a){if(a&&a.__esModule)return a;var b={};if(null!=a)for(var c in a)Object.prototype.hasOwnProperty.call(a,c)&&(b[c]=a[c]);return b.default=a,b}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError('Cannot call a class as a function')}function _possibleConstructorReturn(a,b){if(!a)throw new ReferenceError('this hasn\'t been initialised - super() hasn\'t been called');return b&&('object'==typeof b||'function'==typeof b)?b:a}function _inherits(a,b){if('function'!=typeof b&&null!==b)throw new TypeError('Super expression must either be null or a function, not '+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b);}var DH_STATES=exports.DH_STATES={IDLE:'IDLE',SKIPPED:'SKIPPED',STARTED:'STARTED',DOWNLOADING:'DOWNLOADING',RETRY:'RETRY',PAUSED:'PAUSED',RESUMED:'RESUMED',STOPPED:'STOPPED',FINISHED:'FINISHED',FAILED:'FAILED'};exports.DownloaderHelper=function(a){function b(a,c){var d=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};_classCallCheck(this,b);var e=_possibleConstructorReturn(this,(b.__proto__||Object.getPrototypeOf(b)).call(this,{captureRejections:!0}));return e.__validate(a,c)?(e.url=e.requestURL=a.trim(),e.state=DH_STATES.IDLE,e.__defaultOpts={body:null,retry:!1,method:'GET',headers:{},fileName:'',timeout:-1,metadata:null,override:!1,forceResume:!1,removeOnStop:!0,removeOnFail:!0,progressThrottle:1e3,httpRequestOptions:{},httpsRequestOptions:{},resumeOnIncomplete:!0,resumeIfFileExists:!1,resumeOnIncompleteMaxRetry:5},e.__opts=Object.assign({},e.__defaultOpts),e.__pipes=[],e.__total=0,e.__downloaded=0,e.__progress=0,e.__retryCount=0,e.__retryTimeout=null,e.__resumeRetryCount=0,e.__states=DH_STATES,e.__promise=null,e.__request=null,e.__response=null,e.__isAborted=!1,e.__isResumed=!1,e.__isResumable=!1,e.__isRedirected=!1,e.__destFolder=c,e.__statsEstimate={time:0,bytes:0,prevBytes:0,throttleTime:0},e.__fileName='',e.__filePath='',e.updateOptions(d),e):_possibleConstructorReturn(e)}return _inherits(b,a),_createClass(b,[{key:'start',value:function c(){var a=this,b=function(){return new Promise(function(b,c){a.__promise={resolve:b,reject:c},a.__start();})};return this.__opts.resumeIfFileExists&&this.state!==this.__states.RESUMED?this.getTotalSize().then(function(c){var d=c.name,e=c.total,f=a.__opts.override;if(a.__opts.override=!0,a.__filePath=a.__getFilePath(d),a.__opts.override=f,a.__filePath&&fs.existsSync(a.__filePath)){var g=a.__getFilesizeInBytes(a.__filePath);return g===e?b():a.resumeFromFile(a.__filePath,{total:e,fileName:d})}return b()}):b()}},{key:'pause',value:function b(){var a=this;return this.state===this.__states.STOPPED?Promise.resolve(!0):(this.__response&&(this.__response.unpipe(),this.__pipes.forEach(function(a){return a.stream.unpipe()})),this.__fileStream&&this.__fileStream.removeAllListeners(),this.__requestAbort(),this.__closeFileStream().then(function(){return a.__setState(a.__states.PAUSED),a.emit('pause'),!0}))}},{key:'resume',value:function a(){return this.__promise?this.state===this.__states.STOPPED?Promise.resolve(!1):(this.__setState(this.__states.RESUMED),this.__isResumable&&(this.__isResumed=!0,this.__reqOptions.headers.range='bytes='+this.__downloaded+'-'),this.emit('resume',this.__isResumed),this.__start()):this.start()}},{key:'stop',value:function c(){var a=this;if(this.state===this.__states.STOPPED)return Promise.resolve(!0);var b=function(){return new Promise(function(b,c){fs.access(a.__filePath,function(d){return d?(a.__emitStop(),b(!0)):void fs.unlink(a.__filePath,function(d){return d?(a.__setState(a.__states.FAILED),a.emit('error',d),c(d)):void(a.__emitStop(),b(!0))})});})};return this.__requestAbort(),this.__closeFileStream().then(function(){return a.__opts.removeOnStop?b():(a.__emitStop(),Promise.resolve(!0))})}},{key:'pipe',value:function c(a){var b=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null;return this.__pipes.push({stream:a,options:b}),a}},{key:'unpipe',value:function d(){var a=this,b=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null,c=function(b){return a.__response?a.__response.unpipe(b):b.unpipe()};if(b){var e=this.__pipes.find(function(a){return a.stream===b});return void(e&&(c(b),this.__pipes=this.__pipes.filter(function(a){return a.stream!==b})))}this.__pipes.forEach(function(a){return c(a.stream)}),this.__pipes=[];}},{key:'getDownloadPath',value:function a(){return this.__filePath}},{key:'isResumable',value:function a(){return this.__isResumable}},{key:'updateOptions',value:function c(a){var b=1<arguments.length&&void 0!==arguments[1]?arguments[1]:'';this.__opts=Object.assign({},this.__opts,a),this.__headers=this.__opts.headers,-1<this.__opts.timeout&&(this.__opts.httpRequestOptions.timeout=this.__opts.timeout,this.__opts.httpsRequestOptions.timeout=this.__opts.timeout),('number'!=typeof this.__opts.progressThrottle||0>this.__opts.progressThrottle)&&(this.__opts.progressThrottle=this.__defaultOpts.progressThrottle),this.url=b||this.url,this.__reqOptions=this.__getReqOptions(this.__opts.method,this.url,this.__opts.headers),this.__initProtocol(this.url);}},{key:'getOptions',value:function a(){return this.__opts}},{key:'getMetadata',value:function a(){return this.__opts.metadata}},{key:'getStats',value:function a(){return {total:this.__total,name:this.__fileName,downloaded:this.__downloaded,progress:this.__progress,speed:this.__statsEstimate.bytes}}},{key:'getTotalSize',value:function b(){var a=this;return new Promise(function(b,c){var d=function(b){a.__initProtocol(b);var c=Object.assign({},a.__headers);c.hasOwnProperty('range')&&delete c.range;var d=a.__getReqOptions('HEAD',b,c);return Object.assign({},a.__reqOptions,d)},e=0,f=null,g=function(b,c){if(!a.__opts.retry||'object'!==_typeof(a.__opts.retry))return Promise.reject(b||new Error('wrong retry options'));f&&(clearTimeout(f),f=null);var g=a.__opts.retry,i=g.delay,j=void 0===i?0:i,k=g.maxRetries,l=void 0===k?999:k;return e>=l?Promise.reject(b||new Error('reached the maximum retries')):(e++,a.__setState(a.__states.RETRY),a.emit('retry',e,a.__opts.retry,b),new Promise(function(b){f=setTimeout(function(){a.__setState(a.__states.IDLE),h(c,d(c)),b();},j);}))},h=function(e,i){f&&(clearTimeout(f),f=null);var j=a.__protocol.request(i,function(f){if(a.__isRequireRedirect(f)){var i=/^https?:\/\//.test(f.headers.location)?f.headers.location:new _url.URL(f.headers.location,e).href;return a.emit('redirected',i,e),h(i,d(i))}if(200>f.statusCode||400<=f.statusCode){var j=new Error('Response status was '+f.statusCode);return a.__opts.retry&&500<=f.statusCode&&600>f.statusCode?g(j,e).catch(c):c(j)}b({name:a.__getFileNameFromHeaders(f.headers,f),total:parseInt(f.headers['content-length'])||null});});j.on('error',function(b){return a.__opts.retry?g(b,e).catch(c):void c(b)}),j.on('timeout',function(){return a.__opts.retry?g(new Error('timeout'),e).catch(c):void c(new Error('timeout'))}),j.on('uncaughtException',function(b){return a.__opts.retry?g(b,e).catch(c):void c(b)}),j.end();};h(a.url,d(a.url));})}},{key:'getResumeState',value:function a(){return {downloaded:this.__downloaded,filePath:this.__filePath,fileName:this.__fileName,total:this.__total}}},{key:'resumeFromFile',value:function d(a){var b=this,c=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};return this.__opts.override=!0,this.__filePath=a,(c.total&&c.fileName?Promise.resolve({name:c.fileName,total:c.total}):this.getTotalSize()).then(function(a){var d=a.name,e=a.total;return b.__total=c.total||e,b.__fileName=c.fileName||d,b.__downloaded=c.downloaded||b.__getFilesizeInBytes(b.__filePath),b.__reqOptions.headers.range='bytes='+b.__downloaded+'-',b.__isResumed=!0,b.__isResumable=!0,b.__setState(b.__states.RESUMED),b.emit('resume',b.__isResumed),new Promise(function(a,c){b.__promise={resolve:a,reject:c},b.__start();})})}},{key:'__start',value:function a(){this.__isRedirected||this.state===this.__states.RESUMED||(this.emit('start'),this.__setState(this.__states.STARTED),this.__initProtocol(this.url)),this.__response=null,this.__isAborted=!1,this.__request&&!this.__request.destroyed&&this.__request.destroy(),this.__retryTimeout&&(clearTimeout(this.__retryTimeout),this.__retryTimeout=null),this.__request=this.__downloadRequest(this.__promise.resolve,this.__promise.reject),this.__request.on('error',this.__onError(this.__promise.resolve,this.__promise.reject)),this.__request.on('timeout',this.__onTimeout(this.__promise.resolve,this.__promise.reject)),this.__request.on('uncaughtException',this.__onError(this.__promise.resolve,this.__promise.reject,!0)),this.__opts.body&&this.__request.write(this.__opts.body),this.__request.end();}},{key:'__resolvePending',value:function b(){if(this.__promise){var a=this.__promise.resolve;return this.__promise=null,a(!0)}}},{key:'__downloadRequest',value:function d(a,b){var c=this;return this.__protocol.request(this.__reqOptions,function(d){if(c.__response=d,c.__isResumed||(c.__total=parseInt(d.headers['content-length'])||null,c.__resetStats()),c.__isRequireRedirect(d)){var e=/^https?:\/\//.test(d.headers.location)?d.headers.location:new _url.URL(d.headers.location,c.url).href;return c.__isRedirected=!0,c.__initProtocol(e),c.emit('redirected',e,c.url),c.__start()}if(200>d.statusCode||400<=d.statusCode){var f=new Error('Response status was '+d.statusCode);return (f.status=d.statusCode||0,f.body=d.body||'',500<=d.statusCode&&600>d.statusCode)?c.__onError(a,b)(f):(c.__setState(c.__states.FAILED),c.emit('error',f),b(f))}c.__opts.forceResume?c.__isResumable=!0:d.headers.hasOwnProperty('accept-ranges')&&'none'!==d.headers['accept-ranges']&&(c.__isResumable=!0),c.__startDownload(d,a,b);})}},{key:'__startDownload',value:function h(a,b,c){var d=this,e=a;if(!this.__isResumed){var i=this.__getFileNameFromHeaders(a.headers);if(this.__filePath=this.__getFilePath(i),this.__fileName=this.__filePath.split(path.sep).pop(),fs.existsSync(this.__filePath)){var f=this.__getFilesizeInBytes(this.__filePath),g=this.__total?this.__total:0;if('object'===_typeof(this.__opts.override)&&this.__opts.override.skip&&(this.__opts.override.skipSmaller||f>=g))return this.emit('skip',{totalSize:this.__total,fileName:this.__fileName,filePath:this.__filePath,downloadedSize:f}),this.__setState(this.__states.SKIPPED),b(!0)}this.__fileStream=fs.createWriteStream(this.__filePath,{});}else this.__fileStream=fs.createWriteStream(this.__filePath,{flags:'a'});this.emit('download',{fileName:this.__fileName,filePath:this.__filePath,totalSize:this.__total,isResumed:this.__isResumed,downloadedSize:this.__downloaded}),this.__retryCount=0,this.__isResumed=!1,this.__isRedirected=!1,this.__setState(this.__states.DOWNLOADING),this.__statsEstimate.time=new Date,this.__statsEstimate.throttleTime=new Date,e.on('data',function(a){return d.__calculateStats(a.length)}),this.__pipes.forEach(function(a){e.pipe(a.stream,a.options),e=a.stream;}),e.pipe(this.__fileStream),e.on('error',this.__onError(b,c)),this.__fileStream.on('finish',this.__onFinished(b,c)),this.__fileStream.on('error',this.__onError(b,c));}},{key:'__hasFinished',value:function a(){return !this.__isAborted&&-1===[this.__states.PAUSED,this.__states.STOPPED,this.__states.RETRY,this.__states.FAILED,this.__states.RESUMED].indexOf(this.state)}},{key:'__isRequireRedirect',value:function b(a){return 300<a.statusCode&&400>a.statusCode&&a.headers.hasOwnProperty('location')&&a.headers.location}},{key:'__onFinished',value:function d(a,b){var c=this;return function(){c.__fileStream.close(function(d){if(d)return b(d);if(c.__hasFinished()){var e=!!c.__total&&c.__downloaded!==c.__total;if(e&&c.__isResumable&&c.__opts.resumeOnIncomplete&&c.__resumeRetryCount<=c.__opts.resumeOnIncompleteMaxRetry)return c.__resumeRetryCount++,c.emit('warning',new Error('uncomplete download, retrying')),c.resume();c.__setState(c.__states.FINISHED),c.__pipes=[],c.emit('end',{fileName:c.__fileName,filePath:c.__filePath,totalSize:c.__total,incomplete:e,onDiskSize:c.__getFilesizeInBytes(c.__filePath),downloadedSize:c.__downloaded});}return a(c.__downloaded===c.__total)});}}},{key:'__closeFileStream',value:function b(){var a=this;return this.__fileStream?new Promise(function(b,c){a.__fileStream.close(function(a){return a?c(a):b(!0)});}):Promise.resolve(!0)}},{key:'__onError',value:function e(a,b){var c=this,d=!!(2<arguments.length&&void 0!==arguments[2])&&arguments[2];return function(a){return c.__pipes=[],d&&c.__requestAbort(),c.state===c.__states.STOPPED||c.state===c.__states.FAILED?void 0:c.__opts.retry?c.__retry(a).catch(function(d){c.__removeFile().finally(function(){c.__setState(c.__states.FAILED),c.emit('error',d?d:a),b(d?d:a);});}):c.__removeFile().finally(function(){c.__setState(c.__states.FAILED),c.emit('error',a),b(a);})}}},{key:'__retry',value:function h(){var a=this,b=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null;if(!this.__opts.retry||'object'!==_typeof(this.__opts.retry))return Promise.reject(b||new Error('wrong retry options'));var c=this.__opts.retry,d=c.delay,e=void 0===d?0:d,f=c.maxRetries,g=void 0===f?999:f;return this.__retryCount>=g?Promise.reject(b||new Error('reached the maximum retries')):(this.__retryCount++,this.__setState(this.__states.RETRY),this.emit('retry',this.__retryCount,this.__opts.retry,b),this.__response&&(this.__response.unpipe(),this.__pipes.forEach(function(a){return a.stream.unpipe()})),this.__fileStream&&this.__fileStream.removeAllListeners(),this.__requestAbort(),this.__closeFileStream().then(function(){return new Promise(function(b){return a.__retryTimeout=setTimeout(function(){return b(0<a.__downloaded?a.resume():a.__start())},e)})}))}},{key:'__onTimeout',value:function d(a,b){var c=this;return function(){return c.__requestAbort(),c.__opts.retry?c.__retry(new Error('timeout')).catch(function(a){c.__removeFile().finally(function(){c.__setState(c.__states.FAILED),a?b(a):(c.emit('timeout'),b(new Error('timeout')));});}):c.__removeFile().finally(function(){c.__setState(c.__states.FAILED),c.emit('timeout'),b(new Error('timeout'));})}}},{key:'__resetStats',value:function a(){this.__retryCount=0,this.__downloaded=0,this.__progress=0,this.__resumeRetryCount=0,this.__statsEstimate={time:0,bytes:0,prevBytes:0,throttleTime:0};}},{key:'__getFileNameFromHeaders',value:function k(a,b){var c='',d=/.*filename\*=.*?'.*?'([^"].+?[^"])(?:(?:;)|$)/i,e=/.*filename="(.*?)";?/i,f=/.*filename=([^"].+?[^"])(?:(?:;)|$)/i,g=a.hasOwnProperty('content-disposition'),h=g?a['content-disposition'].match(d):null,i=!g||h?null:a['content-disposition'].match(e),j=!g||h||i?null:a['content-disposition'].match(f);return g&&(h||i||j)?(c=a['content-disposition'],c=c.trim(),h?c=h[1]:i?c=i[1]:j&&(c=j[1]),c=c.replace(/[/\\]/g,'')):0<path.basename(new _url.URL(this.requestURL).pathname).length?c=path.basename(new _url.URL(this.requestURL).pathname):c=new _url.URL(this.requestURL).hostname+'.html',this.__opts.fileName?this.__getFileNameFromOpts(c,b):c.replace(/\.*$/,'')}},{key:'__getFilePath',value:function d(a){var b=path.join(this.__destFolder,a),c=b;return this.__opts.override||this.state===this.__states.RESUMED||(c=this.__uniqFileNameSync(c),b!==c&&this.emit('renamed',{path:c,fileName:c.split(path.sep).pop(),prevPath:b,prevFileName:b.split(path.sep).pop()})),c}},{key:'__getFileNameFromOpts',value:function g(a,b){if(!this.__opts.fileName)return a;if('string'==typeof this.__opts.fileName)return this.__opts.fileName;if('function'==typeof this.__opts.fileName){var h=path.join(this.__destFolder,a);return b&&b.headers||this.__response&&this.__response.headers?this.__opts.fileName(a,h,(b?b:this.__response).headers['content-type']):this.__opts.fileName(a,h)}if('object'===_typeof(this.__opts.fileName)){var c=this.__opts.fileName,d=c.name,e=!!c.hasOwnProperty('ext')&&c.ext;if('string'==typeof e)return d+'.'+e;if('boolean'==typeof e){if(e)return d;var f=a.includes('.')?a.split('.').pop():'';return ''===f?d:d+'.'+f}}return a}},{key:'__calculateStats',value:function f(a){var b=new Date,c=b-this.__statsEstimate.time,d=b-this.__statsEstimate.throttleTime,e=this.__total||0;a&&(this.__downloaded+=a,this.__progress=0===e?0:100*(this.__downloaded/e),(this.__downloaded===e||1e3<c)&&(this.__statsEstimate.time=b,this.__statsEstimate.bytes=this.__downloaded-this.__statsEstimate.prevBytes,this.__statsEstimate.prevBytes=this.__downloaded),(this.__downloaded===e||d>this.__opts.progressThrottle)&&(this.__statsEstimate.throttleTime=b,this.emit('progress.throttled',this.getStats())),this.emit('progress',this.getStats()));}},{key:'__setState',value:function b(a){this.state=a,this.emit('stateChanged',this.state);}},{key:'__getReqOptions',value:function f(a,b){var c=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},d=new _url.URL(b),e={protocol:d.protocol,host:d.hostname,port:d.port,path:d.pathname+d.search,method:a};return c&&(e.headers=c),e}},{key:'__getFilesizeInBytes',value:function d(a){try{var b=fs.statSync(a,{throwIfNoEntry:!1}),c=b.size||0;return c}catch(a){this.emit('warning',a);}return 0}},{key:'__validate',value:function d(a,b){if('string'!=typeof a)throw new Error('URL should be an string');if(''===a.trim())throw new Error('URL couldn\'t be empty');if('string'!=typeof b)throw new Error('Destination Folder should be an string');if(''===b.trim())throw new Error('Destination Folder couldn\'t be empty');if(!fs.existsSync(b))throw new Error('Destination Folder must exist');var c=fs.statSync(b);if(!c.isDirectory())throw new Error('Destination Folder must be a directory');try{fs.accessSync(b,fs.constants.W_OK);}catch(a){throw new Error('Destination Folder must be writable')}return !0}},{key:'__initProtocol',value:function c(a){var b=this.__getReqOptions(this.__opts.method,a,this.__headers);this.requestURL=a,-1<a.indexOf('https://')?(this.__protocol=https,b.agent=new https.Agent({keepAlive:!1}),this.__reqOptions=Object.assign({},b,this.__opts.httpsRequestOptions)):(this.__protocol=http,b.agent=new http.Agent({keepAlive:!1}),this.__reqOptions=Object.assign({},b,this.__opts.httpRequestOptions));}},{key:'__uniqFileNameSync',value:function f(a){if('string'!=typeof a||''===a)return a;try{fs.accessSync(a,fs.F_OK);var b=a.match(/(.*)(\([0-9]+\))(\..*)$/),c=b?b[1].trim():a,d=b?parseInt(b[2].replace(/\(|\)/,'')):0,e=a.split('.').pop();return e!==a&&0<e.length?(e='.'+e,c=c.replace(e,'')):e='',this.__uniqFileNameSync(c+' ('+ ++d+')'+e)}catch(b){return a}}},{key:'__removeFile',value:function b(){var a=this;return new Promise(function(b){return a.__fileStream?void a.__fileStream.close(function(c){return c&&a.emit('warning',c),a.__opts.removeOnFail?fs.access(a.__filePath,function(d){return d?b():void fs.unlink(a.__filePath,function(d){d&&a.emit('warning',c),b();})}):void b()}):b()})}},{key:'__requestAbort',value:function a(){this.__isAborted=!0,this.__retryTimeout&&(clearTimeout(this.__retryTimeout),this.__retryTimeout=null),this.__response&&this.__response.destroy(),this.__request&&(this.__request.destroy?this.__request.destroy():this.__request.abort());}},{key:'__emitStop',value:function a(){this.__resolvePending(),this.__setState(this.__states.STOPPED),this.emit('stop');}}]),b}(_events.EventEmitter);
75302
75353
  } (dist));
75303
75354
 
75304
75355
  async function download(output, url, options) {
@@ -76773,6 +76824,7 @@ async function subtitleRecognize(file, modelId, options) {
76773
76824
  fillGap,
76774
76825
  disableCache,
76775
76826
  song: options?.song,
76827
+ modelId,
76776
76828
  });
76777
76829
  try {
76778
76830
  // 生成缓存路径
@@ -76882,8 +76934,11 @@ router$1.post("/subtitle", async (ctx) => {
76882
76934
  };
76883
76935
  return;
76884
76936
  }
76885
- const config = index$1.appConfig.get("ai") || {};
76886
- const asrModelId = config.subtitleRecognize.modelId;
76937
+ let asrModelId = data.modelId;
76938
+ if (!asrModelId) {
76939
+ const config = index$1.appConfig.get("ai") || {};
76940
+ asrModelId = config.subtitleRecognize.modelId;
76941
+ }
76887
76942
  if (!asrModelId) {
76888
76943
  throw new Error("请先在配置中设置字幕识别ASR模型");
76889
76944
  }
@@ -79203,7 +79258,7 @@ let handler;
79203
79258
  let appConfig;
79204
79259
  let container;
79205
79260
  const fileCache = createFileCache();
79206
- path$3.dirname(require$$0$4.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index-BFO4BeOx.cjs', document.baseURI).href))));
79261
+ path$3.dirname(urlLib.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index-CNjM3nfn.cjs', document.baseURI).href))));
79207
79262
  const authMiddleware = (passKey) => {
79208
79263
  return async (ctx, next) => {
79209
79264
  const authHeader = ctx.headers["authorization"] || ctx.request.query.auth;
@@ -79284,7 +79339,7 @@ async function serverStart(options, axContainer) {
79284
79339
  async function createServer(options) {
79285
79340
  index$1.logObj.info(`开始创建服务器: ${options.host}:${options.port}`);
79286
79341
  {
79287
- const httpServer = require$$2$1.createServer(app.callback());
79342
+ const httpServer = http$4.createServer(app.callback());
79288
79343
  httpServer.on("error", (err) => {
79289
79344
  index$1.logObj.error("HTTP 服务器错误:", err);
79290
79345
  });