@bililive-tools/douyin-recorder 1.4.0 → 1.5.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/README.md CHANGED
@@ -43,6 +43,7 @@ interface Options {
43
43
  saveGiftDanma?: boolean; // 保存礼物弹幕
44
44
  saveCover?: boolean; // 保存封面
45
45
  videoFormat?: "auto"; // 视频格式: "auto", "ts", "mkv" ,auto模式下, 分段使用 "ts",不分段使用 "mp4"
46
+ useServerTimestamp?: boolean; // 控制弹幕是否使用服务端时间戳,默认为true
46
47
  doubleScreen?: boolean; // 是否使用双屏直播流,开启后如果是双屏直播,那么就使用拼接的流,默认为true
47
48
  auth?: string; // 传递cookie,用于录制会员视频
48
49
  }
package/lib/douyin_api.js CHANGED
@@ -105,6 +105,7 @@ export async function getRoomInfo(webRoomId, opts = {}) {
105
105
  // enter_source:,
106
106
  "Room-Enter-User-Login-Ab": 0,
107
107
  is_need_double_stream: "false",
108
+ a_bogus: "1",
108
109
  },
109
110
  headers: {
110
111
  cookie: cookies,
package/lib/index.js CHANGED
@@ -18,6 +18,7 @@ function createRecorder(opts) {
18
18
  availableSources: [],
19
19
  qualityMaxRetry: opts.qualityRetry ?? 0,
20
20
  qualityRetry: opts.qualityRetry ?? 0,
21
+ useServerTimestamp: opts.useServerTimestamp ?? true,
21
22
  state: "idle",
22
23
  getChannelURL() {
23
24
  return `https://live.douyin.com/${this.channelId}`;
@@ -179,7 +180,7 @@ const checkLiveStatusAndRecord = async function ({ getSavePath, banLiveId, isMan
179
180
  room_id: this.channelId,
180
181
  platform: provider?.id,
181
182
  // liveStartTimestamp: liveInfo.startTime?.getTime(),
182
- recordStopTimestamp: Date.now(),
183
+ // recordStopTimestamp: Date.now(),
183
184
  title: title,
184
185
  user_name: owner,
185
186
  });
@@ -206,7 +207,7 @@ const checkLiveStatusAndRecord = async function ({ getSavePath, banLiveId, isMan
206
207
  return;
207
208
  const comment = {
208
209
  type: "comment",
209
- timestamp: Number(msg.eventTime) * 1000,
210
+ timestamp: this.useServerTimestamp ? Number(msg.eventTime) * 1000 : Date.now(),
210
211
  text: msg.content,
211
212
  color: "#ffffff",
212
213
  sender: {
@@ -227,11 +228,12 @@ const checkLiveStatusAndRecord = async function ({ getSavePath, banLiveId, isMan
227
228
  return;
228
229
  if (this.saveGiftDanma === false)
229
230
  return;
231
+ const serverTimestamp = Number(msg.common.createTime) > 9999999999
232
+ ? Number(msg.common.createTime)
233
+ : Number(msg.common.createTime) * 1000;
230
234
  const gift = {
231
235
  type: "give_gift",
232
- timestamp: Number(msg.common.createTime) > 9999999999
233
- ? Number(msg.common.createTime)
234
- : Number(msg.common.createTime) * 1000,
236
+ timestamp: this.useServerTimestamp ? serverTimestamp : Date.now(),
235
237
  name: msg.gift.name,
236
238
  price: 1,
237
239
  count: Number(msg.totalCount ?? 1),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bililive-tools/douyin-recorder",
3
- "version": "1.4.0",
3
+ "version": "1.5.1",
4
4
  "description": "@bililive-tools douyin recorder implemention",
5
5
  "main": "./lib/index.js",
6
6
  "type": "module",
@@ -37,8 +37,8 @@
37
37
  "axios": "^1.7.8",
38
38
  "lodash-es": "^4.17.21",
39
39
  "mitt": "^3.0.1",
40
- "douyin-danma-listener": "0.2.0",
41
- "@bililive-tools/manager": "^1.3.0"
40
+ "@bililive-tools/manager": "^1.4.0",
41
+ "douyin-danma-listener": "0.2.0"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@types/node": "*"