@bililive-tools/douyu-recorder 1.1.0 → 1.2.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 +16 -0
- package/lib/dy_client/index.js +1 -1
- package/lib/index.js +3 -1
- package/lib/stream.d.ts +1 -0
- package/lib/stream.js +1 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -36,6 +36,7 @@ interface Options {
|
|
|
36
36
|
channelId: string; // 直播间ID,具体解析见文档,也可自行解析
|
|
37
37
|
quality: number; // 见画质参数
|
|
38
38
|
qualityRetry?: number; // 画质匹配重试次数, -1为强制匹配画质,0为自动配置,正整数为最大匹配次数
|
|
39
|
+
source?: string; // 指定 cdn,见文档,不传为自动
|
|
39
40
|
streamPriorities: []; // 废弃
|
|
40
41
|
sourcePriorities: []; // 废弃
|
|
41
42
|
disableAutoCheck?: boolean; // 为 true 时 manager 将跳过自动检查
|
|
@@ -45,6 +46,7 @@ interface Options {
|
|
|
45
46
|
saveGiftDanma?: boolean; // 保存礼物弹幕
|
|
46
47
|
saveSCDanma?: boolean; // 保存高能弹幕
|
|
47
48
|
saveCover?: boolean; // 保存封面
|
|
49
|
+
videoFormat?: "auto"; // 视频格式: "auto", "ts", "mkv" ,auto模式下, 分段使用 "ts",不分段使用 "mp4"
|
|
48
50
|
}
|
|
49
51
|
```
|
|
50
52
|
|
|
@@ -71,6 +73,20 @@ const url = "https://www.douyu.com/2140934";
|
|
|
71
73
|
const { id } = await provider.resolveChannelInfoFromURL(url);
|
|
72
74
|
```
|
|
73
75
|
|
|
76
|
+
## cdn
|
|
77
|
+
|
|
78
|
+
如果有更多线路或者错误,请发issue
|
|
79
|
+
|
|
80
|
+
| 线路 | 值 |
|
|
81
|
+
| ------ | --------- |
|
|
82
|
+
| 自动 | auto |
|
|
83
|
+
| 线路1 | scdnctshh |
|
|
84
|
+
| 线路4 | tctc-h5 |
|
|
85
|
+
| 线路5 | tct-h5 |
|
|
86
|
+
| 线路6 | ali-h5 |
|
|
87
|
+
| 线路7 | hw-h5 |
|
|
88
|
+
| 线路13 | hs-h5 |
|
|
89
|
+
|
|
74
90
|
# 协议
|
|
75
91
|
|
|
76
92
|
与原项目保存一致为 LGPL
|
package/lib/dy_client/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import { BufferCoder } from "./buffer_coder.js";
|
|
|
9
9
|
import { STT } from "./stt.js";
|
|
10
10
|
export function createDYClient(channelId, opts = {}) {
|
|
11
11
|
let ws = null;
|
|
12
|
-
let maxRetry =
|
|
12
|
+
let maxRetry = 10;
|
|
13
13
|
let coder = new BufferCoder();
|
|
14
14
|
let heartbeatTimer = null;
|
|
15
15
|
const send = (message) => ws?.send(coder.encode(STT.serialize(message)));
|
package/lib/index.js
CHANGED
|
@@ -108,7 +108,6 @@ const checkLiveStatusAndRecord = async function ({ getSavePath, banLiveId, isMan
|
|
|
108
108
|
const liveInfo = await getInfo(this.channelId);
|
|
109
109
|
const { living, owner, title, liveId } = liveInfo;
|
|
110
110
|
this.liveInfo = liveInfo;
|
|
111
|
-
this.emit("LiveStart", { liveId });
|
|
112
111
|
if (liveInfo.liveId === banLiveId) {
|
|
113
112
|
this.tempStopIntervalCheck = true;
|
|
114
113
|
}
|
|
@@ -138,6 +137,7 @@ const checkLiveStatusAndRecord = async function ({ getSavePath, banLiveId, isMan
|
|
|
138
137
|
return null;
|
|
139
138
|
}
|
|
140
139
|
}
|
|
140
|
+
this.emit("LiveStart", { liveId });
|
|
141
141
|
let res;
|
|
142
142
|
// TODO: 先不做什么错误处理,就简单包一下预期上会有错误的地方
|
|
143
143
|
try {
|
|
@@ -154,6 +154,7 @@ const checkLiveStatusAndRecord = async function ({ getSavePath, banLiveId, isMan
|
|
|
154
154
|
res = await getStream({
|
|
155
155
|
channelId: this.channelId,
|
|
156
156
|
quality: this.quality,
|
|
157
|
+
source: this.source,
|
|
157
158
|
strictQuality,
|
|
158
159
|
});
|
|
159
160
|
}
|
|
@@ -186,6 +187,7 @@ const checkLiveStatusAndRecord = async function ({ getSavePath, banLiveId, isMan
|
|
|
186
187
|
segment: this.segment ?? 0,
|
|
187
188
|
getSavePath: (opts) => getSavePath({ owner, title, startTime: opts.startTime }),
|
|
188
189
|
disableDanma: this.disableProvideCommentsWhenRecording,
|
|
190
|
+
videoFormat: this.videoFormat ?? "auto",
|
|
189
191
|
}, onEnd);
|
|
190
192
|
const savePath = getSavePath({
|
|
191
193
|
owner,
|
package/lib/stream.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export declare function getInfo(channelId: string): Promise<{
|
|
|
11
11
|
export declare function getStream(opts: Pick<Recorder, "channelId" | "quality"> & {
|
|
12
12
|
rejectCache?: boolean;
|
|
13
13
|
strictQuality?: boolean;
|
|
14
|
+
source?: string;
|
|
14
15
|
}): Promise<{
|
|
15
16
|
living: true;
|
|
16
17
|
sources: import("./dy_api.js").SourceProfile[];
|
package/lib/stream.js
CHANGED
|
@@ -47,6 +47,7 @@ export async function getStream(opts) {
|
|
|
47
47
|
let liveInfo = await getLiveInfo({
|
|
48
48
|
channelId: opts.channelId,
|
|
49
49
|
rate: qn,
|
|
50
|
+
cdn: opts.source === "auto" ? undefined : opts.source,
|
|
50
51
|
});
|
|
51
52
|
if (!liveInfo.living)
|
|
52
53
|
throw new Error("It must be called getStream when living");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bililive-tools/douyu-recorder",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.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.2.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@types/ws": "^8.5.13"
|