@ikenxuan/amagi 4.4.8 → 4.4.10

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 = {
@@ -241,447 +735,169 @@ var BilibiliData = async (data2, cookie) => {
241
735
  headers: headers2,
242
736
  ...data2
243
737
  });
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;
264
- }
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,
270
- ...data2
271
- });
272
- return result;
273
- }
274
- case "\u7533\u8BF7\u4E8C\u7EF4\u7801": {
275
- const result = await GlobalGetData({
276
- url: bilibiliAPI.\u7533\u8BF7\u4E8C\u7EF4\u7801(),
277
- headers: headers2,
278
- ...data2
279
- });
280
- return result;
281
- }
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 }),
286
- headers: headers2,
287
- ...data2
288
- }).getHeadersAndData();
289
- return result;
290
- }
291
- case "\u767B\u5F55\u57FA\u672C\u4FE1\u606F": {
292
- const result = await GlobalGetData({
293
- url: bilibiliAPI.\u767B\u5F55\u57FA\u672C\u4FE1\u606F(),
294
- headers: headers2,
295
- ...data2
296
- });
297
- return result;
298
- }
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 }),
303
- headers: headers2,
304
- ...data2
305
- });
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
- };
329
- }
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
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;
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;
522
827
  }
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
828
  };
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;
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;
672
848
  }
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
- }
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 {
@@ -1042,13 +1258,21 @@ var headers = {
1042
1258
  "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36"
1043
1259
  };
1044
1260
  var douyinSign = class {
1045
- /** 生成一个指定长度的随机字符串 */
1261
+ /**
1262
+ * 生成一个指定长度的随机字符串
1263
+ * @param length 字符串长度,默认为116
1264
+ * @returns
1265
+ */
1046
1266
  static Mstoken(length) {
1047
1267
  const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
1048
- const randomBytes = crypto.randomBytes(length);
1268
+ const randomBytes = crypto.randomBytes(length ?? 116);
1049
1269
  return Array.from(randomBytes, (byte) => characters[byte % characters.length]).join("");
1050
1270
  }
1051
- /** a_bogus 签名算法 */
1271
+ /**
1272
+ * a_bogus 签名算法
1273
+ * @param url 需要签名的地址
1274
+ * @returns 对此地址签名后的URL查询参数
1275
+ */
1052
1276
  static AB(url) {
1053
1277
  return a_bogus_default(url, headers["User-Agent"]);
1054
1278
  }
@@ -1073,70 +1297,339 @@ var douyinSign = class {
1073
1297
  }
1074
1298
  };
1075
1299
 
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
- }
1300
+ // src/platform/douyin/API.ts
1301
+ var fp = douyinSign.VerifyFpManager();
1302
+ var DouyinAPI = class {
1303
+ \u89C6\u9891\u6216\u56FE\u96C6(data2) {
1304
+ 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(
1305
+ 116
1306
+ )}&verifyFp=${fp}&fp=${fp}`;
1307
+ }
1308
+ \u8BC4\u8BBA(data2) {
1309
+ 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(
1310
+ 116
1311
+ )}&verifyFp=${fp}&fp=${fp}`;
1312
+ }
1313
+ \u4E8C\u7EA7\u8BC4\u8BBA(data2) {
1314
+ 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}`;
1315
+ }
1316
+ \u52A8\u56FE(data2) {
1317
+ 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(
1318
+ 116
1319
+ )}&verifyFp=${fp}&fp=${fp}`;
1320
+ }
1321
+ \u8868\u60C5() {
1322
+ return "https://www.douyin.com/aweme/v1/web/emoji/list";
1323
+ }
1324
+ \u7528\u6237\u4E3B\u9875\u89C6\u9891(data2) {
1325
+ 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(
1326
+ 116
1327
+ )}&verifyFp=${fp}&fp=${fp}`;
1328
+ }
1329
+ \u7528\u6237\u4E3B\u9875\u4FE1\u606F(data2) {
1330
+ 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(
1331
+ 116
1332
+ )}&verifyFp=${fp}&fp=${fp}`;
1333
+ }
1334
+ \u70ED\u70B9\u8BCD(data2) {
1335
+ 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(
1336
+ 116
1337
+ )}&verifyFp=${fp}&fp=${fp}`;
1338
+ }
1339
+ \u641C\u7D22(data2) {
1340
+ 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(
1341
+ 116
1342
+ )}&verifyFp=${fp}&fp=${fp}&search_id=${data2.search_id ?? ""}&count=${data2.number ?? 10}`;
1343
+ }
1344
+ \u4E92\u52A8\u8868\u60C5() {
1345
+ 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(
1346
+ 116
1347
+ )}&verifyFp=${fp}&fp=${fp}`;
1348
+ }
1349
+ \u80CC\u666F\u97F3\u4E50(data2) {
1350
+ 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(
1351
+ 116
1352
+ )}&verifyFp=${fp}&fp=${fp}`;
1353
+ }
1354
+ \u76F4\u64AD\u95F4\u4FE1\u606F(data2) {
1355
+ 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(
1356
+ 116
1357
+ )}&verifyFp=${fp}&fp=${fp}`;
1358
+ }
1359
+ \u7533\u8BF7\u4E8C\u7EF4\u7801(data2) {
1360
+ return `https://sso.douyin.com/get_qrcode/?verifyFp=${data2.verify_fp}&fp=${data2.verify_fp}`;
1361
+ }
1362
+ };
1363
+ var douyinAPI = new DouyinAPI();
1364
+ var douyinApiUrls = new DouyinAPI();
1365
+
1366
+ // src/platform/douyin/DouyinApi.ts
1367
+ var douyin = {
1368
+ /**
1369
+ * 聚合解析 (视频/图集/合辑)
1370
+ * @param options 请求参数,包含 aweme_id 和可选的 typeMode
1371
+ * @param cookie 有效的用户 Cookie
1372
+ * @returns 接口返回的原始数据
1373
+ */
1374
+ async getWorkInfo(options, cookie) {
1375
+ const { typeMode, ...restOptions } = options;
1376
+ const data2 = await DouyinData({ ...restOptions, methodType: "\u805A\u5408\u89E3\u6790" }, cookie);
1377
+ return data2;
1378
+ },
1379
+ /**
1380
+ * 获取视频作品数据
1381
+ * @param options 请求参数,包含 aweme_id 和可选的 typeMode
1382
+ * @param cookie 有效的用户 Cookie
1383
+ * @returns 接口返回的原始数据
1384
+ */
1385
+ async getVideoWorkInfo(options, cookie) {
1386
+ const { typeMode, ...restOptions } = options;
1387
+ const data2 = await DouyinData({ ...restOptions, methodType: "\u89C6\u9891\u4F5C\u54C1\u6570\u636E" }, cookie);
1388
+ return data2;
1389
+ },
1390
+ /**
1391
+ * 获取图集作品数据
1392
+ * @param options 请求参数,包含 aweme_id 和可选的 typeMode
1393
+ * @param cookie 有效的用户 Cookie
1394
+ * @returns 接口返回的原始数据
1395
+ */
1396
+ async getImageAlbumWorkInfo(options, cookie) {
1397
+ const { typeMode, ...restOptions } = options;
1398
+ const data2 = await DouyinData({ ...restOptions, methodType: "\u56FE\u96C6\u4F5C\u54C1\u6570\u636E" }, cookie);
1399
+ return data2;
1400
+ },
1401
+ /**
1402
+ * 获取合辑作品数据
1403
+ * @param options 请求参数,包含 aweme_id 和可选的 typeMode
1404
+ * @param cookie 有效的用户 Cookie
1405
+ * @returns 接口返回的原始数据
1406
+ */
1407
+ async getSlidesWorkInfo(options, cookie) {
1408
+ const { typeMode, ...restOptions } = options;
1409
+ const data2 = await DouyinData({ ...restOptions, methodType: "\u5408\u8F91\u4F5C\u54C1\u6570\u636E" }, cookie);
1410
+ return data2;
1411
+ },
1412
+ /**
1413
+ * 获取评论数据
1414
+ * @param options 请求参数,包含 aweme_id, 可选的 number, cursor 和 typeMode
1415
+ * @param cookie 有效的用户 Cookie
1416
+ * @returns 接口返回的原始数据
1417
+ */
1418
+ async getComments(options, cookie) {
1419
+ const { typeMode, ...restOptions } = options;
1420
+ const data2 = await DouyinData({ ...restOptions, methodType: "\u8BC4\u8BBA\u6570\u636E" }, cookie);
1421
+ return data2;
1422
+ },
1423
+ /**
1424
+ * 获取指定评论回复数据
1425
+ * @param options 请求参数,包含 aweme_id, comment_id, 可选的 number, cursor 和 typeMode
1426
+ * @param cookie 有效的用户 Cookie
1427
+ * @returns 接口返回的原始数据
1428
+ */
1429
+ async getCommentReplies(options, cookie) {
1430
+ const { typeMode, ...restOptions } = options;
1431
+ const data2 = await DouyinData({ ...restOptions, methodType: "\u6307\u5B9A\u8BC4\u8BBA\u56DE\u590D\u6570\u636E" }, cookie);
1432
+ return data2;
1433
+ },
1434
+ /**
1435
+ * 获取用户主页数据
1436
+ * @param options 请求参数,包含 sec_uid 和可选的 typeMode
1437
+ * @param cookie 有效的用户 Cookie
1438
+ * @returns 接口返回的原始数据
1439
+ */
1440
+ async getUserProfile(options, cookie) {
1441
+ const { typeMode, ...restOptions } = options;
1442
+ const data2 = await DouyinData({ ...restOptions, methodType: "\u7528\u6237\u4E3B\u9875\u6570\u636E" }, cookie);
1443
+ return data2;
1444
+ },
1445
+ /**
1446
+ * 获取 Emoji 数据
1447
+ * @param options 可选的请求参数 (主要用于 typeMode)
1448
+ * @param cookie 可选的用户 Cookie
1449
+ * @returns 接口返回的原始数据
1450
+ */
1451
+ async getEmojiList(options, cookie) {
1452
+ const { typeMode, ...restOptions } = options;
1453
+ const data2 = await DouyinData({ ...restOptions, methodType: "Emoji\u6570\u636E" }, cookie);
1454
+ return data2;
1455
+ },
1456
+ /**
1457
+ * 获取动态表情数据
1458
+ * @param options 可选的请求参数 (主要用于 typeMode)
1459
+ * @param cookie 有效的用户 Cookie
1460
+ * @returns 接口返回的原始数据
1461
+ */
1462
+ async getEmojiProList(options, cookie) {
1463
+ const { typeMode, ...restOptions } = options;
1464
+ const data2 = await DouyinData({ ...restOptions, methodType: "\u52A8\u6001\u8868\u60C5\u6570\u636E" }, cookie);
1465
+ return data2;
1466
+ },
1467
+ /**
1468
+ * 获取用户主页视频列表数据
1469
+ * @param options 请求参数,包含 sec_uid, 可选的 number, max_cursor 和 typeMode
1470
+ * @param cookie 有效的用户 Cookie
1471
+ * @returns 接口返回的原始数据
1472
+ */
1473
+ async getUserVideos(options, cookie) {
1474
+ const { typeMode, ...restOptions } = options;
1475
+ const data2 = await DouyinData({ ...restOptions, methodType: "\u7528\u6237\u4E3B\u9875\u89C6\u9891\u5217\u8868\u6570\u636E" }, cookie);
1476
+ return data2;
1477
+ },
1478
+ /**
1479
+ * 获取音乐数据
1480
+ * @param options 请求参数,包含 music_id 和可选的 typeMode
1481
+ * @param cookie 有效的用户 Cookie
1482
+ * @returns 接口返回的原始数据
1483
+ */
1484
+ async getMusicInfo(options, cookie) {
1485
+ const { typeMode, ...restOptions } = options;
1486
+ const data2 = await DouyinData({ ...restOptions, methodType: "\u97F3\u4E50\u6570\u636E" }, cookie);
1487
+ return data2;
1488
+ },
1489
+ /**
1490
+ * 获取热点词数据
1491
+ * @param options 请求参数,包含 query, 可选的 number 和 typeMode
1492
+ * @param cookie 有效的用户 Cookie
1493
+ * @returns 接口返回的原始数据
1494
+ */
1495
+ async getSuggestWords(options, cookie) {
1496
+ const { typeMode, ...restOptions } = options;
1497
+ const data2 = await DouyinData({ ...restOptions, methodType: "\u70ED\u70B9\u8BCD\u6570\u636E" }, cookie);
1498
+ return data2;
1499
+ },
1500
+ /**
1501
+ * 获取搜索数据
1502
+ * @param options 请求参数,包含 query, 可选的 number, search_id, cursor 和 typeMode
1503
+ * @param cookie 有效的用户 Cookie
1504
+ * @returns 接口返回的原始数据
1505
+ */
1506
+ async search(options, cookie) {
1507
+ const { typeMode, ...restOptions } = options;
1508
+ const data2 = await DouyinData({ ...restOptions, methodType: "\u641C\u7D22\u6570\u636E" }, cookie);
1509
+ return data2;
1510
+ },
1511
+ /**
1512
+ * 获取直播间信息
1513
+ * @param options 请求参数,包含 sec_uid 和可选的 typeMode
1514
+ * @param cookie 有效的用户 Cookie
1515
+ * @returns 接口返回的原始数据
1516
+ */
1517
+ async getLiveRoomInfo(options, cookie) {
1518
+ const { typeMode, ...restOptions } = options;
1519
+ const data2 = await DouyinData({ ...restOptions, methodType: "\u76F4\u64AD\u95F4\u4FE1\u606F\u6570\u636E" }, cookie);
1520
+ return data2;
1521
+ },
1522
+ /**
1523
+ * 申请二维码数据
1524
+ * @param options 请求参数,包含 verify_fp 和可选的 typeMode
1525
+ * @param cookie 有效的用户 Cookie
1526
+ * @returns 接口返回的原始数据 (any)
1527
+ */
1528
+ async getLoginQrcode(options, cookie) {
1529
+ const { typeMode, ...restOptions } = options;
1530
+ const data2 = await DouyinData({ ...restOptions, methodType: "\u7533\u8BF7\u4E8C\u7EF4\u7801\u6570\u636E" }, cookie);
1531
+ return data2;
1532
+ }
1533
+ };
1534
+ var registerDouyinRoutes = (cookie) => {
1535
+ const router = express.Router();
1536
+ router.get("/fetch_one_work", async (req, res) => {
1537
+ const data2 = await DouyinData({
1538
+ methodType: "\u805A\u5408\u89E3\u6790",
1539
+ aweme_id: req.query.aweme_id
1540
+ }, req.headers.cookie || cookie);
1541
+ res.json(data2);
1542
+ });
1543
+ router.get("/fetch_work_comments", async (req, res) => {
1544
+ const data2 = await DouyinData({
1545
+ methodType: "\u8BC4\u8BBA\u6570\u636E",
1546
+ aweme_id: req.query.aweme_id,
1547
+ number: parseInt(req.query.number ?? "50"),
1548
+ cursor: parseInt(req.query.cursor ?? "0")
1549
+ }, req.headers.cookie || cookie);
1550
+ res.json(data2);
1551
+ });
1552
+ router.get("/fetch_video_comment_replies", async (req, res) => {
1553
+ const data2 = await DouyinData({
1554
+ methodType: "\u6307\u5B9A\u8BC4\u8BBA\u56DE\u590D\u6570\u636E",
1555
+ aweme_id: req.query.aweme_id,
1556
+ comment_id: req.query.comment_id
1557
+ }, req.headers.cookie || cookie);
1558
+ res.json(data2);
1559
+ });
1560
+ router.get("/fetch_user_info", async (req, res) => {
1561
+ const data2 = await DouyinData({
1562
+ methodType: "\u7528\u6237\u4E3B\u9875\u6570\u636E",
1563
+ sec_uid: req.query.sec_uid
1564
+ }, req.headers.cookie || cookie);
1565
+ res.json(data2);
1566
+ });
1567
+ router.get("/fetch_user_post_videos", async (req, res) => {
1568
+ const data2 = await DouyinData({
1569
+ methodType: "\u7528\u6237\u4E3B\u9875\u89C6\u9891\u5217\u8868\u6570\u636E",
1570
+ sec_uid: req.query.sec_uid
1571
+ }, req.headers.cookie || cookie);
1572
+ res.json(data2);
1573
+ });
1574
+ router.get("/fetch_suggest_words", async (req, res) => {
1575
+ const data2 = await DouyinData({
1576
+ methodType: "\u70ED\u70B9\u8BCD\u6570\u636E",
1577
+ query: req.query.query
1578
+ }, req.headers.cookie || cookie);
1579
+ res.json(data2);
1580
+ });
1581
+ router.get("/fetch_search_info", async (req, res) => {
1582
+ const data2 = await DouyinData({
1583
+ methodType: "\u641C\u7D22\u6570\u636E",
1584
+ query: req.query.query,
1585
+ number: parseInt(req.query.number ?? "10"),
1586
+ search_id: req.query.search_id
1587
+ }, req.headers.cookie || cookie);
1588
+ res.json(data2);
1589
+ });
1590
+ router.get("/fetch_emoji_list", async (req, res) => {
1591
+ const data2 = await DouyinData({
1592
+ methodType: "Emoji\u6570\u636E"
1593
+ }, req.headers.cookie || cookie);
1594
+ res.json(data2);
1595
+ });
1596
+ router.get("/fetch_emoji_pro_list", async (req, res) => {
1597
+ const data2 = await DouyinData({
1598
+ methodType: "\u52A8\u6001\u8868\u60C5\u6570\u636E"
1599
+ }, req.headers.cookie || cookie);
1600
+ res.json(data2);
1601
+ });
1602
+ router.get("/fetch_music_work", async (req, res) => {
1603
+ const data2 = await DouyinData({
1604
+ methodType: "\u97F3\u4E50\u6570\u636E",
1605
+ music_id: req.query.music_id
1606
+ }, req.headers.cookie || cookie);
1607
+ res.json(data2);
1608
+ });
1609
+ router.get("/fetch_user_mix_videos", async (req, res) => {
1610
+ const data2 = await DouyinData({
1611
+ methodType: "\u5408\u8F91\u4F5C\u54C1\u6570\u636E",
1612
+ aweme_id: req.query.aweme_id
1613
+ }, req.headers.cookie || cookie);
1614
+ res.json(data2);
1615
+ });
1616
+ router.get("/fetch_user_live_videos", async (req, res) => {
1617
+ const data2 = await DouyinData({
1618
+ methodType: "\u76F4\u64AD\u95F4\u4FE1\u606F\u6570\u636E",
1619
+ sec_uid: req.query.sec_uid
1620
+ }, req.headers.cookie || cookie);
1621
+ res.json(data2);
1622
+ });
1623
+ return router;
1624
+ };
1625
+
1626
+ // src/platform/douyin/index.ts
1627
+ var douyinUtils = {
1628
+ sign: douyinSign,
1629
+ douyinApiUrls,
1630
+ getDouyinData,
1631
+ api: douyin
1138
1632
  };
1139
- var douyinAPI = new DouyinAPI();
1140
1633
 
1141
1634
  // src/platform/douyin/getdata.ts
1142
1635
  var defheaders2 = {
@@ -1257,6 +1750,10 @@ var DouyinData = async (data2, cookie) => {
1257
1750
  },
1258
1751
  ...data2
1259
1752
  });
1753
+ if (response.data.length === 0) {
1754
+ 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);
1755
+ return false;
1756
+ }
1260
1757
  if (!response.data) {
1261
1758
  response.data = [];
1262
1759
  }
@@ -1331,6 +1828,9 @@ var DouyinData = async (data2, cookie) => {
1331
1828
  });
1332
1829
  return LoginQrcodeStatusData;
1333
1830
  }
1831
+ default:
1832
+ logger.warn(`\u672A\u77E5\u7684B\u7AD9\u6570\u636E\u63A5\u53E3\uFF1A\u300C${logger.red(data2.methodType)}\u300D`);
1833
+ return null;
1334
1834
  }
1335
1835
  };
1336
1836
  async function fetchPaginatedData(apiUrlGenerator, params, maxPageSize, headers2) {
@@ -1366,102 +1866,14 @@ async function fetchPaginatedData(apiUrlGenerator, params, maxPageSize, headers2
1366
1866
  async function GlobalGetData2(options) {
1367
1867
  const ResponseData = await new Networks(options).getData();
1368
1868
  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);
1869
+ logger.warn(`\u83B7\u53D6\u54CD\u5E94\u6570\u636E\u5931\u8D25\uFF01\u63A5\u53E3\u8FD4\u56DE\u5185\u5BB9\u4E3A\u7A7A
1870
+ \u4F60\u7684\u6296\u97F3ck\u53EF\u80FD\u5DF2\u7ECF\u5931\u6548\uFF01
1871
+ \u8BF7\u6C42\u7C7B\u578B\uFF1A\u300C${options.methodType}\u300D
1872
+ \u8BF7\u6C42URL\uFF1A options.url`);
1370
1873
  return false;
1371
1874
  }
1372
1875
  return ResponseData;
1373
1876
  }
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
1877
 
1466
1878
  // src/platform/kuaishou/API.ts
1467
1879
  var API = class {
@@ -1511,6 +1923,73 @@ var API = class {
1511
1923
  }
1512
1924
  };
1513
1925
  var KuaishouAPI = new API();
1926
+ var kuaishouAPI = new API();
1927
+ var kuaishouApiUrls = new API();
1928
+ var registerKuaishouRoutes = (cookie) => {
1929
+ const router = express.Router();
1930
+ router.get("/fetch_one_work", async (req, res) => {
1931
+ const data2 = await KuaishouData({
1932
+ methodType: "\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E",
1933
+ photoId: req.query.photoId
1934
+ }, req.headers.cookie || cookie);
1935
+ res.json(data2);
1936
+ });
1937
+ router.get("/fetch_work_comments", async (req, res) => {
1938
+ const data2 = await KuaishouData({
1939
+ methodType: "\u8BC4\u8BBA\u6570\u636E",
1940
+ photoId: req.query.photoId
1941
+ }, req.headers.cookie || cookie);
1942
+ res.json(data2);
1943
+ });
1944
+ router.get("/fetch_emoji_list", async (req, res) => {
1945
+ const data2 = await KuaishouData({
1946
+ methodType: "Emoji\u6570\u636E"
1947
+ }, req.headers.cookie || cookie);
1948
+ res.json(data2);
1949
+ });
1950
+ return router;
1951
+ };
1952
+
1953
+ // src/platform/kuaishou/KuaishouApi.ts
1954
+ var kuaishou = {
1955
+ /**
1956
+ * 获取单个视频作品数据
1957
+ * @param options 请求参数,包含 photoId 和可选的 typeMode
1958
+ * @param cookie 可选的用户 Cookie
1959
+ * @returns 接口返回的原始数据
1960
+ */
1961
+ async getWorkInfo(options, cookie) {
1962
+ const data2 = await KuaishouData({ ...options, methodType: "\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E" }, cookie);
1963
+ return data2;
1964
+ },
1965
+ /**
1966
+ * 获取评论数据
1967
+ * @param options 请求参数,包含 photoId 和可选的 typeMode
1968
+ * @param cookie 可选的用户 Cookie
1969
+ * @returns 接口返回的原始数据
1970
+ */
1971
+ async getComments(options, cookie) {
1972
+ const data2 = await KuaishouData({ ...options, methodType: "\u8BC4\u8BBA\u6570\u636E" }, cookie);
1973
+ return data2;
1974
+ },
1975
+ /**
1976
+ * 获取 Emoji 数据
1977
+ * @param options 可选的请求参数 (主要用于 typeMode)
1978
+ * @param cookie 可选的用户 Cookie
1979
+ * @returns 接口返回的原始数据
1980
+ */
1981
+ async getEmojiList(options, cookie) {
1982
+ const data2 = await KuaishouData({ ...options, methodType: "Emoji\u6570\u636E" }, cookie);
1983
+ return data2;
1984
+ }
1985
+ };
1986
+
1987
+ // src/platform/kuaishou/index.ts
1988
+ var kuaishouUtils = {
1989
+ kuaishouApiUrls,
1990
+ getKuaishouData,
1991
+ api: kuaishou
1992
+ };
1514
1993
 
1515
1994
  // src/platform/kuaishou/getdata.ts
1516
1995
  var defheaders3 = {
@@ -1529,7 +2008,7 @@ var KuaishouData = async (data2, cookie) => {
1529
2008
  switch (data2.methodType) {
1530
2009
  case "\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E": {
1531
2010
  KusiahouValidateData(data2, ["photoId"]);
1532
- const body = KuaishouAPI.\u5355\u4E2A\u4F5C\u54C1\u4FE1\u606F({ photoId: data2.photoId });
2011
+ const body = kuaishouAPI.\u5355\u4E2A\u4F5C\u54C1\u4FE1\u606F({ photoId: data2.photoId });
1533
2012
  const VideoData = await GlobalGetData3({
1534
2013
  url: body.url,
1535
2014
  method: "POST",
@@ -1541,7 +2020,7 @@ var KuaishouData = async (data2, cookie) => {
1541
2020
  }
1542
2021
  case "\u8BC4\u8BBA\u6570\u636E": {
1543
2022
  KusiahouValidateData(data2, ["photoId"]);
1544
- const body = KuaishouAPI.\u4F5C\u54C1\u8BC4\u8BBA\u4FE1\u606F({ photoId: data2.photoId });
2023
+ const body = kuaishouAPI.\u4F5C\u54C1\u8BC4\u8BBA\u4FE1\u606F({ photoId: data2.photoId });
1545
2024
  const VideoData = await GlobalGetData3({
1546
2025
  url: body.url,
1547
2026
  method: "POST",
@@ -1552,7 +2031,7 @@ var KuaishouData = async (data2, cookie) => {
1552
2031
  return VideoData;
1553
2032
  }
1554
2033
  case "Emoji\u6570\u636E": {
1555
- const body = KuaishouAPI.\u8868\u60C5();
2034
+ const body = kuaishouAPI.\u8868\u60C5();
1556
2035
  const EmojiData = await GlobalGetData3({
1557
2036
  url: body.url,
1558
2037
  method: "POST",
@@ -1562,6 +2041,9 @@ var KuaishouData = async (data2, cookie) => {
1562
2041
  });
1563
2042
  return EmojiData;
1564
2043
  }
2044
+ default:
2045
+ logger.warn(`\u672A\u77E5\u7684\u5FEB\u624B\u6570\u636E\u63A5\u53E3\uFF1A\u300C${logger.red(data2.methodType)}\u300D`);
2046
+ return null;
1565
2047
  }
1566
2048
  };
1567
2049
  async function GlobalGetData3(options) {
@@ -1576,30 +2058,6 @@ async function GlobalGetData3(options) {
1576
2058
  }
1577
2059
  return ResponseData;
1578
2060
  }
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
2061
 
1604
2062
  // src/model/DataFetchers.ts
1605
2063
  async function getDouyinData(type, arg2, arg3) {
@@ -1900,7 +2358,7 @@ var KusiahouValidateData = (data2, fields, atLeastOne = false) => {
1900
2358
  throw new Error(`\u83B7\u53D6\u300C${data2.methodType}\u300D${logger.red("\u7F3A\u5C11\u53C2\u6570")}: ${missingStr}`);
1901
2359
  }
1902
2360
  };
1903
- var amagi = class {
2361
+ var amagiClient = class {
1904
2362
  douyin;
1905
2363
  bilibili;
1906
2364
  kuaishou;
@@ -1908,10 +2366,10 @@ var amagi = class {
1908
2366
  *
1909
2367
  * @param cookie - 包含抖音ck、B站ck、快手ck的对象
1910
2368
  */
1911
- constructor(data2) {
1912
- this.douyin = (data2 == null ? void 0 : data2.douyin) ?? "";
1913
- this.bilibili = (data2 == null ? void 0 : data2.bilibili) ?? "";
1914
- this.kuaishou = (data2 == null ? void 0 : data2.kuaishou) ?? "";
2369
+ constructor(options) {
2370
+ this.douyin = (options == null ? void 0 : options.douyin) ?? "";
2371
+ this.bilibili = (options == null ? void 0 : options.bilibili) ?? "";
2372
+ this.kuaishou = (options == null ? void 0 : options.kuaishou) ?? "";
1915
2373
  }
1916
2374
  /**
1917
2375
  * 启动本地 HTTP 服务
@@ -1937,22 +2395,10 @@ var amagi = class {
1937
2395
  return app;
1938
2396
  }
1939
2397
  /**
1940
- * 获取抖音数据
2398
+ * 快捷获取抖音数据
1941
2399
  * @param type - 请求数据类型
1942
2400
  * @param options - 请求参数,是一个对象
1943
2401
  * @returns 返回接口的原始数据
1944
- * @example
1945
- * ```ts
1946
- * import Client from '@ikenxuan/amagi'
1947
- *
1948
- * const amagi = new Client({
1949
- * douyin: '' // 有效的抖音ck
1950
- * })
1951
- * const data = await amagi.getDouyinData('搜索数据', {
1952
- * query: '114514',
1953
- * number: 10
1954
- * })
1955
- * ```
1956
2402
  */
1957
2403
  getDouyinData = async (methodType, options) => {
1958
2404
  const fullOptions = {
@@ -1962,21 +2408,10 @@ var amagi = class {
1962
2408
  return await getDouyinData(methodType, this.douyin, fullOptions);
1963
2409
  };
1964
2410
  /**
1965
- * 获取B站数据
2411
+ * 快捷获取B站数据
1966
2412
  * @param type - 请求数据类型
1967
2413
  * @param options - 请求参数,是一个对象
1968
2414
  * @returns 返回接口的原始数据
1969
- * @example
1970
- * ```ts
1971
- * import Client from '@ikenxuan/amagi'
1972
- *
1973
- * const amagi = new Client({
1974
- * bilibili: '' // 有效的B站ck
1975
- * })
1976
- * const data = await amagi.getBilibiliData('单个视频作品数据', {
1977
- * bvid: 'BV1fK4y1q79u'
1978
- * })
1979
- * ```
1980
2415
  */
1981
2416
  getBilibiliData = async (methodType, options) => {
1982
2417
  const fullOptions = {
@@ -1986,21 +2421,10 @@ var amagi = class {
1986
2421
  return await getBilibiliData(methodType, this.bilibili, fullOptions);
1987
2422
  };
1988
2423
  /**
1989
- * 获取快手数据
2424
+ * 快捷获取快手数据
1990
2425
  * @param type - 请求数据类型
1991
2426
  * @param options - 请求参数,是一个对象
1992
2427
  * @returns 返回接口的原始数据
1993
- * @example
1994
- * ```ts
1995
- * import Client from '@ikenxuan/amagi'
1996
- *
1997
- * const amagi = new Client({
1998
- * kuaishou: '' // 有效的快手ck
1999
- * })
2000
- * const data = await amagi.getKuaishouData('单个视频作品数据', {
2001
- * photoId: '3xdpv6sfi8yjsqy'
2002
- * })
2003
- * ```
2004
2428
  */
2005
2429
  getKuaishouData = async (methodType, options) => {
2006
2430
  const fullOptions = {
@@ -2012,9 +2436,13 @@ var amagi = class {
2012
2436
  };
2013
2437
 
2014
2438
  // src/index.ts
2015
- var index_default = amagi;
2016
- function Amagi(options) {
2017
- return new amagi(options);
2018
- }
2439
+ var createAmagiClient = (data2) => {
2440
+ return new amagiClient(data2);
2441
+ };
2442
+ Object.defineProperty(createAmagiClient, "prototype", {
2443
+ value: amagiClient.prototype
2444
+ });
2445
+ var Client = createAmagiClient;
2446
+ var index_default = Client;
2019
2447
 
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 };
2448
+ export { BilibiliValidateData, Client, DouyinValidateData, KuaishouAPI, KusiahouValidateData, Networks, 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 };