@bililive-tools/bilibili-recorder 1.13.0 → 1.16.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/bilibili_api.d.ts +1 -0
- package/lib/bilibili_api.js +3 -0
- package/lib/index.js +2 -16
- package/lib/stream.d.ts +1 -0
- package/lib/stream.js +2 -0
- package/package.json +3 -3
package/lib/bilibili_api.d.ts
CHANGED
|
@@ -42,6 +42,7 @@ export declare function getStatusInfoByUIDs<UID extends number>(userIds: UID[]):
|
|
|
42
42
|
online: number;
|
|
43
43
|
room_id: number;
|
|
44
44
|
short_id: number;
|
|
45
|
+
area_v2_parent_name: string;
|
|
45
46
|
}>>;
|
|
46
47
|
export declare function getRoomBaseInfo<RoomId extends number>(roomId: RoomId): Promise<Record<RoomId, {
|
|
47
48
|
title: string;
|
package/lib/bilibili_api.js
CHANGED
|
@@ -8,6 +8,9 @@ const requester = axios.create({
|
|
|
8
8
|
// axios 会自动读取环境变量中的 http_proxy 和 https_proxy 并应用,
|
|
9
9
|
// 但会导致请求报错 "Client network socket disconnected before secure TLS connection was established"。
|
|
10
10
|
proxy: false,
|
|
11
|
+
headers: {
|
|
12
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36",
|
|
13
|
+
},
|
|
11
14
|
});
|
|
12
15
|
export async function getRoomInit(roomIdOrShortId) {
|
|
13
16
|
const res = await requester.get(`https://api.live.bilibili.com/room/v1/Room/room_init?id=${roomIdOrShortId}`);
|
package/lib/index.js
CHANGED
|
@@ -2,7 +2,6 @@ import path from "node:path";
|
|
|
2
2
|
import mitt from "mitt";
|
|
3
3
|
import { defaultFromJSON, defaultToJSON, genRecorderUUID, genRecordUUID, utils, createDownloader, } from "@bililive-tools/manager";
|
|
4
4
|
import { getInfo, getStream, getLiveStatus, getStrictStream } from "./stream.js";
|
|
5
|
-
import { ensureFolderExist } from "./utils.js";
|
|
6
5
|
import DanmaClient from "./danma.js";
|
|
7
6
|
function createRecorder(opts) {
|
|
8
7
|
// 内部实现时,应该只有 proxy 包裹的那一层会使用这个 recorder 标识符,不应该有直接通过
|
|
@@ -185,6 +184,7 @@ const checkLiveStatusAndRecord = async function ({ getSavePath, isManualStart, b
|
|
|
185
184
|
startTime: opts.startTime,
|
|
186
185
|
liveStartTime: liveStartTime,
|
|
187
186
|
recordStartTime,
|
|
187
|
+
extraMs: opts.extraMs,
|
|
188
188
|
}),
|
|
189
189
|
formatName: streamOptions.format_name,
|
|
190
190
|
disableDanma: this.disableProvideCommentsWhenRecording,
|
|
@@ -197,20 +197,6 @@ const checkLiveStatusAndRecord = async function ({ getSavePath, isManualStart, b
|
|
|
197
197
|
const info = await getInfo(this.channelId);
|
|
198
198
|
return info;
|
|
199
199
|
});
|
|
200
|
-
const savePath = getSavePath({
|
|
201
|
-
owner,
|
|
202
|
-
title,
|
|
203
|
-
startTime: Date.now(),
|
|
204
|
-
liveStartTime: liveStartTime,
|
|
205
|
-
recordStartTime,
|
|
206
|
-
});
|
|
207
|
-
try {
|
|
208
|
-
ensureFolderExist(savePath);
|
|
209
|
-
}
|
|
210
|
-
catch (err) {
|
|
211
|
-
this.state = "idle";
|
|
212
|
-
throw err;
|
|
213
|
-
}
|
|
214
200
|
const handleVideoCreated = async ({ filename, title, cover, rawFilename }) => {
|
|
215
201
|
this.emit("videoFileCreated", { filename, cover, rawFilename });
|
|
216
202
|
if (title && this?.liveInfo) {
|
|
@@ -313,7 +299,7 @@ const checkLiveStatusAndRecord = async function ({ getSavePath, isManualStart, b
|
|
|
313
299
|
recorderType: downloader.type,
|
|
314
300
|
url: stream.url,
|
|
315
301
|
downloaderArgs,
|
|
316
|
-
savePath:
|
|
302
|
+
savePath: downloader.videoFilePath,
|
|
317
303
|
stop,
|
|
318
304
|
cut,
|
|
319
305
|
};
|
package/lib/stream.d.ts
CHANGED
package/lib/stream.js
CHANGED
|
@@ -55,6 +55,7 @@ export async function getInfo(channelId) {
|
|
|
55
55
|
roomId: roomInit.room_id,
|
|
56
56
|
liveId: utils.md5(`${roomInit.room_id}-${liveStartTime?.getTime()}`),
|
|
57
57
|
recordStartTime,
|
|
58
|
+
area: status.parent_area_name,
|
|
58
59
|
};
|
|
59
60
|
}
|
|
60
61
|
const liveStartTime = new Date(status.live_time * 1000);
|
|
@@ -69,6 +70,7 @@ export async function getInfo(channelId) {
|
|
|
69
70
|
liveStartTime: liveStartTime,
|
|
70
71
|
liveId: utils.md5(`${roomInit.room_id}-${liveStartTime.getTime()}`),
|
|
71
72
|
recordStartTime,
|
|
73
|
+
area: status.area_v2_parent_name,
|
|
72
74
|
};
|
|
73
75
|
}
|
|
74
76
|
async function getLiveInfo(roomIdOrShortId, opts) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bililive-tools/bilibili-recorder",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.16.0",
|
|
4
4
|
"description": "bililive-tools bilibili recorder implemention",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"mitt": "^3.0.1",
|
|
39
39
|
"tiny-bilibili-ws": "^1.0.2",
|
|
40
40
|
"lodash-es": "^4.17.21",
|
|
41
|
-
"axios": "^1.
|
|
42
|
-
"@bililive-tools/manager": "^1.
|
|
41
|
+
"axios": "^1.15.0",
|
|
42
|
+
"@bililive-tools/manager": "^1.16.0"
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
45
45
|
"build": "tsc",
|