bililive-cli 3.16.1 → 3.17.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.
@@ -2,27 +2,27 @@
2
2
 
3
3
  var path$3 = require('node:path');
4
4
  var require$$2$1 = require('node:http');
5
- var require$$1$2 = require('node:url');
5
+ var require$$0$4 = require('node:url');
6
6
  var a$1 = require('node:https');
7
- var index$1 = require('./index-BUEtH4Dz.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');
7
+ var index$1 = require('./index-BZBJd-mI.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');
16
16
  var zlib$1 = require('zlib');
17
- var require$$0$a = require('url');
18
- var require$$1$3 = require('crypto');
17
+ var require$$0$b = require('url');
18
+ var require$$1$2 = require('crypto');
19
19
  var require$$3$1 = require('http');
20
- var require$$0$c = require('net');
20
+ var require$$0$d = require('net');
21
21
  var require$$5$1 = require('querystring');
22
22
  var require$$17 = require('async_hooks');
23
- var require$$1$5 = require('string_decoder');
23
+ var require$$1$4 = require('string_decoder');
24
24
  var os$1 = require('node:os');
25
- var require$$1$6 = require('os');
25
+ var require$$1$5 = 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');
@@ -32,9 +32,9 @@ 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$d = require('child_process');
36
- var require$$1$7 = require('https');
37
- var require$$0$e = require('node:stream');
35
+ var require$$0$e = require('child_process');
36
+ var require$$1$6 = require('https');
37
+ var require$$0$f = require('node:stream');
38
38
  var web = require('node:stream/web');
39
39
  var shazamioCore = require('shazamio-core');
40
40
 
@@ -871,7 +871,7 @@ class AliyunPan extends index$1.TypedEmitter {
871
871
  */
872
872
  const combineURLs = (baseURL, relativeURL) => {
873
873
  return relativeURL
874
- ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
874
+ ? baseURL.replace(/\/+$/, "") + "/" + relativeURL.replace(/^\/+/, "")
875
875
  : baseURL;
876
876
  };
877
877
 
@@ -1183,7 +1183,7 @@ class Alist extends index$1.TypedEmitter {
1183
1183
  this.emit("canceled", "上传已取消");
1184
1184
  },
1185
1185
  };
1186
- const url = new require$$1$2.URL(combineURLs(this.server, "/api/fs/put"));
1186
+ const url = new require$$0$4.URL(combineURLs(this.server, "/api/fs/put"));
1187
1187
  const httpModule = url.protocol === "https:" ? a$1 : require$$2$1;
1188
1188
  try {
1189
1189
  await new Promise((resolve, reject) => {
@@ -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$4;
1545
+ const EventEmitter$3 = require$$0$5;
1546
1546
  const http$3 = require$$3$1;
1547
- const { createHash } = require$$1$3;
1547
+ const { createHash } = require$$1$2;
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$5;
2702
- const util = require$$1$4;
2701
+ const tty = require$$0$6;
2702
+ const util = require$$1$3;
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$6;
3318
+ var buffer = require$$0$7;
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$7.basename;
3404
+ var basename$2 = require$$0$8.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$4.EventEmitter;
4780
- var ReadStream = require$$0$8.ReadStream;
4781
- var Stream$3 = require$$0$9;
4779
+ var EventEmitter$2 = require$$0$5.EventEmitter;
4780
+ var ReadStream = require$$0$9.ReadStream;
4781
+ var Stream$3 = require$$0$a;
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$b;
5210
- const extname = require$$0$7.extname;
5209
+ const assert = require$$0$c;
5210
+ const extname = require$$0$8.extname;
5211
5211
  const vary = varyExports;
5212
5212
  const only = only$1;
5213
- const util = require$$1$4;
5213
+ const util = require$$1$3;
5214
5214
  const encodeUrl = encodeurl;
5215
- const Stream = require$$0$9;
5216
- const URL = require$$0$a.URL;
5215
+ const Stream = require$$0$a;
5216
+ const URL = require$$0$b.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$4.EventEmitter;
5999
+ var EventEmitter = require$$0$5.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$7.relative;
6081
+ var relative$1 = require$$0$8.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$7.relative;
7255
+ var relative = require$$0$8.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$3;
7790
+ var crypto$2 = require$$1$2;
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$3;
7828
+ var crypto$1 = require$$1$2;
7829
7829
 
7830
7830
  function Keygrip$1(keys, algorithm, encoding) {
7831
7831
  if (!algorithm) algorithm = "sha1";
@@ -8163,7 +8163,7 @@ var cookies = Cookies;
8163
8163
  * Module dependencies.
8164
8164
  */
8165
8165
 
8166
- const util = require$$1$4;
8166
+ const util = require$$1$3;
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$a;
9814
+ var url = require$$0$b;
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$a.URL;
10102
- const net = require$$0$c;
10101
+ const URL = require$$0$b.URL;
10102
+ const net = require$$0$d;
10103
10103
  const accepts$1 = accepts;
10104
10104
  const contentType$1 = contentType;
10105
- const stringify = require$$0$a.format;
10105
+ const stringify = require$$0$b.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$4;
10111
+ const util = require$$1$3;
10112
10112
 
10113
10113
  const IP = Symbol('context#ip');
10114
10114
 
@@ -11169,15 +11169,15 @@ 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$b;
11172
+ const assert = require$$0$c;
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$4;
11179
- const util$3 = require$$1$4;
11180
- const Stream$2 = require$$0$9;
11178
+ const Emitter = require$$0$5;
11179
+ const util$3 = require$$1$3;
11180
+ const Stream$2 = require$$0$a;
11181
11181
  const http$1 = require$$3$1;
11182
11182
  const only = only$1;
11183
11183
  const convert = koaConvert;
@@ -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$$1$2;
12396
+ const { parse: parseUrl, format: formatUrl } = require$$0$4;
12397
12397
 
12398
12398
  const { pathToRegexp: pathToRegexp$1, compile, parse: parse$a } = dist$1;
12399
12399
 
@@ -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$6;
13847
+ var buffer$1 = require$$0$7;
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$5.StringDecoder;
14028
+ var StringDecoder = require$$1$4.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$6.Buffer,
24430
- Transform = require$$0$9.Transform;
24429
+ var Buffer = require$$0$7.Buffer,
24430
+ Transform = require$$0$a.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$6.Buffer;
24556
+ var Buffer = require$$0$7.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$6.SlowBuffer;
24589
+ var SlowBuffer = require$$0$7.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$9.Readable;
24729
+ var Readable = require$$0$a.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$6.SlowBuffer;
24752
+ var SlowBuffer = require$$0$7.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$9.Readable;
24763
+ var Readable = require$$0$a.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$4.inspect;
25710
+ var util_inspect = require$$1$3.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;
@@ -30293,7 +30293,7 @@ var hasRequiredStream$1;
30293
30293
  function requireStream$1 () {
30294
30294
  if (hasRequiredStream$1) return stream$3;
30295
30295
  hasRequiredStream$1 = 1;
30296
- stream$3 = require$$0$9;
30296
+ stream$3 = require$$0$a;
30297
30297
  return stream$3;
30298
30298
  }
30299
30299
 
@@ -30406,7 +30406,7 @@ function requireUtil () {
30406
30406
  }
30407
30407
  util$2.isPrimitive = isPrimitive;
30408
30408
 
30409
- util$2.isBuffer = require$$0$6.Buffer.isBuffer;
30409
+ util$2.isBuffer = require$$0$7.Buffer.isBuffer;
30410
30410
 
30411
30411
  function objectToString(o) {
30412
30412
  return Object.prototype.toString.call(o);
@@ -30426,7 +30426,7 @@ function requireBufferList () {
30426
30426
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
30427
30427
 
30428
30428
  var Buffer = index$1.safeBufferExports.Buffer;
30429
- var util = require$$1$4;
30429
+ var util = require$$1$3;
30430
30430
 
30431
30431
  function copyBuffer(src, target, offset) {
30432
30432
  src.copy(target, offset);
@@ -30605,7 +30605,7 @@ function requireNode () {
30605
30605
  * For Node.js, simply re-export the core `util.deprecate` function.
30606
30606
  */
30607
30607
 
30608
- node = require$$1$4.deprecate;
30608
+ node = require$$1$3.deprecate;
30609
30609
  return node;
30610
30610
  }
30611
30611
 
@@ -31690,7 +31690,7 @@ function require_stream_readable$1 () {
31690
31690
  Readable.ReadableState = ReadableState;
31691
31691
 
31692
31692
  /*<replacement>*/
31693
- require$$0$4.EventEmitter;
31693
+ require$$0$5.EventEmitter;
31694
31694
 
31695
31695
  var EElistenerCount = function (emitter, type) {
31696
31696
  return emitter.listeners(type).length;
@@ -31720,7 +31720,7 @@ function require_stream_readable$1 () {
31720
31720
  /*</replacement>*/
31721
31721
 
31722
31722
  /*<replacement>*/
31723
- var debugUtil = require$$1$4;
31723
+ var debugUtil = require$$1$3;
31724
31724
  var debug = void 0;
31725
31725
  if (debugUtil && debugUtil.debuglog) {
31726
31726
  debug = debugUtil.debuglog('stream');
@@ -32866,7 +32866,7 @@ function requireReadable () {
32866
32866
  if (hasRequiredReadable) return readable$1.exports;
32867
32867
  hasRequiredReadable = 1;
32868
32868
  (function (module, exports) {
32869
- var Stream = require$$0$9;
32869
+ var Stream = require$$0$a;
32870
32870
  if (process.env.READABLE_STREAM === 'disable' && Stream) {
32871
32871
  module.exports = Stream;
32872
32872
  exports = module.exports = Stream.Readable;
@@ -45242,7 +45242,7 @@ function matchNeedle(self, data, pos, len) {
45242
45242
 
45243
45243
  var sbmh = SBMH;
45244
45244
 
45245
- const { Readable: Readable$1, Writable: Writable$2 } = require$$0$9;
45245
+ const { Readable: Readable$1, Writable: Writable$2 } = require$$0$a;
45246
45246
 
45247
45247
  const StreamSearch = sbmh;
45248
45248
 
@@ -45892,7 +45892,7 @@ const FIELD_VCHAR = [
45892
45892
 
45893
45893
  var multipart = Multipart;
45894
45894
 
45895
- const { Writable: Writable$1 } = require$$0$9;
45895
+ const { Writable: Writable$1 } = require$$0$a;
45896
45896
 
45897
45897
  const { getDecoder } = utils;
45898
45898
 
@@ -46449,7 +46449,7 @@ function appendField$1 (store, key, value) {
46449
46449
 
46450
46450
  var appendField_1 = appendField$1;
46451
46451
 
46452
- var EventEmitter$1 = require$$0$4.EventEmitter;
46452
+ var EventEmitter$1 = require$$0$5.EventEmitter;
46453
46453
 
46454
46454
  function Counter$1 () {
46455
46455
  EventEmitter$1.call(this);
@@ -46478,7 +46478,7 @@ Counter$1.prototype.onceZero = function onceZero (fn) {
46478
46478
 
46479
46479
  var counter = Counter$1;
46480
46480
 
46481
- var util$1 = require$$1$4;
46481
+ var util$1 = require$$1$3;
46482
46482
 
46483
46483
  var errorMessages = {
46484
46484
  LIMIT_PART_COUNT: 'Too many parts',
@@ -46863,8 +46863,8 @@ function makeMiddleware$1 (setup) {
46863
46863
 
46864
46864
  var makeMiddleware_1 = makeMiddleware$1;
46865
46865
 
46866
- var path$2 = require$$0$7;
46867
- var fs$5 = require$$0$8;
46866
+ var path$2 = require$$0$8;
46867
+ var fs$5 = require$$0$9;
46868
46868
  var _0777 = parseInt('0777', 8);
46869
46869
 
46870
46870
  var mkdirp$1 = mkdirP.mkdirp = mkdirP.mkdirP = mkdirP;
@@ -46966,10 +46966,10 @@ mkdirP.sync = function sync (p, opts, made) {
46966
46966
  return made;
46967
46967
  };
46968
46968
 
46969
- var fs$4 = require$$0$8;
46970
- var os = require$$1$6;
46971
- var path$1 = require$$0$7;
46972
- var crypto = require$$1$3;
46969
+ var fs$4 = require$$0$9;
46970
+ var os = require$$1$5;
46971
+ var path$1 = require$$0$8;
46972
+ var crypto = require$$1$2;
46973
46973
  var mkdirp = mkdirp$1;
46974
46974
 
46975
46975
  function getFilename (req, file, cb) {
@@ -48283,7 +48283,31 @@ router$g.post("/import", upload$1.single("file"), async (ctx) => {
48283
48283
  });
48284
48284
  router$g.post("/notifyTest", async (ctx) => {
48285
48285
  const { title, desp, options, notifyType } = ctx.request.body;
48286
- await index$1._send(title, desp, options, notifyType);
48286
+ await index$1._send(title, desp, options, notifyType, {
48287
+ context: {
48288
+ event: "notify_test",
48289
+ eventLabel: "测试通知",
48290
+ roomId: "123456",
48291
+ platform: "Bilibili",
48292
+ username: "测试主播",
48293
+ liveTitle: "这是一条测试直播标题",
48294
+ liveId: "live_test_001",
48295
+ roomUrl: "https://live.bilibili.com/123456",
48296
+ taskName: "上传视频:测试文件.mp4",
48297
+ taskType: "upload",
48298
+ taskStatus: "success",
48299
+ taskId: "task_test_001",
48300
+ filename: "test-file.mp4",
48301
+ filePath: "D:/record/test-file.mp4",
48302
+ mediaTitle: "测试稿件",
48303
+ aid: 123456789,
48304
+ startedAt: new Date().toISOString(),
48305
+ endedAt: new Date().toISOString(),
48306
+ durationMs: 3000,
48307
+ error: "",
48308
+ output: "测试输出内容",
48309
+ },
48310
+ });
48287
48311
  ctx.body = "success";
48288
48312
  });
48289
48313
 
@@ -49355,8 +49379,8 @@ class Ollama extends Ollama$1 {
49355
49379
  return Buffer.from(image).toString("base64");
49356
49380
  }
49357
49381
  try {
49358
- if (require$$0$8.existsSync(image)) {
49359
- const fileBuffer = await require$$0$8.promises.readFile(require$$0$7.resolve(image));
49382
+ if (require$$0$9.existsSync(image)) {
49383
+ const fileBuffer = await require$$0$9.promises.readFile(require$$0$8.resolve(image));
49360
49384
  return Buffer.from(fileBuffer).toString("base64");
49361
49385
  }
49362
49386
  } catch {
@@ -49395,9 +49419,9 @@ class Ollama extends Ollama$1 {
49395
49419
  */
49396
49420
  resolvePath(inputPath, mfDir) {
49397
49421
  if (inputPath.startsWith("~")) {
49398
- return require$$0$7.join(require$$1$6.homedir(), inputPath.slice(1));
49422
+ return require$$0$8.join(require$$1$5.homedir(), inputPath.slice(1));
49399
49423
  }
49400
- return require$$0$7.resolve(mfDir, inputPath);
49424
+ return require$$0$8.resolve(mfDir, inputPath);
49401
49425
  }
49402
49426
  /**
49403
49427
  * checks if a file exists
@@ -49407,7 +49431,7 @@ class Ollama extends Ollama$1 {
49407
49431
  */
49408
49432
  async fileExists(path) {
49409
49433
  try {
49410
- await require$$0$8.promises.access(path);
49434
+ await require$$0$9.promises.access(path);
49411
49435
  return true;
49412
49436
  } catch {
49413
49437
  return false;
@@ -49417,9 +49441,9 @@ class Ollama extends Ollama$1 {
49417
49441
  if (typeof ReadableStream === "undefined") {
49418
49442
  throw new Error("Streaming uploads are not supported in this environment.");
49419
49443
  }
49420
- const fileStream = require$$0$8.createReadStream(path);
49444
+ const fileStream = require$$0$9.createReadStream(path);
49421
49445
  const sha256sum = await new Promise((resolve2, reject) => {
49422
- const hash = require$$1$3.createHash("sha256");
49446
+ const hash = require$$1$2.createHash("sha256");
49423
49447
  fileStream.on("data", (data) => hash.update(data));
49424
49448
  fileStream.on("end", () => resolve2(hash.digest("hex")));
49425
49449
  fileStream.on("error", reject);
@@ -49456,10 +49480,10 @@ class Ollama extends Ollama$1 {
49456
49480
  async create(request) {
49457
49481
  let modelfileContent = "";
49458
49482
  if (request.path) {
49459
- modelfileContent = await require$$0$8.promises.readFile(request.path, { encoding: "utf8" });
49483
+ modelfileContent = await require$$0$9.promises.readFile(request.path, { encoding: "utf8" });
49460
49484
  modelfileContent = await this.parseModelfile(
49461
49485
  modelfileContent,
49462
- require$$0$7.dirname(request.path)
49486
+ require$$0$8.dirname(request.path)
49463
49487
  );
49464
49488
  } else if (request.modelfile) {
49465
49489
  modelfileContent = await this.parseModelfile(request.modelfile);
@@ -49588,7 +49612,7 @@ var hasRequiredStream;
49588
49612
  function requireStream () {
49589
49613
  if (hasRequiredStream) return stream$1;
49590
49614
  hasRequiredStream = 1;
49591
- stream$1 = require$$0$9;
49615
+ stream$1 = require$$0$a;
49592
49616
  return stream$1;
49593
49617
  }
49594
49618
 
@@ -49607,9 +49631,9 @@ function requireBuffer_list () {
49607
49631
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
49608
49632
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
49609
49633
  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); }
49610
- var _require = require$$0$6,
49634
+ var _require = require$$0$7,
49611
49635
  Buffer = _require.Buffer;
49612
- var _require2 = require$$1$4,
49636
+ var _require2 = require$$1$3,
49613
49637
  inspect = _require2.inspect;
49614
49638
  var custom = inspect && inspect.custom || 'inspect';
49615
49639
  function copyBuffer(src, target, offset) {
@@ -50079,7 +50103,7 @@ function require_stream_writable () {
50079
50103
  var Stream = requireStream();
50080
50104
  /*</replacement>*/
50081
50105
 
50082
- var Buffer = require$$0$6.Buffer;
50106
+ var Buffer = require$$0$7.Buffer;
50083
50107
  var OurUint8Array = (typeof index$1.commonjsGlobal !== 'undefined' ? index$1.commonjsGlobal : typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : {}).Uint8Array || function () {};
50084
50108
  function _uint8ArrayToBuffer(chunk) {
50085
50109
  return Buffer.from(chunk);
@@ -51404,7 +51428,7 @@ function require_stream_readable () {
51404
51428
  Readable.ReadableState = ReadableState;
51405
51429
 
51406
51430
  /*<replacement>*/
51407
- require$$0$4.EventEmitter;
51431
+ require$$0$5.EventEmitter;
51408
51432
  var EElistenerCount = function EElistenerCount(emitter, type) {
51409
51433
  return emitter.listeners(type).length;
51410
51434
  };
@@ -51414,7 +51438,7 @@ function require_stream_readable () {
51414
51438
  var Stream = requireStream();
51415
51439
  /*</replacement>*/
51416
51440
 
51417
- var Buffer = require$$0$6.Buffer;
51441
+ var Buffer = require$$0$7.Buffer;
51418
51442
  var OurUint8Array = (typeof index$1.commonjsGlobal !== 'undefined' ? index$1.commonjsGlobal : typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : {}).Uint8Array || function () {};
51419
51443
  function _uint8ArrayToBuffer(chunk) {
51420
51444
  return Buffer.from(chunk);
@@ -51424,7 +51448,7 @@ function require_stream_readable () {
51424
51448
  }
51425
51449
 
51426
51450
  /*<replacement>*/
51427
- var debugUtil = require$$1$4;
51451
+ var debugUtil = require$$1$3;
51428
51452
  var debug;
51429
51453
  if (debugUtil && debugUtil.debuglog) {
51430
51454
  debug = debugUtil.debuglog('stream');
@@ -52649,7 +52673,7 @@ function requirePipeline () {
52649
52673
  }
52650
52674
 
52651
52675
  (function (module, exports) {
52652
- var Stream = require$$0$9;
52676
+ var Stream = require$$0$a;
52653
52677
  if (process.env.READABLE_STREAM === 'disable' && Stream) {
52654
52678
  module.exports = Stream.Readable;
52655
52679
  Object.assign(module.exports, Stream);
@@ -56042,7 +56066,7 @@ router$d.post("/get_cookie", async (ctx) => {
56042
56066
  return;
56043
56067
  }
56044
56068
  const secret = "r96gkr8ahc34fsrewr34";
56045
- const hash = require$$1$3.createHmac("sha256", secret).update(`${uid}${timestamp}`).digest("hex");
56069
+ const hash = require$$1$2.createHmac("sha256", secret).update(`${uid}${timestamp}`).digest("hex");
56046
56070
  if (hash !== signature) {
56047
56071
  ctx.status = 400;
56048
56072
  ctx.body = "签名无效";
@@ -56210,10 +56234,10 @@ router$c.put("/subtitle-style/:id", async (ctx) => {
56210
56234
 
56211
56235
  var chokidar = {};
56212
56236
 
56213
- const fs$3 = require$$0$8;
56214
- const { Readable } = require$$0$9;
56215
- const sysPath$3 = require$$0$7;
56216
- const { promisify: promisify$3 } = require$$1$4;
56237
+ const fs$3 = require$$0$9;
56238
+ const { Readable } = require$$0$a;
56239
+ const sysPath$3 = require$$0$8;
56240
+ const { promisify: promisify$3 } = require$$1$3;
56217
56241
  const picomatch$1 = index$1.picomatch;
56218
56242
 
56219
56243
  const readdir$1 = promisify$3(fs$3.readdir);
@@ -56907,7 +56931,7 @@ var require$$0 = [
56907
56931
 
56908
56932
  var binaryExtensions$1 = require$$0;
56909
56933
 
56910
- const path = require$$0$7;
56934
+ const path = require$$0$8;
56911
56935
  const binaryExtensions = binaryExtensions$1;
56912
56936
 
56913
56937
  const extensions = new Set(binaryExtensions);
@@ -56918,9 +56942,9 @@ var constants$1 = {};
56918
56942
 
56919
56943
  (function (exports) {
56920
56944
 
56921
- const {sep} = require$$0$7;
56945
+ const {sep} = require$$0$8;
56922
56946
  const {platform} = process;
56923
- const os = require$$1$6;
56947
+ const os = require$$1$5;
56924
56948
 
56925
56949
  exports.EV_ALL = 'all';
56926
56950
  exports.EV_READY = 'ready';
@@ -56984,9 +57008,9 @@ var constants$1 = {};
56984
57008
  exports.isIBMi = os.type() === 'OS400';
56985
57009
  } (constants$1));
56986
57010
 
56987
- const fs$2 = require$$0$8;
56988
- const sysPath$2 = require$$0$7;
56989
- const { promisify: promisify$2 } = require$$1$4;
57011
+ const fs$2 = require$$0$9;
57012
+ const sysPath$2 = require$$0$8;
57013
+ const { promisify: promisify$2 } = require$$1$3;
56990
57014
  const isBinaryPath = isBinaryPath$1;
56991
57015
  const {
56992
57016
  isWindows: isWindows$1,
@@ -57635,9 +57659,9 @@ var nodefsHandler = NodeFsHandler$1;
57635
57659
 
57636
57660
  var fseventsHandler = {exports: {}};
57637
57661
 
57638
- const fs$1 = require$$0$8;
57639
- const sysPath$1 = require$$0$7;
57640
- const { promisify: promisify$1 } = require$$1$4;
57662
+ const fs$1 = require$$0$9;
57663
+ const sysPath$1 = require$$0$8;
57664
+ const { promisify: promisify$1 } = require$$1$3;
57641
57665
 
57642
57666
  let fsevents;
57643
57667
  try {
@@ -58162,10 +58186,10 @@ fseventsHandler.exports.canUse = canUse;
58162
58186
 
58163
58187
  var fseventsHandlerExports = fseventsHandler.exports;
58164
58188
 
58165
- const { EventEmitter } = require$$0$4;
58166
- const fs = require$$0$8;
58167
- const sysPath = require$$0$7;
58168
- const { promisify } = require$$1$4;
58189
+ const { EventEmitter } = require$$0$5;
58190
+ const fs = require$$0$9;
58191
+ const sysPath = require$$0$8;
58192
+ const { promisify } = require$$1$3;
58169
58193
  const readdirp = readdirp_1;
58170
58194
  const anymatch = anymatchExports.default;
58171
58195
  const globParent = index$1.globParent;
@@ -59134,7 +59158,7 @@ const watch = (paths, options) => {
59134
59158
 
59135
59159
  chokidar.watch = watch;
59136
59160
 
59137
- const stream = require$$0$9;
59161
+ const stream = require$$0$a;
59138
59162
  const Transform = stream.Transform;
59139
59163
 
59140
59164
 
@@ -59254,7 +59278,7 @@ SSETransform.defOpts = {
59254
59278
  var sse$1 = SSETransform;
59255
59279
 
59256
59280
  const SSE = sse$1;
59257
- const Stream$1 = require$$0$9;
59281
+ const Stream$1 = require$$0$a;
59258
59282
  const DEFAULT_OPTS = {
59259
59283
  maxClients: 10000,
59260
59284
  pingInterval: 60000,
@@ -59710,10 +59734,10 @@ class FFmpegWhisperASR {
59710
59734
  throw new Error(`音频文件不存在: ${filePath}`);
59711
59735
  }
59712
59736
  // 创建临时目录存放结果
59713
- const tempDir = require$$0$7.join(require$$1$6.tmpdir(), "whisper-asr");
59737
+ const tempDir = require$$0$8.join(require$$1$5.tmpdir(), "whisper-asr");
59714
59738
  await index$1.fs.ensureDir(tempDir);
59715
59739
  // 生成唯一的输出文件名
59716
- const outputFile = require$$0$7.join(tempDir, `${v4()}.json`);
59740
+ const outputFile = require$$0$8.join(tempDir, `${v4()}.json`);
59717
59741
  try {
59718
59742
  // 执行 ffmpeg 命令
59719
59743
  await this.executeFFmpeg(filePath, outputFile);
@@ -59772,7 +59796,7 @@ class FFmpegWhisperASR {
59772
59796
  ];
59773
59797
  this.options.logger.info(`执行 FFmpeg Whisper 命令: ${this.options.ffmpegPath} ${args.join(" ")}`);
59774
59798
  // 使用 spawn 执行命令
59775
- const process = require$$0$d.spawn(this.options.ffmpegPath, args);
59799
+ const process = require$$0$e.spawn(this.options.ffmpegPath, args);
59776
59800
  let stderr = "";
59777
59801
  // 收集标准错误输出(ffmpeg 的日志)
59778
59802
  process.stderr.on("data", (data) => {
@@ -60728,7 +60752,7 @@ const isFile = (value) => value instanceof File;
60728
60752
 
60729
60753
  const isBlob = (value) => value instanceof Blob$1;
60730
60754
 
60731
- const deprecateConstructorEntries = require$$1$4.deprecate(() => { }, "Constructor \"entries\" argument is not spec-compliant "
60755
+ const deprecateConstructorEntries = require$$1$3.deprecate(() => { }, "Constructor \"entries\" argument is not spec-compliant "
60732
60756
  + "and will be removed in next major release.");
60733
60757
 
60734
60758
  var __classPrivateFieldGet$8 = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
@@ -60865,7 +60889,7 @@ let FormData$1 = class FormData {
60865
60889
  get [Symbol.toStringTag]() {
60866
60890
  return "FormData";
60867
60891
  }
60868
- [require$$1$4.inspect.custom]() {
60892
+ [require$$1$3.inspect.custom]() {
60869
60893
  return this[Symbol.toStringTag];
60870
60894
  }
60871
60895
  };
@@ -60882,7 +60906,7 @@ var agentkeepalive = {exports: {}};
60882
60906
  * Module dependencies.
60883
60907
  */
60884
60908
 
60885
- var util = require$$1$4;
60909
+ var util = require$$1$3;
60886
60910
  var ms$1 = index$1.requireMs();
60887
60911
 
60888
60912
  var humanizeMs = function (t) {
@@ -60910,7 +60934,7 @@ var constants = {
60910
60934
 
60911
60935
  const OriginalAgent = require$$3$1.Agent;
60912
60936
  const ms = humanizeMs;
60913
- const debug$1 = require$$1$4.debuglog('agentkeepalive');
60937
+ const debug$1 = require$$1$3.debuglog('agentkeepalive');
60914
60938
  const {
60915
60939
  INIT_SOCKET: INIT_SOCKET$1,
60916
60940
  CURRENT_ID,
@@ -61309,7 +61333,7 @@ function inspect(obj) {
61309
61333
  return res;
61310
61334
  }
61311
61335
 
61312
- const OriginalHttpsAgent = require$$1$7.Agent;
61336
+ const OriginalHttpsAgent = require$$1$6.Agent;
61313
61337
  const HttpAgent$1 = agent;
61314
61338
  const {
61315
61339
  INIT_SOCKET,
@@ -62525,7 +62549,7 @@ class MultipartBody {
62525
62549
  let fileFromPathWarned = false;
62526
62550
  async function fileFromPath(path, ...args) {
62527
62551
  // this import fails in environments that don't handle export maps correctly, like old versions of Jest
62528
- const { fileFromPath: _fileFromPath } = await Promise.resolve().then(function () { return require('./fileFromPath-C9aolqJz.cjs'); });
62552
+ const { fileFromPath: _fileFromPath } = await Promise.resolve().then(function () { return require('./fileFromPath-x9JhF4gH.cjs'); });
62529
62553
  if (!fileFromPathWarned) {
62530
62554
  console.warn(`fileFromPath is deprecated; use fs.createReadStream(${JSON.stringify(path)}) instead`);
62531
62555
  fileFromPathWarned = true;
@@ -62537,7 +62561,7 @@ const defaultHttpAgent = new KeepAliveAgent({ keepAlive: true, timeout: 5 * 60 *
62537
62561
  const defaultHttpsAgent = new KeepAliveAgent.HttpsAgent({ keepAlive: true, timeout: 5 * 60 * 1000 });
62538
62562
  async function getMultipartRequestOptions(form, opts) {
62539
62563
  const encoder = new FormDataEncoder(form);
62540
- const readable = require$$0$e.Readable.from(encoder);
62564
+ const readable = require$$0$f.Readable.from(encoder);
62541
62565
  const body = new MultipartBody(readable);
62542
62566
  const headers = {
62543
62567
  ...opts.headers,
@@ -68942,7 +68966,7 @@ class DecodedMessage {
68942
68966
  if (!uri.startsWith(DATA_URI_PREFIX)) {
68943
68967
  throw new Error('assert 4');
68944
68968
  }
68945
- return this.decodeFromBinary(require$$0$6.Buffer.from(uri.replace(DATA_URI_PREFIX, ''), 'base64'));
68969
+ return this.decodeFromBinary(require$$0$7.Buffer.from(uri.replace(DATA_URI_PREFIX, ''), 'base64'));
68946
68970
  }
68947
68971
  encodeToBinary() {
68948
68972
  const header = {
@@ -68993,7 +69017,7 @@ class DecodedMessage {
68993
69017
  }
68994
69018
  encodeToUri() {
68995
69019
  const bin = this.encodeToBinary();
68996
- return DATA_URI_PREFIX + require$$0$6.Buffer.from(bin).toString('base64');
69020
+ return DATA_URI_PREFIX + require$$0$7.Buffer.from(bin).toString('base64');
68997
69021
  }
68998
69022
  }
68999
69023
 
@@ -69833,7 +69857,7 @@ class Shazam {
69833
69857
  * @returns {ShazamRoot | null}
69834
69858
  */
69835
69859
  async recognise(path, language = "en-US", minimal = false) {
69836
- const signatures = shazamioCore.recognizeBytes(require$$0$8.readFileSync(path), 0, Number.MAX_SAFE_INTEGER);
69860
+ const signatures = shazamioCore.recognizeBytes(require$$0$9.readFileSync(path), 0, Number.MAX_SAFE_INTEGER);
69837
69861
  let response;
69838
69862
  for (let i = Math.floor(signatures.length / 2); i < signatures.length; i += 4) {
69839
69863
  const data = {
@@ -73023,6 +73047,9 @@ async function shazamRecognizeWithSampling(file) {
73023
73047
  // 获取文件时长
73024
73048
  const meta = await index$1.readVideoMeta(file);
73025
73049
  const duration = Number(meta.format.duration || 0);
73050
+ if (duration === 0 || isNaN(duration)) {
73051
+ throw new Error("视频无法读取到时间,无法处理");
73052
+ }
73026
73053
  if (duration < 10) {
73027
73054
  // 如果文件时长小于10秒,直接识别
73028
73055
  return shazamRecognizeWithRetry(file);
@@ -73950,7 +73977,7 @@ router$a.get("/ws/danma-test", async (ctx) => {
73950
73977
  };
73951
73978
  });
73952
73979
  router$a.post("/add", async (ctx) => {
73953
- 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", "liveEndNotification", "weight", "source", "videoFormat", "recorderType", "cookie", "doubleScreen", "onlyAudio", "useServerTimestamp", "handleTime", "debugLevel", "api");
73980
+ 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");
73954
73981
  const data = await recorderService.addRecorder(args);
73955
73982
  ctx.body = { payload: data };
73956
73983
  });
@@ -73966,7 +73993,7 @@ router$a.get("/:id", (ctx) => {
73966
73993
  });
73967
73994
  router$a.put("/:id", (ctx) => {
73968
73995
  const { id } = ctx.params;
73969
- 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", "liveEndNotification", "weight", "source", "videoFormat", "recorderType", "cookie", "doubleScreen", "onlyAudio", "useServerTimestamp", "handleTime", "debugLevel", "convert2Mp4", "api");
73996
+ 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");
73970
73997
  ctx.body = { payload: recorderService.updateRecorder({ id, ...patch }) };
73971
73998
  });
73972
73999
  /**
@@ -74839,6 +74866,14 @@ router$8.post("/flvRepair", async (ctx) => {
74839
74866
  */
74840
74867
  router$8.post("/cut", async (ctx) => {
74841
74868
  const { files, output, options, ffmpegOptions } = ctx.request.body;
74869
+ if (options?.uploadOptions?.upload) {
74870
+ const [status, msg] = index$1.validateBiliupConfig(options?.uploadOptions?.config || {});
74871
+ if (!status) {
74872
+ ctx.status = 400;
74873
+ ctx.body = msg;
74874
+ return;
74875
+ }
74876
+ }
74842
74877
  // 处理srt字幕切割
74843
74878
  const srtContent = files.srtContent;
74844
74879
  let subtitlePath;
@@ -74876,6 +74911,13 @@ router$8.post("/cut", async (ctx) => {
74876
74911
  ...options,
74877
74912
  removeSubtitle: true,
74878
74913
  });
74914
+ if (options?.uploadOptions?.upload) {
74915
+ task.on("task-end", () => {
74916
+ const uid = options?.uploadOptions?.uid;
74917
+ const file = options?.uploadOptions?.filePath;
74918
+ index$1.biliApi.addMedia([file], options?.uploadOptions?.config, uid);
74919
+ });
74920
+ }
74879
74921
  ctx.body = { taskId: task.taskId };
74880
74922
  });
74881
74923
  /**
@@ -75110,8 +75152,8 @@ async function download$1(output, url, options) {
75110
75152
  const mp4Output = index$1.replaceExtName(output, ".mp4");
75111
75153
  if ((await index$1.fs.pathExists(mp4Output)) && !options.override)
75112
75154
  throw new Error(`${mp4Output}已存在`);
75113
- const { dir, name } = require$$0$7.parse(output);
75114
- const tsOutput = require$$0$7.join(dir, `${name}.ts`);
75155
+ const { dir, name } = require$$0$8.parse(output);
75156
+ const tsOutput = require$$0$8.join(dir, `${name}.ts`);
75115
75157
  if (await index$1.fs.pathExists(tsOutput)) {
75116
75158
  throw new Error(`${tsOutput}已存在,您可以直接执行转封装命令,或者删除后重新下载`);
75117
75159
  }
@@ -75119,10 +75161,10 @@ async function download$1(output, url, options) {
75119
75161
  const downloader = new index$1.M3U8Downloader(url, tsOutput, {
75120
75162
  convert2Mp4: false,
75121
75163
  ffmpegPath: ffmpegPath,
75122
- segmentsDir: require$$0$7.join(index$1.getTempPath(), index$1.uuid()),
75164
+ segmentsDir: require$$0$8.join(index$1.getTempPath(), index$1.uuid()),
75123
75165
  });
75124
75166
  const task = new index$1.KuaishouDownloadVideoTask(downloader, {
75125
- name: `下载任务:${require$$0$7.parse(output).name}`,
75167
+ name: `下载任务:${require$$0$8.parse(output).name}`,
75126
75168
  }, {
75127
75169
  onEnd: async () => {
75128
75170
  const outputName = `${name}.mp4`;
@@ -75165,7 +75207,7 @@ var kuaishou = {
75165
75207
  var dist = {};
75166
75208
 
75167
75209
  (function (exports) {
75168
- 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$$3$1,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);
75210
+ 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);
75169
75211
  } (dist));
75170
75212
 
75171
75213
  async function download(output, url, options) {
@@ -79049,7 +79091,7 @@ let handler;
79049
79091
  let appConfig;
79050
79092
  let container;
79051
79093
  const fileCache = createFileCache();
79052
- path$3.dirname(require$$1$2.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index-Bn38UlXg.cjs', document.baseURI).href))));
79094
+ 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-cBdgazGf.cjs', document.baseURI).href))));
79053
79095
  const authMiddleware = (passKey) => {
79054
79096
  return async (ctx, next) => {
79055
79097
  const authHeader = ctx.headers["authorization"] || ctx.request.query.auth;