bililive-cli 3.18.0 → 3.20.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.
- package/lib/{chunked-exec-BDg-2e7Y.cjs → chunked-exec-Cfbn8ECo.cjs} +2 -2
- package/lib/{fileFromPath-Df_wQ1he.cjs → fileFromPath-Cqq5W5LP.cjs} +3 -2
- package/lib/{index-CYt93UQb.cjs → index-DTguSku6.cjs} +341 -193
- package/lib/{index-CWUSa9VA.cjs → index-RwUbYTSt.cjs} +116919 -46523
- package/lib/index.cjs +3 -3
- package/lib/{linux-Cj0-4UT4.cjs → linux-B_JvwbpW.cjs} +2 -1
- package/lib/{macos-BMyL_rNA.cjs → macos-DgYbD5DI.cjs} +2 -2
- package/lib/{windows-DIBE4d8E.cjs → windows-C30k1cv-.cjs} +2 -2
- package/package.json +4 -4
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var path$3 = require('node:path');
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var index$1 = require('./index-
|
|
8
|
-
var require$$0$
|
|
9
|
-
var require$$1$
|
|
10
|
-
var require$$0$
|
|
11
|
-
var require$$0$
|
|
12
|
-
var require$$0$
|
|
13
|
-
var require$$0$
|
|
14
|
-
var require$$0$
|
|
15
|
-
var require$$0$
|
|
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-RwUbYTSt.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$
|
|
18
|
-
var require$$1$
|
|
19
|
-
var require$$
|
|
20
|
-
var require$$
|
|
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$
|
|
23
|
+
var require$$1$5 = require('string_decoder');
|
|
24
24
|
var os$1 = require('node:os');
|
|
25
|
-
var require$$1$
|
|
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');
|
|
@@ -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$
|
|
36
|
-
var require$$1$
|
|
37
|
-
var require$$0$
|
|
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
|
|
1187
|
-
const httpModule = url.protocol === "https:" ?
|
|
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$
|
|
1546
|
-
const http$3 = require$$
|
|
1547
|
-
const { createHash } = require$$1$
|
|
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$
|
|
2702
|
-
const util = require$$1$
|
|
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$
|
|
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$
|
|
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$
|
|
4780
|
-
var ReadStream = require$$0$
|
|
4781
|
-
var Stream$3 = require$$0$
|
|
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$
|
|
5210
|
-
const extname = require$$0$
|
|
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$
|
|
5213
|
+
const util = require$$1$4;
|
|
5214
5214
|
const encodeUrl = encodeurl;
|
|
5215
|
-
const Stream = require$$0$
|
|
5216
|
-
const URL = require$$0$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$$
|
|
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$
|
|
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$
|
|
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$
|
|
10102
|
-
const net = require$$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
11179
|
-
const util$3 = require$$1$
|
|
11180
|
-
const Stream$2 = require$$0$
|
|
11181
|
-
const http$1 = require$$
|
|
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 } =
|
|
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 =
|
|
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$
|
|
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$
|
|
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$
|
|
24430
|
-
Transform = require$$0$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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;
|
|
@@ -29621,8 +29621,9 @@ async function getRecorders(params) {
|
|
|
29621
29621
|
if (params.platform) {
|
|
29622
29622
|
list = list.filter((item) => item.providerId === params.platform);
|
|
29623
29623
|
}
|
|
29624
|
-
if (params.
|
|
29625
|
-
|
|
29624
|
+
if (params.status) {
|
|
29625
|
+
const normalizedStatus = params.status;
|
|
29626
|
+
list = list.filter((item) => item.state === normalizedStatus);
|
|
29626
29627
|
}
|
|
29627
29628
|
if (params.name) {
|
|
29628
29629
|
list = list.filter((item) => item.remarks?.includes(params.name) ||
|
|
@@ -29841,7 +29842,12 @@ function recorderToClient(recorder) {
|
|
|
29841
29842
|
}
|
|
29842
29843
|
function resolveChannel(url) {
|
|
29843
29844
|
const recorderManager = container.resolve("recorderManager");
|
|
29844
|
-
|
|
29845
|
+
const matchedProviders = recorderManager.manager.getChannelURLMatchedRecorderProviders(url);
|
|
29846
|
+
const isTikTok = matchedProviders.some((provider) => provider.id === "TikTok");
|
|
29847
|
+
const proxy = isTikTok
|
|
29848
|
+
? container.resolve("appConfig").get("recorder").tiktok.proxy || undefined
|
|
29849
|
+
: undefined;
|
|
29850
|
+
return recorderManager.resolveChannel(url, { proxy });
|
|
29845
29851
|
}
|
|
29846
29852
|
async function resolve(url) {
|
|
29847
29853
|
const channelInfo = await resolveChannel(url);
|
|
@@ -29908,6 +29914,36 @@ async function batchResolveChannel(urls) {
|
|
|
29908
29914
|
failedCount,
|
|
29909
29915
|
};
|
|
29910
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
|
+
}
|
|
29911
29947
|
async function getLiveInfo(ids) {
|
|
29912
29948
|
const recorderManager = container.resolve("recorderManager");
|
|
29913
29949
|
const recorders = recorderManager.manager.recorders;
|
|
@@ -29986,6 +30022,7 @@ var recorderService = {
|
|
|
29986
30022
|
batchResolveChannel,
|
|
29987
30023
|
getBiliStream,
|
|
29988
30024
|
resolve,
|
|
30025
|
+
getStreamUrl,
|
|
29989
30026
|
};
|
|
29990
30027
|
|
|
29991
30028
|
const router$h = new Router$1();
|
|
@@ -30293,7 +30330,7 @@ var hasRequiredStream$1;
|
|
|
30293
30330
|
function requireStream$1 () {
|
|
30294
30331
|
if (hasRequiredStream$1) return stream$3;
|
|
30295
30332
|
hasRequiredStream$1 = 1;
|
|
30296
|
-
stream$3 = require$$0$
|
|
30333
|
+
stream$3 = require$$0$9;
|
|
30297
30334
|
return stream$3;
|
|
30298
30335
|
}
|
|
30299
30336
|
|
|
@@ -30406,7 +30443,7 @@ function requireUtil () {
|
|
|
30406
30443
|
}
|
|
30407
30444
|
util$2.isPrimitive = isPrimitive;
|
|
30408
30445
|
|
|
30409
|
-
util$2.isBuffer = require$$0$
|
|
30446
|
+
util$2.isBuffer = require$$0$6.Buffer.isBuffer;
|
|
30410
30447
|
|
|
30411
30448
|
function objectToString(o) {
|
|
30412
30449
|
return Object.prototype.toString.call(o);
|
|
@@ -30426,7 +30463,7 @@ function requireBufferList () {
|
|
|
30426
30463
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
30427
30464
|
|
|
30428
30465
|
var Buffer = index$1.safeBufferExports.Buffer;
|
|
30429
|
-
var util = require$$1$
|
|
30466
|
+
var util = require$$1$4;
|
|
30430
30467
|
|
|
30431
30468
|
function copyBuffer(src, target, offset) {
|
|
30432
30469
|
src.copy(target, offset);
|
|
@@ -30605,7 +30642,7 @@ function requireNode () {
|
|
|
30605
30642
|
* For Node.js, simply re-export the core `util.deprecate` function.
|
|
30606
30643
|
*/
|
|
30607
30644
|
|
|
30608
|
-
node = require$$1$
|
|
30645
|
+
node = require$$1$4.deprecate;
|
|
30609
30646
|
return node;
|
|
30610
30647
|
}
|
|
30611
30648
|
|
|
@@ -31690,7 +31727,7 @@ function require_stream_readable$1 () {
|
|
|
31690
31727
|
Readable.ReadableState = ReadableState;
|
|
31691
31728
|
|
|
31692
31729
|
/*<replacement>*/
|
|
31693
|
-
require$$0$
|
|
31730
|
+
require$$0$4.EventEmitter;
|
|
31694
31731
|
|
|
31695
31732
|
var EElistenerCount = function (emitter, type) {
|
|
31696
31733
|
return emitter.listeners(type).length;
|
|
@@ -31720,7 +31757,7 @@ function require_stream_readable$1 () {
|
|
|
31720
31757
|
/*</replacement>*/
|
|
31721
31758
|
|
|
31722
31759
|
/*<replacement>*/
|
|
31723
|
-
var debugUtil = require$$1$
|
|
31760
|
+
var debugUtil = require$$1$4;
|
|
31724
31761
|
var debug = void 0;
|
|
31725
31762
|
if (debugUtil && debugUtil.debuglog) {
|
|
31726
31763
|
debug = debugUtil.debuglog('stream');
|
|
@@ -32866,7 +32903,7 @@ function requireReadable () {
|
|
|
32866
32903
|
if (hasRequiredReadable) return readable$1.exports;
|
|
32867
32904
|
hasRequiredReadable = 1;
|
|
32868
32905
|
(function (module, exports) {
|
|
32869
|
-
var Stream = require$$0$
|
|
32906
|
+
var Stream = require$$0$9;
|
|
32870
32907
|
if (process.env.READABLE_STREAM === 'disable' && Stream) {
|
|
32871
32908
|
module.exports = Stream;
|
|
32872
32909
|
exports = module.exports = Stream.Readable;
|
|
@@ -45242,7 +45279,7 @@ function matchNeedle(self, data, pos, len) {
|
|
|
45242
45279
|
|
|
45243
45280
|
var sbmh = SBMH;
|
|
45244
45281
|
|
|
45245
|
-
const { Readable: Readable$1, Writable: Writable$2 } = require$$0$
|
|
45282
|
+
const { Readable: Readable$1, Writable: Writable$2 } = require$$0$9;
|
|
45246
45283
|
|
|
45247
45284
|
const StreamSearch = sbmh;
|
|
45248
45285
|
|
|
@@ -45892,7 +45929,7 @@ const FIELD_VCHAR = [
|
|
|
45892
45929
|
|
|
45893
45930
|
var multipart = Multipart;
|
|
45894
45931
|
|
|
45895
|
-
const { Writable: Writable$1 } = require$$0$
|
|
45932
|
+
const { Writable: Writable$1 } = require$$0$9;
|
|
45896
45933
|
|
|
45897
45934
|
const { getDecoder } = utils;
|
|
45898
45935
|
|
|
@@ -46449,7 +46486,7 @@ function appendField$1 (store, key, value) {
|
|
|
46449
46486
|
|
|
46450
46487
|
var appendField_1 = appendField$1;
|
|
46451
46488
|
|
|
46452
|
-
var EventEmitter$1 = require$$0$
|
|
46489
|
+
var EventEmitter$1 = require$$0$4.EventEmitter;
|
|
46453
46490
|
|
|
46454
46491
|
function Counter$1 () {
|
|
46455
46492
|
EventEmitter$1.call(this);
|
|
@@ -46478,7 +46515,7 @@ Counter$1.prototype.onceZero = function onceZero (fn) {
|
|
|
46478
46515
|
|
|
46479
46516
|
var counter = Counter$1;
|
|
46480
46517
|
|
|
46481
|
-
var util$1 = require$$1$
|
|
46518
|
+
var util$1 = require$$1$4;
|
|
46482
46519
|
|
|
46483
46520
|
var errorMessages = {
|
|
46484
46521
|
LIMIT_PART_COUNT: 'Too many parts',
|
|
@@ -46863,8 +46900,8 @@ function makeMiddleware$1 (setup) {
|
|
|
46863
46900
|
|
|
46864
46901
|
var makeMiddleware_1 = makeMiddleware$1;
|
|
46865
46902
|
|
|
46866
|
-
var path$2 = require$$0$
|
|
46867
|
-
var fs$5 = require$$0$
|
|
46903
|
+
var path$2 = require$$0$7;
|
|
46904
|
+
var fs$5 = require$$0$8;
|
|
46868
46905
|
var _0777 = parseInt('0777', 8);
|
|
46869
46906
|
|
|
46870
46907
|
var mkdirp$1 = mkdirP.mkdirp = mkdirP.mkdirP = mkdirP;
|
|
@@ -46966,10 +47003,10 @@ mkdirP.sync = function sync (p, opts, made) {
|
|
|
46966
47003
|
return made;
|
|
46967
47004
|
};
|
|
46968
47005
|
|
|
46969
|
-
var fs$4 = require$$0$
|
|
46970
|
-
var os = require$$1$
|
|
46971
|
-
var path$1 = require$$0$
|
|
46972
|
-
var crypto = require$$1$
|
|
47006
|
+
var fs$4 = require$$0$8;
|
|
47007
|
+
var os = require$$1$6;
|
|
47008
|
+
var path$1 = require$$0$7;
|
|
47009
|
+
var crypto = require$$1$3;
|
|
46973
47010
|
var mkdirp = mkdirp$1;
|
|
46974
47011
|
|
|
46975
47012
|
function getFilename (req, file, cb) {
|
|
@@ -48078,6 +48115,15 @@ router$g.post("/", async (ctx) => {
|
|
|
48078
48115
|
appConfig.setAll(data);
|
|
48079
48116
|
ctx.body = "success";
|
|
48080
48117
|
});
|
|
48118
|
+
router$g.get("/get", async (ctx) => {
|
|
48119
|
+
const key = ctx.query.key;
|
|
48120
|
+
if (!key) {
|
|
48121
|
+
ctx.body = "key is required";
|
|
48122
|
+
return;
|
|
48123
|
+
}
|
|
48124
|
+
const value = appConfig.get(key);
|
|
48125
|
+
ctx.body = value;
|
|
48126
|
+
});
|
|
48081
48127
|
router$g.post("/set", async (ctx) => {
|
|
48082
48128
|
const data = ctx.request.body;
|
|
48083
48129
|
if (!data.key || !data.value) {
|
|
@@ -48132,7 +48178,7 @@ router$g.post("/verifyBiliKey", async (ctx) => {
|
|
|
48132
48178
|
ctx.body = response;
|
|
48133
48179
|
}
|
|
48134
48180
|
});
|
|
48135
|
-
router$g.post("/
|
|
48181
|
+
router$g.post("/reset-bin", async (ctx) => {
|
|
48136
48182
|
const data = ctx.request.body;
|
|
48137
48183
|
const type = data.type;
|
|
48138
48184
|
if (!type) {
|
|
@@ -49379,8 +49425,8 @@ class Ollama extends Ollama$1 {
|
|
|
49379
49425
|
return Buffer.from(image).toString("base64");
|
|
49380
49426
|
}
|
|
49381
49427
|
try {
|
|
49382
|
-
if (require$$0$
|
|
49383
|
-
const fileBuffer = await require$$0$
|
|
49428
|
+
if (require$$0$8.existsSync(image)) {
|
|
49429
|
+
const fileBuffer = await require$$0$8.promises.readFile(require$$0$7.resolve(image));
|
|
49384
49430
|
return Buffer.from(fileBuffer).toString("base64");
|
|
49385
49431
|
}
|
|
49386
49432
|
} catch {
|
|
@@ -49419,9 +49465,9 @@ class Ollama extends Ollama$1 {
|
|
|
49419
49465
|
*/
|
|
49420
49466
|
resolvePath(inputPath, mfDir) {
|
|
49421
49467
|
if (inputPath.startsWith("~")) {
|
|
49422
|
-
return require$$0$
|
|
49468
|
+
return require$$0$7.join(require$$1$6.homedir(), inputPath.slice(1));
|
|
49423
49469
|
}
|
|
49424
|
-
return require$$0$
|
|
49470
|
+
return require$$0$7.resolve(mfDir, inputPath);
|
|
49425
49471
|
}
|
|
49426
49472
|
/**
|
|
49427
49473
|
* checks if a file exists
|
|
@@ -49431,7 +49477,7 @@ class Ollama extends Ollama$1 {
|
|
|
49431
49477
|
*/
|
|
49432
49478
|
async fileExists(path) {
|
|
49433
49479
|
try {
|
|
49434
|
-
await require$$0$
|
|
49480
|
+
await require$$0$8.promises.access(path);
|
|
49435
49481
|
return true;
|
|
49436
49482
|
} catch {
|
|
49437
49483
|
return false;
|
|
@@ -49441,9 +49487,9 @@ class Ollama extends Ollama$1 {
|
|
|
49441
49487
|
if (typeof ReadableStream === "undefined") {
|
|
49442
49488
|
throw new Error("Streaming uploads are not supported in this environment.");
|
|
49443
49489
|
}
|
|
49444
|
-
const fileStream = require$$0$
|
|
49490
|
+
const fileStream = require$$0$8.createReadStream(path);
|
|
49445
49491
|
const sha256sum = await new Promise((resolve2, reject) => {
|
|
49446
|
-
const hash = require$$1$
|
|
49492
|
+
const hash = require$$1$3.createHash("sha256");
|
|
49447
49493
|
fileStream.on("data", (data) => hash.update(data));
|
|
49448
49494
|
fileStream.on("end", () => resolve2(hash.digest("hex")));
|
|
49449
49495
|
fileStream.on("error", reject);
|
|
@@ -49480,10 +49526,10 @@ class Ollama extends Ollama$1 {
|
|
|
49480
49526
|
async create(request) {
|
|
49481
49527
|
let modelfileContent = "";
|
|
49482
49528
|
if (request.path) {
|
|
49483
|
-
modelfileContent = await require$$0$
|
|
49529
|
+
modelfileContent = await require$$0$8.promises.readFile(request.path, { encoding: "utf8" });
|
|
49484
49530
|
modelfileContent = await this.parseModelfile(
|
|
49485
49531
|
modelfileContent,
|
|
49486
|
-
require$$0$
|
|
49532
|
+
require$$0$7.dirname(request.path)
|
|
49487
49533
|
);
|
|
49488
49534
|
} else if (request.modelfile) {
|
|
49489
49535
|
modelfileContent = await this.parseModelfile(request.modelfile);
|
|
@@ -49612,7 +49658,7 @@ var hasRequiredStream;
|
|
|
49612
49658
|
function requireStream () {
|
|
49613
49659
|
if (hasRequiredStream) return stream$1;
|
|
49614
49660
|
hasRequiredStream = 1;
|
|
49615
|
-
stream$1 = require$$0$
|
|
49661
|
+
stream$1 = require$$0$9;
|
|
49616
49662
|
return stream$1;
|
|
49617
49663
|
}
|
|
49618
49664
|
|
|
@@ -49631,9 +49677,9 @@ function requireBuffer_list () {
|
|
|
49631
49677
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
49632
49678
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
49633
49679
|
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); }
|
|
49634
|
-
var _require = require$$0$
|
|
49680
|
+
var _require = require$$0$6,
|
|
49635
49681
|
Buffer = _require.Buffer;
|
|
49636
|
-
var _require2 = require$$1$
|
|
49682
|
+
var _require2 = require$$1$4,
|
|
49637
49683
|
inspect = _require2.inspect;
|
|
49638
49684
|
var custom = inspect && inspect.custom || 'inspect';
|
|
49639
49685
|
function copyBuffer(src, target, offset) {
|
|
@@ -50103,7 +50149,7 @@ function require_stream_writable () {
|
|
|
50103
50149
|
var Stream = requireStream();
|
|
50104
50150
|
/*</replacement>*/
|
|
50105
50151
|
|
|
50106
|
-
var Buffer = require$$0$
|
|
50152
|
+
var Buffer = require$$0$6.Buffer;
|
|
50107
50153
|
var OurUint8Array = (typeof index$1.commonjsGlobal !== 'undefined' ? index$1.commonjsGlobal : typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : {}).Uint8Array || function () {};
|
|
50108
50154
|
function _uint8ArrayToBuffer(chunk) {
|
|
50109
50155
|
return Buffer.from(chunk);
|
|
@@ -51428,7 +51474,7 @@ function require_stream_readable () {
|
|
|
51428
51474
|
Readable.ReadableState = ReadableState;
|
|
51429
51475
|
|
|
51430
51476
|
/*<replacement>*/
|
|
51431
|
-
require$$0$
|
|
51477
|
+
require$$0$4.EventEmitter;
|
|
51432
51478
|
var EElistenerCount = function EElistenerCount(emitter, type) {
|
|
51433
51479
|
return emitter.listeners(type).length;
|
|
51434
51480
|
};
|
|
@@ -51438,7 +51484,7 @@ function require_stream_readable () {
|
|
|
51438
51484
|
var Stream = requireStream();
|
|
51439
51485
|
/*</replacement>*/
|
|
51440
51486
|
|
|
51441
|
-
var Buffer = require$$0$
|
|
51487
|
+
var Buffer = require$$0$6.Buffer;
|
|
51442
51488
|
var OurUint8Array = (typeof index$1.commonjsGlobal !== 'undefined' ? index$1.commonjsGlobal : typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : {}).Uint8Array || function () {};
|
|
51443
51489
|
function _uint8ArrayToBuffer(chunk) {
|
|
51444
51490
|
return Buffer.from(chunk);
|
|
@@ -51448,7 +51494,7 @@ function require_stream_readable () {
|
|
|
51448
51494
|
}
|
|
51449
51495
|
|
|
51450
51496
|
/*<replacement>*/
|
|
51451
|
-
var debugUtil = require$$1$
|
|
51497
|
+
var debugUtil = require$$1$4;
|
|
51452
51498
|
var debug;
|
|
51453
51499
|
if (debugUtil && debugUtil.debuglog) {
|
|
51454
51500
|
debug = debugUtil.debuglog('stream');
|
|
@@ -52673,7 +52719,7 @@ function requirePipeline () {
|
|
|
52673
52719
|
}
|
|
52674
52720
|
|
|
52675
52721
|
(function (module, exports) {
|
|
52676
|
-
var Stream = require$$0$
|
|
52722
|
+
var Stream = require$$0$9;
|
|
52677
52723
|
if (process.env.READABLE_STREAM === 'disable' && Stream) {
|
|
52678
52724
|
module.exports = Stream.Readable;
|
|
52679
52725
|
Object.assign(module.exports, Stream);
|
|
@@ -55535,7 +55581,7 @@ router$e.post("/danma/timestamp", async (ctx) => {
|
|
|
55535
55581
|
const { filepath } = ctx.request.body;
|
|
55536
55582
|
ctx.body = await index$1.readXmlTimestamp(filepath);
|
|
55537
55583
|
});
|
|
55538
|
-
router$e.post("/
|
|
55584
|
+
router$e.post("/parse-video-metadata", async (ctx) => {
|
|
55539
55585
|
const files = ctx.request.body;
|
|
55540
55586
|
ctx.body = await index$1.parseMeta(files);
|
|
55541
55587
|
});
|
|
@@ -56066,7 +56112,7 @@ router$d.post("/get_cookie", async (ctx) => {
|
|
|
56066
56112
|
return;
|
|
56067
56113
|
}
|
|
56068
56114
|
const secret = "r96gkr8ahc34fsrewr34";
|
|
56069
|
-
const hash = require$$1$
|
|
56115
|
+
const hash = require$$1$3.createHmac("sha256", secret).update(`${uid}${timestamp}`).digest("hex");
|
|
56070
56116
|
if (hash !== signature) {
|
|
56071
56117
|
ctx.status = 400;
|
|
56072
56118
|
ctx.body = "签名无效";
|
|
@@ -56145,7 +56191,7 @@ router$c.get("/danmu/:id", async (ctx) => {
|
|
|
56145
56191
|
router$c.post("/danmu", async (ctx) => {
|
|
56146
56192
|
const danmuPreset = container.resolve("danmuPreset");
|
|
56147
56193
|
const data = ctx.request.body;
|
|
56148
|
-
ctx.body = await danmuPreset.save(data);
|
|
56194
|
+
ctx.body = await danmuPreset.save({ ...data, id: index$1.uuid() });
|
|
56149
56195
|
});
|
|
56150
56196
|
router$c.del("/danmu/:id", async (ctx) => {
|
|
56151
56197
|
const danmuPreset = container.resolve("danmuPreset");
|
|
@@ -56169,7 +56215,11 @@ router$c.post("/video", async (ctx) => {
|
|
|
56169
56215
|
const preset = container.resolve("videoPreset");
|
|
56170
56216
|
const data = ctx.request.body;
|
|
56171
56217
|
data.config = index$1.omit(data.config, ["dtime"]);
|
|
56172
|
-
|
|
56218
|
+
const [status, msg] = index$1.validateBiliupConfig(data.config);
|
|
56219
|
+
if (!status) {
|
|
56220
|
+
throw new Error(msg || "配置验证失败");
|
|
56221
|
+
}
|
|
56222
|
+
ctx.body = await preset.save({ ...data, id: index$1.uuid() });
|
|
56173
56223
|
});
|
|
56174
56224
|
router$c.del("/video/:id", async (ctx) => {
|
|
56175
56225
|
const preset = container.resolve("videoPreset");
|
|
@@ -56179,6 +56229,10 @@ router$c.put("/video/:id", async (ctx) => {
|
|
|
56179
56229
|
const preset = container.resolve("videoPreset");
|
|
56180
56230
|
const data = ctx.request.body;
|
|
56181
56231
|
data.config = index$1.omit(data.config, ["dtime"]);
|
|
56232
|
+
const [status, msg] = index$1.validateBiliupConfig(data.config);
|
|
56233
|
+
if (!status) {
|
|
56234
|
+
throw new Error(msg || "配置验证失败");
|
|
56235
|
+
}
|
|
56182
56236
|
ctx.body = await preset.save({ ...data, id: ctx.params.id });
|
|
56183
56237
|
});
|
|
56184
56238
|
////////////////// ffmpeg预设 ///////////////////////////////
|
|
@@ -56197,7 +56251,7 @@ router$c.get("/ffmpeg/:id", async (ctx) => {
|
|
|
56197
56251
|
router$c.post("/ffmpeg", async (ctx) => {
|
|
56198
56252
|
const preset = container.resolve("ffmpegPreset");
|
|
56199
56253
|
const data = ctx.request.body;
|
|
56200
|
-
ctx.body = await preset.save(data);
|
|
56254
|
+
ctx.body = await preset.save({ ...data, id: index$1.uuid() });
|
|
56201
56255
|
});
|
|
56202
56256
|
router$c.del("/ffmpeg/:id", async (ctx) => {
|
|
56203
56257
|
const preset = container.resolve("ffmpegPreset");
|
|
@@ -56220,7 +56274,7 @@ router$c.get("/subtitle-style/:id", async (ctx) => {
|
|
|
56220
56274
|
router$c.post("/subtitle-style", async (ctx) => {
|
|
56221
56275
|
const preset = container.resolve("subtitleStylePreset");
|
|
56222
56276
|
const data = ctx.request.body;
|
|
56223
|
-
ctx.body = await preset.save(data);
|
|
56277
|
+
ctx.body = await preset.save({ ...data, id: index$1.uuid() });
|
|
56224
56278
|
});
|
|
56225
56279
|
router$c.del("/subtitle-style/:id", async (ctx) => {
|
|
56226
56280
|
const preset = container.resolve("subtitleStylePreset");
|
|
@@ -56234,10 +56288,10 @@ router$c.put("/subtitle-style/:id", async (ctx) => {
|
|
|
56234
56288
|
|
|
56235
56289
|
var chokidar = {};
|
|
56236
56290
|
|
|
56237
|
-
const fs$3 = require$$0$
|
|
56238
|
-
const { Readable } = require$$0$
|
|
56239
|
-
const sysPath$3 = require$$0$
|
|
56240
|
-
const { promisify: promisify$3 } = require$$1$
|
|
56291
|
+
const fs$3 = require$$0$8;
|
|
56292
|
+
const { Readable } = require$$0$9;
|
|
56293
|
+
const sysPath$3 = require$$0$7;
|
|
56294
|
+
const { promisify: promisify$3 } = require$$1$4;
|
|
56241
56295
|
const picomatch$1 = index$1.picomatch;
|
|
56242
56296
|
|
|
56243
56297
|
const readdir$1 = promisify$3(fs$3.readdir);
|
|
@@ -56931,7 +56985,7 @@ var require$$0 = [
|
|
|
56931
56985
|
|
|
56932
56986
|
var binaryExtensions$1 = require$$0;
|
|
56933
56987
|
|
|
56934
|
-
const path = require$$0$
|
|
56988
|
+
const path = require$$0$7;
|
|
56935
56989
|
const binaryExtensions = binaryExtensions$1;
|
|
56936
56990
|
|
|
56937
56991
|
const extensions = new Set(binaryExtensions);
|
|
@@ -56942,9 +56996,9 @@ var constants$1 = {};
|
|
|
56942
56996
|
|
|
56943
56997
|
(function (exports) {
|
|
56944
56998
|
|
|
56945
|
-
const {sep} = require$$0$
|
|
56999
|
+
const {sep} = require$$0$7;
|
|
56946
57000
|
const {platform} = process;
|
|
56947
|
-
const os = require$$1$
|
|
57001
|
+
const os = require$$1$6;
|
|
56948
57002
|
|
|
56949
57003
|
exports.EV_ALL = 'all';
|
|
56950
57004
|
exports.EV_READY = 'ready';
|
|
@@ -57008,9 +57062,9 @@ var constants$1 = {};
|
|
|
57008
57062
|
exports.isIBMi = os.type() === 'OS400';
|
|
57009
57063
|
} (constants$1));
|
|
57010
57064
|
|
|
57011
|
-
const fs$2 = require$$0$
|
|
57012
|
-
const sysPath$2 = require$$0$
|
|
57013
|
-
const { promisify: promisify$2 } = require$$1$
|
|
57065
|
+
const fs$2 = require$$0$8;
|
|
57066
|
+
const sysPath$2 = require$$0$7;
|
|
57067
|
+
const { promisify: promisify$2 } = require$$1$4;
|
|
57014
57068
|
const isBinaryPath = isBinaryPath$1;
|
|
57015
57069
|
const {
|
|
57016
57070
|
isWindows: isWindows$1,
|
|
@@ -57659,9 +57713,9 @@ var nodefsHandler = NodeFsHandler$1;
|
|
|
57659
57713
|
|
|
57660
57714
|
var fseventsHandler = {exports: {}};
|
|
57661
57715
|
|
|
57662
|
-
const fs$1 = require$$0$
|
|
57663
|
-
const sysPath$1 = require$$0$
|
|
57664
|
-
const { promisify: promisify$1 } = require$$1$
|
|
57716
|
+
const fs$1 = require$$0$8;
|
|
57717
|
+
const sysPath$1 = require$$0$7;
|
|
57718
|
+
const { promisify: promisify$1 } = require$$1$4;
|
|
57665
57719
|
|
|
57666
57720
|
let fsevents;
|
|
57667
57721
|
try {
|
|
@@ -58186,10 +58240,10 @@ fseventsHandler.exports.canUse = canUse;
|
|
|
58186
58240
|
|
|
58187
58241
|
var fseventsHandlerExports = fseventsHandler.exports;
|
|
58188
58242
|
|
|
58189
|
-
const { EventEmitter } = require$$0$
|
|
58190
|
-
const fs = require$$0$
|
|
58191
|
-
const sysPath = require$$0$
|
|
58192
|
-
const { promisify } = require$$1$
|
|
58243
|
+
const { EventEmitter } = require$$0$4;
|
|
58244
|
+
const fs = require$$0$8;
|
|
58245
|
+
const sysPath = require$$0$7;
|
|
58246
|
+
const { promisify } = require$$1$4;
|
|
58193
58247
|
const readdirp = readdirp_1;
|
|
58194
58248
|
const anymatch = anymatchExports.default;
|
|
58195
58249
|
const globParent = index$1.globParent;
|
|
@@ -59158,7 +59212,7 @@ const watch = (paths, options) => {
|
|
|
59158
59212
|
|
|
59159
59213
|
chokidar.watch = watch;
|
|
59160
59214
|
|
|
59161
|
-
const stream = require$$0$
|
|
59215
|
+
const stream = require$$0$9;
|
|
59162
59216
|
const Transform = stream.Transform;
|
|
59163
59217
|
|
|
59164
59218
|
|
|
@@ -59278,7 +59332,7 @@ SSETransform.defOpts = {
|
|
|
59278
59332
|
var sse$1 = SSETransform;
|
|
59279
59333
|
|
|
59280
59334
|
const SSE = sse$1;
|
|
59281
|
-
const Stream$1 = require$$0$
|
|
59335
|
+
const Stream$1 = require$$0$9;
|
|
59282
59336
|
const DEFAULT_OPTS = {
|
|
59283
59337
|
maxClients: 10000,
|
|
59284
59338
|
pingInterval: 60000,
|
|
@@ -59734,10 +59788,10 @@ class FFmpegWhisperASR {
|
|
|
59734
59788
|
throw new Error(`音频文件不存在: ${filePath}`);
|
|
59735
59789
|
}
|
|
59736
59790
|
// 创建临时目录存放结果
|
|
59737
|
-
const tempDir = require$$0$
|
|
59791
|
+
const tempDir = require$$0$7.join(require$$1$6.tmpdir(), "whisper-asr");
|
|
59738
59792
|
await index$1.fs.ensureDir(tempDir);
|
|
59739
59793
|
// 生成唯一的输出文件名
|
|
59740
|
-
const outputFile = require$$0$
|
|
59794
|
+
const outputFile = require$$0$7.join(tempDir, `${v4()}.json`);
|
|
59741
59795
|
try {
|
|
59742
59796
|
// 执行 ffmpeg 命令
|
|
59743
59797
|
await this.executeFFmpeg(filePath, outputFile);
|
|
@@ -59796,7 +59850,7 @@ class FFmpegWhisperASR {
|
|
|
59796
59850
|
];
|
|
59797
59851
|
this.options.logger.info(`执行 FFmpeg Whisper 命令: ${this.options.ffmpegPath} ${args.join(" ")}`);
|
|
59798
59852
|
// 使用 spawn 执行命令
|
|
59799
|
-
const process = require$$0$
|
|
59853
|
+
const process = require$$0$c.spawn(this.options.ffmpegPath, args);
|
|
59800
59854
|
let stderr = "";
|
|
59801
59855
|
// 收集标准错误输出(ffmpeg 的日志)
|
|
59802
59856
|
process.stderr.on("data", (data) => {
|
|
@@ -60752,7 +60806,7 @@ const isFile = (value) => value instanceof File;
|
|
|
60752
60806
|
|
|
60753
60807
|
const isBlob = (value) => value instanceof Blob$1;
|
|
60754
60808
|
|
|
60755
|
-
const deprecateConstructorEntries = require$$1$
|
|
60809
|
+
const deprecateConstructorEntries = require$$1$4.deprecate(() => { }, "Constructor \"entries\" argument is not spec-compliant "
|
|
60756
60810
|
+ "and will be removed in next major release.");
|
|
60757
60811
|
|
|
60758
60812
|
var __classPrivateFieldGet$8 = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
@@ -60889,7 +60943,7 @@ let FormData$1 = class FormData {
|
|
|
60889
60943
|
get [Symbol.toStringTag]() {
|
|
60890
60944
|
return "FormData";
|
|
60891
60945
|
}
|
|
60892
|
-
[require$$1$
|
|
60946
|
+
[require$$1$4.inspect.custom]() {
|
|
60893
60947
|
return this[Symbol.toStringTag];
|
|
60894
60948
|
}
|
|
60895
60949
|
};
|
|
@@ -60906,7 +60960,7 @@ var agentkeepalive = {exports: {}};
|
|
|
60906
60960
|
* Module dependencies.
|
|
60907
60961
|
*/
|
|
60908
60962
|
|
|
60909
|
-
var util = require$$1$
|
|
60963
|
+
var util = require$$1$4;
|
|
60910
60964
|
var ms$1 = index$1.requireMs();
|
|
60911
60965
|
|
|
60912
60966
|
var humanizeMs = function (t) {
|
|
@@ -60932,9 +60986,9 @@ var constants = {
|
|
|
60932
60986
|
SOCKET_REQUEST_FINISHED_COUNT: Symbol('agentkeepalive#socketRequestFinishedCount'),
|
|
60933
60987
|
};
|
|
60934
60988
|
|
|
60935
|
-
const OriginalAgent = require$$
|
|
60989
|
+
const OriginalAgent = require$$1$2.Agent;
|
|
60936
60990
|
const ms = humanizeMs;
|
|
60937
|
-
const debug$1 = require$$1$
|
|
60991
|
+
const debug$1 = require$$1$4.debuglog('agentkeepalive');
|
|
60938
60992
|
const {
|
|
60939
60993
|
INIT_SOCKET: INIT_SOCKET$1,
|
|
60940
60994
|
CURRENT_ID,
|
|
@@ -61333,7 +61387,7 @@ function inspect(obj) {
|
|
|
61333
61387
|
return res;
|
|
61334
61388
|
}
|
|
61335
61389
|
|
|
61336
|
-
const OriginalHttpsAgent = require$$1$
|
|
61390
|
+
const OriginalHttpsAgent = require$$1$7.Agent;
|
|
61337
61391
|
const HttpAgent$1 = agent;
|
|
61338
61392
|
const {
|
|
61339
61393
|
INIT_SOCKET,
|
|
@@ -62549,7 +62603,7 @@ class MultipartBody {
|
|
|
62549
62603
|
let fileFromPathWarned = false;
|
|
62550
62604
|
async function fileFromPath(path, ...args) {
|
|
62551
62605
|
// this import fails in environments that don't handle export maps correctly, like old versions of Jest
|
|
62552
|
-
const { fileFromPath: _fileFromPath } = await Promise.resolve().then(function () { return require('./fileFromPath-
|
|
62606
|
+
const { fileFromPath: _fileFromPath } = await Promise.resolve().then(function () { return require('./fileFromPath-Cqq5W5LP.cjs'); });
|
|
62553
62607
|
if (!fileFromPathWarned) {
|
|
62554
62608
|
console.warn(`fileFromPath is deprecated; use fs.createReadStream(${JSON.stringify(path)}) instead`);
|
|
62555
62609
|
fileFromPathWarned = true;
|
|
@@ -62561,7 +62615,7 @@ const defaultHttpAgent = new KeepAliveAgent({ keepAlive: true, timeout: 5 * 60 *
|
|
|
62561
62615
|
const defaultHttpsAgent = new KeepAliveAgent.HttpsAgent({ keepAlive: true, timeout: 5 * 60 * 1000 });
|
|
62562
62616
|
async function getMultipartRequestOptions(form, opts) {
|
|
62563
62617
|
const encoder = new FormDataEncoder(form);
|
|
62564
|
-
const readable = require$$0$
|
|
62618
|
+
const readable = require$$0$d.Readable.from(encoder);
|
|
62565
62619
|
const body = new MultipartBody(readable);
|
|
62566
62620
|
const headers = {
|
|
62567
62621
|
...opts.headers,
|
|
@@ -68966,7 +69020,7 @@ class DecodedMessage {
|
|
|
68966
69020
|
if (!uri.startsWith(DATA_URI_PREFIX)) {
|
|
68967
69021
|
throw new Error('assert 4');
|
|
68968
69022
|
}
|
|
68969
|
-
return this.decodeFromBinary(require$$0$
|
|
69023
|
+
return this.decodeFromBinary(require$$0$6.Buffer.from(uri.replace(DATA_URI_PREFIX, ''), 'base64'));
|
|
68970
69024
|
}
|
|
68971
69025
|
encodeToBinary() {
|
|
68972
69026
|
const header = {
|
|
@@ -69017,7 +69071,7 @@ class DecodedMessage {
|
|
|
69017
69071
|
}
|
|
69018
69072
|
encodeToUri() {
|
|
69019
69073
|
const bin = this.encodeToBinary();
|
|
69020
|
-
return DATA_URI_PREFIX + require$$0$
|
|
69074
|
+
return DATA_URI_PREFIX + require$$0$6.Buffer.from(bin).toString('base64');
|
|
69021
69075
|
}
|
|
69022
69076
|
}
|
|
69023
69077
|
|
|
@@ -69857,33 +69911,37 @@ class Shazam {
|
|
|
69857
69911
|
* @returns {ShazamRoot | null}
|
|
69858
69912
|
*/
|
|
69859
69913
|
async recognise(path, language = "en-US", minimal = false) {
|
|
69860
|
-
const signatures = shazamioCore.recognizeBytes(require$$0$
|
|
69861
|
-
|
|
69862
|
-
|
|
69863
|
-
|
|
69864
|
-
|
|
69865
|
-
|
|
69866
|
-
|
|
69867
|
-
|
|
69868
|
-
|
|
69869
|
-
|
|
69870
|
-
|
|
69871
|
-
|
|
69872
|
-
|
|
69873
|
-
|
|
69874
|
-
|
|
69875
|
-
|
|
69876
|
-
|
|
69877
|
-
|
|
69878
|
-
|
|
69914
|
+
const signatures = shazamioCore.recognizeBytes(require$$0$8.readFileSync(path), 0, Number.MAX_SAFE_INTEGER);
|
|
69915
|
+
try {
|
|
69916
|
+
let response;
|
|
69917
|
+
for (let i = Math.floor(signatures.length / 2); i < signatures.length; i += 4) {
|
|
69918
|
+
const data = {
|
|
69919
|
+
timezone: this.endpoint.timezone,
|
|
69920
|
+
signature: {
|
|
69921
|
+
uri: signatures[i].uri,
|
|
69922
|
+
samplems: signatures[i].samplems,
|
|
69923
|
+
},
|
|
69924
|
+
timestamp: new Date().getTime(),
|
|
69925
|
+
context: {},
|
|
69926
|
+
geolocation: {},
|
|
69927
|
+
};
|
|
69928
|
+
const url = new URL(this.endpoint.url());
|
|
69929
|
+
Object.entries(this.endpoint.params()).forEach(([a, b]) => url.searchParams.append(a, b));
|
|
69930
|
+
response = await this.endpoint.sendRecognizeRequest(url.toString(), JSON.stringify(data), language);
|
|
69931
|
+
if (response?.matches?.length === 0)
|
|
69932
|
+
continue;
|
|
69933
|
+
break;
|
|
69934
|
+
}
|
|
69935
|
+
if (!response)
|
|
69936
|
+
return null;
|
|
69937
|
+
if (response?.matches?.length === 0)
|
|
69938
|
+
return null;
|
|
69939
|
+
return response;
|
|
69940
|
+
}
|
|
69941
|
+
finally {
|
|
69942
|
+
for (const sig of signatures)
|
|
69943
|
+
sig.free();
|
|
69879
69944
|
}
|
|
69880
|
-
for (const sig of signatures)
|
|
69881
|
-
sig.free();
|
|
69882
|
-
if (!response)
|
|
69883
|
-
return null;
|
|
69884
|
-
if (response?.matches.length === 0)
|
|
69885
|
-
return null;
|
|
69886
|
-
return response;
|
|
69887
69945
|
}
|
|
69888
69946
|
createSignatureGenerator(samples) {
|
|
69889
69947
|
const signatureGenerator = new SignatureGenerator();
|
|
@@ -73901,7 +73959,7 @@ danmaTestWSS.on("connection", (socket, request) => {
|
|
|
73901
73959
|
}, sendTextAfterMs);
|
|
73902
73960
|
}
|
|
73903
73961
|
});
|
|
73904
|
-
const getSingleQueryValue = (value) => {
|
|
73962
|
+
const getSingleQueryValue$1 = (value) => {
|
|
73905
73963
|
if (Array.isArray(value)) {
|
|
73906
73964
|
return value[0];
|
|
73907
73965
|
}
|
|
@@ -73910,8 +73968,8 @@ const getSingleQueryValue = (value) => {
|
|
|
73910
73968
|
/**
|
|
73911
73969
|
* 录制任务相关接口
|
|
73912
73970
|
* @route GET /recorder/list
|
|
73913
|
-
* @param platform 直播平台,DouYu: 斗鱼, HuYa: 虎牙, Bilibili: 哔哩哔哩, DouYin:
|
|
73914
|
-
* @param
|
|
73971
|
+
* @param platform 直播平台,DouYu: 斗鱼, HuYa: 虎牙, Bilibili: 哔哩哔哩, DouYin: 抖音, XHS: 小红书, TikTok: TikTok
|
|
73972
|
+
* @param status 录制状态 recording: 录制中 idle: 空闲中 check-error: 检查错误 title-blocked: 标题被屏蔽
|
|
73915
73973
|
* @param name 备注名称或直播间号,模糊搜索
|
|
73916
73974
|
* @param autoCheck 是否自动监控
|
|
73917
73975
|
* @param page 页码
|
|
@@ -73925,11 +73983,11 @@ router$a.get("/list", async (ctx) => {
|
|
|
73925
73983
|
ctx.body = { payload: await recorderService.getRecorders(query) };
|
|
73926
73984
|
});
|
|
73927
73985
|
router$a.get("/detail", async (ctx) => {
|
|
73928
|
-
const recorderId = getSingleQueryValue(ctx.request.query.recorderId);
|
|
73929
|
-
const page = getSingleQueryValue(ctx.request.query.page);
|
|
73930
|
-
const pageSize = getSingleQueryValue(ctx.request.query.pageSize);
|
|
73931
|
-
const startTime = getSingleQueryValue(ctx.request.query.startTime);
|
|
73932
|
-
const endTime = getSingleQueryValue(ctx.request.query.endTime);
|
|
73986
|
+
const recorderId = getSingleQueryValue$1(ctx.request.query.recorderId);
|
|
73987
|
+
const page = getSingleQueryValue$1(ctx.request.query.page);
|
|
73988
|
+
const pageSize = getSingleQueryValue$1(ctx.request.query.pageSize);
|
|
73989
|
+
const startTime = getSingleQueryValue$1(ctx.request.query.startTime);
|
|
73990
|
+
const endTime = getSingleQueryValue$1(ctx.request.query.endTime);
|
|
73933
73991
|
if (!recorderId) {
|
|
73934
73992
|
ctx.status = 400;
|
|
73935
73993
|
ctx.body = {
|
|
@@ -73991,6 +74049,19 @@ router$a.get("/:id", (ctx) => {
|
|
|
73991
74049
|
const { id } = ctx.params;
|
|
73992
74050
|
ctx.body = { payload: recorderService.getRecorder({ id }) };
|
|
73993
74051
|
});
|
|
74052
|
+
/**
|
|
74053
|
+
* 获取直播播放列表
|
|
74054
|
+
* @route GET /recorder/:recorderId/stream
|
|
74055
|
+
* @param recorderId 录制器 ID
|
|
74056
|
+
* @returns 重写分片地址后的 HLS 播放列表
|
|
74057
|
+
*/
|
|
74058
|
+
router$a.post("/:id/stream", async (ctx) => {
|
|
74059
|
+
const { id } = ctx.params;
|
|
74060
|
+
const data = await recorderService.getStreamUrl(id);
|
|
74061
|
+
ctx.body = {
|
|
74062
|
+
payload: data,
|
|
74063
|
+
};
|
|
74064
|
+
});
|
|
73994
74065
|
router$a.put("/:id", (ctx) => {
|
|
73995
74066
|
const { id } = ctx.params;
|
|
73996
74067
|
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");
|
|
@@ -74012,16 +74083,28 @@ router$a.delete("/:id", (ctx) => {
|
|
|
74012
74083
|
});
|
|
74013
74084
|
/**
|
|
74014
74085
|
* 开始录制
|
|
74086
|
+
* @deprecated
|
|
74015
74087
|
* @route POST /recorder/:recorderId/start_record
|
|
74016
|
-
* @param recorderId
|
|
74088
|
+
* @param recorderId 录制ID
|
|
74017
74089
|
* @returns 录制任务信息
|
|
74018
74090
|
*/
|
|
74019
74091
|
router$a.post("/:id/start_record", async (ctx) => {
|
|
74020
74092
|
const { id } = ctx.params;
|
|
74021
74093
|
ctx.body = { payload: await recorderService.startRecord({ id }) };
|
|
74022
74094
|
});
|
|
74095
|
+
/**
|
|
74096
|
+
* 开始录制
|
|
74097
|
+
* @route POST /recorder/:recorderId/start
|
|
74098
|
+
* @param recorderId 录制ID
|
|
74099
|
+
* @returns 录制任务信息
|
|
74100
|
+
*/
|
|
74101
|
+
router$a.post("/:id/start", async (ctx) => {
|
|
74102
|
+
const { id } = ctx.params;
|
|
74103
|
+
ctx.body = { payload: await recorderService.startRecord({ id }) };
|
|
74104
|
+
});
|
|
74023
74105
|
/**
|
|
74024
74106
|
* 停止录制
|
|
74107
|
+
* @deprecated
|
|
74025
74108
|
* @route POST /recorder/:recorderId/stop_record
|
|
74026
74109
|
* @param recorderId 直播间ID
|
|
74027
74110
|
* @returns 录制任务信息
|
|
@@ -74030,6 +74113,17 @@ router$a.post("/:id/stop_record", async (ctx) => {
|
|
|
74030
74113
|
const { id } = ctx.params;
|
|
74031
74114
|
ctx.body = { payload: await recorderService.stopRecord({ id }) };
|
|
74032
74115
|
});
|
|
74116
|
+
/**
|
|
74117
|
+
* 停止录制
|
|
74118
|
+
* @deprecated
|
|
74119
|
+
* @route POST /recorder/:recorderId/stop
|
|
74120
|
+
* @param recorderId 录制ID
|
|
74121
|
+
* @returns 录制任务信息
|
|
74122
|
+
*/
|
|
74123
|
+
router$a.post("/:id/stop", async (ctx) => {
|
|
74124
|
+
const { id } = ctx.params;
|
|
74125
|
+
ctx.body = { payload: await recorderService.stopRecord({ id }) };
|
|
74126
|
+
});
|
|
74033
74127
|
/**
|
|
74034
74128
|
* 切割录制
|
|
74035
74129
|
* @route POST /recorder/:recorderId/cut
|
|
@@ -74072,11 +74166,11 @@ router$a.post("/manager/batch_stop_record", async (ctx) => {
|
|
|
74072
74166
|
});
|
|
74073
74167
|
/**
|
|
74074
74168
|
* 解析直播间地址,获取对应的直播间信息
|
|
74075
|
-
* @route GET /recorder/manager/
|
|
74169
|
+
* @route GET /recorder/manager/resolve-channel
|
|
74076
74170
|
* @param url 直播间地址
|
|
74077
74171
|
* @returns 直播间信息
|
|
74078
74172
|
*/
|
|
74079
|
-
router$a.get("/manager/
|
|
74173
|
+
router$a.get("/manager/resolve-channel", async (ctx) => {
|
|
74080
74174
|
const { url } = ctx.query;
|
|
74081
74175
|
const data = await recorderService.resolveChannel(url);
|
|
74082
74176
|
ctx.body = { payload: data };
|
|
@@ -74105,12 +74199,12 @@ router$a.post("/manager/batchResolveChannel", async (ctx) => {
|
|
|
74105
74199
|
});
|
|
74106
74200
|
/**
|
|
74107
74201
|
* 获取直播间实时信息
|
|
74108
|
-
* @route POST /recorder/manager/
|
|
74202
|
+
* @route POST /recorder/manager/live-info
|
|
74109
74203
|
* @param ids 直播间ID列表
|
|
74110
74204
|
* @param forceRequest 强制查询直播间信息,不受配置限制,默认true
|
|
74111
74205
|
* @returns 直播间实时信息列表
|
|
74112
74206
|
*/
|
|
74113
|
-
router$a.post("/manager/
|
|
74207
|
+
router$a.post("/manager/live-info", async (ctx) => {
|
|
74114
74208
|
const { ids } = ctx.request.body;
|
|
74115
74209
|
const forceRequest = ctx.request.body.forceRequest ?? true;
|
|
74116
74210
|
let requestInfoForRecord = true;
|
|
@@ -74168,7 +74262,7 @@ router$a.get("/douyin/stream-info", async (ctx) => {
|
|
|
74168
74262
|
try {
|
|
74169
74263
|
const info = await index$1.getStream({
|
|
74170
74264
|
channelId: roomId,
|
|
74171
|
-
quality: getSingleQueryValue(quality) || "origin",
|
|
74265
|
+
quality: getSingleQueryValue$1(quality) || "origin",
|
|
74172
74266
|
streamPriorities: [],
|
|
74173
74267
|
sourcePriorities: [],
|
|
74174
74268
|
formatPriorities: ["flv"],
|
|
@@ -74667,15 +74761,47 @@ const generateWaveformData = async (videoFilePath) => {
|
|
|
74667
74761
|
const router$8 = new Router$1({
|
|
74668
74762
|
prefix: "/task",
|
|
74669
74763
|
});
|
|
74764
|
+
const getSingleQueryValue = (value) => {
|
|
74765
|
+
if (Array.isArray(value)) {
|
|
74766
|
+
return value[0];
|
|
74767
|
+
}
|
|
74768
|
+
return value;
|
|
74769
|
+
};
|
|
74670
74770
|
router$8.get("/", async (ctx) => {
|
|
74671
|
-
const type = ctx.query.type;
|
|
74771
|
+
const type = getSingleQueryValue(ctx.request.query.type);
|
|
74772
|
+
const status = getSingleQueryValue(ctx.request.query.status);
|
|
74773
|
+
const page = getSingleQueryValue(ctx.request.query.page);
|
|
74774
|
+
const pageSize = getSingleQueryValue(ctx.request.query.pageSize);
|
|
74672
74775
|
let data = index$1.handleListTask();
|
|
74673
74776
|
if (type) {
|
|
74674
74777
|
data = data.filter((item) => item.type === type);
|
|
74675
74778
|
}
|
|
74779
|
+
if (status) {
|
|
74780
|
+
data = data.filter((item) => item.status === status);
|
|
74781
|
+
}
|
|
74782
|
+
const currentPage = page ? Number(page) : 1;
|
|
74783
|
+
const currentPageSize = pageSize ? Number(pageSize) : data.length || 1;
|
|
74784
|
+
if (!Number.isInteger(currentPage) || currentPage < 1) {
|
|
74785
|
+
ctx.status = 400;
|
|
74786
|
+
ctx.body = "page must be a positive integer";
|
|
74787
|
+
return;
|
|
74788
|
+
}
|
|
74789
|
+
if (!Number.isInteger(currentPageSize) || currentPageSize < 1) {
|
|
74790
|
+
ctx.status = 400;
|
|
74791
|
+
ctx.body = "pageSize must be a positive integer";
|
|
74792
|
+
return;
|
|
74793
|
+
}
|
|
74794
|
+
const total = data.length;
|
|
74795
|
+
const start = (currentPage - 1) * currentPageSize;
|
|
74796
|
+
const list = data.slice(start, start + currentPageSize);
|
|
74676
74797
|
ctx.body = {
|
|
74677
|
-
list
|
|
74798
|
+
list,
|
|
74678
74799
|
runningTaskNum: data.filter((item) => item.status === "running").length,
|
|
74800
|
+
pagination: {
|
|
74801
|
+
total,
|
|
74802
|
+
page: currentPage,
|
|
74803
|
+
pageSize: currentPageSize,
|
|
74804
|
+
},
|
|
74679
74805
|
};
|
|
74680
74806
|
});
|
|
74681
74807
|
router$8.get("/:id", async (ctx) => {
|
|
@@ -75152,8 +75278,8 @@ async function download$1(output, url, options) {
|
|
|
75152
75278
|
const mp4Output = index$1.replaceExtName(output, ".mp4");
|
|
75153
75279
|
if ((await index$1.fs.pathExists(mp4Output)) && !options.override)
|
|
75154
75280
|
throw new Error(`${mp4Output}已存在`);
|
|
75155
|
-
const { dir, name } = require$$0$
|
|
75156
|
-
const tsOutput = require$$0$
|
|
75281
|
+
const { dir, name } = require$$0$7.parse(output);
|
|
75282
|
+
const tsOutput = require$$0$7.join(dir, `${name}.ts`);
|
|
75157
75283
|
if (await index$1.fs.pathExists(tsOutput)) {
|
|
75158
75284
|
throw new Error(`${tsOutput}已存在,您可以直接执行转封装命令,或者删除后重新下载`);
|
|
75159
75285
|
}
|
|
@@ -75161,10 +75287,10 @@ async function download$1(output, url, options) {
|
|
|
75161
75287
|
const downloader = new index$1.M3U8Downloader(url, tsOutput, {
|
|
75162
75288
|
convert2Mp4: false,
|
|
75163
75289
|
ffmpegPath: ffmpegPath,
|
|
75164
|
-
segmentsDir: require$$0$
|
|
75290
|
+
segmentsDir: require$$0$7.join(index$1.getTempPath(), index$1.uuid()),
|
|
75165
75291
|
});
|
|
75166
75292
|
const task = new index$1.KuaishouDownloadVideoTask(downloader, {
|
|
75167
|
-
name: `下载任务:${require$$0$
|
|
75293
|
+
name: `下载任务:${require$$0$7.parse(output).name}`,
|
|
75168
75294
|
}, {
|
|
75169
75295
|
onEnd: async () => {
|
|
75170
75296
|
const outputName = `${name}.mp4`;
|
|
@@ -75207,7 +75333,7 @@ var kuaishou = {
|
|
|
75207
75333
|
var dist = {};
|
|
75208
75334
|
|
|
75209
75335
|
(function (exports) {
|
|
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);
|
|
75336
|
+
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);
|
|
75211
75337
|
} (dist));
|
|
75212
75338
|
|
|
75213
75339
|
async function download(output, url, options) {
|
|
@@ -75277,6 +75403,28 @@ router$6.post("/download", async (ctx) => {
|
|
|
75277
75403
|
let options = ctx.request.body;
|
|
75278
75404
|
ctx.body = await downloadVideo(options);
|
|
75279
75405
|
});
|
|
75406
|
+
router$6.get("/douyu/videoList", async (ctx) => {
|
|
75407
|
+
const { subId, page, limit } = ctx.query;
|
|
75408
|
+
const res = await index$1.douyu.getReplayList(String(subId), {
|
|
75409
|
+
page: Number(page || 1),
|
|
75410
|
+
limit: Number(limit || 20),
|
|
75411
|
+
});
|
|
75412
|
+
const data = res.list.map((item) => {
|
|
75413
|
+
const firstVideo = item.video_list[0];
|
|
75414
|
+
return {
|
|
75415
|
+
startTime: firstVideo?.start_time,
|
|
75416
|
+
title: item.title,
|
|
75417
|
+
timeStr: new Date(firstVideo?.start_time * 1000).toLocaleString(),
|
|
75418
|
+
videos: item.video_list.map((video) => ({
|
|
75419
|
+
videoId: video.hash_id,
|
|
75420
|
+
title: video.title,
|
|
75421
|
+
url: `https://v.douyu.com/show/${video.hash_id}`,
|
|
75422
|
+
})),
|
|
75423
|
+
};
|
|
75424
|
+
});
|
|
75425
|
+
console.log(data);
|
|
75426
|
+
ctx.body = data;
|
|
75427
|
+
});
|
|
75280
75428
|
router$6.post("/sub/parse", async (ctx) => {
|
|
75281
75429
|
let data = ctx.request.body;
|
|
75282
75430
|
if (!data.url) {
|
|
@@ -76726,7 +76874,7 @@ const router$1 = new Router$1({
|
|
|
76726
76874
|
// });
|
|
76727
76875
|
// ctx.body = result;
|
|
76728
76876
|
// });
|
|
76729
|
-
router$1.post("/
|
|
76877
|
+
router$1.post("/song-recognize", async (ctx) => {
|
|
76730
76878
|
const data = ctx.request.body;
|
|
76731
76879
|
if (!data.file || data.startTime == null || data.endTime == null) {
|
|
76732
76880
|
ctx.status = 400;
|
|
@@ -79090,7 +79238,7 @@ let handler;
|
|
|
79090
79238
|
let appConfig;
|
|
79091
79239
|
let container;
|
|
79092
79240
|
const fileCache = createFileCache();
|
|
79093
|
-
path$3.dirname(
|
|
79241
|
+
path$3.dirname(urlLib.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index-DTguSku6.cjs', document.baseURI).href))));
|
|
79094
79242
|
const authMiddleware = (passKey) => {
|
|
79095
79243
|
return async (ctx, next) => {
|
|
79096
79244
|
const authHeader = ctx.headers["authorization"] || ctx.request.query.auth;
|
|
@@ -79171,7 +79319,7 @@ async function serverStart(options, axContainer) {
|
|
|
79171
79319
|
async function createServer(options) {
|
|
79172
79320
|
index$1.logObj.info(`开始创建服务器: ${options.host}:${options.port}`);
|
|
79173
79321
|
{
|
|
79174
|
-
const httpServer =
|
|
79322
|
+
const httpServer = http$4.createServer(app.callback());
|
|
79175
79323
|
httpServer.on("error", (err) => {
|
|
79176
79324
|
index$1.logObj.error("HTTP 服务器错误:", err);
|
|
79177
79325
|
});
|