@bililive-tools/douyu-recorder 1.12.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/index.js +2 -16
- package/lib/requester.d.ts +1 -2
- package/lib/stream.d.ts +1 -0
- package/lib/stream.js +1 -0
- package/lib/utils.d.ts +0 -1
- package/lib/utils.js +0 -25
- package/package.json +3 -3
package/lib/index.js
CHANGED
|
@@ -3,7 +3,6 @@ import { defaultFromJSON, defaultToJSON, genRecorderUUID, genRecordUUID, utils,
|
|
|
3
3
|
import { live } from "douyu-api";
|
|
4
4
|
import { getInfo, getStream } from "./stream.js";
|
|
5
5
|
import { getRoomInfo } from "./dy_api.js";
|
|
6
|
-
import { ensureFolderExist } from "./utils.js";
|
|
7
6
|
import { createDYClient } from "./dy_client/index.js";
|
|
8
7
|
import { giftMap, colorTab } from "./danma.js";
|
|
9
8
|
function createRecorder(opts) {
|
|
@@ -138,6 +137,7 @@ const checkLiveStatusAndRecord = async function ({ getSavePath, banLiveId, isMan
|
|
|
138
137
|
startTime: opts.startTime,
|
|
139
138
|
liveStartTime,
|
|
140
139
|
recordStartTime,
|
|
140
|
+
extraMs: opts.extraMs,
|
|
141
141
|
}),
|
|
142
142
|
disableDanma: this.disableProvideCommentsWhenRecording,
|
|
143
143
|
videoFormat: this.videoFormat ?? "auto",
|
|
@@ -147,20 +147,6 @@ const checkLiveStatusAndRecord = async function ({ getSavePath, banLiveId, isMan
|
|
|
147
147
|
const info = await getInfo(this.channelId);
|
|
148
148
|
return info;
|
|
149
149
|
});
|
|
150
|
-
const savePath = getSavePath({
|
|
151
|
-
owner,
|
|
152
|
-
title,
|
|
153
|
-
startTime: Date.now(),
|
|
154
|
-
liveStartTime,
|
|
155
|
-
recordStartTime,
|
|
156
|
-
});
|
|
157
|
-
try {
|
|
158
|
-
ensureFolderExist(savePath);
|
|
159
|
-
}
|
|
160
|
-
catch (err) {
|
|
161
|
-
this.state = "idle";
|
|
162
|
-
throw err;
|
|
163
|
-
}
|
|
164
150
|
const handleVideoCreated = async ({ filename, title, cover, rawFilename }) => {
|
|
165
151
|
this.emit("videoFileCreated", { filename, cover, rawFilename });
|
|
166
152
|
if (title && this?.liveInfo) {
|
|
@@ -372,7 +358,7 @@ const checkLiveStatusAndRecord = async function ({ getSavePath, banLiveId, isMan
|
|
|
372
358
|
recorderType: downloader.type,
|
|
373
359
|
url: stream.url,
|
|
374
360
|
downloaderArgs,
|
|
375
|
-
savePath:
|
|
361
|
+
savePath: downloader.videoFilePath,
|
|
376
362
|
stop,
|
|
377
363
|
cut,
|
|
378
364
|
};
|
package/lib/requester.d.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const requester: axios.AxiosInstance;
|
|
1
|
+
export declare const requester: import("axios").AxiosInstance;
|
package/lib/stream.d.ts
CHANGED
package/lib/stream.js
CHANGED
|
@@ -36,6 +36,7 @@ export async function getInfo(channelId) {
|
|
|
36
36
|
liveStartTime: startTime,
|
|
37
37
|
liveId: utils.md5(`${channelId}-${startTime?.getTime() ?? Date.now()}`),
|
|
38
38
|
recordStartTime: recordStartTime,
|
|
39
|
+
area: data.room.second_lvl_name,
|
|
39
40
|
// gifts: data.gift.map((g) => ({
|
|
40
41
|
// id: g.id,
|
|
41
42
|
// name: g.name,
|
package/lib/utils.d.ts
CHANGED
|
@@ -18,4 +18,3 @@ export declare function getValuesFromArrayLikeFlexSpaceBetween<T>(array: T[], co
|
|
|
18
18
|
export declare function ensureFolderExist(fileOrFolderPath: string): void;
|
|
19
19
|
export declare function assert(assertion: unknown, msg?: string): asserts assertion;
|
|
20
20
|
export declare const uuid: () => `${string}-${string}-${string}-${string}-${string}`;
|
|
21
|
-
export declare function createInvalidStreamChecker(): (ffmpegLogLine: string) => boolean;
|
package/lib/utils.js
CHANGED
|
@@ -54,28 +54,3 @@ export function assert(assertion, msg) {
|
|
|
54
54
|
export const uuid = () => {
|
|
55
55
|
return crypto.randomUUID();
|
|
56
56
|
};
|
|
57
|
-
export function createInvalidStreamChecker() {
|
|
58
|
-
let prevFrame = 0;
|
|
59
|
-
let frameUnchangedCount = 0;
|
|
60
|
-
return (ffmpegLogLine) => {
|
|
61
|
-
const streamInfo = ffmpegLogLine.match(/frame=\s*(\d+) fps=.*? q=.*? size=.*? time=.*? bitrate=.*? speed=.*?/);
|
|
62
|
-
if (streamInfo != null) {
|
|
63
|
-
const [, frameText] = streamInfo;
|
|
64
|
-
const frame = Number(frameText);
|
|
65
|
-
if (frame === prevFrame) {
|
|
66
|
-
if (++frameUnchangedCount >= 15) {
|
|
67
|
-
return true;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
prevFrame = frame;
|
|
72
|
-
frameUnchangedCount = 0;
|
|
73
|
-
}
|
|
74
|
-
return false;
|
|
75
|
-
}
|
|
76
|
-
if (ffmpegLogLine.includes("HTTP error 404 Not Found")) {
|
|
77
|
-
return true;
|
|
78
|
-
}
|
|
79
|
-
return false;
|
|
80
|
-
};
|
|
81
|
-
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bililive-tools/douyu-recorder",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.16.0",
|
|
4
4
|
"description": "bililive-tools douyu recorder implemention",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
"safe-eval": "^0.4.1",
|
|
40
40
|
"ws": "^8.18.0",
|
|
41
41
|
"lodash-es": "^4.17.21",
|
|
42
|
-
"axios": "^1.
|
|
42
|
+
"axios": "^1.15.0",
|
|
43
43
|
"douyu-api": "^0.2.1",
|
|
44
|
-
"@bililive-tools/manager": "^1.
|
|
44
|
+
"@bililive-tools/manager": "^1.16.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@types/ws": "^8.5.13"
|