@bililive-tools/douyin-recorder 1.12.3 → 1.16.1

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
@@ -84,14 +84,14 @@ const { id } = await provider.resolveChannelInfoFromURL(url);
84
84
 
85
85
  `mobile` 及 `userHTML` 必须传入 `uid` 参数
86
86
 
87
- | 描述 | 备注 |
88
- | ---------------- | ---------------------------------------- |
89
- | web直播间接口 | 效果不错 |
90
- | mobile直播间接口 | 不易风控,无验证码,海外IP可能无法使用 |
91
- | 直播间web解析 | 易风控,有验证码,单个接口1M流量 |
92
- | 用户web解析 | 不易风控,海外IP无法使用,单个接口1M流量 |
93
- | 负载均衡 | 使用负载均衡算法来分摊防止风控 |
94
- | 随机 | 从几个接口里挑一个 |
87
+ | 描述 | 备注 |
88
+ | ---------------- | ------------------------------------------------------ |
89
+ | web直播间接口 | 效果不错 |
90
+ | mobile直播间接口 | 不易风控,无验证码,海外IP可能无法使用,不会应用Cookie |
91
+ | 直播间web解析 | 易风控,有验证码,单个接口1M流量 |
92
+ | 用户web解析 | 不易风控,海外IP无法使用,单个接口1M流量 |
93
+ | 负载均衡 | 使用负载均衡算法来分摊防止风控 |
94
+ | 随机 | 从几个接口里挑一个 |
95
95
 
96
96
  # 协议
97
97
 
package/lib/douyin_api.js CHANGED
@@ -153,6 +153,9 @@ async function getRoomInfoByUserWeb(secUserId, opts = {}) {
153
153
  if (res.data.includes("验证码")) {
154
154
  throw new Error("需要验证码,请在浏览器中打开链接获取" + url);
155
155
  }
156
+ if (!res.data.includes("抖音号")) {
157
+ throw new Error("userHTML页面没有正常加载" + String(res.data));
158
+ }
156
159
  if (!res.data.includes("直播中")) {
157
160
  return {
158
161
  living: false,
@@ -344,6 +347,7 @@ async function getRoomInfoByWeb(webRoomId, opts = {}) {
344
347
  }
345
348
  async function getRoomInfoByMobile(secUserId, opts = {}) {
346
349
  if (!secUserId) {
350
+ console.error(opts);
347
351
  throw new Error("Mobile API need secUserId, please set uid field");
348
352
  }
349
353
  if (typeof secUserId === "number") {
@@ -360,7 +364,7 @@ async function getRoomInfoByMobile(secUserId, opts = {}) {
360
364
  const res = await requester.get(`https://webcast.amemv.com/webcast/room/reflow/info/`, {
361
365
  params,
362
366
  headers: {
363
- cookie: opts.auth,
367
+ // cookie: opts.auth,
364
368
  },
365
369
  });
366
370
  // @ts-ignore
package/lib/index.js CHANGED
@@ -2,7 +2,7 @@ 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 } from "./stream.js";
5
- import { ensureFolderExist, singleton } from "./utils.js";
5
+ import { singleton } from "./utils.js";
6
6
  import { resolveShortURL, parseUser } from "./douyin_api.js";
7
7
  import DouYinDanmaClient from "douyin-danma-listener";
8
8
  function createRecorder(opts) {
@@ -164,6 +164,7 @@ const checkLiveStatusAndRecord = async function ({ getSavePath, banLiveId, isMan
164
164
  startTime: opts.startTime,
165
165
  liveStartTime: liveStartTime,
166
166
  recordStartTime,
167
+ extraMs: opts.extraMs,
167
168
  }),
168
169
  disableDanma: this.disableProvideCommentsWhenRecording,
169
170
  videoFormat: this.videoFormat ?? "auto",
@@ -178,20 +179,6 @@ const checkLiveStatusAndRecord = async function ({ getSavePath, banLiveId, isMan
178
179
  });
179
180
  return info;
180
181
  });
181
- const savePath = getSavePath({
182
- owner,
183
- title,
184
- startTime: Date.now(),
185
- liveStartTime,
186
- recordStartTime,
187
- });
188
- try {
189
- ensureFolderExist(savePath);
190
- }
191
- catch (err) {
192
- this.state = "idle";
193
- throw err;
194
- }
195
182
  const handleVideoCreated = async ({ filename, title, cover, rawFilename }) => {
196
183
  this.emit("videoFileCreated", { filename, cover, rawFilename });
197
184
  if (title && this?.liveInfo) {
@@ -211,8 +198,8 @@ const checkLiveStatusAndRecord = async function ({ getSavePath, banLiveId, isMan
211
198
  });
212
199
  };
213
200
  downloader.on("videoFileCreated", handleVideoCreated);
214
- downloader.on("videoFileCompleted", ({ filename }) => {
215
- this.emit("videoFileCompleted", { filename });
201
+ downloader.on("videoFileCompleted", (data) => {
202
+ this.emit("videoFileCompleted", data);
216
203
  });
217
204
  downloader.on("DebugLog", (data) => {
218
205
  this.emit("DebugLog", data);
@@ -428,7 +415,7 @@ const checkLiveStatusAndRecord = async function ({ getSavePath, banLiveId, isMan
428
415
  recorderType: downloader.type,
429
416
  url: stream.url,
430
417
  downloaderArgs,
431
- savePath: savePath,
418
+ savePath: downloader.videoFilePath,
432
419
  stop,
433
420
  cut,
434
421
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bililive-tools/douyin-recorder",
3
- "version": "1.12.3",
3
+ "version": "1.16.1",
4
4
  "description": "@bililive-tools douyin recorder implemention",
5
5
  "main": "./lib/index.js",
6
6
  "type": "module",
@@ -38,8 +38,8 @@
38
38
  "lodash-es": "^4.17.21",
39
39
  "mitt": "^3.0.1",
40
40
  "sm-crypto": "^0.3.13",
41
- "@bililive-tools/manager": "^1.14.1",
42
- "douyin-danma-listener": "0.4.1"
41
+ "douyin-danma-listener": "0.4.1",
42
+ "@bililive-tools/manager": "^1.16.1"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@types/node": "*"