@bililive-tools/douyin-recorder 1.12.1 → 1.12.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/douyin_api.js +16 -0
- package/lib/index.js +7 -1
- package/package.json +3 -3
package/lib/douyin_api.js
CHANGED
|
@@ -309,6 +309,22 @@ async function getRoomInfoByWeb(webRoomId, opts = {}) {
|
|
|
309
309
|
"User-Agent": ua,
|
|
310
310
|
},
|
|
311
311
|
});
|
|
312
|
+
if (res.data.status_code === 30003) {
|
|
313
|
+
// 直播已结束
|
|
314
|
+
return {
|
|
315
|
+
living: false,
|
|
316
|
+
nickname: "",
|
|
317
|
+
sec_uid: "",
|
|
318
|
+
avatar: "",
|
|
319
|
+
api: "web",
|
|
320
|
+
room: {
|
|
321
|
+
title: "",
|
|
322
|
+
cover: "",
|
|
323
|
+
id_str: "",
|
|
324
|
+
stream_url: null,
|
|
325
|
+
},
|
|
326
|
+
};
|
|
327
|
+
}
|
|
312
328
|
assert(res.data.status_code === 0, `Unexpected resp, code ${res.data.status_code}, msg ${JSON.stringify(res.data.data)}, id ${webRoomId}, cookies: ${cookies}`);
|
|
313
329
|
const data = res.data.data;
|
|
314
330
|
const room = data?.data?.[0];
|
package/lib/index.js
CHANGED
|
@@ -234,9 +234,14 @@ const checkLiveStatusAndRecord = async function ({ getSavePath, banLiveId, isMan
|
|
|
234
234
|
const extraDataController = downloader.getExtraDataController();
|
|
235
235
|
if (!extraDataController)
|
|
236
236
|
return;
|
|
237
|
+
let timestamp = Date.now();
|
|
238
|
+
if (this.useServerTimestamp && msg.eventTime) {
|
|
239
|
+
// 某些消息可能没有 eventTime 字段
|
|
240
|
+
timestamp = Number(msg.eventTime) * 1000;
|
|
241
|
+
}
|
|
237
242
|
const comment = {
|
|
238
243
|
type: "comment",
|
|
239
|
-
timestamp:
|
|
244
|
+
timestamp: timestamp,
|
|
240
245
|
text: msg.content,
|
|
241
246
|
color: "#ffffff",
|
|
242
247
|
sender: {
|
|
@@ -248,6 +253,7 @@ const checkLiveStatusAndRecord = async function ({ getSavePath, banLiveId, isMan
|
|
|
248
253
|
// },
|
|
249
254
|
},
|
|
250
255
|
};
|
|
256
|
+
console.log("Message", JSON.stringify(msg), null, 2);
|
|
251
257
|
this.emit("Message", comment);
|
|
252
258
|
extraDataController.addMessage(comment);
|
|
253
259
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bililive-tools/douyin-recorder",
|
|
3
|
-
"version": "1.12.
|
|
3
|
+
"version": "1.12.2",
|
|
4
4
|
"description": "@bililive-tools douyin recorder implemention",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"lodash-es": "^4.17.21",
|
|
39
39
|
"mitt": "^3.0.1",
|
|
40
40
|
"sm-crypto": "^0.3.13",
|
|
41
|
-
"
|
|
42
|
-
"
|
|
41
|
+
"@bililive-tools/manager": "^1.13.0",
|
|
42
|
+
"douyin-danma-listener": "0.4.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@types/node": "*"
|