@bililive-tools/douyin-recorder 1.5.0 → 1.5.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 +9 -1
- package/lib/index.js +28 -3
- package/package.json +3 -3
package/lib/douyin_api.js
CHANGED
|
@@ -71,6 +71,13 @@ export const getCookie = async () => {
|
|
|
71
71
|
return cookie.split(";")[0];
|
|
72
72
|
})
|
|
73
73
|
.join("; ");
|
|
74
|
+
if (!cookies.includes("ttwid")) {
|
|
75
|
+
// 如果不含ttwid,且已经存在含ttwid的cookie,将缓存时间直接增加1小时,复用之前的参数
|
|
76
|
+
if (cookieCache?.cookies) {
|
|
77
|
+
cookieCache.startTimestamp += 60 * 60 * 1000; // 增加1小时
|
|
78
|
+
return cookieCache.cookies;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
74
81
|
cookieCache = {
|
|
75
82
|
startTimestamp: now,
|
|
76
83
|
cookies,
|
|
@@ -105,6 +112,7 @@ export async function getRoomInfo(webRoomId, opts = {}) {
|
|
|
105
112
|
// enter_source:,
|
|
106
113
|
"Room-Enter-User-Login-Ab": 0,
|
|
107
114
|
is_need_double_stream: "false",
|
|
115
|
+
a_bogus: "1",
|
|
108
116
|
},
|
|
109
117
|
headers: {
|
|
110
118
|
cookie: cookies,
|
|
@@ -125,7 +133,7 @@ export async function getRoomInfo(webRoomId, opts = {}) {
|
|
|
125
133
|
doubleScreen: opts.doubleScreen,
|
|
126
134
|
});
|
|
127
135
|
}
|
|
128
|
-
assert(res.data.status_code === 0, `Unexpected resp, code ${res.data.status_code}, msg ${JSON.stringify(res.data.data)}, id ${webRoomId}`);
|
|
136
|
+
assert(res.data.status_code === 0, `Unexpected resp, code ${res.data.status_code}, msg ${JSON.stringify(res.data.data)}, id ${webRoomId}, cookies: ${cookies}`);
|
|
129
137
|
const data = res.data.data;
|
|
130
138
|
const room = data.data[0];
|
|
131
139
|
assert(room, `No room data, id ${webRoomId}`);
|
package/lib/index.js
CHANGED
|
@@ -253,7 +253,31 @@ const checkLiveStatusAndRecord = async function ({ getSavePath, banLiveId, isMan
|
|
|
253
253
|
client.on("reconnect", (attempts) => {
|
|
254
254
|
this.emit("DebugLog", {
|
|
255
255
|
type: "common",
|
|
256
|
-
text: `danma has reconnect ${attempts}`,
|
|
256
|
+
text: `douyin ${this.channelId} danma has reconnect ${attempts}`,
|
|
257
|
+
});
|
|
258
|
+
});
|
|
259
|
+
client.on("error", (err) => {
|
|
260
|
+
this.emit("DebugLog", {
|
|
261
|
+
type: "common",
|
|
262
|
+
text: `douyin ${this.channelId} danma error: ${String(err)}`,
|
|
263
|
+
});
|
|
264
|
+
});
|
|
265
|
+
client.on("init", (url) => {
|
|
266
|
+
this.emit("DebugLog", {
|
|
267
|
+
type: "common",
|
|
268
|
+
text: `douyin ${this.channelId} danma init ${url}`,
|
|
269
|
+
});
|
|
270
|
+
});
|
|
271
|
+
client.on("open", () => {
|
|
272
|
+
this.emit("DebugLog", {
|
|
273
|
+
type: "common",
|
|
274
|
+
text: `douyin ${this.channelId} danma open`,
|
|
275
|
+
});
|
|
276
|
+
});
|
|
277
|
+
client.on("close", () => {
|
|
278
|
+
this.emit("DebugLog", {
|
|
279
|
+
type: "common",
|
|
280
|
+
text: `douyin danma close`,
|
|
257
281
|
});
|
|
258
282
|
});
|
|
259
283
|
// client.on("open", () => {
|
|
@@ -287,8 +311,8 @@ const checkLiveStatusAndRecord = async function ({ getSavePath, banLiveId, isMan
|
|
|
287
311
|
if (!this.recordHandle)
|
|
288
312
|
return;
|
|
289
313
|
this.state = "stopping-record";
|
|
290
|
-
client.close();
|
|
291
314
|
try {
|
|
315
|
+
client.close();
|
|
292
316
|
await recorder.stop();
|
|
293
317
|
}
|
|
294
318
|
catch (err) {
|
|
@@ -323,7 +347,7 @@ export const provider = {
|
|
|
323
347
|
siteURL: "https://live.douyin.com/",
|
|
324
348
|
matchURL(channelURL) {
|
|
325
349
|
// 支持 v.douyin.com 和 live.douyin.com
|
|
326
|
-
return /https?:\/\/(live|v)\.douyin\.com\//.test(channelURL);
|
|
350
|
+
return /https?:\/\/(live|v|www)\.douyin\.com\//.test(channelURL);
|
|
327
351
|
},
|
|
328
352
|
async resolveChannelInfoFromURL(channelURL) {
|
|
329
353
|
if (!this.matchURL(channelURL))
|
|
@@ -347,6 +371,7 @@ export const provider = {
|
|
|
347
371
|
id: info.roomId,
|
|
348
372
|
title: info.title,
|
|
349
373
|
owner: info.owner,
|
|
374
|
+
avatar: info.avatar,
|
|
350
375
|
};
|
|
351
376
|
},
|
|
352
377
|
createRecorder(opts) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bililive-tools/douyin-recorder",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.2",
|
|
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
|
-
"
|
|
41
|
-
"
|
|
40
|
+
"douyin-danma-listener": "0.2.0",
|
|
41
|
+
"@bililive-tools/manager": "^1.4.1"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@types/node": "*"
|