@bililive-tools/huya-recorder 1.3.0 → 1.3.2

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/huya_api.js CHANGED
@@ -63,9 +63,6 @@ export async function getRoomInfo(roomIdOrShortId, formatPriorities = ["flv", "h
63
63
  }
64
64
  const startTime = new Date(data.gameLiveInfo?.startTime * 1000);
65
65
  const formatSources = getFormatSources(sources, formatPriorities);
66
- if (!formatSources) {
67
- throw new Error("No format sources found");
68
- }
69
66
  return {
70
67
  living: vMultiStreamInfo.length > 0 && data.gameStreamInfoList.length > 0,
71
68
  id: data.gameLiveInfo.profileRoom,
@@ -75,7 +72,7 @@ export async function getRoomInfo(roomIdOrShortId, formatPriorities = ["flv", "h
75
72
  avatar: data.gameLiveInfo.avatar180,
76
73
  cover: data.gameLiveInfo.screenshot,
77
74
  streams,
78
- sources: formatSources.sources,
75
+ sources: formatSources?.sources ?? [],
79
76
  startTime,
80
77
  liveId: utils.md5(`${roomIdOrShortId}-${startTime?.getTime()}`),
81
78
  gid: data.gameLiveInfo.gid,
package/lib/index.js CHANGED
@@ -176,7 +176,7 @@ const checkLiveStatusAndRecord = async function ({ getSavePath, banLiveId, isMan
176
176
  room_id: this.channelId,
177
177
  platform: provider?.id,
178
178
  liveStartTimestamp: liveInfo.startTime?.getTime(),
179
- recordStopTimestamp: Date.now(),
179
+ // recordStopTimestamp: Date.now(),
180
180
  title: title,
181
181
  user_name: owner,
182
182
  });
@@ -242,6 +242,12 @@ const checkLiveStatusAndRecord = async function ({ getSavePath, banLiveId, isMan
242
242
  client.on("error", (e) => {
243
243
  this.emit("DebugLog", { type: "common", text: String(e) });
244
244
  });
245
+ client.on("retry", (e) => {
246
+ this.emit("DebugLog", {
247
+ type: "common",
248
+ text: `huya danmu retry: ${e.count}/${e.max}`,
249
+ });
250
+ });
245
251
  client.start();
246
252
  }
247
253
  const ffmpegArgs = recorder.getArguments();
@@ -260,13 +266,13 @@ const checkLiveStatusAndRecord = async function ({ getSavePath, banLiveId, isMan
260
266
  if (!this.recordHandle)
261
267
  return;
262
268
  this.state = "stopping-record";
263
- client?.stop();
264
269
  try {
270
+ client?.stop();
265
271
  await recorder.stop();
266
272
  }
267
273
  catch (err) {
268
274
  this.emit("DebugLog", {
269
- type: "common",
275
+ type: "error",
270
276
  text: `stop ffmpeg error: ${String(err)}`,
271
277
  });
272
278
  }
@@ -306,6 +312,7 @@ export const provider = {
306
312
  id: info.roomId.toString(),
307
313
  title: info.title,
308
314
  owner: info.owner,
315
+ avatar: info.avatar,
309
316
  };
310
317
  },
311
318
  createRecorder(opts) {
package/lib/stream.js CHANGED
@@ -70,12 +70,17 @@ export async function getStream(opts) {
70
70
  .replace("&fs=bhct", "&fs=bgct");
71
71
  }
72
72
  }
73
+ let url = expectSource.url;
74
+ // MP协议下原画不需要添加ratio参数
75
+ if (expectStream.bitRate) {
76
+ url = url + "&ratio=" + expectStream.bitRate;
77
+ }
73
78
  return {
74
79
  ...info,
75
80
  currentStream: {
76
81
  name: expectStream.desc,
77
82
  source: expectSource.name,
78
- url: expectSource.url + "&ratio=" + expectStream.bitRate,
83
+ url,
79
84
  },
80
85
  };
81
86
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bililive-tools/huya-recorder",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
4
4
  "description": "bililive-tools huya recorder implemention",
5
5
  "main": "./lib/index.js",
6
6
  "type": "module",
@@ -37,8 +37,8 @@
37
37
  "mitt": "^3.0.1",
38
38
  "lodash-es": "^4.17.21",
39
39
  "axios": "^1.7.8",
40
- "@bililive-tools/manager": "^1.3.0",
41
- "huya-danma-listener": "0.1.1"
40
+ "@bililive-tools/manager": "^1.4.1",
41
+ "huya-danma-listener": "0.1.2"
42
42
  },
43
43
  "devDependencies": {},
44
44
  "scripts": {