bililive-cli 3.9.1 → 3.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var node_util = require('node:util');
3
+ var require$$3 = require('node:util');
4
4
  var require$$1 = require('node:child_process');
5
5
  var require$$0 = require('node:url');
6
6
 
@@ -41,7 +41,7 @@ function chunkify(iterable, chunkSize) {
41
41
  };
42
42
  }
43
43
 
44
- const pExecFile = node_util.promisify(require$$1.execFile);
44
+ const pExecFile = require$$3.promisify(require$$1.execFile);
45
45
 
46
46
  async function chunkedExec(binary, paths, maxPaths) {
47
47
  for (const chunk of chunkify(paths, maxPaths)) {
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
3
  var path$7 = require('node:path');
4
- var http$3 = require('node:http');
4
+ var require$$2$1 = require('node:http');
5
5
  var require$$0$4 = require('node:url');
6
6
  var a = require('node:https');
7
- var index = require('./index-B4DHRkFJ.cjs');
7
+ var index = require('./index-CPP-8XuA.cjs');
8
8
  var require$$0$5 = require('tty');
9
9
  var require$$1$2 = require('util');
10
10
  var require$$0$c = require('assert');
@@ -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 工具进行文件上传
@@ -1200,7 +1076,7 @@ class Alist extends index.TypedEmitter {
1200
1076
  },
1201
1077
  };
1202
1078
  const url = new require$$0$4.URL(combineURLs(this.server, "/api/fs/put"));
1203
- const httpModule = url.protocol === "https:" ? a : http$3;
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({
@@ -13179,7 +13055,7 @@ function safeDecodeURIComponent(text) {
13179
13055
  * @link https://github.com/alexmingoia/koa-router
13180
13056
  */
13181
13057
 
13182
- const http = http$3;
13058
+ const http = require$$2$1;
13183
13059
 
13184
13060
  const debug$3 = index.srcExports('koa-router');
13185
13061
 
@@ -26211,19 +26087,19 @@ var getEvalledConstructor = function (expressionSyntax) {
26211
26087
  } catch (e) {}
26212
26088
  };
26213
26089
 
26214
- var $gOPD$1 = Object.getOwnPropertyDescriptor;
26215
- if ($gOPD$1) {
26090
+ var $gOPD$2 = Object.getOwnPropertyDescriptor;
26091
+ if ($gOPD$2) {
26216
26092
  try {
26217
- $gOPD$1({}, '');
26093
+ $gOPD$2({}, '');
26218
26094
  } catch (e) {
26219
- $gOPD$1 = null; // this is IE 8, which has a broken 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$1
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$1(arguments, 'callee').get;
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$1 && (i + 1) >= parts.length) {
26525
- var desc = $gOPD$1(value, part);
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$3 = getIntrinsic;
26455
+ var GetIntrinsic$4 = getIntrinsic;
26580
26456
 
26581
- var $gOPD = GetIntrinsic$3('%Object.getOwnPropertyDescriptor%', true);
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$1 = $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$1;
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$1;
26564
+ var gOPD = gopd;
26674
26565
 
26675
26566
  var $TypeError$1 = type;
26676
26567
  var $floor$1 = GetIntrinsic$2('%Math.floor%');
@@ -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) {
@@ -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("/parseMeta", async (ctx) => {
56476
+ router$d.post("/parseVideoMetadata", async (ctx) => {
56581
56477
  const files = ctx.request.body;
56582
56478
  ctx.body = await index.parseMeta(files);
56583
56479
  });
@@ -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,直接报错
@@ -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$$0$4.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index-Cba0EEtx.cjs', document.baseURI).href))));
80996
+ path$7.dirname(require$$0$4.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index-BEYQyxJU.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 = http$3.createServer(app.callback());
81076
+ const httpServer = require$$2$1.createServer(app.callback());
81180
81077
  httpServer.on("error", (err) => {
81181
81078
  index.logObj.error("HTTP 服务器错误:", err);
81182
81079
  });