@bililive-tools/douyu-recorder 1.8.0 → 1.9.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_api.js +0 -1
- package/lib/index.js +16 -11
- package/package.json +2 -2
package/lib/dy_api.js
CHANGED
|
@@ -46,7 +46,6 @@ export async function getLiveInfo(opts) {
|
|
|
46
46
|
delete signCaches[opts.channelId];
|
|
47
47
|
throw new Error("Unexpected error code, " + json.error);
|
|
48
48
|
}
|
|
49
|
-
console.log(JSON.stringify(json, null, 2));
|
|
50
49
|
const streamUrl = `${json.data.rtmp_url}/${json.data.rtmp_live}`;
|
|
51
50
|
let cdn = json.data.rtmp_cdn;
|
|
52
51
|
let onlyAudio = false;
|
package/lib/index.js
CHANGED
|
@@ -55,14 +55,7 @@ function createRecorder(opts) {
|
|
|
55
55
|
});
|
|
56
56
|
return recorderWithSupportUpdatedEvent;
|
|
57
57
|
}
|
|
58
|
-
const ffmpegOutputOptions = [
|
|
59
|
-
"-c",
|
|
60
|
-
"copy",
|
|
61
|
-
"-movflags",
|
|
62
|
-
"faststart+frag_keyframe+empty_moov",
|
|
63
|
-
"-min_frag_duration",
|
|
64
|
-
"10000000",
|
|
65
|
-
];
|
|
58
|
+
const ffmpegOutputOptions = [];
|
|
66
59
|
const checkLiveStatusAndRecord = async function ({ getSavePath, banLiveId, isManualStart, }) {
|
|
67
60
|
// 如果已经在录制中,只在需要检查标题关键词时才获取最新信息
|
|
68
61
|
if (this.recordHandle != null) {
|
|
@@ -108,7 +101,7 @@ const checkLiveStatusAndRecord = async function ({ getSavePath, banLiveId, isMan
|
|
|
108
101
|
this.state = "check-error";
|
|
109
102
|
throw error;
|
|
110
103
|
}
|
|
111
|
-
const { living, owner, title } = this.liveInfo;
|
|
104
|
+
const { living, owner, title, startTime } = this.liveInfo;
|
|
112
105
|
if (this.liveInfo.liveId === banLiveId) {
|
|
113
106
|
this.tempStopIntervalCheck = true;
|
|
114
107
|
}
|
|
@@ -181,12 +174,19 @@ const checkLiveStatusAndRecord = async function ({ getSavePath, banLiveId, isMan
|
|
|
181
174
|
};
|
|
182
175
|
let isEnded = false;
|
|
183
176
|
let isCutting = false;
|
|
177
|
+
const recordStartTime = new Date();
|
|
184
178
|
const recorder = createBaseRecorder(this.recorderType, {
|
|
185
179
|
url: stream.url,
|
|
186
180
|
// @ts-ignore
|
|
187
181
|
outputOptions: ffmpegOutputOptions,
|
|
188
182
|
segment: this.segment ?? 0,
|
|
189
|
-
getSavePath: (opts) => getSavePath({
|
|
183
|
+
getSavePath: (opts) => getSavePath({
|
|
184
|
+
owner,
|
|
185
|
+
title: opts.title ?? title,
|
|
186
|
+
startTime: opts.startTime,
|
|
187
|
+
liveStartTime: startTime,
|
|
188
|
+
recordStartTime,
|
|
189
|
+
}),
|
|
190
190
|
disableDanma: this.disableProvideCommentsWhenRecording,
|
|
191
191
|
videoFormat: this.videoFormat ?? "auto",
|
|
192
192
|
debugLevel: this.debugLevel ?? "none",
|
|
@@ -198,6 +198,9 @@ const checkLiveStatusAndRecord = async function ({ getSavePath, banLiveId, isMan
|
|
|
198
198
|
const savePath = getSavePath({
|
|
199
199
|
owner,
|
|
200
200
|
title,
|
|
201
|
+
startTime: Date.now(),
|
|
202
|
+
liveStartTime: startTime,
|
|
203
|
+
recordStartTime,
|
|
201
204
|
});
|
|
202
205
|
try {
|
|
203
206
|
ensureFolderExist(savePath);
|
|
@@ -246,7 +249,8 @@ const checkLiveStatusAndRecord = async function ({ getSavePath, banLiveId, isMan
|
|
|
246
249
|
return;
|
|
247
250
|
switch (msg.type) {
|
|
248
251
|
case "chatmsg": {
|
|
249
|
-
|
|
252
|
+
// 某些情况下cst不存在,可能是其他平台发送的弹幕?
|
|
253
|
+
const timestamp = this.useServerTimestamp && msg.cst ? Number(msg.cst) : Date.now();
|
|
250
254
|
const comment = {
|
|
251
255
|
type: "comment",
|
|
252
256
|
timestamp: timestamp,
|
|
@@ -418,6 +422,7 @@ const checkLiveStatusAndRecord = async function ({ getSavePath, banLiveId, isMan
|
|
|
418
422
|
id: genRecordUUID(),
|
|
419
423
|
stream: stream.name,
|
|
420
424
|
source: stream.source,
|
|
425
|
+
recorderType: recorder.type,
|
|
421
426
|
url: stream.url,
|
|
422
427
|
ffmpegArgs,
|
|
423
428
|
savePath: savePath,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bililive-tools/douyu-recorder",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.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.
|
|
44
|
+
"@bililive-tools/manager": "^1.9.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@types/ws": "^8.5.13"
|