@bililive-tools/huya-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/huya_api.js +1 -4
- package/lib/huya_mobile_api.js +6 -8
- package/lib/index.js +14 -10
- package/lib/requester.d.ts +2 -0
- package/lib/requester.js +7 -0
- package/package.json +3 -3
package/lib/huya_api.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { requester } from "./requester.js";
|
|
2
2
|
import { utils } from "@bililive-tools/manager";
|
|
3
3
|
import { assert, getFormatSources } from "./utils.js";
|
|
4
4
|
import { initInfo } from "./anticode.js";
|
|
5
|
-
const requester = axios.create({
|
|
6
|
-
timeout: 10e3,
|
|
7
|
-
});
|
|
8
5
|
export async function getRoomInfo(roomIdOrShortId, opts = {}) {
|
|
9
6
|
const res = await requester.get(`https://www.huya.com/${roomIdOrShortId}`);
|
|
10
7
|
const html = res.data;
|
package/lib/huya_mobile_api.js
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
// import { createHash, randomInt } from "node:crypto";
|
|
2
2
|
// import { URLSearchParams } from "node:url";
|
|
3
|
-
import
|
|
3
|
+
import { requester } from "./requester.js";
|
|
4
4
|
import { utils } from "@bililive-tools/manager";
|
|
5
5
|
import { assert, getFormatSources } from "./utils.js";
|
|
6
|
-
const requester = axios.create({
|
|
7
|
-
timeout: 10e3,
|
|
8
|
-
headers: {
|
|
9
|
-
"User-Agent": "Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 (KHTML, like Gecko)",
|
|
10
|
-
},
|
|
11
|
-
});
|
|
12
6
|
export async function getRoomInfo(roomIdOrShortId, formatPriorities = ["flv", "hls"]) {
|
|
13
|
-
const res = await requester.get(`https://mp.huya.com/cache.php?m=Live&do=profileRoom&roomid=${roomIdOrShortId}
|
|
7
|
+
const res = await requester.get(`https://mp.huya.com/cache.php?m=Live&do=profileRoom&roomid=${roomIdOrShortId}`, {
|
|
8
|
+
headers: {
|
|
9
|
+
"User-Agent": "Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 (KHTML, like Gecko)",
|
|
10
|
+
},
|
|
11
|
+
});
|
|
14
12
|
const html = res.data;
|
|
15
13
|
assert(html, `Unexpected resp, hyPlayerConfig is null`);
|
|
16
14
|
if (res.status !== 200) {
|
package/lib/index.js
CHANGED
|
@@ -56,14 +56,7 @@ function createRecorder(opts) {
|
|
|
56
56
|
});
|
|
57
57
|
return recorderWithSupportUpdatedEvent;
|
|
58
58
|
}
|
|
59
|
-
const ffmpegOutputOptions = [
|
|
60
|
-
"-c",
|
|
61
|
-
"copy",
|
|
62
|
-
"-movflags",
|
|
63
|
-
"faststart+frag_keyframe+empty_moov",
|
|
64
|
-
"-min_frag_duration",
|
|
65
|
-
"10000000",
|
|
66
|
-
];
|
|
59
|
+
const ffmpegOutputOptions = [];
|
|
67
60
|
const ffmpegInputOptions = ["-rw_timeout", "10000000", "-timeout", "10000000"];
|
|
68
61
|
const checkLiveStatusAndRecord = async function ({ getSavePath, banLiveId, isManualStart, }) {
|
|
69
62
|
// 如果已经在录制中,只在需要检查标题关键词时才获取最新信息
|
|
@@ -110,7 +103,7 @@ const checkLiveStatusAndRecord = async function ({ getSavePath, banLiveId, isMan
|
|
|
110
103
|
this.state = "check-error";
|
|
111
104
|
throw error;
|
|
112
105
|
}
|
|
113
|
-
const { living, owner, title } = this.liveInfo;
|
|
106
|
+
const { living, owner, title, startTime } = this.liveInfo;
|
|
114
107
|
if (this.liveInfo.liveId === banLiveId) {
|
|
115
108
|
this.tempStopIntervalCheck = true;
|
|
116
109
|
}
|
|
@@ -185,12 +178,19 @@ const checkLiveStatusAndRecord = async function ({ getSavePath, banLiveId, isMan
|
|
|
185
178
|
const reason = args[0] instanceof Error ? args[0].message : String(args[0]);
|
|
186
179
|
this.recordHandle?.stop(reason);
|
|
187
180
|
};
|
|
181
|
+
const recordStartTime = new Date();
|
|
188
182
|
const recorder = createBaseRecorder(this.recorderType, {
|
|
189
183
|
url: stream.url,
|
|
190
184
|
outputOptions: ffmpegOutputOptions,
|
|
191
185
|
inputOptions: ffmpegInputOptions,
|
|
192
186
|
segment: this.segment ?? 0,
|
|
193
|
-
getSavePath: (opts) => getSavePath({
|
|
187
|
+
getSavePath: (opts) => getSavePath({
|
|
188
|
+
owner,
|
|
189
|
+
title: opts.title ?? title,
|
|
190
|
+
startTime: opts.startTime,
|
|
191
|
+
liveStartTime: startTime,
|
|
192
|
+
recordStartTime,
|
|
193
|
+
}),
|
|
194
194
|
disableDanma: this.disableProvideCommentsWhenRecording,
|
|
195
195
|
videoFormat: this.videoFormat ?? "auto",
|
|
196
196
|
debugLevel: this.debugLevel ?? "none",
|
|
@@ -201,6 +201,9 @@ const checkLiveStatusAndRecord = async function ({ getSavePath, banLiveId, isMan
|
|
|
201
201
|
const savePath = getSavePath({
|
|
202
202
|
owner,
|
|
203
203
|
title,
|
|
204
|
+
startTime: Date.now(),
|
|
205
|
+
liveStartTime: startTime,
|
|
206
|
+
recordStartTime,
|
|
204
207
|
});
|
|
205
208
|
try {
|
|
206
209
|
ensureFolderExist(savePath);
|
|
@@ -333,6 +336,7 @@ const checkLiveStatusAndRecord = async function ({ getSavePath, banLiveId, isMan
|
|
|
333
336
|
id: genRecordUUID(),
|
|
334
337
|
stream: stream.name,
|
|
335
338
|
source: stream.source,
|
|
339
|
+
recorderType: recorder.type,
|
|
336
340
|
url: stream.url,
|
|
337
341
|
ffmpegArgs,
|
|
338
342
|
savePath: savePath,
|
package/lib/requester.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bililive-tools/huya-recorder",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.0",
|
|
4
4
|
"description": "bililive-tools huya recorder implemention",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"mitt": "^3.0.1",
|
|
38
38
|
"lodash-es": "^4.17.21",
|
|
39
39
|
"axios": "^1.7.8",
|
|
40
|
-
"
|
|
41
|
-
"
|
|
40
|
+
"huya-danma-listener": "0.1.3",
|
|
41
|
+
"@bililive-tools/manager": "^1.9.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {},
|
|
44
44
|
"scripts": {
|