@ikenxuan/amagi 4.4.8 → 4.4.9

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.
@@ -66,6 +66,500 @@ var BiLiBiLiAPI = class {
66
66
  }
67
67
  };
68
68
  var bilibiliAPI = new BiLiBiLiAPI();
69
+ var bilibiliApiUrls = new BiLiBiLiAPI();
70
+
71
+ // src/platform/bilibili/qtparam.ts
72
+ async function qtparam(BASEURL, cookie) {
73
+ if (cookie === "") return { QUERY: "&platform=html5", STATUS: "!isLogin" };
74
+ const logininfo = await new Networks({ url: bilibiliAPI.\u767B\u5F55\u57FA\u672C\u4FE1\u606F(), headers: { Cookie: cookie } }).getData();
75
+ const sign = await wbi_sign(BASEURL, cookie);
76
+ const qn = [6, 16, 32, 64, 74, 80, 112, 116, 120, 125, 126, 127];
77
+ let isvip;
78
+ logininfo.data.vipStatus === 1 ? isvip = true : isvip = false;
79
+ if (isvip) {
80
+ return { QUERY: `&fnval=16&fourk=1&${sign}`, STATUS: "isLogin", isvip };
81
+ } else return { QUERY: `&qn=${qn[3]}&fnval=16`, STATUS: "isLogin", isvip };
82
+ }
83
+ var mixinKeyEncTab = [
84
+ 46,
85
+ 47,
86
+ 18,
87
+ 2,
88
+ 53,
89
+ 8,
90
+ 23,
91
+ 32,
92
+ 15,
93
+ 50,
94
+ 10,
95
+ 31,
96
+ 58,
97
+ 3,
98
+ 45,
99
+ 35,
100
+ 27,
101
+ 43,
102
+ 5,
103
+ 49,
104
+ 33,
105
+ 9,
106
+ 42,
107
+ 19,
108
+ 29,
109
+ 28,
110
+ 14,
111
+ 39,
112
+ 12,
113
+ 38,
114
+ 41,
115
+ 13,
116
+ 37,
117
+ 48,
118
+ 7,
119
+ 16,
120
+ 24,
121
+ 55,
122
+ 40,
123
+ 61,
124
+ 26,
125
+ 17,
126
+ 0,
127
+ 1,
128
+ 60,
129
+ 51,
130
+ 30,
131
+ 4,
132
+ 22,
133
+ 25,
134
+ 54,
135
+ 21,
136
+ 56,
137
+ 59,
138
+ 6,
139
+ 63,
140
+ 57,
141
+ 62,
142
+ 11,
143
+ 36,
144
+ 20,
145
+ 34,
146
+ 44,
147
+ 52
148
+ ];
149
+ var getMixinKey = (orig) => mixinKeyEncTab.map((n) => orig[n]).join("").slice(0, 32);
150
+ function encWbi(params, img_key, sub_key) {
151
+ const mixin_key = getMixinKey(img_key + sub_key);
152
+ const curr_time = Math.round(Date.now() / 1e3);
153
+ const chr_filter = /[!'()*]/g;
154
+ Object.assign(params, { wts: curr_time });
155
+ const query = Object.keys(params).sort().map((key) => {
156
+ const value = params[key].toString().replace(chr_filter, "");
157
+ return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
158
+ }).join("&");
159
+ const wbi_sign2 = crypto.createHash("md5").update(query + mixin_key).digest("hex");
160
+ return `&wts=${curr_time}&w_rid=${wbi_sign2}`;
161
+ }
162
+ async function getWbiKeys(cookie) {
163
+ const res = await axios("https://api.bilibili.com/x/web-interface/nav", {
164
+ headers: {
165
+ Cookie: cookie
166
+ }
167
+ });
168
+ const responseJson = res.data;
169
+ const response = responseJson;
170
+ const {
171
+ data: {
172
+ wbi_img: { img_url, sub_url }
173
+ }
174
+ } = response;
175
+ return {
176
+ img_key: img_url.slice(img_url.lastIndexOf("/") + 1, img_url.lastIndexOf(".")),
177
+ sub_key: sub_url.slice(sub_url.lastIndexOf("/") + 1, sub_url.lastIndexOf("."))
178
+ };
179
+ }
180
+ async function wbi_sign(BASEURL, cookie) {
181
+ const web_keys = await getWbiKeys(cookie);
182
+ const url = new URL(BASEURL);
183
+ const params = {};
184
+ for (const [key, value] of url.searchParams.entries()) {
185
+ params[key] = value;
186
+ }
187
+ const query = encWbi(params, web_keys.img_key, web_keys.sub_key);
188
+ return query;
189
+ }
190
+
191
+ // src/platform/bilibili/sign/bv2av.ts
192
+ var XOR_CODE = 23442827791579n;
193
+ var MASK_CODE = 2251799813685247n;
194
+ var MAX_AID = 1n << 51n;
195
+ var BASE = 58n;
196
+ var data = "FcwAPNKTMug3GV5Lj7EJnHpWsx4tb8haYeviqBz6rkCy12mUSDQX9RdoZf";
197
+ function av2bv(aid) {
198
+ const bytes = ["B", "V", "1", "0", "0", "0", "0", "0", "0", "0", "0", "0"];
199
+ let bvIndex = bytes.length - 1;
200
+ let tmp = (MAX_AID | BigInt(aid)) ^ XOR_CODE;
201
+ while (tmp > 0) {
202
+ bytes[bvIndex] = data[Number(tmp % BigInt(BASE))];
203
+ tmp = tmp / BASE;
204
+ bvIndex -= 1;
205
+ }
206
+ [bytes[3], bytes[9]] = [bytes[9], bytes[3]];
207
+ [bytes[4], bytes[7]] = [bytes[7], bytes[4]];
208
+ return bytes.join("");
209
+ }
210
+ function bv2av(bvid) {
211
+ const bvidArr = Array.from(bvid);
212
+ [bvidArr[3], bvidArr[9]] = [bvidArr[9], bvidArr[3]];
213
+ [bvidArr[4], bvidArr[7]] = [bvidArr[7], bvidArr[4]];
214
+ bvidArr.splice(0, 3);
215
+ const tmp = bvidArr.reduce((pre, bvidChar) => pre * BASE + BigInt(data.indexOf(bvidChar)), 0n);
216
+ return Number(tmp & MASK_CODE ^ XOR_CODE);
217
+ }
218
+
219
+ // src/platform/bilibili/BilibiliApi.ts
220
+ var bilibili = {
221
+ /**
222
+ * 获取单个视频作品数据
223
+ * @param options 请求参数,包含 bvid 和可选的 typeMode
224
+ * @param cookie 有效的用户 Cookie
225
+ * @returns 接口返回的原始数据
226
+ */
227
+ async getVideoInfo(options, cookie) {
228
+ const { typeMode, ...restOptions } = options;
229
+ const data2 = await BilibiliData({ ...restOptions, methodType: "\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E" }, cookie);
230
+ return data2;
231
+ },
232
+ /**
233
+ * 获取单个视频下载信息数据
234
+ * @param options 请求参数,包含 avid, cid 和可选的 typeMode
235
+ * @param cookie 有效的用户 Cookie
236
+ * @returns 接口返回的原始数据
237
+ */
238
+ async getVideoStream(options, cookie) {
239
+ const { typeMode, ...restOptions } = options;
240
+ const data2 = await BilibiliData({ ...restOptions, methodType: "\u5355\u4E2A\u89C6\u9891\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E" }, cookie);
241
+ return data2;
242
+ },
243
+ /**
244
+ * 获取评论数据
245
+ * @param options 请求参数,包含 type, oid, 可选的 number, pn 和 typeMode
246
+ * @param cookie 有效的用户 Cookie
247
+ * @returns 接口返回的原始数据
248
+ */
249
+ async getComments(options, cookie) {
250
+ const { typeMode, ...restOptions } = options;
251
+ const data2 = await BilibiliData({ ...restOptions, methodType: "\u8BC4\u8BBA\u6570\u636E" }, cookie);
252
+ return data2;
253
+ },
254
+ /**
255
+ * 获取用户主页数据
256
+ * @param options 请求参数,包含 host_mid 和可选的 typeMode
257
+ * @param cookie 有效的用户 Cookie
258
+ * @returns 接口返回的原始数据
259
+ */
260
+ async getUserProfile(options, cookie) {
261
+ const { typeMode, ...restOptions } = options;
262
+ const data2 = await BilibiliData({ ...restOptions, methodType: "\u7528\u6237\u4E3B\u9875\u6570\u636E" }, cookie);
263
+ return data2;
264
+ },
265
+ /**
266
+ * 获取用户主页动态列表数据
267
+ * @param options 请求参数,包含 host_mid 和可选的 typeMode
268
+ * @param cookie 有效的用户 Cookie
269
+ * @returns 接口返回的原始数据
270
+ */
271
+ async getUserDynamic(options, cookie) {
272
+ const { typeMode, ...restOptions } = options;
273
+ const data2 = await BilibiliData({ ...restOptions, methodType: "\u7528\u6237\u4E3B\u9875\u52A8\u6001\u5217\u8868\u6570\u636E" }, cookie);
274
+ return data2;
275
+ },
276
+ /**
277
+ * 获取 Emoji 数据
278
+ * @param options 可选的请求参数 (主要用于 typeMode)
279
+ * @param cookie 有效的用户 Cookie
280
+ * @returns 接口返回的原始数据
281
+ */
282
+ async getEmojiList(options, cookie) {
283
+ const { typeMode, ...restOptions } = options;
284
+ const data2 = await BilibiliData({ ...restOptions, methodType: "Emoji\u6570\u636E" }, cookie);
285
+ return data2;
286
+ },
287
+ /**
288
+ * 获取番剧基本信息数据
289
+ * @param options 请求参数,包含可选的 season_id, ep_id 和 typeMode
290
+ * @param cookie 有效的用户 Cookie
291
+ * @returns 接口返回的原始数据
292
+ */
293
+ async getBangumiInfo(options, cookie) {
294
+ const { typeMode, ...restOptions } = options;
295
+ const data2 = await BilibiliData({ ...restOptions, methodType: "\u756A\u5267\u57FA\u672C\u4FE1\u606F\u6570\u636E" }, cookie);
296
+ return data2;
297
+ },
298
+ /**
299
+ * 获取番剧下载信息数据
300
+ * @param options 请求参数,包含 cid, ep_id 和可选的 typeMode
301
+ * @param cookie 有效的用户 Cookie
302
+ * @returns 接口返回的原始数据
303
+ */
304
+ async getBangumiStream(options, cookie) {
305
+ const { typeMode, ...restOptions } = options;
306
+ const data2 = await BilibiliData({ ...restOptions, methodType: "\u756A\u5267\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E" }, cookie);
307
+ return data2;
308
+ },
309
+ /**
310
+ * 获取动态详情数据
311
+ * @param options 请求参数,包含 dynamic_id 和可选的 typeMode
312
+ * @param cookie 有效的用户 Cookie
313
+ * @returns 接口返回的原始数据
314
+ */
315
+ async getDynamicInfo(options, cookie) {
316
+ const { typeMode, ...restOptions } = options;
317
+ const data2 = await BilibiliData({ ...restOptions, methodType: "\u52A8\u6001\u8BE6\u60C5\u6570\u636E" }, cookie);
318
+ return data2;
319
+ },
320
+ /**
321
+ * 获取动态卡片数据
322
+ * @param options 请求参数,包含 dynamic_id 和可选的 typeMode
323
+ * @param cookie 有效的用户 Cookie
324
+ * @returns 接口返回的原始数据
325
+ */
326
+ async getDynamicCard(options, cookie) {
327
+ const { typeMode, ...restOptions } = options;
328
+ const data2 = await BilibiliData({ ...restOptions, methodType: "\u52A8\u6001\u5361\u7247\u6570\u636E" }, cookie);
329
+ return data2;
330
+ },
331
+ /**
332
+ * 获取直播间信息
333
+ * @param options 请求参数,包含 room_id 和可选的 typeMode
334
+ * @param cookie 有效的用户 Cookie
335
+ * @returns 接口返回的原始数据
336
+ */
337
+ async getLiveRoomDetail(options, cookie) {
338
+ const { typeMode, ...restOptions } = options;
339
+ const data2 = await BilibiliData({ ...restOptions, methodType: "\u76F4\u64AD\u95F4\u4FE1\u606F" }, cookie);
340
+ return data2;
341
+ },
342
+ /**
343
+ * 获取直播间初始化信息
344
+ * @param options 请求参数,包含 room_id 和可选的 typeMode
345
+ * @param cookie 有效的用户 Cookie
346
+ * @returns 接口返回的原始数据
347
+ */
348
+ async getLiveRoomInitInfo(options, cookie) {
349
+ const { typeMode, ...restOptions } = options;
350
+ const data2 = await BilibiliData({ ...restOptions, methodType: "\u76F4\u64AD\u95F4\u521D\u59CB\u5316\u4FE1\u606F" }, cookie);
351
+ return data2;
352
+ },
353
+ /**
354
+ * 获取登录基本信息
355
+ * @param options 可选的请求参数 (主要用于 typeMode)
356
+ * @param cookie 有效的用户 Cookie
357
+ * @returns 接口返回的原始数据
358
+ */
359
+ async getLoginBasicInfo(options, cookie) {
360
+ const { typeMode, ...restOptions } = options;
361
+ const data2 = await BilibiliData({ ...restOptions, methodType: "\u767B\u5F55\u57FA\u672C\u4FE1\u606F" }, cookie);
362
+ return data2;
363
+ },
364
+ /**
365
+ * 申请登录二维码
366
+ * @param options 可选的请求参数 (主要用于 typeMode)
367
+ * @param cookie 有效的用户 Cookie
368
+ * @returns 接口返回的原始数据
369
+ */
370
+ async getLoginQrcode(options, cookie) {
371
+ const { typeMode, ...restOptions } = options;
372
+ const data2 = await BilibiliData({ ...restOptions, methodType: "\u7533\u8BF7\u4E8C\u7EF4\u7801" }, cookie);
373
+ return data2;
374
+ },
375
+ /**
376
+ * 检查二维码状态
377
+ * @param options 请求参数,包含 qrcode_key 和可选的 typeMode
378
+ * @param cookie 有效的用户 Cookie
379
+ * @returns 接口返回的原始数据
380
+ */
381
+ async checkQrcodeStatus(options, cookie) {
382
+ const { typeMode, ...restOptions } = options;
383
+ const data2 = await BilibiliData({ ...restOptions, methodType: "\u4E8C\u7EF4\u7801\u72B6\u6001" }, cookie);
384
+ return data2;
385
+ },
386
+ /**
387
+ * 获取 UP 主总播放量
388
+ * @param options 请求参数,包含 host_mid 和可选的 typeMode
389
+ * @param cookie 有效的用户 Cookie
390
+ * @returns 接口返回的原始数据
391
+ */
392
+ async getUserTotalPlayCount(options, cookie) {
393
+ const { typeMode, ...restOptions } = options;
394
+ const data2 = await BilibiliData({ ...restOptions, methodType: "\u83B7\u53D6UP\u4E3B\u603B\u64AD\u653E\u91CF" }, cookie);
395
+ return data2;
396
+ },
397
+ /**
398
+ * 将 AV 号转换为 BV 号
399
+ * @param options 请求参数,包含 avid
400
+ * @param cookie 有效的用户 Cookie (此接口通常不需要)
401
+ * @returns 接口返回的原始数据
402
+ */
403
+ async convertAvToBv(options, cookie) {
404
+ const { typeMode, ...restOptions } = options;
405
+ const data2 = await BilibiliData({ ...restOptions, methodType: "AV\u8F6CBV" }, cookie);
406
+ return data2;
407
+ },
408
+ /**
409
+ * 将 BV 号转换为 AV 号
410
+ * @param options 请求参数,包含 bvid
411
+ * @param cookie 有效的用户 Cookie (此接口通常不需要)
412
+ * @returns 接口返回的原始数据
413
+ */
414
+ async convertBvToAv(options, cookie) {
415
+ const { typeMode, ...restOptions } = options;
416
+ const data2 = await BilibiliData({ ...restOptions, methodType: "BV\u8F6CAV" }, cookie);
417
+ return data2;
418
+ }
419
+ };
420
+ var registerBilibiliRoutes = (cookie) => {
421
+ const router = express.Router();
422
+ router.get("/new_login_qrcode", async (req, res) => {
423
+ const data2 = await BilibiliData({
424
+ methodType: "\u7533\u8BF7\u4E8C\u7EF4\u7801"
425
+ }, req.headers.cookie || cookie);
426
+ res.json(data2);
427
+ });
428
+ router.get("/check_qrcode", async (req, res) => {
429
+ const data2 = await BilibiliData({
430
+ methodType: "\u4E8C\u7EF4\u7801\u72B6\u6001",
431
+ qrcode_key: req.query.qrcode_key
432
+ }, req.headers.cookie || cookie);
433
+ res.json(data2);
434
+ });
435
+ router.get("/login_basic_info", async (req, res) => {
436
+ const data2 = await BilibiliData({
437
+ methodType: "\u767B\u5F55\u57FA\u672C\u4FE1\u606F"
438
+ }, req.headers.cookie || cookie);
439
+ res.json(data2);
440
+ });
441
+ router.get("/fetch_one_video", async (req, res) => {
442
+ const data2 = await BilibiliData({
443
+ methodType: "\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E",
444
+ bvid: req.query.bvid
445
+ }, req.headers.cookie || cookie);
446
+ res.json(data2);
447
+ });
448
+ router.get("/fetch_video_playurl", async (req, res) => {
449
+ const data2 = await BilibiliData({
450
+ methodType: "\u5355\u4E2A\u89C6\u9891\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E",
451
+ avid: parseInt(req.query.avid),
452
+ cid: parseInt(req.query.cid)
453
+ }, req.headers.cookie || cookie);
454
+ res.json(data2);
455
+ });
456
+ router.get("/fetch_work_comments", async (req, res) => {
457
+ const data2 = await BilibiliData({
458
+ methodType: "\u8BC4\u8BBA\u6570\u636E",
459
+ oid: Number(req.query.oid),
460
+ number: Number(req.query.number),
461
+ type: Number(req.query.type ?? 1)
462
+ }, req.headers.cookie || cookie);
463
+ res.json(data2);
464
+ });
465
+ router.get("/fetch_work_comments", async (req, res) => {
466
+ const data2 = await BilibiliData({
467
+ methodType: "Emoji\u6570\u636E"
468
+ }, req.headers.cookie || cookie);
469
+ res.json(data2);
470
+ });
471
+ router.get("/fetch_bangumi_video_info", async (req, res) => {
472
+ const data2 = await BilibiliData({
473
+ methodType: "\u756A\u5267\u57FA\u672C\u4FE1\u606F\u6570\u636E",
474
+ ep_id: req.query.ep_id
475
+ }, req.headers.cookie || cookie);
476
+ res.json(data2);
477
+ });
478
+ router.get("/fetch_bangumi_video_playurl", async (req, res) => {
479
+ const data2 = await BilibiliData({
480
+ methodType: "\u756A\u5267\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E",
481
+ cid: parseInt(req.query.cid),
482
+ ep_id: req.query.ep_id
483
+ }, req.headers.cookie || cookie);
484
+ res.json(data2);
485
+ });
486
+ router.get("/fetch_user_dynamic", async (req, res) => {
487
+ const data2 = await BilibiliData({
488
+ methodType: "\u7528\u6237\u4E3B\u9875\u52A8\u6001\u5217\u8868\u6570\u636E",
489
+ host_mid: parseInt(req.query.host_mid)
490
+ }, req.headers.cookie || cookie);
491
+ res.json(data2);
492
+ });
493
+ router.get("/fetch_dynamic_info", async (req, res) => {
494
+ const data2 = await BilibiliData({
495
+ methodType: "\u52A8\u6001\u8BE6\u60C5\u6570\u636E",
496
+ dynamic_id: req.query.dynamic_id
497
+ }, req.headers.cookie || cookie);
498
+ res.json(data2);
499
+ });
500
+ router.get("/fetch_dynamic_card", async (req, res) => {
501
+ const data2 = await BilibiliData({
502
+ methodType: "\u52A8\u6001\u5361\u7247\u6570\u636E",
503
+ dynamic_id: req.query.dynamic_id
504
+ }, req.headers.cookie || cookie);
505
+ res.json(data2);
506
+ });
507
+ router.get("/fetch_user_profile", async (req, res) => {
508
+ const data2 = await BilibiliData({
509
+ methodType: "\u7528\u6237\u4E3B\u9875\u6570\u636E",
510
+ host_mid: parseInt(req.query.host_mid)
511
+ }, req.headers.cookie || cookie);
512
+ res.json(data2);
513
+ });
514
+ router.get("/fetch_live_room_detail", async (req, res) => {
515
+ const data2 = await BilibiliData({
516
+ methodType: "\u76F4\u64AD\u95F4\u4FE1\u606F",
517
+ room_id: req.query.room_id
518
+ }, req.headers.cookie || cookie);
519
+ res.json(data2);
520
+ });
521
+ router.get("/fetch_liveroom_def", async (req, res) => {
522
+ const data2 = await BilibiliData({
523
+ methodType: "\u76F4\u64AD\u95F4\u521D\u59CB\u5316\u4FE1\u606F",
524
+ room_id: req.query.room_id
525
+ }, req.headers.cookie || cookie);
526
+ res.json(data2);
527
+ });
528
+ router.get("/bv_to_av", async (req, res) => {
529
+ const data2 = await BilibiliData({
530
+ methodType: "BV\u8F6CAV",
531
+ bvid: req.query.bvid
532
+ }, req.headers.cookie || cookie);
533
+ res.json(data2);
534
+ });
535
+ router.get("/av_to_bv", async (req, res) => {
536
+ const data2 = await BilibiliData({
537
+ methodType: "AV\u8F6CBV",
538
+ avid: parseInt(req.query.avid)
539
+ }, req.headers.cookie || cookie);
540
+ res.json(data2);
541
+ });
542
+ router.get("/fetch_user_full_view", async (req, res) => {
543
+ const data2 = await BilibiliData({
544
+ methodType: "\u83B7\u53D6UP\u4E3B\u603B\u64AD\u653E\u91CF",
545
+ host_mid: parseInt(req.query.host_mid)
546
+ }, req.headers.cookie || cookie);
547
+ res.json(data2);
548
+ });
549
+ return router;
550
+ };
551
+
552
+ // src/platform/bilibili/index.ts
553
+ var bilibiliUtils = {
554
+ sign: {
555
+ wbi_sign,
556
+ av2bv,
557
+ bv2av
558
+ },
559
+ bilibiliApiUrls,
560
+ getBilibiliData,
561
+ api: bilibili
562
+ };
69
563
 
70
564
  // src/platform/bilibili/getdata.ts
71
565
  var defheaders = {
@@ -173,515 +667,237 @@ var BilibiliData = async (data2, cookie) => {
173
667
  ...tmpresp,
174
668
  data: {
175
669
  ...tmpresp.data,
176
- // 去重
177
- replies: Array.from(new Map(fetchedComments.map((item) => [item.rpid, item])).values()).slice(0, Number(data2.number))
178
- }
179
- };
180
- return finalResponse;
181
- }
182
- case "Emoji\u6570\u636E": {
183
- return await GlobalGetData({
184
- url: bilibiliAPI.\u8868\u60C5\u5217\u8868(),
185
- ...data2
186
- });
187
- }
188
- case "\u756A\u5267\u57FA\u672C\u4FE1\u606F\u6570\u636E": {
189
- let id = data2.ep_id ? data2.ep_id : data2.season_id;
190
- if (!id) {
191
- BilibiliValidateData(data2, ["ep_id"]);
192
- return false;
193
- }
194
- const idType = id ? id.startsWith("ep") ? "ep_id" : "season_id" : "ep_id";
195
- const newId = idType === "ep_id" ? id.replace("ep", "") : id.replace("ss", "");
196
- const INFO = await GlobalGetData({
197
- url: bilibiliAPI.\u756A\u5267\u660E\u7EC6({ [idType]: newId }),
198
- headers: headers2,
199
- ...data2
200
- });
201
- return INFO;
202
- }
203
- case "\u756A\u5267\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E": {
204
- BilibiliValidateData(data2, ["cid", "ep_id"]);
205
- const BASEURL = bilibiliAPI.\u756A\u5267\u89C6\u9891\u6D41\u4FE1\u606F({ cid: data2.cid, ep_id: data2.ep_id.replace("ep", "") });
206
- const SIGN = await qtparam(BASEURL, headers2.cookie);
207
- const DATA = await GlobalGetData({
208
- url: bilibiliAPI.\u756A\u5267\u89C6\u9891\u6D41\u4FE1\u606F({ cid: data2.cid, ep_id: data2.ep_id.replace("ep", "") }) + SIGN.QUERY,
209
- headers: headers2,
210
- ...data2
211
- });
212
- return DATA;
213
- }
214
- case "\u7528\u6237\u4E3B\u9875\u52A8\u6001\u5217\u8868\u6570\u636E": {
215
- BilibiliValidateData(data2, ["host_mid"]);
216
- delete headers2.referer;
217
- const { host_mid } = data2;
218
- const result = await GlobalGetData({
219
- url: bilibiliAPI.\u7528\u6237\u7A7A\u95F4\u52A8\u6001({ host_mid }),
220
- headers: headers2,
221
- ...data2
222
- });
223
- return result;
224
- }
225
- case "\u52A8\u6001\u8BE6\u60C5\u6570\u636E": {
226
- BilibiliValidateData(data2, ["dynamic_id"]);
227
- delete headers2.referer;
228
- const dynamicINFO = await GlobalGetData({
229
- url: bilibiliAPI.\u52A8\u6001\u8BE6\u60C5({ dynamic_id: data2.dynamic_id }),
230
- headers: headers2,
231
- ...data2
232
- });
233
- return dynamicINFO;
234
- }
235
- case "\u52A8\u6001\u5361\u7247\u6570\u636E": {
236
- BilibiliValidateData(data2, ["dynamic_id"]);
237
- delete headers2.referer;
238
- const { dynamic_id } = data2;
239
- const dynamicINFO_CARD = await GlobalGetData({
240
- url: bilibiliAPI.\u52A8\u6001\u5361\u7247\u4FE1\u606F({ dynamic_id }),
241
- headers: headers2,
242
- ...data2
243
- });
244
- return dynamicINFO_CARD;
245
- }
246
- case "\u7528\u6237\u4E3B\u9875\u6570\u636E": {
247
- BilibiliValidateData(data2, ["host_mid"]);
248
- const { host_mid } = data2;
249
- const result = await GlobalGetData({
250
- url: bilibiliAPI.\u7528\u6237\u540D\u7247\u4FE1\u606F({ host_mid }),
251
- headers: headers2,
252
- ...data2
253
- });
254
- return result;
255
- }
256
- case "\u76F4\u64AD\u95F4\u4FE1\u606F": {
257
- BilibiliValidateData(data2, ["room_id"]);
258
- const result = await GlobalGetData({
259
- url: bilibiliAPI.\u76F4\u64AD\u95F4\u4FE1\u606F({ room_id: data2.room_id }),
260
- headers: headers2,
261
- ...data2
262
- });
263
- return result;
670
+ // 去重
671
+ replies: Array.from(new Map(fetchedComments.map((item) => [item.rpid, item])).values()).slice(0, Number(data2.number))
672
+ }
673
+ };
674
+ return finalResponse;
264
675
  }
265
- case "\u76F4\u64AD\u95F4\u521D\u59CB\u5316\u4FE1\u606F": {
266
- BilibiliValidateData(data2, ["room_id"]);
267
- const result = await GlobalGetData({
268
- url: bilibiliAPI.\u76F4\u64AD\u95F4\u521D\u59CB\u5316\u4FE1\u606F({ room_id: data2.room_id }),
269
- headers: headers2,
676
+ case "Emoji\u6570\u636E": {
677
+ return await GlobalGetData({
678
+ url: bilibiliAPI.\u8868\u60C5\u5217\u8868(),
270
679
  ...data2
271
680
  });
272
- return result;
273
681
  }
274
- case "\u7533\u8BF7\u4E8C\u7EF4\u7801": {
275
- const result = await GlobalGetData({
276
- url: bilibiliAPI.\u7533\u8BF7\u4E8C\u7EF4\u7801(),
682
+ case "\u756A\u5267\u57FA\u672C\u4FE1\u606F\u6570\u636E": {
683
+ let id = data2.ep_id ? data2.ep_id : data2.season_id;
684
+ if (!id) {
685
+ BilibiliValidateData(data2, ["ep_id"]);
686
+ return false;
687
+ }
688
+ const idType = id ? id.startsWith("ep") ? "ep_id" : "season_id" : "ep_id";
689
+ const newId = idType === "ep_id" ? id.replace("ep", "") : id.replace("ss", "");
690
+ const INFO = await GlobalGetData({
691
+ url: bilibiliAPI.\u756A\u5267\u660E\u7EC6({ [idType]: newId }),
277
692
  headers: headers2,
278
693
  ...data2
279
694
  });
280
- return result;
695
+ return INFO;
281
696
  }
282
- case "\u4E8C\u7EF4\u7801\u72B6\u6001": {
283
- BilibiliValidateData(data2, ["qrcode_key"]);
284
- const result = await new Networks({
285
- url: bilibiliAPI.\u4E8C\u7EF4\u7801\u72B6\u6001({ qrcode_key: data2.qrcode_key }),
697
+ case "\u756A\u5267\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E": {
698
+ BilibiliValidateData(data2, ["cid", "ep_id"]);
699
+ const BASEURL = bilibiliAPI.\u756A\u5267\u89C6\u9891\u6D41\u4FE1\u606F({ cid: data2.cid, ep_id: data2.ep_id.replace("ep", "") });
700
+ const SIGN = await qtparam(BASEURL, headers2.cookie);
701
+ const DATA = await GlobalGetData({
702
+ url: bilibiliAPI.\u756A\u5267\u89C6\u9891\u6D41\u4FE1\u606F({ cid: data2.cid, ep_id: data2.ep_id.replace("ep", "") }) + SIGN.QUERY,
286
703
  headers: headers2,
287
704
  ...data2
288
- }).getHeadersAndData();
289
- return result;
705
+ });
706
+ return DATA;
290
707
  }
291
- case "\u767B\u5F55\u57FA\u672C\u4FE1\u606F": {
708
+ case "\u7528\u6237\u4E3B\u9875\u52A8\u6001\u5217\u8868\u6570\u636E": {
709
+ BilibiliValidateData(data2, ["host_mid"]);
710
+ delete headers2.referer;
711
+ const { host_mid } = data2;
292
712
  const result = await GlobalGetData({
293
- url: bilibiliAPI.\u767B\u5F55\u57FA\u672C\u4FE1\u606F(),
713
+ url: bilibiliAPI.\u7528\u6237\u7A7A\u95F4\u52A8\u6001({ host_mid }),
294
714
  headers: headers2,
295
715
  ...data2
296
716
  });
297
717
  return result;
298
718
  }
299
- case "\u83B7\u53D6UP\u4E3B\u603B\u64AD\u653E\u91CF": {
300
- BilibiliValidateData(data2, ["host_mid"]);
301
- const result = await GlobalGetData({
302
- url: bilibiliAPI.\u83B7\u53D6UP\u4E3B\u603B\u64AD\u653E\u91CF({ host_mid: data2.host_mid }),
719
+ case "\u52A8\u6001\u8BE6\u60C5\u6570\u636E": {
720
+ BilibiliValidateData(data2, ["dynamic_id"]);
721
+ delete headers2.referer;
722
+ const dynamicINFO = await GlobalGetData({
723
+ url: bilibiliAPI.\u52A8\u6001\u8BE6\u60C5({ dynamic_id: data2.dynamic_id }),
303
724
  headers: headers2,
304
725
  ...data2
305
726
  });
306
- return result;
307
- }
308
- case "AV\u8F6CBV": {
309
- BilibiliValidateData(data2, ["avid"]);
310
- const result = av2bv(Number(data2.avid.toString().replace(/^av/i, "")));
311
- return {
312
- code: 0,
313
- message: "success",
314
- data: {
315
- bvid: result
316
- }
317
- };
318
- }
319
- case "BV\u8F6CAV": {
320
- BilibiliValidateData(data2, ["bvid"]);
321
- const result = "av" + bv2av(data2.bvid);
322
- return {
323
- code: 0,
324
- message: "success",
325
- data: {
326
- aid: result
327
- }
328
- };
727
+ return dynamicINFO;
329
728
  }
330
- default:
331
- return null;
332
- }
333
- };
334
- var GlobalGetData = async (options) => {
335
- const result = await new Networks(options).getData();
336
- if (result && result.code === 0) {
337
- return result;
338
- } else if (result.code === 12061) {
339
- logger.warn(`\u83B7\u53D6\u54CD\u5E94\u6570\u636E\u5931\u8D25\uFF01
340
- \u8BF7\u6C42\u63A5\u53E3\u7C7B\u578B\uFF1A${options.methodType}
341
- \u8BF7\u6C42URL\uFF1A${options.url}
342
- \u9519\u8BEF\u4EE3\u7801\uFF1A${result.code}\uFF0C
343
- \u542B\u4E49\uFF1A${result.message}`);
344
- return result;
345
- } else {
346
- const errorMessage = errorMap[result.code] || result.message || "\u672A\u77E5\u9519\u8BEF";
347
- logger.warn(`\u83B7\u53D6\u54CD\u5E94\u6570\u636E\u5931\u8D25\uFF01
348
- \u8BF7\u6C42\u63A5\u53E3\u7C7B\u578B\uFF1A${options.methodType}
349
- \u8BF7\u6C42URL\uFF1A${options.url}
350
- \u9519\u8BEF\u4EE3\u7801\uFF1A${result.code}\uFF0C
351
- \u542B\u4E49\uFF1A${errorMessage}`);
352
- return result;
353
- }
354
- };
355
- var errorMap = {
356
- "-1": "\u5E94\u7528\u7A0B\u5E8F\u4E0D\u5B58\u5728\u6216\u5DF2\u88AB\u5C01\u7981",
357
- "-2": "Access Key \u9519\u8BEF",
358
- "-3": "API \u6821\u9A8C\u5BC6\u5319\u9519\u8BEF",
359
- "-4": "\u8C03\u7528\u65B9\u5BF9\u8BE5 Method \u6CA1\u6709\u6743\u9650",
360
- "-101": "\u8D26\u53F7\u672A\u767B\u5F55",
361
- "-102": "\u8D26\u53F7\u88AB\u5C01\u505C",
362
- "-103": "\u79EF\u5206\u4E0D\u8DB3",
363
- "-104": "\u786C\u5E01\u4E0D\u8DB3",
364
- "-105": "\u9A8C\u8BC1\u7801\u9519\u8BEF",
365
- "-106": "\u8D26\u53F7\u975E\u6B63\u5F0F\u4F1A\u5458\u6216\u5728\u9002\u5E94\u671F",
366
- "-107": "\u5E94\u7528\u4E0D\u5B58\u5728\u6216\u8005\u88AB\u5C01\u7981",
367
- "-108": "\u672A\u7ED1\u5B9A\u624B\u673A",
368
- "-110": "\u672A\u7ED1\u5B9A\u624B\u673A",
369
- "-111": "csrf \u6821\u9A8C\u5931\u8D25",
370
- "-112": "\u7CFB\u7EDF\u5347\u7EA7\u4E2D",
371
- "-113": "\u8D26\u53F7\u5C1A\u672A\u5B9E\u540D\u8BA4\u8BC1",
372
- "-114": "\u8BF7\u5148\u7ED1\u5B9A\u624B\u673A",
373
- "-115": "\u8BF7\u5148\u5B8C\u6210\u5B9E\u540D\u8BA4\u8BC1",
374
- "-304": "\u6728\u6709\u6539\u52A8",
375
- "-307": "\u649E\u8F66\u8DF3\u8F6C",
376
- "-352": "\u98CE\u63A7\u6821\u9A8C\u5931\u8D25 (UA \u6216 wbi \u53C2\u6570\u4E0D\u5408\u6CD5)",
377
- "-400": "\u8BF7\u6C42\u9519\u8BEF",
378
- "-401": "\u672A\u8BA4\u8BC1 (\u6216\u975E\u6CD5\u8BF7\u6C42)",
379
- "-403": "\u8BBF\u95EE\u6743\u9650\u4E0D\u8DB3",
380
- "-404": "\u5565\u90FD\u6728\u6709",
381
- "-405": "\u4E0D\u652F\u6301\u8BE5\u65B9\u6CD5",
382
- "-409": "\u51B2\u7A81",
383
- "-412": "\u8BF7\u6C42\u88AB\u62E6\u622A (\u5BA2\u6237\u7AEF ip \u88AB\u670D\u52A1\u7AEF\u98CE\u63A7)",
384
- "-500": "\u670D\u52A1\u5668\u9519\u8BEF",
385
- "-503": "\u8FC7\u8F7D\u4FDD\u62A4,\u670D\u52A1\u6682\u4E0D\u53EF\u7528",
386
- "-504": "\u670D\u52A1\u8C03\u7528\u8D85\u65F6",
387
- "-509": "\u8D85\u51FA\u9650\u5236",
388
- "-616": "\u4E0A\u4F20\u6587\u4EF6\u4E0D\u5B58\u5728",
389
- "-617": "\u4E0A\u4F20\u6587\u4EF6\u592A\u5927",
390
- "-625": "\u767B\u5F55\u5931\u8D25\u6B21\u6570\u592A\u591A",
391
- "-626": "\u7528\u6237\u4E0D\u5B58\u5728",
392
- "-628": "\u5BC6\u7801\u592A\u5F31",
393
- "-629": "\u7528\u6237\u540D\u6216\u5BC6\u7801\u9519\u8BEF",
394
- "-632": "\u64CD\u4F5C\u5BF9\u8C61\u6570\u91CF\u9650\u5236",
395
- "-643": "\u88AB\u9501\u5B9A",
396
- "-650": "\u7528\u6237\u7B49\u7EA7\u592A\u4F4E",
397
- "-652": "\u91CD\u590D\u7684\u7528\u6237",
398
- "-658": "Token \u8FC7\u671F",
399
- "-662": "\u5BC6\u7801\u65F6\u95F4\u6233\u8FC7\u671F",
400
- "-688": "\u5730\u7406\u533A\u57DF\u9650\u5236",
401
- "-689": "\u7248\u6743\u9650\u5236",
402
- "-701": "\u6263\u8282\u64CD\u5931\u8D25",
403
- "-799": "\u8BF7\u6C42\u8FC7\u4E8E\u9891\u7E41\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5",
404
- "-8888": "\u5BF9\u4E0D\u8D77\uFF0C\u670D\u52A1\u5668\u5F00\u5C0F\u5DEE\u4E86~ (\u0CA5\uFE4F\u0CA5)"
405
- };
406
-
407
- // src/platform/bilibili/qtparam.ts
408
- async function qtparam(BASEURL, cookie) {
409
- if (cookie === "") return { QUERY: "&platform=html5", STATUS: "!isLogin" };
410
- const logininfo = await new Networks({ url: bilibiliAPI.\u767B\u5F55\u57FA\u672C\u4FE1\u606F(), headers: { Cookie: cookie } }).getData();
411
- const sign = await wbi_sign(BASEURL, cookie);
412
- const qn = [6, 16, 32, 64, 74, 80, 112, 116, 120, 125, 126, 127];
413
- let isvip;
414
- logininfo.data.vipStatus === 1 ? isvip = true : isvip = false;
415
- if (isvip) {
416
- return { QUERY: `&fnval=16&fourk=1&${sign}`, STATUS: "isLogin", isvip };
417
- } else return { QUERY: `&qn=${qn[3]}&fnval=16`, STATUS: "isLogin", isvip };
418
- }
419
- var mixinKeyEncTab = [
420
- 46,
421
- 47,
422
- 18,
423
- 2,
424
- 53,
425
- 8,
426
- 23,
427
- 32,
428
- 15,
429
- 50,
430
- 10,
431
- 31,
432
- 58,
433
- 3,
434
- 45,
435
- 35,
436
- 27,
437
- 43,
438
- 5,
439
- 49,
440
- 33,
441
- 9,
442
- 42,
443
- 19,
444
- 29,
445
- 28,
446
- 14,
447
- 39,
448
- 12,
449
- 38,
450
- 41,
451
- 13,
452
- 37,
453
- 48,
454
- 7,
455
- 16,
456
- 24,
457
- 55,
458
- 40,
459
- 61,
460
- 26,
461
- 17,
462
- 0,
463
- 1,
464
- 60,
465
- 51,
466
- 30,
467
- 4,
468
- 22,
469
- 25,
470
- 54,
471
- 21,
472
- 56,
473
- 59,
474
- 6,
475
- 63,
476
- 57,
477
- 62,
478
- 11,
479
- 36,
480
- 20,
481
- 34,
482
- 44,
483
- 52
484
- ];
485
- var getMixinKey = (orig) => mixinKeyEncTab.map((n) => orig[n]).join("").slice(0, 32);
486
- function encWbi(params, img_key, sub_key) {
487
- const mixin_key = getMixinKey(img_key + sub_key);
488
- const curr_time = Math.round(Date.now() / 1e3);
489
- const chr_filter = /[!'()*]/g;
490
- Object.assign(params, { wts: curr_time });
491
- const query = Object.keys(params).sort().map((key) => {
492
- const value = params[key].toString().replace(chr_filter, "");
493
- return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
494
- }).join("&");
495
- const wbi_sign2 = crypto.createHash("md5").update(query + mixin_key).digest("hex");
496
- return `&wts=${curr_time}&w_rid=${wbi_sign2}`;
497
- }
498
- async function getWbiKeys(cookie) {
499
- const res = await axios("https://api.bilibili.com/x/web-interface/nav", {
500
- headers: {
501
- Cookie: cookie
729
+ case "\u52A8\u6001\u5361\u7247\u6570\u636E": {
730
+ BilibiliValidateData(data2, ["dynamic_id"]);
731
+ delete headers2.referer;
732
+ const { dynamic_id } = data2;
733
+ const dynamicINFO_CARD = await GlobalGetData({
734
+ url: bilibiliAPI.\u52A8\u6001\u5361\u7247\u4FE1\u606F({ dynamic_id }),
735
+ headers: headers2,
736
+ ...data2
737
+ });
738
+ return dynamicINFO_CARD;
502
739
  }
503
- });
504
- const responseJson = res.data;
505
- const response = responseJson;
506
- const {
507
- data: {
508
- wbi_img: { img_url, sub_url }
740
+ case "\u7528\u6237\u4E3B\u9875\u6570\u636E": {
741
+ BilibiliValidateData(data2, ["host_mid"]);
742
+ const { host_mid } = data2;
743
+ const result = await GlobalGetData({
744
+ url: bilibiliAPI.\u7528\u6237\u540D\u7247\u4FE1\u606F({ host_mid }),
745
+ headers: headers2,
746
+ ...data2
747
+ });
748
+ return result;
509
749
  }
510
- } = response;
511
- return {
512
- img_key: img_url.slice(img_url.lastIndexOf("/") + 1, img_url.lastIndexOf(".")),
513
- sub_key: sub_url.slice(sub_url.lastIndexOf("/") + 1, sub_url.lastIndexOf("."))
514
- };
515
- }
516
- async function wbi_sign(BASEURL, cookie) {
517
- const web_keys = await getWbiKeys(cookie);
518
- const url = new URL(BASEURL);
519
- const params = {};
520
- for (const [key, value] of url.searchParams.entries()) {
521
- params[key] = value;
522
- }
523
- const query = encWbi(params, web_keys.img_key, web_keys.sub_key);
524
- return query;
525
- }
526
- var registerBilibiliRoutes = (cookie) => {
527
- const router = express.Router();
528
- router.get("/new_login_qrcode", async (req, res) => {
529
- const data2 = await BilibiliData({
530
- methodType: "\u7533\u8BF7\u4E8C\u7EF4\u7801"
531
- }, req.headers.cookie || cookie);
532
- res.json(data2);
533
- });
534
- router.get("/check_qrcode", async (req, res) => {
535
- const data2 = await BilibiliData({
536
- methodType: "\u4E8C\u7EF4\u7801\u72B6\u6001",
537
- qrcode_key: req.query.qrcode_key
538
- }, req.headers.cookie || cookie);
539
- res.json(data2);
540
- });
541
- router.get("/login_basic_info", async (req, res) => {
542
- const data2 = await BilibiliData({
543
- methodType: "\u767B\u5F55\u57FA\u672C\u4FE1\u606F"
544
- }, req.headers.cookie || cookie);
545
- res.json(data2);
546
- });
547
- router.get("/fetch_one_video", async (req, res) => {
548
- const data2 = await BilibiliData({
549
- methodType: "\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E",
550
- bvid: req.query.bvid
551
- }, req.headers.cookie || cookie);
552
- res.json(data2);
553
- });
554
- router.get("/fetch_video_playurl", async (req, res) => {
555
- const data2 = await BilibiliData({
556
- methodType: "\u5355\u4E2A\u89C6\u9891\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E",
557
- avid: parseInt(req.query.avid),
558
- cid: parseInt(req.query.cid)
559
- }, req.headers.cookie || cookie);
560
- res.json(data2);
561
- });
562
- router.get("/fetch_work_comments", async (req, res) => {
563
- const data2 = await BilibiliData({
564
- methodType: "\u8BC4\u8BBA\u6570\u636E",
565
- oid: Number(req.query.oid),
566
- number: Number(req.query.number),
567
- type: Number(req.query.type ?? 1)
568
- }, req.headers.cookie || cookie);
569
- res.json(data2);
570
- });
571
- router.get("/fetch_work_comments", async (req, res) => {
572
- const data2 = await BilibiliData({
573
- methodType: "Emoji\u6570\u636E"
574
- }, req.headers.cookie || cookie);
575
- res.json(data2);
576
- });
577
- router.get("/fetch_bangumi_video_info", async (req, res) => {
578
- const data2 = await BilibiliData({
579
- methodType: "\u756A\u5267\u57FA\u672C\u4FE1\u606F\u6570\u636E",
580
- ep_id: req.query.ep_id
581
- }, req.headers.cookie || cookie);
582
- res.json(data2);
583
- });
584
- router.get("/fetch_bangumi_video_playurl", async (req, res) => {
585
- const data2 = await BilibiliData({
586
- methodType: "\u756A\u5267\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E",
587
- cid: parseInt(req.query.cid),
588
- ep_id: req.query.ep_id
589
- }, req.headers.cookie || cookie);
590
- res.json(data2);
591
- });
592
- router.get("/fetch_user_dynamic", async (req, res) => {
593
- const data2 = await BilibiliData({
594
- methodType: "\u7528\u6237\u4E3B\u9875\u52A8\u6001\u5217\u8868\u6570\u636E",
595
- host_mid: parseInt(req.query.host_mid)
596
- }, req.headers.cookie || cookie);
597
- res.json(data2);
598
- });
599
- router.get("/fetch_dynamic_info", async (req, res) => {
600
- const data2 = await BilibiliData({
601
- methodType: "\u52A8\u6001\u8BE6\u60C5\u6570\u636E",
602
- dynamic_id: req.query.dynamic_id
603
- }, req.headers.cookie || cookie);
604
- res.json(data2);
605
- });
606
- router.get("/fetch_dynamic_card", async (req, res) => {
607
- const data2 = await BilibiliData({
608
- methodType: "\u52A8\u6001\u5361\u7247\u6570\u636E",
609
- dynamic_id: req.query.dynamic_id
610
- }, req.headers.cookie || cookie);
611
- res.json(data2);
612
- });
613
- router.get("/fetch_user_profile", async (req, res) => {
614
- const data2 = await BilibiliData({
615
- methodType: "\u7528\u6237\u4E3B\u9875\u6570\u636E",
616
- host_mid: parseInt(req.query.host_mid)
617
- }, req.headers.cookie || cookie);
618
- res.json(data2);
619
- });
620
- router.get("/fetch_live_room_detail", async (req, res) => {
621
- const data2 = await BilibiliData({
622
- methodType: "\u76F4\u64AD\u95F4\u4FE1\u606F",
623
- room_id: req.query.room_id
624
- }, req.headers.cookie || cookie);
625
- res.json(data2);
626
- });
627
- router.get("/fetch_liveroom_def", async (req, res) => {
628
- const data2 = await BilibiliData({
629
- methodType: "\u76F4\u64AD\u95F4\u521D\u59CB\u5316\u4FE1\u606F",
630
- room_id: req.query.room_id
631
- }, req.headers.cookie || cookie);
632
- res.json(data2);
633
- });
634
- router.get("/bv_to_av", async (req, res) => {
635
- const data2 = await BilibiliData({
636
- methodType: "BV\u8F6CAV",
637
- bvid: req.query.bvid
638
- }, req.headers.cookie || cookie);
639
- res.json(data2);
640
- });
641
- router.get("/av_to_bv", async (req, res) => {
642
- const data2 = await BilibiliData({
643
- methodType: "AV\u8F6CBV",
644
- avid: parseInt(req.query.avid)
645
- }, req.headers.cookie || cookie);
646
- res.json(data2);
647
- });
648
- router.get("/fetch_user_full_view", async (req, res) => {
649
- const data2 = await BilibiliData({
650
- methodType: "\u83B7\u53D6UP\u4E3B\u603B\u64AD\u653E\u91CF",
651
- host_mid: parseInt(req.query.host_mid)
652
- }, req.headers.cookie || cookie);
653
- res.json(data2);
654
- });
655
- return router;
656
- };
657
-
658
- // src/platform/bilibili/sign/bv2av.ts
659
- var XOR_CODE = 23442827791579n;
660
- var MASK_CODE = 2251799813685247n;
661
- var MAX_AID = 1n << 51n;
662
- var BASE = 58n;
663
- var data = "FcwAPNKTMug3GV5Lj7EJnHpWsx4tb8haYeviqBz6rkCy12mUSDQX9RdoZf";
664
- function av2bv(aid) {
665
- const bytes = ["B", "V", "1", "0", "0", "0", "0", "0", "0", "0", "0", "0"];
666
- let bvIndex = bytes.length - 1;
667
- let tmp = (MAX_AID | BigInt(aid)) ^ XOR_CODE;
668
- while (tmp > 0) {
669
- bytes[bvIndex] = data[Number(tmp % BigInt(BASE))];
670
- tmp = tmp / BASE;
671
- bvIndex -= 1;
750
+ case "\u76F4\u64AD\u95F4\u4FE1\u606F": {
751
+ BilibiliValidateData(data2, ["room_id"]);
752
+ const result = await GlobalGetData({
753
+ url: bilibiliAPI.\u76F4\u64AD\u95F4\u4FE1\u606F({ room_id: data2.room_id }),
754
+ headers: headers2,
755
+ ...data2
756
+ });
757
+ return result;
758
+ }
759
+ case "\u76F4\u64AD\u95F4\u521D\u59CB\u5316\u4FE1\u606F": {
760
+ BilibiliValidateData(data2, ["room_id"]);
761
+ const result = await GlobalGetData({
762
+ url: bilibiliAPI.\u76F4\u64AD\u95F4\u521D\u59CB\u5316\u4FE1\u606F({ room_id: data2.room_id }),
763
+ headers: headers2,
764
+ ...data2
765
+ });
766
+ return result;
767
+ }
768
+ case "\u7533\u8BF7\u4E8C\u7EF4\u7801": {
769
+ const result = await GlobalGetData({
770
+ url: bilibiliAPI.\u7533\u8BF7\u4E8C\u7EF4\u7801(),
771
+ headers: headers2,
772
+ ...data2
773
+ });
774
+ return result;
775
+ }
776
+ case "\u4E8C\u7EF4\u7801\u72B6\u6001": {
777
+ BilibiliValidateData(data2, ["qrcode_key"]);
778
+ const result = await new Networks({
779
+ url: bilibiliAPI.\u4E8C\u7EF4\u7801\u72B6\u6001({ qrcode_key: data2.qrcode_key }),
780
+ headers: headers2,
781
+ ...data2
782
+ }).getHeadersAndData();
783
+ return result;
784
+ }
785
+ case "\u767B\u5F55\u57FA\u672C\u4FE1\u606F": {
786
+ const result = await GlobalGetData({
787
+ url: bilibiliAPI.\u767B\u5F55\u57FA\u672C\u4FE1\u606F(),
788
+ headers: headers2,
789
+ ...data2
790
+ });
791
+ return result;
792
+ }
793
+ case "\u83B7\u53D6UP\u4E3B\u603B\u64AD\u653E\u91CF": {
794
+ BilibiliValidateData(data2, ["host_mid"]);
795
+ const result = await GlobalGetData({
796
+ url: bilibiliAPI.\u83B7\u53D6UP\u4E3B\u603B\u64AD\u653E\u91CF({ host_mid: data2.host_mid }),
797
+ headers: headers2,
798
+ ...data2
799
+ });
800
+ return result;
801
+ }
802
+ case "AV\u8F6CBV": {
803
+ BilibiliValidateData(data2, ["avid"]);
804
+ const result = av2bv(Number(data2.avid.toString().replace(/^av/i, "")));
805
+ return {
806
+ code: 0,
807
+ message: "success",
808
+ data: {
809
+ bvid: result
810
+ }
811
+ };
812
+ }
813
+ case "BV\u8F6CAV": {
814
+ BilibiliValidateData(data2, ["bvid"]);
815
+ const result = "av" + bv2av(data2.bvid);
816
+ return {
817
+ code: 0,
818
+ message: "success",
819
+ data: {
820
+ aid: result
821
+ }
822
+ };
823
+ }
824
+ default:
825
+ logger.warn(`\u672A\u77E5\u7684\u6296\u97F3\u6570\u636E\u63A5\u53E3\uFF1A\u300D${logger.red(data2.methodType)}\u300D`);
826
+ return null;
672
827
  }
673
- [bytes[3], bytes[9]] = [bytes[9], bytes[3]];
674
- [bytes[4], bytes[7]] = [bytes[7], bytes[4]];
675
- return bytes.join("");
676
- }
677
- function bv2av(bvid) {
678
- const bvidArr = Array.from(bvid);
679
- [bvidArr[3], bvidArr[9]] = [bvidArr[9], bvidArr[3]];
680
- [bvidArr[4], bvidArr[7]] = [bvidArr[7], bvidArr[4]];
681
- bvidArr.splice(0, 3);
682
- const tmp = bvidArr.reduce((pre, bvidChar) => pre * BASE + BigInt(data.indexOf(bvidChar)), 0n);
683
- return Number(tmp & MASK_CODE ^ XOR_CODE);
684
- }
828
+ };
829
+ var GlobalGetData = async (options) => {
830
+ const result = await new Networks(options).getData();
831
+ if (result && result.code === 0) {
832
+ return result;
833
+ } else if (result.code === 12061) {
834
+ logger.warn(`\u83B7\u53D6\u54CD\u5E94\u6570\u636E\u5931\u8D25\uFF01
835
+ \u8BF7\u6C42\u63A5\u53E3\u7C7B\u578B\uFF1A\u300C${options.methodType}\u300D
836
+ \u8BF7\u6C42URL\uFF1A${options.url}
837
+ \u9519\u8BEF\u4EE3\u7801\uFF1A${result.code}\uFF0C
838
+ \u542B\u4E49\uFF1A${result.message}`);
839
+ return result;
840
+ } else {
841
+ const errorMessage = errorMap[result.code] || result.message || "\u672A\u77E5\u9519\u8BEF";
842
+ logger.warn(`\u83B7\u53D6\u54CD\u5E94\u6570\u636E\u5931\u8D25\uFF01
843
+ \u8BF7\u6C42\u63A5\u53E3\u7C7B\u578B\uFF1A\u300C${options.methodType}\u300D
844
+ \u8BF7\u6C42URL\uFF1A${options.url}
845
+ \u9519\u8BEF\u4EE3\u7801\uFF1A${result.code}\uFF0C
846
+ \u542B\u4E49\uFF1A${errorMessage}`);
847
+ return result;
848
+ }
849
+ };
850
+ var errorMap = {
851
+ "-1": "\u5E94\u7528\u7A0B\u5E8F\u4E0D\u5B58\u5728\u6216\u5DF2\u88AB\u5C01\u7981",
852
+ "-2": "Access Key \u9519\u8BEF",
853
+ "-3": "API \u6821\u9A8C\u5BC6\u5319\u9519\u8BEF",
854
+ "-4": "\u8C03\u7528\u65B9\u5BF9\u8BE5 Method \u6CA1\u6709\u6743\u9650",
855
+ "-101": "\u8D26\u53F7\u672A\u767B\u5F55",
856
+ "-102": "\u8D26\u53F7\u88AB\u5C01\u505C",
857
+ "-103": "\u79EF\u5206\u4E0D\u8DB3",
858
+ "-104": "\u786C\u5E01\u4E0D\u8DB3",
859
+ "-105": "\u9A8C\u8BC1\u7801\u9519\u8BEF",
860
+ "-106": "\u8D26\u53F7\u975E\u6B63\u5F0F\u4F1A\u5458\u6216\u5728\u9002\u5E94\u671F",
861
+ "-107": "\u5E94\u7528\u4E0D\u5B58\u5728\u6216\u8005\u88AB\u5C01\u7981",
862
+ "-108": "\u672A\u7ED1\u5B9A\u624B\u673A",
863
+ "-110": "\u672A\u7ED1\u5B9A\u624B\u673A",
864
+ "-111": "csrf \u6821\u9A8C\u5931\u8D25",
865
+ "-112": "\u7CFB\u7EDF\u5347\u7EA7\u4E2D",
866
+ "-113": "\u8D26\u53F7\u5C1A\u672A\u5B9E\u540D\u8BA4\u8BC1",
867
+ "-114": "\u8BF7\u5148\u7ED1\u5B9A\u624B\u673A",
868
+ "-115": "\u8BF7\u5148\u5B8C\u6210\u5B9E\u540D\u8BA4\u8BC1",
869
+ "-304": "\u6728\u6709\u6539\u52A8",
870
+ "-307": "\u649E\u8F66\u8DF3\u8F6C",
871
+ "-352": "\u98CE\u63A7\u6821\u9A8C\u5931\u8D25 (UA \u6216 wbi \u53C2\u6570\u4E0D\u5408\u6CD5)",
872
+ "-400": "\u8BF7\u6C42\u9519\u8BEF",
873
+ "-401": "\u672A\u8BA4\u8BC1 (\u6216\u975E\u6CD5\u8BF7\u6C42)",
874
+ "-403": "\u8BBF\u95EE\u6743\u9650\u4E0D\u8DB3",
875
+ "-404": "\u5565\u90FD\u6728\u6709",
876
+ "-405": "\u4E0D\u652F\u6301\u8BE5\u65B9\u6CD5",
877
+ "-409": "\u51B2\u7A81",
878
+ "-412": "\u8BF7\u6C42\u88AB\u62E6\u622A (\u5BA2\u6237\u7AEF ip \u88AB\u670D\u52A1\u7AEF\u98CE\u63A7)",
879
+ "-500": "\u670D\u52A1\u5668\u9519\u8BEF",
880
+ "-503": "\u8FC7\u8F7D\u4FDD\u62A4,\u670D\u52A1\u6682\u4E0D\u53EF\u7528",
881
+ "-504": "\u670D\u52A1\u8C03\u7528\u8D85\u65F6",
882
+ "-509": "\u8D85\u51FA\u9650\u5236",
883
+ "-616": "\u4E0A\u4F20\u6587\u4EF6\u4E0D\u5B58\u5728",
884
+ "-617": "\u4E0A\u4F20\u6587\u4EF6\u592A\u5927",
885
+ "-625": "\u767B\u5F55\u5931\u8D25\u6B21\u6570\u592A\u591A",
886
+ "-626": "\u7528\u6237\u4E0D\u5B58\u5728",
887
+ "-628": "\u5BC6\u7801\u592A\u5F31",
888
+ "-629": "\u7528\u6237\u540D\u6216\u5BC6\u7801\u9519\u8BEF",
889
+ "-632": "\u64CD\u4F5C\u5BF9\u8C61\u6570\u91CF\u9650\u5236",
890
+ "-643": "\u88AB\u9501\u5B9A",
891
+ "-650": "\u7528\u6237\u7B49\u7EA7\u592A\u4F4E",
892
+ "-652": "\u91CD\u590D\u7684\u7528\u6237",
893
+ "-658": "Token \u8FC7\u671F",
894
+ "-662": "\u5BC6\u7801\u65F6\u95F4\u6233\u8FC7\u671F",
895
+ "-688": "\u5730\u7406\u533A\u57DF\u9650\u5236",
896
+ "-689": "\u7248\u6743\u9650\u5236",
897
+ "-701": "\u6263\u8282\u64CD\u5931\u8D25",
898
+ "-799": "\u8BF7\u6C42\u8FC7\u4E8E\u9891\u7E41\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5",
899
+ "-8888": "\u5BF9\u4E0D\u8D77\uFF0C\u670D\u52A1\u5668\u5F00\u5C0F\u5DEE\u4E86~ (\u0CA5\uFE4F\u0CA5)"
900
+ };
685
901
 
686
902
  // src/platform/douyin/sign/a_bogus.ts
687
903
  var SM3 = class {
@@ -1073,70 +1289,339 @@ var douyinSign = class {
1073
1289
  }
1074
1290
  };
1075
1291
 
1076
- // src/platform/douyin/API.ts
1077
- var fp = douyinSign.VerifyFpManager();
1078
- var DouyinAPI = class {
1079
- \u89C6\u9891\u6216\u56FE\u96C6(data2) {
1080
- return `https://www.douyin.com/aweme/v1/web/aweme/detail/?device_platform=webapp&aid=6383&channel=channel_pc_web&aweme_id=${data2.aweme_id}&update_version_code=170400&pc_client_type=1&version_code=190500&version_name=19.5.0&cookie_enabled=true&screen_width=2328&screen_height=1310&browser_language=zh-CN&browser_platform=Win32&browser_name=Chrome&browser_version=125.0.0.0&browser_online=true&engine_name=Blink&engine_version=125.0.0.0&os_name=Windows&os_version=10&cpu_core_num=16&device_memory=8&platform=PC&downlink=10&effective_type=4g&round_trip_time=150&webid=7351848354471872041&msToken=${douyinSign.Mstoken(
1081
- 116
1082
- )}&verifyFp=${fp}&fp=${fp}`;
1083
- }
1084
- \u8BC4\u8BBA(data2) {
1085
- return `https://www.douyin.com/aweme/v1/web/comment/list/?device_platform=webapp&aid=6383&channel=channel_pc_web&aweme_id=${data2.aweme_id}&cursor=${data2.cursor ?? 0}&count=${data2.number ?? 50}&item_type=0&insert_ids=&whale_cut_token=&cut_version=1&rcFT=&pc_client_type=1&version_code=170400&version_name=17.4.0&cookie_enabled=true&screen_width=1552&screen_height=970&browser_language=zh-CN&browser_platform=Win32&browser_name=Chrome&browser_version=125.0.0.0&browser_online=true&engine_name=Blink&engine_version=125.0.0.0&os_name=Windows&os_version=10&cpu_core_num=16&device_memory=8&platform=PC&downlink=10&effective_type=4g&msToken=${douyinSign.Mstoken(
1086
- 116
1087
- )}&verifyFp=${fp}&fp=${fp}`;
1088
- }
1089
- \u4E8C\u7EA7\u8BC4\u8BBA(data2) {
1090
- return `https://www.douyin.com/aweme/v1/web/comment/list/reply/?device_platform=webapp&aid=6383&channel=channel_pc_web&item_id=${data2.aweme_id}&comment_id=${data2.comment_id}&cut_version=1&cursor=${data2.cursor}&count=${data2.number}&item_type=0&update_version_code=170400&pc_client_type=1&pc_libra_divert=Windows&support_h265=1&support_dash=1&version_code=170400&version_name=17.4.0&cookie_enabled=true&screen_width=1552&screen_height=970&browser_language=zh-CN&browser_platform=Win32&browser_name=Edge&browser_version=132.0.0.0&browser_online=true&engine_name=Blink&engine_version=132.0.0.0&os_name=Windows&os_version=10&cpu_core_num=16&device_memory=8&platform=PC&downlink=10&effective_type=4g&round_trip_time=50&webid=7386217876267796006&verifyFp=${fp}&fp=${fp}`;
1091
- }
1092
- \u52A8\u56FE(data2) {
1093
- return `https://www.iesdouyin.com/web/api/v2/aweme/slidesinfo/?reflow_source=reflow_page&web_id=7326472315356857893&device_id=7326472315356857893&aweme_ids=[${data2.aweme_id}]&request_source=200&msToken=${douyinSign.Mstoken(
1094
- 116
1095
- )}&verifyFp=${fp}&fp=${fp}`;
1096
- }
1097
- \u8868\u60C5() {
1098
- return "https://www.douyin.com/aweme/v1/web/emoji/list";
1099
- }
1100
- \u7528\u6237\u4E3B\u9875\u89C6\u9891(data2) {
1101
- return `https://www.douyin.com/aweme/v1/web/aweme/post/?device_platform=webapp&aid=6383&channel=channel_pc_web&sec_user_id=${data2.sec_uid}&max_cursor=0&locate_query=false&show_live_replay_strategy=1&need_time_list=1&time_list_query=0&whale_cut_token=&cut_version=1&count=18&publish_video_strategy_type=2&pc_client_type=1&version_code=170400&version_name=17.4.0&cookie_enabled=true&screen_width=1552&screen_height=970&browser_language=zh-CN&browser_platform=Win32&browser_name=Chrome&browser_version=125.0.0.0&browser_online=true&engine_name=Blink&engine_version=125.0.0.0&os_name=Windows&os_version=10&cpu_core_num=16&device_memory=8&platform=PC&downlink=10&effective_type=4g&round_trip_time=50&webid=7338423850134226495&msToken=${douyinSign.Mstoken(
1102
- 116
1103
- )}&verifyFp=${fp}&fp=${fp}`;
1104
- }
1105
- \u7528\u6237\u4E3B\u9875\u4FE1\u606F(data2) {
1106
- return `https://www.douyin.com/aweme/v1/web/user/profile/other/?device_platform=webapp&aid=6383&channel=channel_pc_web&publish_video_strategy_type=2&source=channel_pc_web&sec_user_id=${data2.sec_uid}&personal_center_strategy=1&pc_client_type=1&version_code=170400&version_name=17.4.0&cookie_enabled=true&screen_width=1552&screen_height=970&browser_language=zh-CN&browser_platform=Win32&browser_name=Chrome&browser_version=125.0.0.0&browser_online=true&engine_name=Blink&engine_version=125.0.0.0&os_name=Windows&os_version=10&cpu_core_num=16&device_memory=8&platform=PC&downlink=10&effective_type=4g&round_trip_time=0&webid=7327957959955580467&msToken=${douyinSign.Mstoken(
1107
- 116
1108
- )}&verifyFp=${fp}&fp=${fp}`;
1109
- }
1110
- \u70ED\u70B9\u8BCD(data2) {
1111
- return `https://www.douyin.com/aweme/v1/web/api/suggest_words/?device_platform=webapp&aid=6383&channel=channel_pc_web&query=${data2.query}&business_id=30088&from_group_id=7129543174929812767&pc_client_type=1&version_code=170400&version_name=17.4.0&cookie_enabled=true&screen_width=1552&screen_height=970&browser_language=zh - CN&browser_platform=Win32&browser_name=Chrome&browser_version=125.0.0.0&browser_online=true&engine_name=Blink&engine_version=125.0.0.0&os_name=Windows&os_version=10&cpu_core_num=16&device_memory=8&platform=PC&downlink=10&effective_type=4g&round_trip_time=50&webid=7327957959955580467&msToken=${douyinSign.Mstoken(
1112
- 116
1113
- )}&verifyFp=${fp}&fp=${fp}`;
1114
- }
1115
- \u641C\u7D22(data2) {
1116
- return `https://www.douyin.com/aweme/v1/web/general/search/single/?device_platform=webapp&aid=6383&channel=channel_pc_web&search_channel=aweme_general&sort_type=0&publish_time=0&keyword=${data2.query}&search_source=normal_search&query_correct_type=1&is_filter_search=0&from_group_id=&offset=0&count=15&pc_client_type=1&version_code=190600&version_name=19.6.0&cookie_enabled=true&screen_width=1552&screen_height=970&browser_language=zh-CN&browser_platform=Win32&browser_name=Chrome&browser_version=125.0.0.0&browser_online=true&engine_name=Blink&engine_version=125.0.0.0&os_name=Windows&os_version=10&cpu_core_num=16&device_memory=8&platform=PC&downlink=10&effective_type=4g&round_trip_time=50&webid=7338423850134226495&msToken=${douyinSign.Mstoken(
1117
- 116
1118
- )}&verifyFp=${fp}&fp=${fp}&search_id=${data2.search_id ?? ""}&count=${data2.number ?? 10}`;
1119
- }
1120
- \u4E92\u52A8\u8868\u60C5() {
1121
- return `https://www.douyin.com/aweme/v1/web/im/strategy/config?device_platform=webapp&aid=1128&channel=channel_pc_web&publish_video_strategy_type=2&app_id=1128&scenes=[%22interactive_resources%22]&pc_client_type=1&version_code=170400&version_name=17.4.0&cookie_enabled=true&screen_width=2328&screen_height=1310&browser_language=zh-CN&browser_platform=Win32&browser_name=Chrome&browser_version=126.0.0.0&browser_online=true&engine_name=Blink&engine_version=126.0.0.0&os_name=Windows&os_version=10&cpu_core_num=16&device_memory=8&platform=PC&downlink=1.5&effective_type=4g&round_trip_time=350&webid=7347329698282833447&msToken=${douyinSign.Mstoken(
1122
- 116
1123
- )}&verifyFp=${fp}&fp=${fp}`;
1124
- }
1125
- \u80CC\u666F\u97F3\u4E50(data2) {
1126
- return `https://www.douyin.com/aweme/v1/web/music/detail/?device_platform=webapp&aid=6383&channel=channel_pc_web&music_id=${data2.music_id}&scene=1&pc_client_type=1&version_code=170400&version_name=17.4.0&cookie_enabled=true&screen_width=2328&screen_height=1310&browser_language=zh-CN&browser_platform=Win32&browser_name=Chrome&browser_version=126.0.0.0&browser_online=true&engine_name=Blink&engine_version=126.0.0.0&os_name=Windows&os_version=10&cpu_core_num=16&device_memory=8&platform=PC&downlink=1.5&effective_type=4g&round_trip_time=350&webid=7347329698282833447&msToken=${douyinSign.Mstoken(
1127
- 116
1128
- )}&verifyFp=${fp}&fp=${fp}`;
1129
- }
1130
- \u76F4\u64AD\u95F4\u4FE1\u606F(data2) {
1131
- return `https://live.douyin.com/webcast/room/web/enter/?aid=6383&app_name=douyin_web&live_id=1&device_platform=web&language=zh-CN&enter_from=web_share_link&cookie_enabled=true&screen_width=2048&screen_height=1152&browser_language=zh-CN&browser_platform=Win32&browser_name=Chrome&browser_version=125.0.0.0&web_rid=${data2.web_rid}&room_id_str=${data2.room_id}&enter_source=&is_need_double_stream=false&insert_task_id=&live_reason=&msToken=${douyinSign.Mstoken(
1132
- 116
1133
- )}&verifyFp=${fp}&fp=${fp}`;
1134
- }
1135
- \u7533\u8BF7\u4E8C\u7EF4\u7801(data2) {
1136
- return `https://sso.douyin.com/get_qrcode/?verifyFp=${data2.verify_fp}&fp=${data2.verify_fp}`;
1137
- }
1292
+ // src/platform/douyin/API.ts
1293
+ var fp = douyinSign.VerifyFpManager();
1294
+ var DouyinAPI = class {
1295
+ \u89C6\u9891\u6216\u56FE\u96C6(data2) {
1296
+ return `https://www.douyin.com/aweme/v1/web/aweme/detail/?device_platform=webapp&aid=6383&channel=channel_pc_web&aweme_id=${data2.aweme_id}&update_version_code=170400&pc_client_type=1&version_code=190500&version_name=19.5.0&cookie_enabled=true&screen_width=2328&screen_height=1310&browser_language=zh-CN&browser_platform=Win32&browser_name=Chrome&browser_version=125.0.0.0&browser_online=true&engine_name=Blink&engine_version=125.0.0.0&os_name=Windows&os_version=10&cpu_core_num=16&device_memory=8&platform=PC&downlink=10&effective_type=4g&round_trip_time=150&webid=7351848354471872041&msToken=${douyinSign.Mstoken(
1297
+ 116
1298
+ )}&verifyFp=${fp}&fp=${fp}`;
1299
+ }
1300
+ \u8BC4\u8BBA(data2) {
1301
+ return `https://www.douyin.com/aweme/v1/web/comment/list/?device_platform=webapp&aid=6383&channel=channel_pc_web&aweme_id=${data2.aweme_id}&cursor=${data2.cursor ?? 0}&count=${data2.number ?? 50}&item_type=0&insert_ids=&whale_cut_token=&cut_version=1&rcFT=&pc_client_type=1&version_code=170400&version_name=17.4.0&cookie_enabled=true&screen_width=1552&screen_height=970&browser_language=zh-CN&browser_platform=Win32&browser_name=Chrome&browser_version=125.0.0.0&browser_online=true&engine_name=Blink&engine_version=125.0.0.0&os_name=Windows&os_version=10&cpu_core_num=16&device_memory=8&platform=PC&downlink=10&effective_type=4g&msToken=${douyinSign.Mstoken(
1302
+ 116
1303
+ )}&verifyFp=${fp}&fp=${fp}`;
1304
+ }
1305
+ \u4E8C\u7EA7\u8BC4\u8BBA(data2) {
1306
+ return `https://www.douyin.com/aweme/v1/web/comment/list/reply/?device_platform=webapp&aid=6383&channel=channel_pc_web&item_id=${data2.aweme_id}&comment_id=${data2.comment_id}&cut_version=1&cursor=${data2.cursor}&count=${data2.number}&item_type=0&update_version_code=170400&pc_client_type=1&pc_libra_divert=Windows&support_h265=1&support_dash=1&version_code=170400&version_name=17.4.0&cookie_enabled=true&screen_width=1552&screen_height=970&browser_language=zh-CN&browser_platform=Win32&browser_name=Edge&browser_version=132.0.0.0&browser_online=true&engine_name=Blink&engine_version=132.0.0.0&os_name=Windows&os_version=10&cpu_core_num=16&device_memory=8&platform=PC&downlink=10&effective_type=4g&round_trip_time=50&webid=7386217876267796006&verifyFp=${fp}&fp=${fp}`;
1307
+ }
1308
+ \u52A8\u56FE(data2) {
1309
+ return `https://www.iesdouyin.com/web/api/v2/aweme/slidesinfo/?reflow_source=reflow_page&web_id=7326472315356857893&device_id=7326472315356857893&aweme_ids=[${data2.aweme_id}]&request_source=200&msToken=${douyinSign.Mstoken(
1310
+ 116
1311
+ )}&verifyFp=${fp}&fp=${fp}`;
1312
+ }
1313
+ \u8868\u60C5() {
1314
+ return "https://www.douyin.com/aweme/v1/web/emoji/list";
1315
+ }
1316
+ \u7528\u6237\u4E3B\u9875\u89C6\u9891(data2) {
1317
+ return `https://www.douyin.com/aweme/v1/web/aweme/post/?device_platform=webapp&aid=6383&channel=channel_pc_web&sec_user_id=${data2.sec_uid}&max_cursor=0&locate_query=false&show_live_replay_strategy=1&need_time_list=1&time_list_query=0&whale_cut_token=&cut_version=1&count=18&publish_video_strategy_type=2&pc_client_type=1&version_code=170400&version_name=17.4.0&cookie_enabled=true&screen_width=1552&screen_height=970&browser_language=zh-CN&browser_platform=Win32&browser_name=Chrome&browser_version=125.0.0.0&browser_online=true&engine_name=Blink&engine_version=125.0.0.0&os_name=Windows&os_version=10&cpu_core_num=16&device_memory=8&platform=PC&downlink=10&effective_type=4g&round_trip_time=50&webid=7338423850134226495&msToken=${douyinSign.Mstoken(
1318
+ 116
1319
+ )}&verifyFp=${fp}&fp=${fp}`;
1320
+ }
1321
+ \u7528\u6237\u4E3B\u9875\u4FE1\u606F(data2) {
1322
+ return `https://www.douyin.com/aweme/v1/web/user/profile/other/?device_platform=webapp&aid=6383&channel=channel_pc_web&publish_video_strategy_type=2&source=channel_pc_web&sec_user_id=${data2.sec_uid}&personal_center_strategy=1&pc_client_type=1&version_code=170400&version_name=17.4.0&cookie_enabled=true&screen_width=1552&screen_height=970&browser_language=zh-CN&browser_platform=Win32&browser_name=Chrome&browser_version=125.0.0.0&browser_online=true&engine_name=Blink&engine_version=125.0.0.0&os_name=Windows&os_version=10&cpu_core_num=16&device_memory=8&platform=PC&downlink=10&effective_type=4g&round_trip_time=0&webid=7327957959955580467&msToken=${douyinSign.Mstoken(
1323
+ 116
1324
+ )}&verifyFp=${fp}&fp=${fp}`;
1325
+ }
1326
+ \u70ED\u70B9\u8BCD(data2) {
1327
+ return `https://www.douyin.com/aweme/v1/web/api/suggest_words/?device_platform=webapp&aid=6383&channel=channel_pc_web&query=${data2.query}&business_id=30088&from_group_id=7129543174929812767&pc_client_type=1&version_code=170400&version_name=17.4.0&cookie_enabled=true&screen_width=1552&screen_height=970&browser_language=zh - CN&browser_platform=Win32&browser_name=Chrome&browser_version=125.0.0.0&browser_online=true&engine_name=Blink&engine_version=125.0.0.0&os_name=Windows&os_version=10&cpu_core_num=16&device_memory=8&platform=PC&downlink=10&effective_type=4g&round_trip_time=50&webid=7327957959955580467&msToken=${douyinSign.Mstoken(
1328
+ 116
1329
+ )}&verifyFp=${fp}&fp=${fp}`;
1330
+ }
1331
+ \u641C\u7D22(data2) {
1332
+ return `https://www.douyin.com/aweme/v1/web/general/search/single/?device_platform=webapp&aid=6383&channel=channel_pc_web&search_channel=aweme_general&sort_type=0&publish_time=0&keyword=${data2.query}&search_source=normal_search&query_correct_type=1&is_filter_search=0&from_group_id=&offset=0&count=15&pc_client_type=1&version_code=190600&version_name=19.6.0&cookie_enabled=true&screen_width=1552&screen_height=970&browser_language=zh-CN&browser_platform=Win32&browser_name=Chrome&browser_version=125.0.0.0&browser_online=true&engine_name=Blink&engine_version=125.0.0.0&os_name=Windows&os_version=10&cpu_core_num=16&device_memory=8&platform=PC&downlink=10&effective_type=4g&round_trip_time=50&webid=7338423850134226495&msToken=${douyinSign.Mstoken(
1333
+ 116
1334
+ )}&verifyFp=${fp}&fp=${fp}&search_id=${data2.search_id ?? ""}&count=${data2.number ?? 10}`;
1335
+ }
1336
+ \u4E92\u52A8\u8868\u60C5() {
1337
+ return `https://www.douyin.com/aweme/v1/web/im/strategy/config?device_platform=webapp&aid=1128&channel=channel_pc_web&publish_video_strategy_type=2&app_id=1128&scenes=[%22interactive_resources%22]&pc_client_type=1&version_code=170400&version_name=17.4.0&cookie_enabled=true&screen_width=2328&screen_height=1310&browser_language=zh-CN&browser_platform=Win32&browser_name=Chrome&browser_version=126.0.0.0&browser_online=true&engine_name=Blink&engine_version=126.0.0.0&os_name=Windows&os_version=10&cpu_core_num=16&device_memory=8&platform=PC&downlink=1.5&effective_type=4g&round_trip_time=350&webid=7347329698282833447&msToken=${douyinSign.Mstoken(
1338
+ 116
1339
+ )}&verifyFp=${fp}&fp=${fp}`;
1340
+ }
1341
+ \u80CC\u666F\u97F3\u4E50(data2) {
1342
+ return `https://www.douyin.com/aweme/v1/web/music/detail/?device_platform=webapp&aid=6383&channel=channel_pc_web&music_id=${data2.music_id}&scene=1&pc_client_type=1&version_code=170400&version_name=17.4.0&cookie_enabled=true&screen_width=2328&screen_height=1310&browser_language=zh-CN&browser_platform=Win32&browser_name=Chrome&browser_version=126.0.0.0&browser_online=true&engine_name=Blink&engine_version=126.0.0.0&os_name=Windows&os_version=10&cpu_core_num=16&device_memory=8&platform=PC&downlink=1.5&effective_type=4g&round_trip_time=350&webid=7347329698282833447&msToken=${douyinSign.Mstoken(
1343
+ 116
1344
+ )}&verifyFp=${fp}&fp=${fp}`;
1345
+ }
1346
+ \u76F4\u64AD\u95F4\u4FE1\u606F(data2) {
1347
+ return `https://live.douyin.com/webcast/room/web/enter/?aid=6383&app_name=douyin_web&live_id=1&device_platform=web&language=zh-CN&enter_from=web_share_link&cookie_enabled=true&screen_width=2048&screen_height=1152&browser_language=zh-CN&browser_platform=Win32&browser_name=Chrome&browser_version=125.0.0.0&web_rid=${data2.web_rid}&room_id_str=${data2.room_id}&enter_source=&is_need_double_stream=false&insert_task_id=&live_reason=&msToken=${douyinSign.Mstoken(
1348
+ 116
1349
+ )}&verifyFp=${fp}&fp=${fp}`;
1350
+ }
1351
+ \u7533\u8BF7\u4E8C\u7EF4\u7801(data2) {
1352
+ return `https://sso.douyin.com/get_qrcode/?verifyFp=${data2.verify_fp}&fp=${data2.verify_fp}`;
1353
+ }
1354
+ };
1355
+ var douyinAPI = new DouyinAPI();
1356
+ var douyinApiUrls = new DouyinAPI();
1357
+
1358
+ // src/platform/douyin/DouyinApi.ts
1359
+ var douyin = {
1360
+ /**
1361
+ * 聚合解析 (视频/图集/合辑)
1362
+ * @param options 请求参数,包含 aweme_id 和可选的 typeMode
1363
+ * @param cookie 有效的用户 Cookie
1364
+ * @returns 接口返回的原始数据
1365
+ */
1366
+ async getWorkInfo(options, cookie) {
1367
+ const { typeMode, ...restOptions } = options;
1368
+ const data2 = await DouyinData({ ...restOptions, methodType: "\u805A\u5408\u89E3\u6790" }, cookie);
1369
+ return data2;
1370
+ },
1371
+ /**
1372
+ * 获取视频作品数据
1373
+ * @param options 请求参数,包含 aweme_id 和可选的 typeMode
1374
+ * @param cookie 有效的用户 Cookie
1375
+ * @returns 接口返回的原始数据
1376
+ */
1377
+ async getVideoWorkInfo(options, cookie) {
1378
+ const { typeMode, ...restOptions } = options;
1379
+ const data2 = await DouyinData({ ...restOptions, methodType: "\u89C6\u9891\u4F5C\u54C1\u6570\u636E" }, cookie);
1380
+ return data2;
1381
+ },
1382
+ /**
1383
+ * 获取图集作品数据
1384
+ * @param options 请求参数,包含 aweme_id 和可选的 typeMode
1385
+ * @param cookie 有效的用户 Cookie
1386
+ * @returns 接口返回的原始数据
1387
+ */
1388
+ async getImageAlbumWorkInfo(options, cookie) {
1389
+ const { typeMode, ...restOptions } = options;
1390
+ const data2 = await DouyinData({ ...restOptions, methodType: "\u56FE\u96C6\u4F5C\u54C1\u6570\u636E" }, cookie);
1391
+ return data2;
1392
+ },
1393
+ /**
1394
+ * 获取合辑作品数据
1395
+ * @param options 请求参数,包含 aweme_id 和可选的 typeMode
1396
+ * @param cookie 有效的用户 Cookie
1397
+ * @returns 接口返回的原始数据
1398
+ */
1399
+ async getSlidesWorkInfo(options, cookie) {
1400
+ const { typeMode, ...restOptions } = options;
1401
+ const data2 = await DouyinData({ ...restOptions, methodType: "\u5408\u8F91\u4F5C\u54C1\u6570\u636E" }, cookie);
1402
+ return data2;
1403
+ },
1404
+ /**
1405
+ * 获取评论数据
1406
+ * @param options 请求参数,包含 aweme_id, 可选的 number, cursor 和 typeMode
1407
+ * @param cookie 有效的用户 Cookie
1408
+ * @returns 接口返回的原始数据
1409
+ */
1410
+ async getComments(options, cookie) {
1411
+ const { typeMode, ...restOptions } = options;
1412
+ const data2 = await DouyinData({ ...restOptions, methodType: "\u8BC4\u8BBA\u6570\u636E" }, cookie);
1413
+ return data2;
1414
+ },
1415
+ /**
1416
+ * 获取指定评论回复数据
1417
+ * @param options 请求参数,包含 aweme_id, comment_id, 可选的 number, cursor 和 typeMode
1418
+ * @param cookie 有效的用户 Cookie
1419
+ * @returns 接口返回的原始数据
1420
+ */
1421
+ async getCommentReplies(options, cookie) {
1422
+ const { typeMode, ...restOptions } = options;
1423
+ const data2 = await DouyinData({ ...restOptions, methodType: "\u6307\u5B9A\u8BC4\u8BBA\u56DE\u590D\u6570\u636E" }, cookie);
1424
+ return data2;
1425
+ },
1426
+ /**
1427
+ * 获取用户主页数据
1428
+ * @param options 请求参数,包含 sec_uid 和可选的 typeMode
1429
+ * @param cookie 有效的用户 Cookie
1430
+ * @returns 接口返回的原始数据
1431
+ */
1432
+ async getUserProfile(options, cookie) {
1433
+ const { typeMode, ...restOptions } = options;
1434
+ const data2 = await DouyinData({ ...restOptions, methodType: "\u7528\u6237\u4E3B\u9875\u6570\u636E" }, cookie);
1435
+ return data2;
1436
+ },
1437
+ /**
1438
+ * 获取 Emoji 数据
1439
+ * @param options 可选的请求参数 (主要用于 typeMode)
1440
+ * @param cookie 可选的用户 Cookie
1441
+ * @returns 接口返回的原始数据
1442
+ */
1443
+ async getEmojiList(options, cookie) {
1444
+ const { typeMode, ...restOptions } = options;
1445
+ const data2 = await DouyinData({ ...restOptions, methodType: "Emoji\u6570\u636E" }, cookie);
1446
+ return data2;
1447
+ },
1448
+ /**
1449
+ * 获取动态表情数据
1450
+ * @param options 可选的请求参数 (主要用于 typeMode)
1451
+ * @param cookie 有效的用户 Cookie
1452
+ * @returns 接口返回的原始数据
1453
+ */
1454
+ async getEmojiProList(options, cookie) {
1455
+ const { typeMode, ...restOptions } = options;
1456
+ const data2 = await DouyinData({ ...restOptions, methodType: "\u52A8\u6001\u8868\u60C5\u6570\u636E" }, cookie);
1457
+ return data2;
1458
+ },
1459
+ /**
1460
+ * 获取用户主页视频列表数据
1461
+ * @param options 请求参数,包含 sec_uid, 可选的 number, max_cursor 和 typeMode
1462
+ * @param cookie 有效的用户 Cookie
1463
+ * @returns 接口返回的原始数据
1464
+ */
1465
+ async getUserVideos(options, cookie) {
1466
+ const { typeMode, ...restOptions } = options;
1467
+ const data2 = await DouyinData({ ...restOptions, methodType: "\u7528\u6237\u4E3B\u9875\u89C6\u9891\u5217\u8868\u6570\u636E" }, cookie);
1468
+ return data2;
1469
+ },
1470
+ /**
1471
+ * 获取音乐数据
1472
+ * @param options 请求参数,包含 music_id 和可选的 typeMode
1473
+ * @param cookie 有效的用户 Cookie
1474
+ * @returns 接口返回的原始数据
1475
+ */
1476
+ async getMusicInfo(options, cookie) {
1477
+ const { typeMode, ...restOptions } = options;
1478
+ const data2 = await DouyinData({ ...restOptions, methodType: "\u97F3\u4E50\u6570\u636E" }, cookie);
1479
+ return data2;
1480
+ },
1481
+ /**
1482
+ * 获取热点词数据
1483
+ * @param options 请求参数,包含 query, 可选的 number 和 typeMode
1484
+ * @param cookie 有效的用户 Cookie
1485
+ * @returns 接口返回的原始数据
1486
+ */
1487
+ async getSuggestWords(options, cookie) {
1488
+ const { typeMode, ...restOptions } = options;
1489
+ const data2 = await DouyinData({ ...restOptions, methodType: "\u70ED\u70B9\u8BCD\u6570\u636E" }, cookie);
1490
+ return data2;
1491
+ },
1492
+ /**
1493
+ * 获取搜索数据
1494
+ * @param options 请求参数,包含 query, 可选的 number, search_id, cursor 和 typeMode
1495
+ * @param cookie 有效的用户 Cookie
1496
+ * @returns 接口返回的原始数据
1497
+ */
1498
+ async search(options, cookie) {
1499
+ const { typeMode, ...restOptions } = options;
1500
+ const data2 = await DouyinData({ ...restOptions, methodType: "\u641C\u7D22\u6570\u636E" }, cookie);
1501
+ return data2;
1502
+ },
1503
+ /**
1504
+ * 获取直播间信息
1505
+ * @param options 请求参数,包含 sec_uid 和可选的 typeMode
1506
+ * @param cookie 有效的用户 Cookie
1507
+ * @returns 接口返回的原始数据
1508
+ */
1509
+ async getLiveRoomInfo(options, cookie) {
1510
+ const { typeMode, ...restOptions } = options;
1511
+ const data2 = await DouyinData({ ...restOptions, methodType: "\u76F4\u64AD\u95F4\u4FE1\u606F\u6570\u636E" }, cookie);
1512
+ return data2;
1513
+ },
1514
+ /**
1515
+ * 申请二维码数据
1516
+ * @param options 请求参数,包含 verify_fp 和可选的 typeMode
1517
+ * @param cookie 有效的用户 Cookie
1518
+ * @returns 接口返回的原始数据 (any)
1519
+ */
1520
+ async getLoginQrcode(options, cookie) {
1521
+ const { typeMode, ...restOptions } = options;
1522
+ const data2 = await DouyinData({ ...restOptions, methodType: "\u7533\u8BF7\u4E8C\u7EF4\u7801\u6570\u636E" }, cookie);
1523
+ return data2;
1524
+ }
1525
+ };
1526
+ var registerDouyinRoutes = (cookie) => {
1527
+ const router = express.Router();
1528
+ router.get("/fetch_one_work", async (req, res) => {
1529
+ const data2 = await DouyinData({
1530
+ methodType: "\u805A\u5408\u89E3\u6790",
1531
+ aweme_id: req.query.aweme_id
1532
+ }, req.headers.cookie || cookie);
1533
+ res.json(data2);
1534
+ });
1535
+ router.get("/fetch_work_comments", async (req, res) => {
1536
+ const data2 = await DouyinData({
1537
+ methodType: "\u8BC4\u8BBA\u6570\u636E",
1538
+ aweme_id: req.query.aweme_id,
1539
+ number: parseInt(req.query.number ?? "50"),
1540
+ cursor: parseInt(req.query.cursor ?? "0")
1541
+ }, req.headers.cookie || cookie);
1542
+ res.json(data2);
1543
+ });
1544
+ router.get("/fetch_video_comment_replies", async (req, res) => {
1545
+ const data2 = await DouyinData({
1546
+ methodType: "\u6307\u5B9A\u8BC4\u8BBA\u56DE\u590D\u6570\u636E",
1547
+ aweme_id: req.query.aweme_id,
1548
+ comment_id: req.query.comment_id
1549
+ }, req.headers.cookie || cookie);
1550
+ res.json(data2);
1551
+ });
1552
+ router.get("/fetch_user_info", async (req, res) => {
1553
+ const data2 = await DouyinData({
1554
+ methodType: "\u7528\u6237\u4E3B\u9875\u6570\u636E",
1555
+ sec_uid: req.query.sec_uid
1556
+ }, req.headers.cookie || cookie);
1557
+ res.json(data2);
1558
+ });
1559
+ router.get("/fetch_user_post_videos", async (req, res) => {
1560
+ const data2 = await DouyinData({
1561
+ methodType: "\u7528\u6237\u4E3B\u9875\u89C6\u9891\u5217\u8868\u6570\u636E",
1562
+ sec_uid: req.query.sec_uid
1563
+ }, req.headers.cookie || cookie);
1564
+ res.json(data2);
1565
+ });
1566
+ router.get("/fetch_suggest_words", async (req, res) => {
1567
+ const data2 = await DouyinData({
1568
+ methodType: "\u70ED\u70B9\u8BCD\u6570\u636E",
1569
+ query: req.query.query
1570
+ }, req.headers.cookie || cookie);
1571
+ res.json(data2);
1572
+ });
1573
+ router.get("/fetch_search_info", async (req, res) => {
1574
+ const data2 = await DouyinData({
1575
+ methodType: "\u641C\u7D22\u6570\u636E",
1576
+ query: req.query.query,
1577
+ number: parseInt(req.query.number ?? "10"),
1578
+ search_id: req.query.search_id
1579
+ }, req.headers.cookie || cookie);
1580
+ res.json(data2);
1581
+ });
1582
+ router.get("/fetch_emoji_list", async (req, res) => {
1583
+ const data2 = await DouyinData({
1584
+ methodType: "Emoji\u6570\u636E"
1585
+ }, req.headers.cookie || cookie);
1586
+ res.json(data2);
1587
+ });
1588
+ router.get("/fetch_emoji_pro_list", async (req, res) => {
1589
+ const data2 = await DouyinData({
1590
+ methodType: "\u52A8\u6001\u8868\u60C5\u6570\u636E"
1591
+ }, req.headers.cookie || cookie);
1592
+ res.json(data2);
1593
+ });
1594
+ router.get("/fetch_music_work", async (req, res) => {
1595
+ const data2 = await DouyinData({
1596
+ methodType: "\u97F3\u4E50\u6570\u636E",
1597
+ music_id: req.query.music_id
1598
+ }, req.headers.cookie || cookie);
1599
+ res.json(data2);
1600
+ });
1601
+ router.get("/fetch_user_mix_videos", async (req, res) => {
1602
+ const data2 = await DouyinData({
1603
+ methodType: "\u5408\u8F91\u4F5C\u54C1\u6570\u636E",
1604
+ aweme_id: req.query.aweme_id
1605
+ }, req.headers.cookie || cookie);
1606
+ res.json(data2);
1607
+ });
1608
+ router.get("/fetch_user_live_videos", async (req, res) => {
1609
+ const data2 = await DouyinData({
1610
+ methodType: "\u76F4\u64AD\u95F4\u4FE1\u606F\u6570\u636E",
1611
+ sec_uid: req.query.sec_uid
1612
+ }, req.headers.cookie || cookie);
1613
+ res.json(data2);
1614
+ });
1615
+ return router;
1616
+ };
1617
+
1618
+ // src/platform/douyin/index.ts
1619
+ var douyinUtils = {
1620
+ sign: douyinSign,
1621
+ douyinApiUrls,
1622
+ getDouyinData,
1623
+ api: douyin
1138
1624
  };
1139
- var douyinAPI = new DouyinAPI();
1140
1625
 
1141
1626
  // src/platform/douyin/getdata.ts
1142
1627
  var defheaders2 = {
@@ -1257,6 +1742,10 @@ var DouyinData = async (data2, cookie) => {
1257
1742
  },
1258
1743
  ...data2
1259
1744
  });
1745
+ if (response.data.length === 0) {
1746
+ logger.warn("\u83B7\u53D6\u641C\u7D22\u6570\u636E\u5931\u8D25\uFF01\u8BF7\u6C42\u6210\u529F\u4F46\u63A5\u53E3\u8FD4\u56DE\u5185\u5BB9\u4E3A\u7A7A\n\u4F60\u7684\u6296\u97F3ck\u53EF\u80FD\u5DF2\u7ECF\u5931\u6548\uFF01\n\u8BF7\u6C42\u7C7B\u578B\uFF1A" + data2.methodType);
1747
+ return false;
1748
+ }
1260
1749
  if (!response.data) {
1261
1750
  response.data = [];
1262
1751
  }
@@ -1331,6 +1820,9 @@ var DouyinData = async (data2, cookie) => {
1331
1820
  });
1332
1821
  return LoginQrcodeStatusData;
1333
1822
  }
1823
+ default:
1824
+ logger.warn(`\u672A\u77E5\u7684B\u7AD9\u6570\u636E\u63A5\u53E3\uFF1A\u300C${logger.red(data2.methodType)}\u300D`);
1825
+ return null;
1334
1826
  }
1335
1827
  };
1336
1828
  async function fetchPaginatedData(apiUrlGenerator, params, maxPageSize, headers2) {
@@ -1366,102 +1858,14 @@ async function fetchPaginatedData(apiUrlGenerator, params, maxPageSize, headers2
1366
1858
  async function GlobalGetData2(options) {
1367
1859
  const ResponseData = await new Networks(options).getData();
1368
1860
  if (ResponseData === "" || !ResponseData) {
1369
- logger.warn("\u83B7\u53D6\u54CD\u5E94\u6570\u636E\u5931\u8D25\uFF01\u63A5\u53E3\u8FD4\u56DE\u5185\u5BB9\u4E3A\u7A7A\n\u4F60\u7684\u6296\u97F3ck\u53EF\u80FD\u5DF2\u7ECF\u5931\u6548\uFF01\n\u8BF7\u6C42\u7C7B\u578B\uFF1A" + options.methodType + "\n\u8BF7\u6C42URL\uFF1A" + options.url);
1861
+ logger.warn(`\u83B7\u53D6\u54CD\u5E94\u6570\u636E\u5931\u8D25\uFF01\u63A5\u53E3\u8FD4\u56DE\u5185\u5BB9\u4E3A\u7A7A
1862
+ \u4F60\u7684\u6296\u97F3ck\u53EF\u80FD\u5DF2\u7ECF\u5931\u6548\uFF01
1863
+ \u8BF7\u6C42\u7C7B\u578B\uFF1A\u300C${options.methodType}\u300D
1864
+ \u8BF7\u6C42URL\uFF1A options.url`);
1370
1865
  return false;
1371
1866
  }
1372
1867
  return ResponseData;
1373
1868
  }
1374
- var registerDouyinRoutes = (cookie) => {
1375
- const router = express.Router();
1376
- router.get("/fetch_one_work", async (req, res) => {
1377
- const data2 = await DouyinData({
1378
- methodType: "\u805A\u5408\u89E3\u6790",
1379
- aweme_id: req.query.aweme_id
1380
- }, req.headers.cookie || cookie);
1381
- res.json(data2);
1382
- });
1383
- router.get("/fetch_work_comments", async (req, res) => {
1384
- const data2 = await DouyinData({
1385
- methodType: "\u8BC4\u8BBA\u6570\u636E",
1386
- aweme_id: req.query.aweme_id,
1387
- number: parseInt(req.query.number ?? "50"),
1388
- cursor: parseInt(req.query.cursor ?? "0")
1389
- }, req.headers.cookie || cookie);
1390
- res.json(data2);
1391
- });
1392
- router.get("/fetch_video_comment_replies", async (req, res) => {
1393
- const data2 = await DouyinData({
1394
- methodType: "\u6307\u5B9A\u8BC4\u8BBA\u56DE\u590D\u6570\u636E",
1395
- aweme_id: req.query.aweme_id,
1396
- comment_id: req.query.comment_id
1397
- }, req.headers.cookie || cookie);
1398
- res.json(data2);
1399
- });
1400
- router.get("/fetch_user_info", async (req, res) => {
1401
- const data2 = await DouyinData({
1402
- methodType: "\u7528\u6237\u4E3B\u9875\u6570\u636E",
1403
- sec_uid: req.query.sec_uid
1404
- }, req.headers.cookie || cookie);
1405
- res.json(data2);
1406
- });
1407
- router.get("/fetch_user_post_videos", async (req, res) => {
1408
- const data2 = await DouyinData({
1409
- methodType: "\u7528\u6237\u4E3B\u9875\u89C6\u9891\u5217\u8868\u6570\u636E",
1410
- sec_uid: req.query.sec_uid
1411
- }, req.headers.cookie || cookie);
1412
- res.json(data2);
1413
- });
1414
- router.get("/fetch_suggest_words", async (req, res) => {
1415
- const data2 = await DouyinData({
1416
- methodType: "\u70ED\u70B9\u8BCD\u6570\u636E",
1417
- query: req.query.query
1418
- }, req.headers.cookie || cookie);
1419
- res.json(data2);
1420
- });
1421
- router.get("/fetch_search_info", async (req, res) => {
1422
- const data2 = await DouyinData({
1423
- methodType: "\u641C\u7D22\u6570\u636E",
1424
- query: req.query.query,
1425
- number: parseInt(req.query.number ?? "10"),
1426
- search_id: req.query.search_id
1427
- }, req.headers.cookie || cookie);
1428
- res.json(data2);
1429
- });
1430
- router.get("/fetch_emoji_list", async (req, res) => {
1431
- const data2 = await DouyinData({
1432
- methodType: "Emoji\u6570\u636E"
1433
- }, req.headers.cookie || cookie);
1434
- res.json(data2);
1435
- });
1436
- router.get("/fetch_emoji_pro_list", async (req, res) => {
1437
- const data2 = await DouyinData({
1438
- methodType: "\u52A8\u6001\u8868\u60C5\u6570\u636E"
1439
- }, req.headers.cookie || cookie);
1440
- res.json(data2);
1441
- });
1442
- router.get("/fetch_music_work", async (req, res) => {
1443
- const data2 = await DouyinData({
1444
- methodType: "\u97F3\u4E50\u6570\u636E",
1445
- music_id: req.query.music_id
1446
- }, req.headers.cookie || cookie);
1447
- res.json(data2);
1448
- });
1449
- router.get("/fetch_user_mix_videos", async (req, res) => {
1450
- const data2 = await DouyinData({
1451
- methodType: "\u5408\u8F91\u4F5C\u54C1\u6570\u636E",
1452
- aweme_id: req.query.aweme_id
1453
- }, req.headers.cookie || cookie);
1454
- res.json(data2);
1455
- });
1456
- router.get("/fetch_user_live_videos", async (req, res) => {
1457
- const data2 = await DouyinData({
1458
- methodType: "\u76F4\u64AD\u95F4\u4FE1\u606F\u6570\u636E",
1459
- sec_uid: req.query.sec_uid
1460
- }, req.headers.cookie || cookie);
1461
- res.json(data2);
1462
- });
1463
- return router;
1464
- };
1465
1869
 
1466
1870
  // src/platform/kuaishou/API.ts
1467
1871
  var API = class {
@@ -1511,6 +1915,73 @@ var API = class {
1511
1915
  }
1512
1916
  };
1513
1917
  var KuaishouAPI = new API();
1918
+ var kuaishouAPI = new API();
1919
+ var kuaishouApiUrls = new API();
1920
+ var registerKuaishouRoutes = (cookie) => {
1921
+ const router = express.Router();
1922
+ router.get("/fetch_one_work", async (req, res) => {
1923
+ const data2 = await KuaishouData({
1924
+ methodType: "\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E",
1925
+ photoId: req.query.photoId
1926
+ }, req.headers.cookie || cookie);
1927
+ res.json(data2);
1928
+ });
1929
+ router.get("/fetch_work_comments", async (req, res) => {
1930
+ const data2 = await KuaishouData({
1931
+ methodType: "\u8BC4\u8BBA\u6570\u636E",
1932
+ photoId: req.query.photoId
1933
+ }, req.headers.cookie || cookie);
1934
+ res.json(data2);
1935
+ });
1936
+ router.get("/fetch_emoji_list", async (req, res) => {
1937
+ const data2 = await KuaishouData({
1938
+ methodType: "Emoji\u6570\u636E"
1939
+ }, req.headers.cookie || cookie);
1940
+ res.json(data2);
1941
+ });
1942
+ return router;
1943
+ };
1944
+
1945
+ // src/platform/kuaishou/KuaishouApi.ts
1946
+ var kuaishou = {
1947
+ /**
1948
+ * 获取单个视频作品数据
1949
+ * @param options 请求参数,包含 photoId 和可选的 typeMode
1950
+ * @param cookie 可选的用户 Cookie
1951
+ * @returns 接口返回的原始数据
1952
+ */
1953
+ async getWorkInfo(options, cookie) {
1954
+ const data2 = await KuaishouData({ ...options, methodType: "\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E" }, cookie);
1955
+ return data2;
1956
+ },
1957
+ /**
1958
+ * 获取评论数据
1959
+ * @param options 请求参数,包含 photoId 和可选的 typeMode
1960
+ * @param cookie 可选的用户 Cookie
1961
+ * @returns 接口返回的原始数据
1962
+ */
1963
+ async getComments(options, cookie) {
1964
+ const data2 = await KuaishouData({ ...options, methodType: "\u8BC4\u8BBA\u6570\u636E" }, cookie);
1965
+ return data2;
1966
+ },
1967
+ /**
1968
+ * 获取 Emoji 数据
1969
+ * @param options 可选的请求参数 (主要用于 typeMode)
1970
+ * @param cookie 可选的用户 Cookie
1971
+ * @returns 接口返回的原始数据
1972
+ */
1973
+ async getEmojiList(options, cookie) {
1974
+ const data2 = await KuaishouData({ ...options, methodType: "Emoji\u6570\u636E" }, cookie);
1975
+ return data2;
1976
+ }
1977
+ };
1978
+
1979
+ // src/platform/kuaishou/index.ts
1980
+ var kuaishouUtils = {
1981
+ kuaishouApiUrls,
1982
+ getKuaishouData,
1983
+ api: kuaishou
1984
+ };
1514
1985
 
1515
1986
  // src/platform/kuaishou/getdata.ts
1516
1987
  var defheaders3 = {
@@ -1529,7 +2000,7 @@ var KuaishouData = async (data2, cookie) => {
1529
2000
  switch (data2.methodType) {
1530
2001
  case "\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E": {
1531
2002
  KusiahouValidateData(data2, ["photoId"]);
1532
- const body = KuaishouAPI.\u5355\u4E2A\u4F5C\u54C1\u4FE1\u606F({ photoId: data2.photoId });
2003
+ const body = kuaishouAPI.\u5355\u4E2A\u4F5C\u54C1\u4FE1\u606F({ photoId: data2.photoId });
1533
2004
  const VideoData = await GlobalGetData3({
1534
2005
  url: body.url,
1535
2006
  method: "POST",
@@ -1541,7 +2012,7 @@ var KuaishouData = async (data2, cookie) => {
1541
2012
  }
1542
2013
  case "\u8BC4\u8BBA\u6570\u636E": {
1543
2014
  KusiahouValidateData(data2, ["photoId"]);
1544
- const body = KuaishouAPI.\u4F5C\u54C1\u8BC4\u8BBA\u4FE1\u606F({ photoId: data2.photoId });
2015
+ const body = kuaishouAPI.\u4F5C\u54C1\u8BC4\u8BBA\u4FE1\u606F({ photoId: data2.photoId });
1545
2016
  const VideoData = await GlobalGetData3({
1546
2017
  url: body.url,
1547
2018
  method: "POST",
@@ -1552,7 +2023,7 @@ var KuaishouData = async (data2, cookie) => {
1552
2023
  return VideoData;
1553
2024
  }
1554
2025
  case "Emoji\u6570\u636E": {
1555
- const body = KuaishouAPI.\u8868\u60C5();
2026
+ const body = kuaishouAPI.\u8868\u60C5();
1556
2027
  const EmojiData = await GlobalGetData3({
1557
2028
  url: body.url,
1558
2029
  method: "POST",
@@ -1562,6 +2033,9 @@ var KuaishouData = async (data2, cookie) => {
1562
2033
  });
1563
2034
  return EmojiData;
1564
2035
  }
2036
+ default:
2037
+ logger.warn(`\u672A\u77E5\u7684\u5FEB\u624B\u6570\u636E\u63A5\u53E3\uFF1A\u300C${logger.red(data2.methodType)}\u300D`);
2038
+ return null;
1565
2039
  }
1566
2040
  };
1567
2041
  async function GlobalGetData3(options) {
@@ -1576,30 +2050,6 @@ async function GlobalGetData3(options) {
1576
2050
  }
1577
2051
  return ResponseData;
1578
2052
  }
1579
- var registerKuaishouRoutes = (cookie) => {
1580
- const router = express.Router();
1581
- router.get("/fetch_one_work", async (req, res) => {
1582
- const data2 = await KuaishouData({
1583
- methodType: "\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E",
1584
- photoId: req.query.photoId
1585
- }, req.headers.cookie || cookie);
1586
- res.json(data2);
1587
- });
1588
- router.get("/fetch_work_comments", async (req, res) => {
1589
- const data2 = await KuaishouData({
1590
- methodType: "\u8BC4\u8BBA\u6570\u636E",
1591
- photoId: req.query.photoId
1592
- }, req.headers.cookie || cookie);
1593
- res.json(data2);
1594
- });
1595
- router.get("/fetch_emoji_list", async (req, res) => {
1596
- const data2 = await KuaishouData({
1597
- methodType: "Emoji\u6570\u636E"
1598
- }, req.headers.cookie || cookie);
1599
- res.json(data2);
1600
- });
1601
- return router;
1602
- };
1603
2053
 
1604
2054
  // src/model/DataFetchers.ts
1605
2055
  async function getDouyinData(type, arg2, arg3) {
@@ -1900,7 +2350,7 @@ var KusiahouValidateData = (data2, fields, atLeastOne = false) => {
1900
2350
  throw new Error(`\u83B7\u53D6\u300C${data2.methodType}\u300D${logger.red("\u7F3A\u5C11\u53C2\u6570")}: ${missingStr}`);
1901
2351
  }
1902
2352
  };
1903
- var amagi = class {
2353
+ var amagiClient = class {
1904
2354
  douyin;
1905
2355
  bilibili;
1906
2356
  kuaishou;
@@ -1937,7 +2387,7 @@ var amagi = class {
1937
2387
  return app;
1938
2388
  }
1939
2389
  /**
1940
- * 获取抖音数据
2390
+ * 快捷获取抖音数据
1941
2391
  * @param type - 请求数据类型
1942
2392
  * @param options - 请求参数,是一个对象
1943
2393
  * @returns 返回接口的原始数据
@@ -1962,7 +2412,7 @@ var amagi = class {
1962
2412
  return await getDouyinData(methodType, this.douyin, fullOptions);
1963
2413
  };
1964
2414
  /**
1965
- * 获取B站数据
2415
+ * 快捷获取B站数据
1966
2416
  * @param type - 请求数据类型
1967
2417
  * @param options - 请求参数,是一个对象
1968
2418
  * @returns 返回接口的原始数据
@@ -1986,7 +2436,7 @@ var amagi = class {
1986
2436
  return await getBilibiliData(methodType, this.bilibili, fullOptions);
1987
2437
  };
1988
2438
  /**
1989
- * 获取快手数据
2439
+ * 快捷获取快手数据
1990
2440
  * @param type - 请求数据类型
1991
2441
  * @param options - 请求参数,是一个对象
1992
2442
  * @returns 返回接口的原始数据
@@ -2012,9 +2462,12 @@ var amagi = class {
2012
2462
  };
2013
2463
 
2014
2464
  // src/index.ts
2015
- var index_default = amagi;
2465
+ var index_default = amagiClient;
2466
+ function amagi(options) {
2467
+ return new amagiClient(options);
2468
+ }
2016
2469
  function Amagi(options) {
2017
- return new amagi(options);
2470
+ return new amagiClient(options);
2018
2471
  }
2019
2472
 
2020
- export { Amagi, BilibiliData, BilibiliValidateData, DouyinData, DouyinValidateData, KuaishouAPI, KuaishouData, KusiahouValidateData, Networks, amagi, av2bv, bilibiliAPI, bv2av, index_default as default, douyinAPI, douyinSign, fetchBilibiliData, fetchDouyinData, fetchKuaishouData, getBilibiliData, getDouyinData, getKuaishouData, logMiddleware, logger, qtparam, registerBilibiliRoutes, registerDouyinRoutes, registerKuaishouRoutes, wbi_sign };
2473
+ export { Amagi, BilibiliValidateData, DouyinValidateData, KuaishouAPI, KusiahouValidateData, Networks, amagi, amagiClient, av2bv, bilibili, bilibiliAPI, bilibiliApiUrls, bilibiliUtils, bv2av, index_default as default, douyin, douyinAPI, douyinApiUrls, douyinSign, douyinUtils, fetchBilibiliData, fetchDouyinData, fetchKuaishouData, getBilibiliData, getDouyinData, getKuaishouData, kuaishou, kuaishouAPI, kuaishouApiUrls, kuaishouUtils, logMiddleware, logger, qtparam, registerBilibiliRoutes, registerDouyinRoutes, registerKuaishouRoutes, wbi_sign };