bililive-cli 3.9.1 → 3.10.1
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-wqkoyRnJ.cjs → chunked-exec-tHzxUWFk.cjs} +5 -5
- package/lib/{index-B4DHRkFJ.cjs → index-CuJEbURl.cjs} +52452 -10812
- package/lib/{index-Cba0EEtx.cjs → index-DOo0dewT.cjs} +202 -305
- package/lib/index.cjs +3 -3
- package/lib/{linux-CNe7K9Gx.cjs → linux-CINV_k6s.cjs} +13 -1
- package/lib/{macos-Dd90ykMt.cjs → macos-BYKwI9yg.cjs} +2 -2
- package/lib/{windows-CJCw0QtL.cjs → windows-OmnJ7a39.cjs} +2 -2
- package/package.json +6 -6
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var path$7 = require('node:path');
|
|
4
|
-
var
|
|
5
|
-
var require$$
|
|
4
|
+
var require$$2$1 = require('node:http');
|
|
5
|
+
var require$$1$2 = require('node:url');
|
|
6
6
|
var a = require('node:https');
|
|
7
|
-
var index = 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$
|
|
7
|
+
var index = require('./index-CuJEbURl.cjs');
|
|
8
|
+
var require$$0$4 = require('tty');
|
|
9
|
+
var require$$1$3 = require('util');
|
|
10
|
+
var require$$0$b = require('assert');
|
|
11
|
+
var require$$0$6 = require('path');
|
|
12
|
+
var require$$0$5 = require('buffer');
|
|
13
|
+
var require$$0$7 = 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$
|
|
17
|
+
var require$$0$a = require('url');
|
|
18
|
+
var require$$1$4 = require('crypto');
|
|
19
19
|
var require$$3$1 = require('http');
|
|
20
|
-
var require$$0$
|
|
20
|
+
var require$$0$c = 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 fs$6 = require('node:fs');
|
|
28
28
|
var EventEmitter$3 = require('node:events');
|
|
@@ -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$
|
|
35
|
+
var require$$0$d = require('child_process');
|
|
36
36
|
var shazamioCore = require('shazamio-core');
|
|
37
|
-
var require$$1$
|
|
37
|
+
var require$$1$7 = require('https');
|
|
38
38
|
require('node:dns');
|
|
39
39
|
require('constants');
|
|
40
40
|
require('node:fs/promises');
|
|
@@ -49,144 +49,20 @@ require('node:stream/promises');
|
|
|
49
49
|
require('fs/promises');
|
|
50
50
|
require('node:net');
|
|
51
51
|
require('node:zlib');
|
|
52
|
+
require('node:assert');
|
|
53
|
+
require('node:querystring');
|
|
54
|
+
require('node:diagnostics_channel');
|
|
55
|
+
require('node:tls');
|
|
56
|
+
require('node:buffer');
|
|
57
|
+
require('node:perf_hooks');
|
|
58
|
+
require('node:util/types');
|
|
59
|
+
require('node:sqlite');
|
|
60
|
+
require('node:worker_threads');
|
|
61
|
+
require('node:async_hooks');
|
|
62
|
+
require('node:console');
|
|
63
|
+
require('node:timers');
|
|
52
64
|
|
|
53
65
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
54
|
-
/**
|
|
55
|
-
* 支持{{title}},{{user}},{{now}}等占位符,会覆盖预设中的标题,如【{{user}}】{{title}}-{{now}}<br/>
|
|
56
|
-
* 直播标题:{{title}}<br/>
|
|
57
|
-
* 主播名:{{user}}<br/>
|
|
58
|
-
* 房间号:{{roomId}}<br/>
|
|
59
|
-
* 当前时间(快速):{{now}},示例:2024.01.24<br/>
|
|
60
|
-
* 年:{{yyyy}}<br/>
|
|
61
|
-
* 月(补零):{{MM}}<br/>
|
|
62
|
-
* 日(补零):{{dd}}<br/>
|
|
63
|
-
* 时(补零):{{HH}}<br/>
|
|
64
|
-
* 分(补零):{{mm}}<br/>
|
|
65
|
-
* 秒(补零):{{ss}}<br/>
|
|
66
|
-
* 文件名:{{filename}}<br/>
|
|
67
|
-
*
|
|
68
|
-
* @param {object} options 格式化参数
|
|
69
|
-
* @param {string} options.title 直播标题
|
|
70
|
-
* @param {string} options.username 主播名
|
|
71
|
-
* @param {string} options.time 直播时间
|
|
72
|
-
* @param {number} options.roomId 房间号
|
|
73
|
-
* @param {string} options.filename 文件名
|
|
74
|
-
* @param {string} template 格式化模板
|
|
75
|
-
*/
|
|
76
|
-
function formatTitle(options, template) {
|
|
77
|
-
const { year, month, day, hours, minutes, seconds, now } = formatTime(options.time);
|
|
78
|
-
let renderText = template;
|
|
79
|
-
try {
|
|
80
|
-
const renderOptions = {
|
|
81
|
-
title: options.title,
|
|
82
|
-
user: options.username,
|
|
83
|
-
time: new Date(options.time),
|
|
84
|
-
roomId: options.roomId,
|
|
85
|
-
filename: options.filename,
|
|
86
|
-
};
|
|
87
|
-
renderText = index.ejs.render(template, renderOptions);
|
|
88
|
-
}
|
|
89
|
-
catch (error) {
|
|
90
|
-
index.logObj.error("模板解析错误", error);
|
|
91
|
-
}
|
|
92
|
-
const title = renderText
|
|
93
|
-
.replaceAll("{{title}}", options.title)
|
|
94
|
-
.replaceAll("{{user}}", options.username)
|
|
95
|
-
.replaceAll("{{roomId}}", String(options.roomId))
|
|
96
|
-
.replaceAll("{{now}}", now)
|
|
97
|
-
.replaceAll("{{yyyy}}", year)
|
|
98
|
-
.replaceAll("{{MM}}", month)
|
|
99
|
-
.replaceAll("{{dd}}", day)
|
|
100
|
-
.replaceAll("{{HH}}", hours)
|
|
101
|
-
.replaceAll("{{mm}}", minutes)
|
|
102
|
-
.replaceAll("{{ss}}", seconds)
|
|
103
|
-
.replaceAll("{{filename}}", options.filename)
|
|
104
|
-
.trim()
|
|
105
|
-
.slice(0, 80);
|
|
106
|
-
return title;
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* 分P标题格式化
|
|
110
|
-
* 直播标题:{{title}}<br/>
|
|
111
|
-
* 主播名:{{user}}<br/>
|
|
112
|
-
* 房间号:{{roomId}}<br/>
|
|
113
|
-
* 当前时间(快速):{{now}},示例:2024.01.24<br/>
|
|
114
|
-
* 年:{{yyyy}}<br/>
|
|
115
|
-
* 月(补零):{{MM}}<br/>
|
|
116
|
-
* 日(补零):{{dd}}<br/>
|
|
117
|
-
* 时(补零):{{HH}}<br/>
|
|
118
|
-
* 分(补零):{{mm}}<br/>
|
|
119
|
-
* 秒(补零):{{ss}}<br/>
|
|
120
|
-
* 文件名:{{filename}}<br/>
|
|
121
|
-
*
|
|
122
|
-
* @param {object} options 格式化参数
|
|
123
|
-
* @param {string} options.title 直播标题
|
|
124
|
-
* @param {string} options.username 主播名
|
|
125
|
-
* @param {string} options.time 直播时间
|
|
126
|
-
* @param {number} options.roomId 房间号
|
|
127
|
-
* @param {string} options.filename 文件名
|
|
128
|
-
* @param {string} template 格式化模板
|
|
129
|
-
*/
|
|
130
|
-
function formatPartTitle(options, template) {
|
|
131
|
-
const { year, month, day, hours, minutes, seconds } = formatTime(options.time);
|
|
132
|
-
let renderText = template;
|
|
133
|
-
const isDanmaFile = options.filename.includes("-弹幕版");
|
|
134
|
-
const hasDanmaStr = isDanmaFile ? "弹幕版" : "纯享版";
|
|
135
|
-
try {
|
|
136
|
-
const renderOptions = {
|
|
137
|
-
title: options.title,
|
|
138
|
-
user: options.username,
|
|
139
|
-
time: new Date(options.time),
|
|
140
|
-
roomId: options.roomId,
|
|
141
|
-
filename: options.filename,
|
|
142
|
-
isDanmaFile,
|
|
143
|
-
hasDanmaStr,
|
|
144
|
-
};
|
|
145
|
-
renderText = index.ejs.render(template, renderOptions);
|
|
146
|
-
}
|
|
147
|
-
catch (error) {
|
|
148
|
-
index.logObj.error("模板解析错误", error);
|
|
149
|
-
}
|
|
150
|
-
const title = renderText
|
|
151
|
-
.replaceAll("{{title}}", options.title)
|
|
152
|
-
.replaceAll("{{user}}", options.username)
|
|
153
|
-
.replaceAll("{{roomId}}", String(options.roomId))
|
|
154
|
-
.replaceAll("{{yyyy}}", year)
|
|
155
|
-
.replaceAll("{{MM}}", month)
|
|
156
|
-
.replaceAll("{{dd}}", day)
|
|
157
|
-
.replaceAll("{{HH}}", hours)
|
|
158
|
-
.replaceAll("{{mm}}", minutes)
|
|
159
|
-
.replaceAll("{{ss}}", seconds)
|
|
160
|
-
.replaceAll("{{filename}}", options.filename)
|
|
161
|
-
.replaceAll("{{index}}", String(options.index))
|
|
162
|
-
.replaceAll("{{hasDanmaStr}}", hasDanmaStr)
|
|
163
|
-
.trim()
|
|
164
|
-
.slice(0, 80);
|
|
165
|
-
return title;
|
|
166
|
-
}
|
|
167
|
-
function formatTime(time) {
|
|
168
|
-
// 创建一个Date对象
|
|
169
|
-
const timestamp = new Date(time);
|
|
170
|
-
// 提取年、月、日部分
|
|
171
|
-
const year = timestamp.getFullYear();
|
|
172
|
-
const month = String(timestamp.getMonth() + 1).padStart(2, "0");
|
|
173
|
-
const day = String(timestamp.getDate()).padStart(2, "0");
|
|
174
|
-
const hours = String(timestamp.getHours()).padStart(2, "0");
|
|
175
|
-
const minutes = String(timestamp.getMinutes()).padStart(2, "0");
|
|
176
|
-
const seconds = String(timestamp.getSeconds()).padStart(2, "0");
|
|
177
|
-
// 格式化为"YYYY.MM.DD"的形式
|
|
178
|
-
const formattedDate = `${year}.${month}.${day}`;
|
|
179
|
-
return {
|
|
180
|
-
year: String(year),
|
|
181
|
-
month,
|
|
182
|
-
day,
|
|
183
|
-
hours,
|
|
184
|
-
minutes,
|
|
185
|
-
seconds,
|
|
186
|
-
now: formattedDate,
|
|
187
|
-
};
|
|
188
|
-
}
|
|
189
|
-
|
|
190
66
|
/**
|
|
191
67
|
* 百度网盘上传类
|
|
192
68
|
* 使用 BaiduPCS-Go 工具进行文件上传
|
|
@@ -1199,8 +1075,8 @@ class Alist extends index.TypedEmitter {
|
|
|
1199
1075
|
this.emit("canceled", "上传已取消");
|
|
1200
1076
|
},
|
|
1201
1077
|
};
|
|
1202
|
-
const url = new require$$
|
|
1203
|
-
const httpModule = url.protocol === "https:" ? a :
|
|
1078
|
+
const url = new require$$1$2.URL(combineURLs(this.server, "/api/fs/put"));
|
|
1079
|
+
const httpModule = url.protocol === "https:" ? a : require$$2$1;
|
|
1204
1080
|
try {
|
|
1205
1081
|
await new Promise((resolve, reject) => {
|
|
1206
1082
|
req = httpModule.request({
|
|
@@ -2161,8 +2037,8 @@ function requireNode$1 () {
|
|
|
2161
2037
|
if (hasRequiredNode$1) return node$1.exports;
|
|
2162
2038
|
hasRequiredNode$1 = 1;
|
|
2163
2039
|
(function (module, exports) {
|
|
2164
|
-
const tty = require$$0$
|
|
2165
|
-
const util = require$$1$
|
|
2040
|
+
const tty = require$$0$4;
|
|
2041
|
+
const util = require$$1$3;
|
|
2166
2042
|
|
|
2167
2043
|
/**
|
|
2168
2044
|
* This is the Node.js implementation of `debug()`.
|
|
@@ -2778,7 +2654,7 @@ var safeBuffer$2 = {exports: {}};
|
|
|
2778
2654
|
|
|
2779
2655
|
(function (module, exports) {
|
|
2780
2656
|
/* eslint-disable node/no-deprecated-api */
|
|
2781
|
-
var buffer = require$$0$
|
|
2657
|
+
var buffer = require$$0$5;
|
|
2782
2658
|
var Buffer = buffer.Buffer;
|
|
2783
2659
|
|
|
2784
2660
|
// alternative to using Object.keys for old browsers
|
|
@@ -2864,7 +2740,7 @@ contentDisposition$1.exports.parse = parse$k;
|
|
|
2864
2740
|
* @private
|
|
2865
2741
|
*/
|
|
2866
2742
|
|
|
2867
|
-
var basename$2 = require$$0$
|
|
2743
|
+
var basename$2 = require$$0$6.basename;
|
|
2868
2744
|
var Buffer$2 = safeBufferExports.Buffer;
|
|
2869
2745
|
|
|
2870
2746
|
/**
|
|
@@ -4239,9 +4115,9 @@ function status$1 (code) {
|
|
|
4239
4115
|
* @private
|
|
4240
4116
|
*/
|
|
4241
4117
|
|
|
4242
|
-
var EventEmitter$2 = require$$0$
|
|
4243
|
-
var ReadStream = require$$0$
|
|
4244
|
-
var Stream$3 = require$$0$
|
|
4118
|
+
var EventEmitter$2 = require$$0$7.EventEmitter;
|
|
4119
|
+
var ReadStream = require$$0$8.ReadStream;
|
|
4120
|
+
var Stream$3 = require$$0$9;
|
|
4245
4121
|
var Zlib = zlib$1;
|
|
4246
4122
|
|
|
4247
4123
|
/**
|
|
@@ -4669,14 +4545,14 @@ function encodeUrl (url) {
|
|
|
4669
4545
|
const typeis = typeIsExports.is;
|
|
4670
4546
|
const statuses = statuses$2;
|
|
4671
4547
|
const destroy = destroy_1$2;
|
|
4672
|
-
const assert = require$$0$
|
|
4673
|
-
const extname = require$$0$
|
|
4548
|
+
const assert = require$$0$b;
|
|
4549
|
+
const extname = require$$0$6.extname;
|
|
4674
4550
|
const vary = varyExports;
|
|
4675
4551
|
const only = only$1;
|
|
4676
|
-
const util = require$$1$
|
|
4552
|
+
const util = require$$1$3;
|
|
4677
4553
|
const encodeUrl = encodeurl;
|
|
4678
|
-
const Stream = require$$0$
|
|
4679
|
-
const URL = require$$0$
|
|
4554
|
+
const Stream = require$$0$9;
|
|
4555
|
+
const URL = require$$0$a.URL;
|
|
4680
4556
|
|
|
4681
4557
|
/**
|
|
4682
4558
|
* Prototype.
|
|
@@ -5459,7 +5335,7 @@ function requireEventListenerCount$1 () {
|
|
|
5459
5335
|
* @private
|
|
5460
5336
|
*/
|
|
5461
5337
|
|
|
5462
|
-
var EventEmitter = require$$0$
|
|
5338
|
+
var EventEmitter = require$$0$7.EventEmitter;
|
|
5463
5339
|
|
|
5464
5340
|
/**
|
|
5465
5341
|
* Module exports.
|
|
@@ -5541,7 +5417,7 @@ var compatExports$1 = compat$1.exports;
|
|
|
5541
5417
|
|
|
5542
5418
|
var callSiteToString$1 = compatExports$1.callSiteToString;
|
|
5543
5419
|
var eventListenerCount$1 = compatExports$1.eventListenerCount;
|
|
5544
|
-
var relative$2 = require$$0$
|
|
5420
|
+
var relative$2 = require$$0$6.relative;
|
|
5545
5421
|
|
|
5546
5422
|
/**
|
|
5547
5423
|
* Module exports.
|
|
@@ -6560,7 +6436,7 @@ function requireEventListenerCount () {
|
|
|
6560
6436
|
* @private
|
|
6561
6437
|
*/
|
|
6562
6438
|
|
|
6563
|
-
var EventEmitter = require$$0$
|
|
6439
|
+
var EventEmitter = require$$0$7.EventEmitter;
|
|
6564
6440
|
|
|
6565
6441
|
/**
|
|
6566
6442
|
* Module exports.
|
|
@@ -6642,7 +6518,7 @@ var compatExports = compat.exports;
|
|
|
6642
6518
|
|
|
6643
6519
|
var callSiteToString = compatExports.callSiteToString;
|
|
6644
6520
|
var eventListenerCount = compatExports.eventListenerCount;
|
|
6645
|
-
var relative$1 = require$$0$
|
|
6521
|
+
var relative$1 = require$$0$6.relative;
|
|
6646
6522
|
|
|
6647
6523
|
/**
|
|
6648
6524
|
* Module exports.
|
|
@@ -7768,7 +7644,7 @@ Delegator.prototype.fluent = function (name) {
|
|
|
7768
7644
|
* Module dependencies.
|
|
7769
7645
|
*/
|
|
7770
7646
|
|
|
7771
|
-
var relative = require$$0$
|
|
7647
|
+
var relative = require$$0$6.relative;
|
|
7772
7648
|
|
|
7773
7649
|
/**
|
|
7774
7650
|
* Module exports.
|
|
@@ -8303,7 +8179,7 @@ function DeprecationError (namespace, message, stack) {
|
|
|
8303
8179
|
// https://github.com/nodejs/node/issues/3043
|
|
8304
8180
|
// https://github.com/nodejs/node/pull/3073
|
|
8305
8181
|
|
|
8306
|
-
var crypto$3 = require$$1$
|
|
8182
|
+
var crypto$3 = require$$1$4;
|
|
8307
8183
|
|
|
8308
8184
|
function bufferEqual(a, b) {
|
|
8309
8185
|
if (a.length !== b.length) {
|
|
@@ -8341,7 +8217,7 @@ var lib$8 = timeSafeCompare;
|
|
|
8341
8217
|
*/
|
|
8342
8218
|
|
|
8343
8219
|
var compare$c = lib$8;
|
|
8344
|
-
var crypto$2 = require$$1$
|
|
8220
|
+
var crypto$2 = require$$1$4;
|
|
8345
8221
|
|
|
8346
8222
|
function Keygrip$1(keys, algorithm, encoding) {
|
|
8347
8223
|
if (!algorithm) algorithm = "sha1";
|
|
@@ -8679,7 +8555,7 @@ var cookies = Cookies;
|
|
|
8679
8555
|
* Module dependencies.
|
|
8680
8556
|
*/
|
|
8681
8557
|
|
|
8682
|
-
const util = require$$1$
|
|
8558
|
+
const util = require$$1$3;
|
|
8683
8559
|
const createError = httpErrorsExports$2;
|
|
8684
8560
|
const httpAssert$1 = httpAssert;
|
|
8685
8561
|
const delegate = delegates;
|
|
@@ -10327,7 +10203,7 @@ var parseurl$1 = {exports: {}};
|
|
|
10327
10203
|
* @private
|
|
10328
10204
|
*/
|
|
10329
10205
|
|
|
10330
|
-
var url = require$$0$
|
|
10206
|
+
var url = require$$0$a;
|
|
10331
10207
|
var parse$g = url.parse;
|
|
10332
10208
|
var Url = url.Url;
|
|
10333
10209
|
|
|
@@ -10614,17 +10490,17 @@ function parseTokenList (str) {
|
|
|
10614
10490
|
* Module dependencies.
|
|
10615
10491
|
*/
|
|
10616
10492
|
|
|
10617
|
-
const URL = require$$0$
|
|
10618
|
-
const net = require$$0$
|
|
10493
|
+
const URL = require$$0$a.URL;
|
|
10494
|
+
const net = require$$0$c;
|
|
10619
10495
|
const accepts$1 = accepts;
|
|
10620
10496
|
const contentType$1 = contentType;
|
|
10621
|
-
const stringify = require$$0$
|
|
10497
|
+
const stringify = require$$0$a.format;
|
|
10622
10498
|
const parse = parseurlExports;
|
|
10623
10499
|
const qs = require$$5$1;
|
|
10624
10500
|
const typeis = typeIsExports;
|
|
10625
10501
|
const fresh = fresh_1;
|
|
10626
10502
|
const only = only$1;
|
|
10627
|
-
const util = require$$1$
|
|
10503
|
+
const util = require$$1$3;
|
|
10628
10504
|
|
|
10629
10505
|
const IP = Symbol('context#ip');
|
|
10630
10506
|
|
|
@@ -11685,15 +11561,15 @@ convert$1.back = function (mw) {
|
|
|
11685
11561
|
const isGeneratorFunction = isGeneratorFunction$2;
|
|
11686
11562
|
const debug$4 = srcExports('koa:application');
|
|
11687
11563
|
const onFinished = onFinishedExports;
|
|
11688
|
-
const assert = require$$0$
|
|
11564
|
+
const assert = require$$0$b;
|
|
11689
11565
|
const response = responseExports;
|
|
11690
11566
|
const compose$1 = koaCompose;
|
|
11691
11567
|
const context = contextExports;
|
|
11692
11568
|
const request = requestExports;
|
|
11693
11569
|
const statuses$1 = statuses$2;
|
|
11694
|
-
const Emitter = require$$0$
|
|
11695
|
-
const util$2 = require$$1$
|
|
11696
|
-
const Stream$2 = require$$0$
|
|
11570
|
+
const Emitter = require$$0$7;
|
|
11571
|
+
const util$2 = require$$1$3;
|
|
11572
|
+
const Stream$2 = require$$0$9;
|
|
11697
11573
|
const http$1 = require$$3$1;
|
|
11698
11574
|
const only = only$1;
|
|
11699
11575
|
const convert = koaConvert;
|
|
@@ -12909,7 +12785,7 @@ function isNextNameSafe(token) {
|
|
|
12909
12785
|
return !ID_CONTINUE.test(token.value[0]);
|
|
12910
12786
|
}
|
|
12911
12787
|
|
|
12912
|
-
const { parse: parseUrl, format: formatUrl } = require$$
|
|
12788
|
+
const { parse: parseUrl, format: formatUrl } = require$$1$2;
|
|
12913
12789
|
|
|
12914
12790
|
const { pathToRegexp: pathToRegexp$1, compile, parse: parse$e } = dist$1;
|
|
12915
12791
|
|
|
@@ -13179,7 +13055,7 @@ function safeDecodeURIComponent(text) {
|
|
|
13179
13055
|
* @link https://github.com/alexmingoia/koa-router
|
|
13180
13056
|
*/
|
|
13181
13057
|
|
|
13182
|
-
const http =
|
|
13058
|
+
const http = require$$2$1;
|
|
13183
13059
|
|
|
13184
13060
|
const debug$3 = index.srcExports('koa-router');
|
|
13185
13061
|
|
|
@@ -14360,7 +14236,7 @@ var lib$7 = {exports: {}};
|
|
|
14360
14236
|
|
|
14361
14237
|
/* eslint-disable node/no-deprecated-api */
|
|
14362
14238
|
|
|
14363
|
-
var buffer$1 = require$$0$
|
|
14239
|
+
var buffer$1 = require$$0$5;
|
|
14364
14240
|
var Buffer$1 = buffer$1.Buffer;
|
|
14365
14241
|
|
|
14366
14242
|
var safer = {};
|
|
@@ -14541,7 +14417,7 @@ function requireInternal () {
|
|
|
14541
14417
|
//------------------------------------------------------------------------------
|
|
14542
14418
|
|
|
14543
14419
|
// We use node.js internal decoder. Its signature is the same as ours.
|
|
14544
|
-
var StringDecoder = require$$1$
|
|
14420
|
+
var StringDecoder = require$$1$5.StringDecoder;
|
|
14545
14421
|
|
|
14546
14422
|
if (!StringDecoder.prototype.end) // Node v0.8 doesn't have this method.
|
|
14547
14423
|
StringDecoder.prototype.end = function() {};
|
|
@@ -24942,8 +24818,8 @@ function requireStreams () {
|
|
|
24942
24818
|
if (hasRequiredStreams) return streams;
|
|
24943
24819
|
hasRequiredStreams = 1;
|
|
24944
24820
|
|
|
24945
|
-
var Buffer = require$$0$
|
|
24946
|
-
Transform = require$$0$
|
|
24821
|
+
var Buffer = require$$0$5.Buffer,
|
|
24822
|
+
Transform = require$$0$9.Transform;
|
|
24947
24823
|
|
|
24948
24824
|
|
|
24949
24825
|
// == Exports ==================================================================
|
|
@@ -25069,7 +24945,7 @@ var hasRequiredExtendNode;
|
|
|
25069
24945
|
function requireExtendNode () {
|
|
25070
24946
|
if (hasRequiredExtendNode) return extendNode;
|
|
25071
24947
|
hasRequiredExtendNode = 1;
|
|
25072
|
-
var Buffer = require$$0$
|
|
24948
|
+
var Buffer = require$$0$5.Buffer;
|
|
25073
24949
|
// Note: not polyfilled with safer-buffer on a purpose, as overrides Buffer
|
|
25074
24950
|
|
|
25075
24951
|
// == Extend Node primitives to use iconv-lite =================================
|
|
@@ -25102,7 +24978,7 @@ function requireExtendNode () {
|
|
|
25102
24978
|
};
|
|
25103
24979
|
|
|
25104
24980
|
// -- SlowBuffer -----------------------------------------------------------
|
|
25105
|
-
var SlowBuffer = require$$0$
|
|
24981
|
+
var SlowBuffer = require$$0$5.SlowBuffer;
|
|
25106
24982
|
|
|
25107
24983
|
original.SlowBufferToString = SlowBuffer.prototype.toString;
|
|
25108
24984
|
SlowBuffer.prototype.toString = function(encoding, start, end) {
|
|
@@ -25242,7 +25118,7 @@ function requireExtendNode () {
|
|
|
25242
25118
|
|
|
25243
25119
|
// -- Readable -------------------------------------------------------------
|
|
25244
25120
|
if (iconv.supportsStreams) {
|
|
25245
|
-
var Readable = require$$0$
|
|
25121
|
+
var Readable = require$$0$9.Readable;
|
|
25246
25122
|
|
|
25247
25123
|
original.ReadableSetEncoding = Readable.prototype.setEncoding;
|
|
25248
25124
|
Readable.prototype.setEncoding = function setEncoding(enc, options) {
|
|
@@ -25265,7 +25141,7 @@ function requireExtendNode () {
|
|
|
25265
25141
|
|
|
25266
25142
|
delete Buffer.isNativeEncoding;
|
|
25267
25143
|
|
|
25268
|
-
var SlowBuffer = require$$0$
|
|
25144
|
+
var SlowBuffer = require$$0$5.SlowBuffer;
|
|
25269
25145
|
|
|
25270
25146
|
SlowBuffer.prototype.toString = original.SlowBufferToString;
|
|
25271
25147
|
SlowBuffer.prototype.write = original.SlowBufferWrite;
|
|
@@ -25276,7 +25152,7 @@ function requireExtendNode () {
|
|
|
25276
25152
|
Buffer.prototype.write = original.BufferWrite;
|
|
25277
25153
|
|
|
25278
25154
|
if (iconv.supportsStreams) {
|
|
25279
|
-
var Readable = require$$0$
|
|
25155
|
+
var Readable = require$$0$9.Readable;
|
|
25280
25156
|
|
|
25281
25157
|
Readable.prototype.setEncoding = original.ReadableSetEncoding;
|
|
25282
25158
|
delete Readable.prototype.collect;
|
|
@@ -26211,19 +26087,19 @@ var getEvalledConstructor = function (expressionSyntax) {
|
|
|
26211
26087
|
} catch (e) {}
|
|
26212
26088
|
};
|
|
26213
26089
|
|
|
26214
|
-
var $gOPD$
|
|
26215
|
-
if ($gOPD$
|
|
26090
|
+
var $gOPD$2 = Object.getOwnPropertyDescriptor;
|
|
26091
|
+
if ($gOPD$2) {
|
|
26216
26092
|
try {
|
|
26217
|
-
$gOPD$
|
|
26093
|
+
$gOPD$2({}, '');
|
|
26218
26094
|
} catch (e) {
|
|
26219
|
-
$gOPD$
|
|
26095
|
+
$gOPD$2 = null; // this is IE 8, which has a broken gOPD
|
|
26220
26096
|
}
|
|
26221
26097
|
}
|
|
26222
26098
|
|
|
26223
26099
|
var throwTypeError = function () {
|
|
26224
26100
|
throw new $TypeError$3();
|
|
26225
26101
|
};
|
|
26226
|
-
var ThrowTypeError = $gOPD$
|
|
26102
|
+
var ThrowTypeError = $gOPD$2
|
|
26227
26103
|
? (function () {
|
|
26228
26104
|
try {
|
|
26229
26105
|
// eslint-disable-next-line no-unused-expressions, no-caller, no-restricted-properties
|
|
@@ -26232,7 +26108,7 @@ var ThrowTypeError = $gOPD$1
|
|
|
26232
26108
|
} catch (calleeThrows) {
|
|
26233
26109
|
try {
|
|
26234
26110
|
// IE 8 throws on Object.getOwnPropertyDescriptor(arguments, '')
|
|
26235
|
-
return $gOPD$
|
|
26111
|
+
return $gOPD$2(arguments, 'callee').get;
|
|
26236
26112
|
} catch (gOPDthrows) {
|
|
26237
26113
|
return throwTypeError;
|
|
26238
26114
|
}
|
|
@@ -26521,8 +26397,8 @@ var getIntrinsic = function GetIntrinsic(name, allowMissing) {
|
|
|
26521
26397
|
}
|
|
26522
26398
|
return void undefined$1;
|
|
26523
26399
|
}
|
|
26524
|
-
if ($gOPD$
|
|
26525
|
-
var desc = $gOPD$
|
|
26400
|
+
if ($gOPD$2 && (i + 1) >= parts.length) {
|
|
26401
|
+
var desc = $gOPD$2(value, part);
|
|
26526
26402
|
isOwn = !!desc;
|
|
26527
26403
|
|
|
26528
26404
|
// By convention, when a data property is converted to an accessor
|
|
@@ -26576,27 +26452,27 @@ function requireEsDefineProperty () {
|
|
|
26576
26452
|
return esDefineProperty;
|
|
26577
26453
|
}
|
|
26578
26454
|
|
|
26579
|
-
var GetIntrinsic$
|
|
26455
|
+
var GetIntrinsic$4 = getIntrinsic;
|
|
26580
26456
|
|
|
26581
|
-
var $gOPD = GetIntrinsic$
|
|
26457
|
+
var $gOPD$1 = GetIntrinsic$4('%Object.getOwnPropertyDescriptor%', true);
|
|
26582
26458
|
|
|
26583
|
-
if ($gOPD) {
|
|
26459
|
+
if ($gOPD$1) {
|
|
26584
26460
|
try {
|
|
26585
|
-
$gOPD([], 'length');
|
|
26461
|
+
$gOPD$1([], 'length');
|
|
26586
26462
|
} catch (e) {
|
|
26587
26463
|
// IE 8 has a broken gOPD
|
|
26588
|
-
$gOPD = null;
|
|
26464
|
+
$gOPD$1 = null;
|
|
26589
26465
|
}
|
|
26590
26466
|
}
|
|
26591
26467
|
|
|
26592
|
-
var gopd$
|
|
26468
|
+
var gopd$2 = $gOPD$1;
|
|
26593
26469
|
|
|
26594
26470
|
var $defineProperty$1 = requireEsDefineProperty();
|
|
26595
26471
|
|
|
26596
26472
|
var $SyntaxError = syntax;
|
|
26597
26473
|
var $TypeError$2 = type;
|
|
26598
26474
|
|
|
26599
|
-
var gopd = gopd$
|
|
26475
|
+
var gopd$1 = gopd$2;
|
|
26600
26476
|
|
|
26601
26477
|
/** @type {import('.')} */
|
|
26602
26478
|
var defineDataProperty = function defineDataProperty(
|
|
@@ -26629,7 +26505,7 @@ var defineDataProperty = function defineDataProperty(
|
|
|
26629
26505
|
var loose = arguments.length > 6 ? arguments[6] : false;
|
|
26630
26506
|
|
|
26631
26507
|
/* @type {false | TypedPropertyDescriptor<unknown>} */
|
|
26632
|
-
var desc = !!gopd && gopd(obj, property);
|
|
26508
|
+
var desc = !!gopd$1 && gopd$1(obj, property);
|
|
26633
26509
|
|
|
26634
26510
|
if ($defineProperty$1) {
|
|
26635
26511
|
$defineProperty$1(obj, property, {
|
|
@@ -26667,10 +26543,25 @@ hasPropertyDescriptors.hasArrayLengthDefineBug = function hasArrayLengthDefineBu
|
|
|
26667
26543
|
|
|
26668
26544
|
var hasPropertyDescriptors_1 = hasPropertyDescriptors;
|
|
26669
26545
|
|
|
26546
|
+
var GetIntrinsic$3 = getIntrinsic;
|
|
26547
|
+
|
|
26548
|
+
var $gOPD = GetIntrinsic$3('%Object.getOwnPropertyDescriptor%', true);
|
|
26549
|
+
|
|
26550
|
+
if ($gOPD) {
|
|
26551
|
+
try {
|
|
26552
|
+
$gOPD([], 'length');
|
|
26553
|
+
} catch (e) {
|
|
26554
|
+
// IE 8 has a broken gOPD
|
|
26555
|
+
$gOPD = null;
|
|
26556
|
+
}
|
|
26557
|
+
}
|
|
26558
|
+
|
|
26559
|
+
var gopd = $gOPD;
|
|
26560
|
+
|
|
26670
26561
|
var GetIntrinsic$2 = getIntrinsic;
|
|
26671
26562
|
var define = defineDataProperty;
|
|
26672
26563
|
var hasDescriptors = hasPropertyDescriptors_1();
|
|
26673
|
-
var gOPD = gopd
|
|
26564
|
+
var gOPD = gopd;
|
|
26674
26565
|
|
|
26675
26566
|
var $TypeError$1 = type;
|
|
26676
26567
|
var $floor$1 = GetIntrinsic$2('%Math.floor%');
|
|
@@ -26761,7 +26652,7 @@ var callBound$1 = function callBoundIntrinsic(name, allowMissing) {
|
|
|
26761
26652
|
return intrinsic;
|
|
26762
26653
|
};
|
|
26763
26654
|
|
|
26764
|
-
var util_inspect = require$$1$
|
|
26655
|
+
var util_inspect = require$$1$3.inspect;
|
|
26765
26656
|
|
|
26766
26657
|
var hasMap = typeof Map === 'function' && Map.prototype;
|
|
26767
26658
|
var mapSizeDescriptor = Object.getOwnPropertyDescriptor && hasMap ? Object.getOwnPropertyDescriptor(Map.prototype, 'size') : null;
|
|
@@ -30897,6 +30788,11 @@ async function resolve(url) {
|
|
|
30897
30788
|
config.uid = channelInfo.uid;
|
|
30898
30789
|
}
|
|
30899
30790
|
}
|
|
30791
|
+
else if (channelInfo.providerId === "XHS") {
|
|
30792
|
+
if (channelInfo.uid) {
|
|
30793
|
+
config.uid = channelInfo.uid;
|
|
30794
|
+
}
|
|
30795
|
+
}
|
|
30900
30796
|
return config;
|
|
30901
30797
|
}
|
|
30902
30798
|
async function batchResolveChannel(urls) {
|
|
@@ -31276,7 +31172,7 @@ var hasRequiredStream$1;
|
|
|
31276
31172
|
function requireStream$1 () {
|
|
31277
31173
|
if (hasRequiredStream$1) return stream$3;
|
|
31278
31174
|
hasRequiredStream$1 = 1;
|
|
31279
|
-
stream$3 = require$$0$
|
|
31175
|
+
stream$3 = require$$0$9;
|
|
31280
31176
|
return stream$3;
|
|
31281
31177
|
}
|
|
31282
31178
|
|
|
@@ -31290,7 +31186,7 @@ function requireSafeBuffer$1 () {
|
|
|
31290
31186
|
if (hasRequiredSafeBuffer$1) return safeBuffer$1.exports;
|
|
31291
31187
|
hasRequiredSafeBuffer$1 = 1;
|
|
31292
31188
|
(function (module, exports) {
|
|
31293
|
-
var buffer = require$$0$
|
|
31189
|
+
var buffer = require$$0$5;
|
|
31294
31190
|
var Buffer = buffer.Buffer;
|
|
31295
31191
|
|
|
31296
31192
|
// alternative to using Object.keys for old browsers
|
|
@@ -31464,7 +31360,7 @@ function requireUtil () {
|
|
|
31464
31360
|
}
|
|
31465
31361
|
util$1.isPrimitive = isPrimitive;
|
|
31466
31362
|
|
|
31467
|
-
util$1.isBuffer = require$$0$
|
|
31363
|
+
util$1.isBuffer = require$$0$5.Buffer.isBuffer;
|
|
31468
31364
|
|
|
31469
31365
|
function objectToString(o) {
|
|
31470
31366
|
return Object.prototype.toString.call(o);
|
|
@@ -31484,7 +31380,7 @@ function requireBufferList () {
|
|
|
31484
31380
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
31485
31381
|
|
|
31486
31382
|
var Buffer = requireSafeBuffer$1().Buffer;
|
|
31487
|
-
var util = require$$1$
|
|
31383
|
+
var util = require$$1$3;
|
|
31488
31384
|
|
|
31489
31385
|
function copyBuffer(src, target, offset) {
|
|
31490
31386
|
src.copy(target, offset);
|
|
@@ -31663,7 +31559,7 @@ function requireNode () {
|
|
|
31663
31559
|
* For Node.js, simply re-export the core `util.deprecate` function.
|
|
31664
31560
|
*/
|
|
31665
31561
|
|
|
31666
|
-
node = require$$1$
|
|
31562
|
+
node = require$$1$3.deprecate;
|
|
31667
31563
|
return node;
|
|
31668
31564
|
}
|
|
31669
31565
|
|
|
@@ -32452,7 +32348,7 @@ function requireSafeBuffer () {
|
|
|
32452
32348
|
if (hasRequiredSafeBuffer) return safeBuffer.exports;
|
|
32453
32349
|
hasRequiredSafeBuffer = 1;
|
|
32454
32350
|
(function (module, exports) {
|
|
32455
|
-
var buffer = require$$0$
|
|
32351
|
+
var buffer = require$$0$5;
|
|
32456
32352
|
var Buffer = buffer.Buffer;
|
|
32457
32353
|
|
|
32458
32354
|
// alternative to using Object.keys for old browsers
|
|
@@ -32823,7 +32719,7 @@ function require_stream_readable$1 () {
|
|
|
32823
32719
|
Readable.ReadableState = ReadableState;
|
|
32824
32720
|
|
|
32825
32721
|
/*<replacement>*/
|
|
32826
|
-
require$$0$
|
|
32722
|
+
require$$0$7.EventEmitter;
|
|
32827
32723
|
|
|
32828
32724
|
var EElistenerCount = function (emitter, type) {
|
|
32829
32725
|
return emitter.listeners(type).length;
|
|
@@ -32853,7 +32749,7 @@ function require_stream_readable$1 () {
|
|
|
32853
32749
|
/*</replacement>*/
|
|
32854
32750
|
|
|
32855
32751
|
/*<replacement>*/
|
|
32856
|
-
var debugUtil = require$$1$
|
|
32752
|
+
var debugUtil = require$$1$3;
|
|
32857
32753
|
var debug = void 0;
|
|
32858
32754
|
if (debugUtil && debugUtil.debuglog) {
|
|
32859
32755
|
debug = debugUtil.debuglog('stream');
|
|
@@ -33999,7 +33895,7 @@ function requireReadable () {
|
|
|
33999
33895
|
if (hasRequiredReadable) return readable$1.exports;
|
|
34000
33896
|
hasRequiredReadable = 1;
|
|
34001
33897
|
(function (module, exports) {
|
|
34002
|
-
var Stream = require$$0$
|
|
33898
|
+
var Stream = require$$0$9;
|
|
34003
33899
|
if (process.env.READABLE_STREAM === 'disable' && Stream) {
|
|
34004
33900
|
module.exports = Stream;
|
|
34005
33901
|
exports = module.exports = Stream.Readable;
|
|
@@ -46375,7 +46271,7 @@ function matchNeedle(self, data, pos, len) {
|
|
|
46375
46271
|
|
|
46376
46272
|
var sbmh = SBMH;
|
|
46377
46273
|
|
|
46378
|
-
const { Readable: Readable$1, Writable: Writable$2 } = require$$0$
|
|
46274
|
+
const { Readable: Readable$1, Writable: Writable$2 } = require$$0$9;
|
|
46379
46275
|
|
|
46380
46276
|
const StreamSearch = sbmh;
|
|
46381
46277
|
|
|
@@ -47025,7 +46921,7 @@ const FIELD_VCHAR = [
|
|
|
47025
46921
|
|
|
47026
46922
|
var multipart = Multipart;
|
|
47027
46923
|
|
|
47028
|
-
const { Writable: Writable$1 } = require$$0$
|
|
46924
|
+
const { Writable: Writable$1 } = require$$0$9;
|
|
47029
46925
|
|
|
47030
46926
|
const { getDecoder } = utils$8;
|
|
47031
46927
|
|
|
@@ -47582,7 +47478,7 @@ function appendField$1 (store, key, value) {
|
|
|
47582
47478
|
|
|
47583
47479
|
var appendField_1 = appendField$1;
|
|
47584
47480
|
|
|
47585
|
-
var EventEmitter$1 = require$$0$
|
|
47481
|
+
var EventEmitter$1 = require$$0$7.EventEmitter;
|
|
47586
47482
|
|
|
47587
47483
|
function Counter$1 () {
|
|
47588
47484
|
EventEmitter$1.call(this);
|
|
@@ -47611,7 +47507,7 @@ Counter$1.prototype.onceZero = function onceZero (fn) {
|
|
|
47611
47507
|
|
|
47612
47508
|
var counter = Counter$1;
|
|
47613
47509
|
|
|
47614
|
-
var util = require$$1$
|
|
47510
|
+
var util = require$$1$3;
|
|
47615
47511
|
|
|
47616
47512
|
var errorMessages = {
|
|
47617
47513
|
LIMIT_PART_COUNT: 'Too many parts',
|
|
@@ -47996,8 +47892,8 @@ function makeMiddleware$1 (setup) {
|
|
|
47996
47892
|
|
|
47997
47893
|
var makeMiddleware_1 = makeMiddleware$1;
|
|
47998
47894
|
|
|
47999
|
-
var path$6 = require$$0$
|
|
48000
|
-
var fs$5 = require$$0$
|
|
47895
|
+
var path$6 = require$$0$6;
|
|
47896
|
+
var fs$5 = require$$0$8;
|
|
48001
47897
|
var _0777 = parseInt('0777', 8);
|
|
48002
47898
|
|
|
48003
47899
|
var mkdirp$1 = mkdirP.mkdirp = mkdirP.mkdirP = mkdirP;
|
|
@@ -48099,10 +47995,10 @@ mkdirP.sync = function sync (p, opts, made) {
|
|
|
48099
47995
|
return made;
|
|
48100
47996
|
};
|
|
48101
47997
|
|
|
48102
|
-
var fs$4 = require$$0$
|
|
48103
|
-
var os = require$$1$
|
|
48104
|
-
var path$5 = require$$0$
|
|
48105
|
-
var crypto$1 = require$$1$
|
|
47998
|
+
var fs$4 = require$$0$8;
|
|
47999
|
+
var os = require$$1$6;
|
|
48000
|
+
var path$5 = require$$0$6;
|
|
48001
|
+
var crypto$1 = require$$1$4;
|
|
48106
48002
|
var mkdirp = mkdirp$1;
|
|
48107
48003
|
|
|
48108
48004
|
function getFilename (req, file, cb) {
|
|
@@ -50444,8 +50340,8 @@ class Ollama extends Ollama$1 {
|
|
|
50444
50340
|
return Buffer.from(image).toString("base64");
|
|
50445
50341
|
}
|
|
50446
50342
|
try {
|
|
50447
|
-
if (require$$0$
|
|
50448
|
-
const fileBuffer = await require$$0$
|
|
50343
|
+
if (require$$0$8.existsSync(image)) {
|
|
50344
|
+
const fileBuffer = await require$$0$8.promises.readFile(require$$0$6.resolve(image));
|
|
50449
50345
|
return Buffer.from(fileBuffer).toString("base64");
|
|
50450
50346
|
}
|
|
50451
50347
|
} catch {
|
|
@@ -50484,9 +50380,9 @@ class Ollama extends Ollama$1 {
|
|
|
50484
50380
|
*/
|
|
50485
50381
|
resolvePath(inputPath, mfDir) {
|
|
50486
50382
|
if (inputPath.startsWith("~")) {
|
|
50487
|
-
return require$$0$
|
|
50383
|
+
return require$$0$6.join(require$$1$6.homedir(), inputPath.slice(1));
|
|
50488
50384
|
}
|
|
50489
|
-
return require$$0$
|
|
50385
|
+
return require$$0$6.resolve(mfDir, inputPath);
|
|
50490
50386
|
}
|
|
50491
50387
|
/**
|
|
50492
50388
|
* checks if a file exists
|
|
@@ -50496,7 +50392,7 @@ class Ollama extends Ollama$1 {
|
|
|
50496
50392
|
*/
|
|
50497
50393
|
async fileExists(path) {
|
|
50498
50394
|
try {
|
|
50499
|
-
await require$$0$
|
|
50395
|
+
await require$$0$8.promises.access(path);
|
|
50500
50396
|
return true;
|
|
50501
50397
|
} catch {
|
|
50502
50398
|
return false;
|
|
@@ -50506,9 +50402,9 @@ class Ollama extends Ollama$1 {
|
|
|
50506
50402
|
if (typeof ReadableStream === "undefined") {
|
|
50507
50403
|
throw new Error("Streaming uploads are not supported in this environment.");
|
|
50508
50404
|
}
|
|
50509
|
-
const fileStream = require$$0$
|
|
50405
|
+
const fileStream = require$$0$8.createReadStream(path);
|
|
50510
50406
|
const sha256sum = await new Promise((resolve2, reject) => {
|
|
50511
|
-
const hash = require$$1$
|
|
50407
|
+
const hash = require$$1$4.createHash("sha256");
|
|
50512
50408
|
fileStream.on("data", (data) => hash.update(data));
|
|
50513
50409
|
fileStream.on("end", () => resolve2(hash.digest("hex")));
|
|
50514
50410
|
fileStream.on("error", reject);
|
|
@@ -50545,10 +50441,10 @@ class Ollama extends Ollama$1 {
|
|
|
50545
50441
|
async create(request) {
|
|
50546
50442
|
let modelfileContent = "";
|
|
50547
50443
|
if (request.path) {
|
|
50548
|
-
modelfileContent = await require$$0$
|
|
50444
|
+
modelfileContent = await require$$0$8.promises.readFile(request.path, { encoding: "utf8" });
|
|
50549
50445
|
modelfileContent = await this.parseModelfile(
|
|
50550
50446
|
modelfileContent,
|
|
50551
|
-
require$$0$
|
|
50447
|
+
require$$0$6.dirname(request.path)
|
|
50552
50448
|
);
|
|
50553
50449
|
} else if (request.modelfile) {
|
|
50554
50450
|
modelfileContent = await this.parseModelfile(request.modelfile);
|
|
@@ -50677,7 +50573,7 @@ var hasRequiredStream;
|
|
|
50677
50573
|
function requireStream () {
|
|
50678
50574
|
if (hasRequiredStream) return stream$1;
|
|
50679
50575
|
hasRequiredStream = 1;
|
|
50680
|
-
stream$1 = require$$0$
|
|
50576
|
+
stream$1 = require$$0$9;
|
|
50681
50577
|
return stream$1;
|
|
50682
50578
|
}
|
|
50683
50579
|
|
|
@@ -50696,9 +50592,9 @@ function requireBuffer_list () {
|
|
|
50696
50592
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
50697
50593
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
50698
50594
|
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); }
|
|
50699
|
-
var _require = require$$0$
|
|
50595
|
+
var _require = require$$0$5,
|
|
50700
50596
|
Buffer = _require.Buffer;
|
|
50701
|
-
var _require2 = require$$1$
|
|
50597
|
+
var _require2 = require$$1$3,
|
|
50702
50598
|
inspect = _require2.inspect;
|
|
50703
50599
|
var custom = inspect && inspect.custom || 'inspect';
|
|
50704
50600
|
function copyBuffer(src, target, offset) {
|
|
@@ -51168,7 +51064,7 @@ function require_stream_writable () {
|
|
|
51168
51064
|
var Stream = requireStream();
|
|
51169
51065
|
/*</replacement>*/
|
|
51170
51066
|
|
|
51171
|
-
var Buffer = require$$0$
|
|
51067
|
+
var Buffer = require$$0$5.Buffer;
|
|
51172
51068
|
var OurUint8Array = (typeof index.commonjsGlobal !== 'undefined' ? index.commonjsGlobal : typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : {}).Uint8Array || function () {};
|
|
51173
51069
|
function _uint8ArrayToBuffer(chunk) {
|
|
51174
51070
|
return Buffer.from(chunk);
|
|
@@ -52493,7 +52389,7 @@ function require_stream_readable () {
|
|
|
52493
52389
|
Readable.ReadableState = ReadableState;
|
|
52494
52390
|
|
|
52495
52391
|
/*<replacement>*/
|
|
52496
|
-
require$$0$
|
|
52392
|
+
require$$0$7.EventEmitter;
|
|
52497
52393
|
var EElistenerCount = function EElistenerCount(emitter, type) {
|
|
52498
52394
|
return emitter.listeners(type).length;
|
|
52499
52395
|
};
|
|
@@ -52503,7 +52399,7 @@ function require_stream_readable () {
|
|
|
52503
52399
|
var Stream = requireStream();
|
|
52504
52400
|
/*</replacement>*/
|
|
52505
52401
|
|
|
52506
|
-
var Buffer = require$$0$
|
|
52402
|
+
var Buffer = require$$0$5.Buffer;
|
|
52507
52403
|
var OurUint8Array = (typeof index.commonjsGlobal !== 'undefined' ? index.commonjsGlobal : typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : {}).Uint8Array || function () {};
|
|
52508
52404
|
function _uint8ArrayToBuffer(chunk) {
|
|
52509
52405
|
return Buffer.from(chunk);
|
|
@@ -52513,7 +52409,7 @@ function require_stream_readable () {
|
|
|
52513
52409
|
}
|
|
52514
52410
|
|
|
52515
52411
|
/*<replacement>*/
|
|
52516
|
-
var debugUtil = require$$1$
|
|
52412
|
+
var debugUtil = require$$1$3;
|
|
52517
52413
|
var debug;
|
|
52518
52414
|
if (debugUtil && debugUtil.debuglog) {
|
|
52519
52415
|
debug = debugUtil.debuglog('stream');
|
|
@@ -53738,7 +53634,7 @@ function requirePipeline () {
|
|
|
53738
53634
|
}
|
|
53739
53635
|
|
|
53740
53636
|
(function (module, exports) {
|
|
53741
|
-
var Stream = require$$0$
|
|
53637
|
+
var Stream = require$$0$9;
|
|
53742
53638
|
if (process.env.READABLE_STREAM === 'disable' && Stream) {
|
|
53743
53639
|
module.exports = Stream.Readable;
|
|
53744
53640
|
Object.assign(module.exports, Stream);
|
|
@@ -56577,7 +56473,7 @@ router$d.post("/danma/timestamp", async (ctx) => {
|
|
|
56577
56473
|
const { filepath } = ctx.request.body;
|
|
56578
56474
|
ctx.body = await index.readXmlTimestamp(filepath);
|
|
56579
56475
|
});
|
|
56580
|
-
router$d.post("/
|
|
56476
|
+
router$d.post("/parseVideoMetadata", async (ctx) => {
|
|
56581
56477
|
const files = ctx.request.body;
|
|
56582
56478
|
ctx.body = await index.parseMeta(files);
|
|
56583
56479
|
});
|
|
@@ -57142,7 +57038,7 @@ router$c.post("/get_cookie", async (ctx) => {
|
|
|
57142
57038
|
return;
|
|
57143
57039
|
}
|
|
57144
57040
|
const secret = "r96gkr8ahc34fsrewr34";
|
|
57145
|
-
const hash = require$$1$
|
|
57041
|
+
const hash = require$$1$4.createHmac("sha256", secret).update(`${uid}${timestamp}`).digest("hex");
|
|
57146
57042
|
if (hash !== signature) {
|
|
57147
57043
|
ctx.status = 400;
|
|
57148
57044
|
ctx.body = "签名无效";
|
|
@@ -57248,7 +57144,7 @@ var chokidar = {};
|
|
|
57248
57144
|
|
|
57249
57145
|
var utils$7 = {};
|
|
57250
57146
|
|
|
57251
|
-
const path$4 = require$$0$
|
|
57147
|
+
const path$4 = require$$0$6;
|
|
57252
57148
|
const WIN_SLASH$1 = '\\\\/';
|
|
57253
57149
|
const WIN_NO_SLASH$1 = `[^${WIN_SLASH$1}]`;
|
|
57254
57150
|
|
|
@@ -57428,7 +57324,7 @@ var constants$6 = {
|
|
|
57428
57324
|
|
|
57429
57325
|
(function (exports) {
|
|
57430
57326
|
|
|
57431
|
-
const path = require$$0$
|
|
57327
|
+
const path = require$$0$6;
|
|
57432
57328
|
const win32 = process.platform === 'win32';
|
|
57433
57329
|
const {
|
|
57434
57330
|
REGEX_BACKSLASH,
|
|
@@ -58972,7 +58868,7 @@ parse$3.fastpaths = (input, options) => {
|
|
|
58972
58868
|
|
|
58973
58869
|
var parse_1$1 = parse$3;
|
|
58974
58870
|
|
|
58975
|
-
const path$3 = require$$0$
|
|
58871
|
+
const path$3 = require$$0$6;
|
|
58976
58872
|
const scan$2 = scan_1$1;
|
|
58977
58873
|
const parse$2 = parse_1$1;
|
|
58978
58874
|
const utils$4 = utils$7;
|
|
@@ -59315,10 +59211,10 @@ var picomatch_1$1 = picomatch$5;
|
|
|
59315
59211
|
|
|
59316
59212
|
var picomatch$4 = picomatch_1$1;
|
|
59317
59213
|
|
|
59318
|
-
const fs$3 = require$$0$
|
|
59319
|
-
const { Readable } = require$$0$
|
|
59320
|
-
const sysPath$3 = require$$0$
|
|
59321
|
-
const { promisify: promisify$3 } = require$$1$
|
|
59214
|
+
const fs$3 = require$$0$8;
|
|
59215
|
+
const { Readable } = require$$0$9;
|
|
59216
|
+
const sysPath$3 = require$$0$6;
|
|
59217
|
+
const { promisify: promisify$3 } = require$$1$3;
|
|
59322
59218
|
const picomatch$3 = picomatch$4;
|
|
59323
59219
|
|
|
59324
59220
|
const readdir$1 = promisify$3(fs$3.readdir);
|
|
@@ -59605,7 +59501,7 @@ var anymatch$2 = {exports: {}};
|
|
|
59605
59501
|
|
|
59606
59502
|
var utils$3 = {};
|
|
59607
59503
|
|
|
59608
|
-
const path$2 = require$$0$
|
|
59504
|
+
const path$2 = require$$0$6;
|
|
59609
59505
|
const WIN_SLASH = '\\\\/';
|
|
59610
59506
|
const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
|
|
59611
59507
|
|
|
@@ -59785,7 +59681,7 @@ var constants$3 = {
|
|
|
59785
59681
|
|
|
59786
59682
|
(function (exports) {
|
|
59787
59683
|
|
|
59788
|
-
const path = require$$0$
|
|
59684
|
+
const path = require$$0$6;
|
|
59789
59685
|
const win32 = process.platform === 'win32';
|
|
59790
59686
|
const {
|
|
59791
59687
|
REGEX_BACKSLASH,
|
|
@@ -61329,7 +61225,7 @@ parse$1.fastpaths = (input, options) => {
|
|
|
61329
61225
|
|
|
61330
61226
|
var parse_1 = parse$1;
|
|
61331
61227
|
|
|
61332
|
-
const path$1 = require$$0$
|
|
61228
|
+
const path$1 = require$$0$6;
|
|
61333
61229
|
const scan = scan_1;
|
|
61334
61230
|
const parse = parse_1;
|
|
61335
61231
|
const utils = utils$3;
|
|
@@ -62081,7 +61977,7 @@ var require$$0 = [
|
|
|
62081
61977
|
|
|
62082
61978
|
var binaryExtensions$1 = require$$0;
|
|
62083
61979
|
|
|
62084
|
-
const path = require$$0$
|
|
61980
|
+
const path = require$$0$6;
|
|
62085
61981
|
const binaryExtensions = binaryExtensions$1;
|
|
62086
61982
|
|
|
62087
61983
|
const extensions = new Set(binaryExtensions);
|
|
@@ -62092,9 +61988,9 @@ var constants = {};
|
|
|
62092
61988
|
|
|
62093
61989
|
(function (exports) {
|
|
62094
61990
|
|
|
62095
|
-
const {sep} = require$$0$
|
|
61991
|
+
const {sep} = require$$0$6;
|
|
62096
61992
|
const {platform} = process;
|
|
62097
|
-
const os = require$$1$
|
|
61993
|
+
const os = require$$1$6;
|
|
62098
61994
|
|
|
62099
61995
|
exports.EV_ALL = 'all';
|
|
62100
61996
|
exports.EV_READY = 'ready';
|
|
@@ -62158,9 +62054,9 @@ var constants = {};
|
|
|
62158
62054
|
exports.isIBMi = os.type() === 'OS400';
|
|
62159
62055
|
} (constants));
|
|
62160
62056
|
|
|
62161
|
-
const fs$2 = require$$0$
|
|
62162
|
-
const sysPath$2 = require$$0$
|
|
62163
|
-
const { promisify: promisify$2 } = require$$1$
|
|
62057
|
+
const fs$2 = require$$0$8;
|
|
62058
|
+
const sysPath$2 = require$$0$6;
|
|
62059
|
+
const { promisify: promisify$2 } = require$$1$3;
|
|
62164
62060
|
const isBinaryPath = isBinaryPath$1;
|
|
62165
62061
|
const {
|
|
62166
62062
|
isWindows: isWindows$1,
|
|
@@ -62809,9 +62705,9 @@ var nodefsHandler = NodeFsHandler$1;
|
|
|
62809
62705
|
|
|
62810
62706
|
var fseventsHandler = {exports: {}};
|
|
62811
62707
|
|
|
62812
|
-
const fs$1 = require$$0$
|
|
62813
|
-
const sysPath$1 = require$$0$
|
|
62814
|
-
const { promisify: promisify$1 } = require$$1$
|
|
62708
|
+
const fs$1 = require$$0$8;
|
|
62709
|
+
const sysPath$1 = require$$0$6;
|
|
62710
|
+
const { promisify: promisify$1 } = require$$1$3;
|
|
62815
62711
|
|
|
62816
62712
|
let fsevents;
|
|
62817
62713
|
try {
|
|
@@ -63336,10 +63232,10 @@ fseventsHandler.exports.canUse = canUse;
|
|
|
63336
63232
|
|
|
63337
63233
|
var fseventsHandlerExports = fseventsHandler.exports;
|
|
63338
63234
|
|
|
63339
|
-
const { EventEmitter } = require$$0$
|
|
63340
|
-
const fs = require$$0$
|
|
63341
|
-
const sysPath = require$$0$
|
|
63342
|
-
const { promisify } = require$$1$
|
|
63235
|
+
const { EventEmitter } = require$$0$7;
|
|
63236
|
+
const fs = require$$0$8;
|
|
63237
|
+
const sysPath = require$$0$6;
|
|
63238
|
+
const { promisify } = require$$1$3;
|
|
63343
63239
|
const readdirp = readdirp_1;
|
|
63344
63240
|
const anymatch = anymatchExports.default;
|
|
63345
63241
|
const globParent = index.globParent;
|
|
@@ -64308,7 +64204,7 @@ const watch = (paths, options) => {
|
|
|
64308
64204
|
|
|
64309
64205
|
chokidar.watch = watch;
|
|
64310
64206
|
|
|
64311
|
-
const stream = require$$0$
|
|
64207
|
+
const stream = require$$0$9;
|
|
64312
64208
|
const Transform = stream.Transform;
|
|
64313
64209
|
|
|
64314
64210
|
|
|
@@ -64428,7 +64324,7 @@ SSETransform.defOpts = {
|
|
|
64428
64324
|
var sse$1 = SSETransform;
|
|
64429
64325
|
|
|
64430
64326
|
const SSE = sse$1;
|
|
64431
|
-
const Stream$1 = require$$0$
|
|
64327
|
+
const Stream$1 = require$$0$9;
|
|
64432
64328
|
const DEFAULT_OPTS = {
|
|
64433
64329
|
maxClients: 10000,
|
|
64434
64330
|
pingInterval: 60000,
|
|
@@ -64884,10 +64780,10 @@ class FFmpegWhisperASR {
|
|
|
64884
64780
|
throw new Error(`音频文件不存在: ${filePath}`);
|
|
64885
64781
|
}
|
|
64886
64782
|
// 创建临时目录存放结果
|
|
64887
|
-
const tempDir = require$$0$
|
|
64783
|
+
const tempDir = require$$0$6.join(require$$1$6.tmpdir(), "whisper-asr");
|
|
64888
64784
|
await index.fs.ensureDir(tempDir);
|
|
64889
64785
|
// 生成唯一的输出文件名
|
|
64890
|
-
const outputFile = require$$0$
|
|
64786
|
+
const outputFile = require$$0$6.join(tempDir, `${v4()}.json`);
|
|
64891
64787
|
try {
|
|
64892
64788
|
// 执行 ffmpeg 命令
|
|
64893
64789
|
await this.executeFFmpeg(filePath, outputFile);
|
|
@@ -64946,7 +64842,7 @@ class FFmpegWhisperASR {
|
|
|
64946
64842
|
];
|
|
64947
64843
|
this.options.logger.info(`执行 FFmpeg Whisper 命令: ${this.options.ffmpegPath} ${args.join(" ")}`);
|
|
64948
64844
|
// 使用 spawn 执行命令
|
|
64949
|
-
const process = require$$0$
|
|
64845
|
+
const process = require$$0$d.spawn(this.options.ffmpegPath, args);
|
|
64950
64846
|
let stderr = "";
|
|
64951
64847
|
// 收集标准错误输出(ffmpeg 的日志)
|
|
64952
64848
|
process.stderr.on("data", (data) => {
|
|
@@ -72061,7 +71957,7 @@ class DecodedMessage {
|
|
|
72061
71957
|
if (!uri.startsWith(DATA_URI_PREFIX)) {
|
|
72062
71958
|
throw new Error('assert 4');
|
|
72063
71959
|
}
|
|
72064
|
-
return this.decodeFromBinary(require$$0$
|
|
71960
|
+
return this.decodeFromBinary(require$$0$5.Buffer.from(uri.replace(DATA_URI_PREFIX, ''), 'base64'));
|
|
72065
71961
|
}
|
|
72066
71962
|
encodeToBinary() {
|
|
72067
71963
|
const header = {
|
|
@@ -72112,7 +72008,7 @@ class DecodedMessage {
|
|
|
72112
72008
|
}
|
|
72113
72009
|
encodeToUri() {
|
|
72114
72010
|
const bin = this.encodeToBinary();
|
|
72115
|
-
return DATA_URI_PREFIX + require$$0$
|
|
72011
|
+
return DATA_URI_PREFIX + require$$0$5.Buffer.from(bin).toString('base64');
|
|
72116
72012
|
}
|
|
72117
72013
|
}
|
|
72118
72014
|
|
|
@@ -72952,7 +72848,7 @@ class Shazam {
|
|
|
72952
72848
|
* @returns {ShazamRoot | null}
|
|
72953
72849
|
*/
|
|
72954
72850
|
async recognise(path, language = "en-US", minimal = false) {
|
|
72955
|
-
const signatures = shazamioCore.recognizeBytes(require$$0$
|
|
72851
|
+
const signatures = shazamioCore.recognizeBytes(require$$0$8.readFileSync(path), 0, Number.MAX_SAFE_INTEGER);
|
|
72956
72852
|
let response;
|
|
72957
72853
|
for (let i = Math.floor(signatures.length / 2); i < signatures.length; i += 4) {
|
|
72958
72854
|
const data = {
|
|
@@ -77063,13 +76959,13 @@ router$8.get("/login/poll", async (ctx) => {
|
|
|
77063
76959
|
router$8.post("/formatTitle", async (ctx) => {
|
|
77064
76960
|
const data = ctx.request.body;
|
|
77065
76961
|
const template = (data.template || "");
|
|
77066
|
-
const title = formatTitle(data.options, template);
|
|
76962
|
+
const title = index.formatTitle(data.options, template);
|
|
77067
76963
|
ctx.body = title;
|
|
77068
76964
|
});
|
|
77069
76965
|
router$8.post("/formatPartTitle", async (ctx) => {
|
|
77070
76966
|
const data = ctx.request.body;
|
|
77071
76967
|
const template = (data.template || "");
|
|
77072
|
-
const title = formatPartTitle(data.options ?? {
|
|
76968
|
+
const title = index.formatPartTitle(data.options ?? {
|
|
77073
76969
|
title: "标题",
|
|
77074
76970
|
username: "主播名",
|
|
77075
76971
|
time: new Date().toISOString(),
|
|
@@ -77079,6 +76975,18 @@ router$8.post("/formatPartTitle", async (ctx) => {
|
|
|
77079
76975
|
}, template);
|
|
77080
76976
|
ctx.body = title;
|
|
77081
76977
|
});
|
|
76978
|
+
router$8.post("/formatDesc", async (ctx) => {
|
|
76979
|
+
const data = ctx.request.body;
|
|
76980
|
+
const template = (data.template || "");
|
|
76981
|
+
const desc = index.formatDesc(data.options ?? {
|
|
76982
|
+
title: "标题",
|
|
76983
|
+
username: "主播名",
|
|
76984
|
+
time: new Date().toISOString(),
|
|
76985
|
+
roomId: 123456,
|
|
76986
|
+
filename: "文件名",
|
|
76987
|
+
}, template);
|
|
76988
|
+
ctx.body = desc;
|
|
76989
|
+
});
|
|
77082
76990
|
|
|
77083
76991
|
async function flvRepair(input, output, opts) {
|
|
77084
76992
|
// 如果不是flv,直接报错
|
|
@@ -77778,10 +77686,10 @@ async function download$1(output, url, options) {
|
|
|
77778
77686
|
const downloader = new index.M3U8Downloader(url, output, {
|
|
77779
77687
|
convert2Mp4: true,
|
|
77780
77688
|
ffmpegPath: ffmpegPath,
|
|
77781
|
-
segmentsDir: require$$0$
|
|
77689
|
+
segmentsDir: require$$0$6.join(index.getTempPath(), index.uuid()),
|
|
77782
77690
|
});
|
|
77783
77691
|
const task = new index.KuaishouDownloadVideoTask(downloader, {
|
|
77784
|
-
name: `下载任务:${require$$0$
|
|
77692
|
+
name: `下载任务:${require$$0$6.parse(output).name}`,
|
|
77785
77693
|
});
|
|
77786
77694
|
index.taskQueue.addTask(task, true);
|
|
77787
77695
|
return task;
|
|
@@ -77812,7 +77720,7 @@ var kuaishou = {
|
|
|
77812
77720
|
var dist = {};
|
|
77813
77721
|
|
|
77814
77722
|
(function (exports) {
|
|
77815
|
-
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$7,path=_interopRequireWildcard(_path),_http=require$$3$1,http=_interopRequireWildcard(_http),_https=require$$1$6,https=_interopRequireWildcard(_https),_events=require$$0$8;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);
|
|
77723
|
+
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$6,path=_interopRequireWildcard(_path),_http=require$$3$1,http=_interopRequireWildcard(_http),_https=require$$1$7,https=_interopRequireWildcard(_https),_events=require$$0$7;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);
|
|
77816
77724
|
} (dist));
|
|
77817
77725
|
|
|
77818
77726
|
async function download(output, url, options) {
|
|
@@ -79990,18 +79898,6 @@ class LiveManager {
|
|
|
79990
79898
|
}
|
|
79991
79899
|
}
|
|
79992
79900
|
|
|
79993
|
-
function buildRoomLink(platform, roomId) {
|
|
79994
|
-
const platformLower = platform.toLowerCase();
|
|
79995
|
-
const platformRoomLinkMap = {
|
|
79996
|
-
bilibili: (id) => `https://live.bilibili.com/${id}`,
|
|
79997
|
-
huya: (id) => `https://www.huya.com/${id}`,
|
|
79998
|
-
douyu: (id) => `https://www.douyu.com/${id}`,
|
|
79999
|
-
douyin: (id) => `https://live.douyin.com/${id}`,
|
|
80000
|
-
};
|
|
80001
|
-
const link = platformRoomLinkMap[platformLower]?.(roomId);
|
|
80002
|
-
return link ?? null;
|
|
80003
|
-
}
|
|
80004
|
-
|
|
80005
79901
|
/**
|
|
80006
79902
|
* 事件缓冲管理器
|
|
80007
79903
|
* 负责匹配 FileOpening 和 FileClosed 事件
|
|
@@ -80871,7 +80767,7 @@ class WebhookHandler {
|
|
|
80871
80767
|
// 构建上传文件列表
|
|
80872
80768
|
for (const part of uploadableParts) {
|
|
80873
80769
|
const filename = path$7.parse(part[filePathField]).name;
|
|
80874
|
-
const title = formatPartTitle({
|
|
80770
|
+
const title = index.formatPartTitle({
|
|
80875
80771
|
title: part.title,
|
|
80876
80772
|
username: live.username,
|
|
80877
80773
|
roomId: live.roomId,
|
|
@@ -80917,9 +80813,10 @@ class WebhookHandler {
|
|
|
80917
80813
|
uploadPreset.cover = cover;
|
|
80918
80814
|
}
|
|
80919
80815
|
// 处理转载来源:当设置为转载类型且转载来源为空时,自动生成直播间链接
|
|
80816
|
+
// TODO: 考虑迁移到上传预设配置实现,需要将metadata参数传递到上传函数中
|
|
80920
80817
|
if (uploadPreset.copyright === 2 &&
|
|
80921
80818
|
(!uploadPreset.source || uploadPreset.source.trim() === "")) {
|
|
80922
|
-
const roomLink = buildRoomLink(live.platform, live.roomId);
|
|
80819
|
+
const roomLink = index.buildRoomLink(live.platform, live.roomId);
|
|
80923
80820
|
if (roomLink) {
|
|
80924
80821
|
uploadPreset.source = roomLink;
|
|
80925
80822
|
}
|
|
@@ -80957,7 +80854,7 @@ class WebhookHandler {
|
|
|
80957
80854
|
template = config.title;
|
|
80958
80855
|
}
|
|
80959
80856
|
}
|
|
80960
|
-
return formatTitle({
|
|
80857
|
+
return index.formatTitle({
|
|
80961
80858
|
title: live.title,
|
|
80962
80859
|
username: live.username,
|
|
80963
80860
|
roomId: live.roomId,
|
|
@@ -81096,7 +80993,7 @@ exports.handler = void 0;
|
|
|
81096
80993
|
exports.appConfig = void 0;
|
|
81097
80994
|
exports.container = void 0;
|
|
81098
80995
|
const fileCache = createFileCache();
|
|
81099
|
-
path$7.dirname(require$$
|
|
80996
|
+
path$7.dirname(require$$1$2.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index-DOo0dewT.cjs', document.baseURI).href))));
|
|
81100
80997
|
const authMiddleware = (passKey) => {
|
|
81101
80998
|
return async (ctx, next) => {
|
|
81102
80999
|
const authHeader = ctx.headers["authorization"] || ctx.request.query.auth;
|
|
@@ -81176,7 +81073,7 @@ async function serverStart(options, axContainer) {
|
|
|
81176
81073
|
async function createServer(options) {
|
|
81177
81074
|
index.logObj.info(`开始创建服务器: ${options.host}:${options.port}`);
|
|
81178
81075
|
{
|
|
81179
|
-
const httpServer =
|
|
81076
|
+
const httpServer = require$$2$1.createServer(app.callback());
|
|
81180
81077
|
httpServer.on("error", (err) => {
|
|
81181
81078
|
index.logObj.error("HTTP 服务器错误:", err);
|
|
81182
81079
|
});
|