@bililive-tools/douyu-recorder 1.3.0 → 1.5.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 CHANGED
@@ -45,8 +45,10 @@ interface Options {
45
45
  disableProvideCommentsWhenRecording?: boolean; // 禁用弹幕录制
46
46
  saveGiftDanma?: boolean; // 保存礼物弹幕
47
47
  saveSCDanma?: boolean; // 保存高能弹幕
48
+ useServerTimestamp?: boolean; // 控制弹幕是否使用服务端时间戳,默认为true,斗鱼服务端时间戳只对文字弹幕生效,礼物等不生效
48
49
  saveCover?: boolean; // 保存封面
49
50
  videoFormat?: "auto"; // 视频格式: "auto", "ts", "mkv" ,auto模式下, 分段使用 "ts",不分段使用 "mp4"
51
+ onlyAudio?: boolean; // 只录制音频,默认为否
50
52
  }
51
53
  ```
52
54
 
package/lib/danma.js CHANGED
@@ -9,6 +9,7 @@ export const colorTab = {
9
9
  /**
10
10
  * from https://webconf.douyucdn.cn/resource/common/prop_gift_list/prop_gift_config.json
11
11
  */
12
+ // 粉丝荧光棒被手动置为0了
12
13
  export const giftMap = {
13
14
  "192": { name: "赞", pc: 10 },
14
15
  "193": { name: "弱鸡", pc: 20 },
@@ -39,7 +40,7 @@ export const giftMap = {
39
40
  "804": { name: "铜牌", pc: 10 },
40
41
  "805": { name: "银牌", pc: 30 },
41
42
  "806": { name: "金牌", pc: 60 },
42
- "824": { name: "粉丝荧光棒", pc: 10 },
43
+ "824": { name: "粉丝荧光棒", pc: 0 },
43
44
  "947": { name: "狼抓手", pc: 10 },
44
45
  "1005": { name: "超级火箭", pc: 200000 },
45
46
  "1075": { name: "这都不叫事", pc: 200000 },
@@ -253,13 +254,13 @@ export const giftMap = {
253
254
  "1800": { name: "69式饺子", pc: 200000 },
254
255
  "1804": { name: "帝国舰队", pc: 50100 },
255
256
  "1805": { name: "可爱羡羡火箭", pc: 50000 },
256
- "1806": { name: "粉丝荧光棒", pc: 10 },
257
+ "1806": { name: "粉丝荧光棒", pc: 0 },
257
258
  "1813": { name: "石西叽", pc: 200000 },
258
259
  "1814": { name: "一箭丹心", pc: 200000 },
259
260
  "1823": { name: "赞", pc: 10 },
260
261
  "1824": { name: "弱鸡", pc: 20 },
261
262
  "1828": { name: "帝国舰队", pc: 10100 },
262
- "1838": { name: "粉丝荧光棒", pc: 10 },
263
+ "1838": { name: "粉丝荧光棒", pc: 0 },
263
264
  "1844": { name: "英嘤英", pc: 200000 },
264
265
  "1850": { name: "一只狗", pc: 200000 },
265
266
  "1852": { name: "穷逼火箭", pc: 200000 },
@@ -280,7 +281,7 @@ export const giftMap = {
280
281
  "1897": { name: "大马猴火箭", pc: 50000 },
281
282
  "1912": { name: "岁月静好", pc: 200000 },
282
283
  "1913": { name: "吃鸡", pc: 10 },
283
- "1914": { name: "粉丝荧光棒", pc: 10 },
284
+ "1914": { name: "粉丝荧光棒", pc: 0 },
284
285
  "1923": { name: "伊C", pc: 200000 },
285
286
  "1924": { name: "装逼王超火", pc: 200000 },
286
287
  "1925": { name: "超级达克宁", pc: 200000 },
@@ -377,7 +378,7 @@ export const giftMap = {
377
378
  "20384": { name: "测试专用皮肤", pc: 10 },
378
379
  "20388": { name: "全民乐PK", pc: 10000 },
379
380
  "20389": { name: "挚爱超火", pc: 200000 },
380
- "20422": { name: "粉丝荧光棒", pc: 10 },
381
+ "20422": { name: "粉丝荧光棒", pc: 0 },
381
382
  "20426": { name: "不网恋超火", pc: 200000 },
382
383
  "20434": { name: "抢位道具卡", pc: 100 },
383
384
  "20435": { name: "普通家庭超火", pc: 200000 },
package/lib/dy_api.d.ts CHANGED
@@ -6,6 +6,7 @@ export declare function getLiveInfo(opts: {
6
6
  cdn?: string;
7
7
  rate?: number;
8
8
  rejectSignFnCache?: boolean;
9
+ onlyAudio?: boolean;
9
10
  }): Promise<{
10
11
  living: false;
11
12
  } | {
package/lib/dy_api.js CHANGED
@@ -21,6 +21,8 @@ export async function getLiveInfo(opts) {
21
21
  cdn: opts.cdn ?? "",
22
22
  // 相当于清晰度类型的 id,给 -1 会由后端决定,0为原画
23
23
  rate: String(opts.rate ?? 0),
24
+ // 是否只录制音频
25
+ fa: opts.onlyAudio ? "1" : "0",
24
26
  }));
25
27
  if (res.status !== 200) {
26
28
  if (res.status === 403 && res.data === "鉴权失败" && !opts.rejectSignFnCache) {
package/lib/index.js CHANGED
@@ -19,6 +19,7 @@ function createRecorder(opts) {
19
19
  availableSources: [],
20
20
  qualityMaxRetry: opts.qualityRetry ?? 0,
21
21
  qualityRetry: opts.qualityRetry ?? 0,
22
+ useServerTimestamp: opts.useServerTimestamp ?? true,
22
23
  state: "idle",
23
24
  getChannelURL() {
24
25
  return `https://www.douyu.com/${this.channelId}`;
@@ -155,6 +156,7 @@ const checkLiveStatusAndRecord = async function ({ getSavePath, banLiveId, isMan
155
156
  quality: this.quality,
156
157
  source: this.source,
157
158
  strictQuality,
159
+ onlyAudio: this.onlyAudio,
158
160
  });
159
161
  }
160
162
  catch (err) {
@@ -220,7 +222,7 @@ const checkLiveStatusAndRecord = async function ({ getSavePath, banLiveId, isMan
220
222
  room_id: this.channelId,
221
223
  platform: provider?.id,
222
224
  liveStartTimestamp: liveInfo.startTime?.getTime(),
223
- recordStopTimestamp: Date.now(),
225
+ // recordStopTimestamp: Date.now(),
224
226
  title: title,
225
227
  user_name: owner,
226
228
  });
@@ -247,9 +249,10 @@ const checkLiveStatusAndRecord = async function ({ getSavePath, banLiveId, isMan
247
249
  return;
248
250
  switch (msg.type) {
249
251
  case "chatmsg": {
252
+ const timestamp = this.useServerTimestamp ? Number(msg.cst) : Date.now();
250
253
  const comment = {
251
254
  type: "comment",
252
- timestamp: Number(msg.cst),
255
+ timestamp: timestamp,
253
256
  text: msg.txt,
254
257
  color: colorTab[msg.col] ?? "#ffffff",
255
258
  sender: {
package/lib/stream.d.ts CHANGED
@@ -12,6 +12,7 @@ export declare function getStream(opts: Pick<Recorder, "channelId" | "quality">
12
12
  rejectCache?: boolean;
13
13
  strictQuality?: boolean;
14
14
  source?: string;
15
+ onlyAudio?: boolean;
15
16
  }): Promise<{
16
17
  living: true;
17
18
  sources: import("./dy_api.js").SourceProfile[];
package/lib/stream.js CHANGED
@@ -48,6 +48,7 @@ export async function getStream(opts) {
48
48
  channelId: opts.channelId,
49
49
  rate: qn,
50
50
  cdn: opts.source === "auto" ? undefined : opts.source,
51
+ onlyAudio: opts.onlyAudio,
51
52
  });
52
53
  if (!liveInfo.living)
53
54
  throw new Error("It must be called getStream when living");
@@ -68,6 +69,7 @@ export async function getStream(opts) {
68
69
  liveInfo = await getLiveInfo({
69
70
  channelId: opts.channelId,
70
71
  rate: liveInfo.streams[0].rate,
72
+ onlyAudio: opts.onlyAudio,
71
73
  });
72
74
  if (!liveInfo.living)
73
75
  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.0",
3
+ "version": "1.5.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.3.0"
44
+ "@bililive-tools/manager": "^1.4.0"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@types/ws": "^8.5.13"