@bililive-tools/douyu-recorder 1.6.0 → 1.7.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/lib/dy_client/buffer_coder.js +2 -0
- package/lib/index.js +12 -7
- package/lib/stream.js +1 -0
- package/package.json +2 -2
|
@@ -18,6 +18,7 @@ export class BufferCoder {
|
|
|
18
18
|
if (littleEndian == null) {
|
|
19
19
|
littleEndian = this.littleEndian;
|
|
20
20
|
}
|
|
21
|
+
// @ts-ignore
|
|
21
22
|
this.buffer = this.concat(this.buffer, newBuffer).buffer;
|
|
22
23
|
while (this.buffer && this.buffer.byteLength > 0) {
|
|
23
24
|
if (this.readLength === 0) {
|
|
@@ -38,6 +39,7 @@ export class BufferCoder {
|
|
|
38
39
|
if (littleEndian == null) {
|
|
39
40
|
littleEndian = this.littleEndian;
|
|
40
41
|
}
|
|
42
|
+
// @ts-ignore
|
|
41
43
|
const out = this.concat(this.encoder.encode(msg), Uint8Array.of(0));
|
|
42
44
|
const formatBodySize = 8 + out.length;
|
|
43
45
|
const dv = new DataView(new ArrayBuffer(formatBodySize + 4));
|
package/lib/index.js
CHANGED
|
@@ -106,10 +106,16 @@ const checkLiveStatusAndRecord = async function ({ getSavePath, banLiveId, isMan
|
|
|
106
106
|
return this.recordHandle;
|
|
107
107
|
}
|
|
108
108
|
// 获取直播间信息
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
109
|
+
try {
|
|
110
|
+
const liveInfo = await getInfo(this.channelId);
|
|
111
|
+
this.liveInfo = liveInfo;
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
this.state = "check-error";
|
|
115
|
+
throw error;
|
|
116
|
+
}
|
|
117
|
+
const { living, owner, title } = this.liveInfo;
|
|
118
|
+
if (this.liveInfo.liveId === banLiveId) {
|
|
113
119
|
this.tempStopIntervalCheck = true;
|
|
114
120
|
}
|
|
115
121
|
else {
|
|
@@ -151,7 +157,6 @@ const checkLiveStatusAndRecord = async function ({ getSavePath, banLiveId, isMan
|
|
|
151
157
|
if (isManualStart) {
|
|
152
158
|
strictQuality = false;
|
|
153
159
|
}
|
|
154
|
-
// TODO: 还需要测试仅音频流的情况,mesio可能并不支持
|
|
155
160
|
res = await getStream({
|
|
156
161
|
channelId: this.channelId,
|
|
157
162
|
quality: this.quality,
|
|
@@ -164,7 +169,7 @@ const checkLiveStatusAndRecord = async function ({ getSavePath, banLiveId, isMan
|
|
|
164
169
|
catch (err) {
|
|
165
170
|
if (this.qualityRetry > 0)
|
|
166
171
|
this.qualityRetry -= 1;
|
|
167
|
-
this.state = "
|
|
172
|
+
this.state = "check-error";
|
|
168
173
|
throw err;
|
|
169
174
|
}
|
|
170
175
|
this.state = "recording";
|
|
@@ -225,7 +230,7 @@ const checkLiveStatusAndRecord = async function ({ getSavePath, banLiveId, isMan
|
|
|
225
230
|
extraDataController?.setMeta({
|
|
226
231
|
room_id: this.channelId,
|
|
227
232
|
platform: provider?.id,
|
|
228
|
-
liveStartTimestamp: liveInfo
|
|
233
|
+
liveStartTimestamp: this?.liveInfo?.startTime?.getTime(),
|
|
229
234
|
// recordStopTimestamp: Date.now(),
|
|
230
235
|
title: title,
|
|
231
236
|
user_name: owner,
|
package/lib/stream.js
CHANGED
|
@@ -46,6 +46,7 @@ export async function getStream(opts) {
|
|
|
46
46
|
const qn = (DouyuQualities.includes(opts.quality) ? opts.quality : 0);
|
|
47
47
|
let cdn = opts.source === "auto" ? undefined : opts.source;
|
|
48
48
|
if (opts.source === "auto" && opts.avoidEdgeCDN) {
|
|
49
|
+
// TODO: 如果不存在 cdn=hw-h5 的源,那么还是可能默认到边缘节点,就先这样吧
|
|
49
50
|
cdn = "hw-h5";
|
|
50
51
|
}
|
|
51
52
|
let liveInfo = await getLiveInfo({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bililive-tools/douyu-recorder",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"description": "bililive-tools douyu recorder implemention",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"lodash-es": "^4.17.21",
|
|
42
42
|
"axios": "^1.7.8",
|
|
43
43
|
"douyu-api": "^0.1.0",
|
|
44
|
-
"@bililive-tools/manager": "^1.6.
|
|
44
|
+
"@bililive-tools/manager": "^1.6.1"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@types/ws": "^8.5.13"
|