@bililive-tools/bilibili-recorder 1.5.1 → 1.6.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/README.md +1 -0
- package/lib/danma.js +17 -17
- package/lib/index.js +10 -6
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -53,6 +53,7 @@ interface Options {
|
|
|
53
53
|
m3u8ProxyUrl?: string; // 代理链接,文档待补充
|
|
54
54
|
videoFormat?: "auto"; // 视频格式: "auto", "ts", "mkv" ,auto模式下, 分段使用 "ts",不分段使用 "mp4"
|
|
55
55
|
onlyAudio?: boolean; // 只录制音频,默认为否
|
|
56
|
+
recorderType?: "auto" | "ffmpeg" | "mesio"; // 底层录制器,使用mesio时videoFormat参数无效
|
|
56
57
|
}
|
|
57
58
|
```
|
|
58
59
|
|
package/lib/danma.js
CHANGED
|
@@ -74,10 +74,10 @@ class DanmaClient extends EventEmitter {
|
|
|
74
74
|
uid: String(msg.body.user.uid),
|
|
75
75
|
name: msg.body.user.uname,
|
|
76
76
|
avatar: msg.body.user.face,
|
|
77
|
-
extra: {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
},
|
|
77
|
+
// extra: {
|
|
78
|
+
// badgeName: msg.body.user?.badge?.name,
|
|
79
|
+
// badgeLevel: msg.body.user?.badge?.level,
|
|
80
|
+
// },
|
|
81
81
|
},
|
|
82
82
|
};
|
|
83
83
|
this.emit("Message", comment);
|
|
@@ -93,10 +93,10 @@ class DanmaClient extends EventEmitter {
|
|
|
93
93
|
uid: String(msg.body.user.uid),
|
|
94
94
|
name: msg.body.user.uname,
|
|
95
95
|
avatar: msg.body.user.face,
|
|
96
|
-
extra: {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
},
|
|
96
|
+
// extra: {
|
|
97
|
+
// badgeName: msg.body.user?.badge?.name,
|
|
98
|
+
// badgeLevel: msg.body.user?.badge?.level,
|
|
99
|
+
// },
|
|
100
100
|
},
|
|
101
101
|
};
|
|
102
102
|
this.emit("Message", comment);
|
|
@@ -106,17 +106,17 @@ class DanmaClient extends EventEmitter {
|
|
|
106
106
|
type: "guard",
|
|
107
107
|
timestamp: this.useServerTimestamp ? msg.timestamp : Date.now(),
|
|
108
108
|
name: msg.body.gift_name,
|
|
109
|
-
price: msg.body.price,
|
|
109
|
+
price: msg.body.price / 1000,
|
|
110
110
|
count: 1,
|
|
111
111
|
level: msg.body.guard_level,
|
|
112
112
|
sender: {
|
|
113
113
|
uid: String(msg.body.user.uid),
|
|
114
114
|
name: msg.body.user.uname,
|
|
115
115
|
avatar: msg.body.user.face,
|
|
116
|
-
extra: {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
},
|
|
116
|
+
// extra: {
|
|
117
|
+
// badgeName: msg.body.user?.badge?.name,
|
|
118
|
+
// badgeLevel: msg.body.user?.badge?.level,
|
|
119
|
+
// },
|
|
120
120
|
},
|
|
121
121
|
};
|
|
122
122
|
this.emit("Message", gift);
|
|
@@ -132,10 +132,10 @@ class DanmaClient extends EventEmitter {
|
|
|
132
132
|
uid: String(msg.body.user.uid),
|
|
133
133
|
name: msg.body.user.uname,
|
|
134
134
|
avatar: msg.body.user.face,
|
|
135
|
-
extra: {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
},
|
|
135
|
+
// extra: {
|
|
136
|
+
// badgeName: msg.body.user?.badge?.name,
|
|
137
|
+
// badgeLevel: msg.body.user?.badge?.level,
|
|
138
|
+
// },
|
|
139
139
|
},
|
|
140
140
|
extra: {
|
|
141
141
|
hits: msg.body.combo?.combo_num,
|
package/lib/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import mitt from "mitt";
|
|
3
|
-
import { defaultFromJSON, defaultToJSON, genRecorderUUID, genRecordUUID, utils,
|
|
3
|
+
import { defaultFromJSON, defaultToJSON, genRecorderUUID, genRecordUUID, utils, createBaseRecorder, } from "@bililive-tools/manager";
|
|
4
4
|
import { getInfo, getStream, getLiveStatus, getStrictStream } from "./stream.js";
|
|
5
5
|
import { ensureFolderExist, hasKeyword } from "./utils.js";
|
|
6
6
|
import DanmaClient from "./danma.js";
|
|
@@ -23,6 +23,7 @@ function createRecorder(opts) {
|
|
|
23
23
|
m3u8ProxyUrl: opts.m3u8ProxyUrl,
|
|
24
24
|
formatName: opts.formatName ?? "auto",
|
|
25
25
|
codecName: opts.codecName ?? "auto",
|
|
26
|
+
recorderType: opts.recorderType ?? "ffmpeg",
|
|
26
27
|
getChannelURL() {
|
|
27
28
|
return `https://live.bilibili.com/${this.channelId}`;
|
|
28
29
|
},
|
|
@@ -146,7 +147,8 @@ const checkLiveStatusAndRecord = async function ({ getSavePath, isManualStart, b
|
|
|
146
147
|
});
|
|
147
148
|
}
|
|
148
149
|
catch (err) {
|
|
149
|
-
this.qualityRetry
|
|
150
|
+
if (this.qualityRetry > 0)
|
|
151
|
+
this.qualityRetry -= 1;
|
|
150
152
|
this.state = "idle";
|
|
151
153
|
throw err;
|
|
152
154
|
}
|
|
@@ -159,7 +161,7 @@ const checkLiveStatusAndRecord = async function ({ getSavePath, isManualStart, b
|
|
|
159
161
|
let url = stream.url;
|
|
160
162
|
let intervalId = null;
|
|
161
163
|
if (this.useM3U8Proxy && streamOptions.protocol_name === "http_hls") {
|
|
162
|
-
url = `${this.m3u8ProxyUrl}?id=${this.id}`;
|
|
164
|
+
url = `${this.m3u8ProxyUrl}?id=${this.id}&format=hls`;
|
|
163
165
|
this.emit("DebugLog", {
|
|
164
166
|
type: "common",
|
|
165
167
|
text: `is hls stream, use proxy: ${url}`,
|
|
@@ -193,18 +195,20 @@ const checkLiveStatusAndRecord = async function ({ getSavePath, isManualStart, b
|
|
|
193
195
|
isEnded = true;
|
|
194
196
|
this.emit("DebugLog", {
|
|
195
197
|
type: "common",
|
|
196
|
-
text: `
|
|
198
|
+
text: `record end, reason: ${JSON.stringify(args, (_, v) => (v instanceof Error ? v.stack : v))}`,
|
|
197
199
|
});
|
|
198
200
|
const reason = args[0] instanceof Error ? args[0].message : String(args[0]);
|
|
199
201
|
this.recordHandle?.stop(reason);
|
|
200
202
|
};
|
|
201
|
-
|
|
203
|
+
let recorderType = this.recorderType === "mesio" ? "mesio" : "ffmpeg";
|
|
204
|
+
const recorder = createBaseRecorder(recorderType, {
|
|
202
205
|
url: url,
|
|
203
206
|
outputOptions: ffmpegOutputOptions,
|
|
204
207
|
inputOptions: ffmpegInputOptions,
|
|
208
|
+
mesioOptions: ["-H", "Referer:https://live.bilibili.com/"],
|
|
205
209
|
segment: this.segment ?? 0,
|
|
206
210
|
getSavePath: (opts) => getSavePath({ owner, title: opts.title ?? title, startTime: opts.startTime }),
|
|
207
|
-
|
|
211
|
+
formatName: streamOptions.format_name,
|
|
208
212
|
disableDanma: this.disableProvideCommentsWhenRecording,
|
|
209
213
|
videoFormat: this.videoFormat,
|
|
210
214
|
}, onEnd, async () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bililive-tools/bilibili-recorder",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "bililive-tools bilibili recorder implemention",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"tiny-bilibili-ws": "^1.0.2",
|
|
40
40
|
"lodash-es": "^4.17.21",
|
|
41
41
|
"axios": "^1.7.8",
|
|
42
|
-
"@bililive-tools/manager": "^1.
|
|
42
|
+
"@bililive-tools/manager": "^1.6.0"
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
45
45
|
"build": "tsc",
|