@bililive-tools/bilibili-recorder 1.12.0 → 1.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -55,6 +55,7 @@ interface Options {
55
55
  onlyAudio?: boolean; // 只录制音频,默认为否
56
56
  recorderType?: "auto" | "ffmpeg" | "mesio" | "bililive"; // 底层录制器,使用mesio和bililive时videoFormat参数无效
57
57
  debugLevel?: `verbose` | "basic"; // verbose参数时,录制器会输出更加详细的log
58
+ customHost?: string; // 自定义host来替换直播流的host
58
59
  }
59
60
  ```
60
61
 
package/lib/index.js CHANGED
@@ -19,6 +19,7 @@ function createRecorder(opts) {
19
19
  state: "idle",
20
20
  qualityRetry: opts.qualityRetry ?? 0,
21
21
  useM3U8Proxy: opts.useM3U8Proxy ?? false,
22
+ customHost: opts.customHost,
22
23
  useServerTimestamp: opts.useServerTimestamp ?? true,
23
24
  m3u8ProxyUrl: opts.m3u8ProxyUrl,
24
25
  formatName: opts.formatName ?? "auto",
@@ -121,6 +122,7 @@ const checkLiveStatusAndRecord = async function ({ getSavePath, isManualStart, b
121
122
  formatName: this.formatName,
122
123
  codecName: this.codecName,
123
124
  onlyAudio: this.onlyAudio,
125
+ customHost: this.customHost,
124
126
  });
125
127
  }
126
128
  catch (err) {
package/lib/stream.d.ts CHANGED
@@ -32,6 +32,7 @@ export declare function getStream(opts: Pick<Recorder, "channelId" | "quality">
32
32
  formatName: RecorderCreateOpts["formatName"];
33
33
  codecName: RecorderCreateOpts["codecName"];
34
34
  onlyAudio?: boolean;
35
+ customHost?: string;
35
36
  }): Promise<{
36
37
  currentStream: {
37
38
  name: string;
package/lib/stream.js CHANGED
@@ -158,6 +158,7 @@ async function getLiveInfo(roomIdOrShortId, opts) {
158
158
  // console.log("conditons", opts.codecName, conditons);
159
159
  let streamInfo;
160
160
  let streamOptions;
161
+ // console.log("conditons", JSON.stringify(res.playurl_info.playurl.stream, null, 2));
161
162
  for (const condition of conditons) {
162
163
  const streamList = res.playurl_info.playurl.stream
163
164
  .find(({ protocol_name }) => protocol_name === condition.protocol_name)
@@ -236,12 +237,14 @@ export async function getStream(opts) {
236
237
  if (!expectSource) {
237
238
  throw new Error("Can not get expect source");
238
239
  }
240
+ const host = opts.customHost ? `https://${opts.customHost}` : expectSource.host;
241
+ const url = host + liveInfo.base_url + expectSource.extra;
239
242
  return {
240
243
  ...liveInfo,
241
244
  currentStream: {
242
245
  name: liveInfo.name,
243
246
  source: expectSource.name,
244
- url: expectSource.host + liveInfo.base_url + expectSource.extra,
247
+ url: url,
245
248
  },
246
249
  };
247
250
  }
package/lib/utils.d.ts CHANGED
@@ -20,4 +20,3 @@ export declare function assert(assertion: unknown, msg?: string): asserts assert
20
20
  export declare function assertStringType(data: unknown, msg?: string): asserts data is string;
21
21
  export declare function assertNumberType(data: unknown, msg?: string): asserts data is number;
22
22
  export declare function assertObjectType(data: unknown, msg?: string): asserts data is object;
23
- export declare function createInvalidStreamChecker(count?: number): (ffmpegLogLine: string) => boolean;
package/lib/utils.js CHANGED
@@ -59,25 +59,3 @@ export function assertNumberType(data, msg) {
59
59
  export function assertObjectType(data, msg) {
60
60
  assert(typeof data === "object", msg);
61
61
  }
62
- export function createInvalidStreamChecker(count = 10) {
63
- let prevFrame = 0;
64
- let frameUnchangedCount = 0;
65
- return (ffmpegLogLine) => {
66
- const streamInfo = ffmpegLogLine.match(/frame=\s*(\d+) fps=.*? q=.*? size=.*? time=.*? bitrate=.*? speed=.*?/);
67
- if (streamInfo != null) {
68
- const [, frameText] = streamInfo;
69
- const frame = Number(frameText);
70
- if (frame === prevFrame) {
71
- if (++frameUnchangedCount >= count) {
72
- return true;
73
- }
74
- }
75
- else {
76
- prevFrame = frame;
77
- frameUnchangedCount = 0;
78
- }
79
- return false;
80
- }
81
- return false;
82
- };
83
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bililive-tools/bilibili-recorder",
3
- "version": "1.12.0",
3
+ "version": "1.13.0",
4
4
  "description": "bililive-tools bilibili recorder implemention",
5
5
  "main": "./lib/index.js",
6
6
  "type": "module",
@@ -39,7 +39,7 @@
39
39
  "tiny-bilibili-ws": "^1.0.2",
40
40
  "lodash-es": "^4.17.21",
41
41
  "axios": "^1.7.8",
42
- "@bililive-tools/manager": "^1.12.0"
42
+ "@bililive-tools/manager": "^1.13.0"
43
43
  },
44
44
  "scripts": {
45
45
  "build": "tsc",