@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.
@@ -78,6 +78,500 @@ var BiLiBiLiAPI = class {
78
78
  }
79
79
  };
80
80
  var bilibiliAPI = new BiLiBiLiAPI();
81
+ var bilibiliApiUrls = new BiLiBiLiAPI();
82
+
83
+ // src/platform/bilibili/qtparam.ts
84
+ async function qtparam(BASEURL, cookie) {
85
+ if (cookie === "") return { QUERY: "&platform=html5", STATUS: "!isLogin" };
86
+ const logininfo = await new Networks({ url: bilibiliAPI.\u767B\u5F55\u57FA\u672C\u4FE1\u606F(), headers: { Cookie: cookie } }).getData();
87
+ const sign = await wbi_sign(BASEURL, cookie);
88
+ const qn = [6, 16, 32, 64, 74, 80, 112, 116, 120, 125, 126, 127];
89
+ let isvip;
90
+ logininfo.data.vipStatus === 1 ? isvip = true : isvip = false;
91
+ if (isvip) {
92
+ return { QUERY: `&fnval=16&fourk=1&${sign}`, STATUS: "isLogin", isvip };
93
+ } else return { QUERY: `&qn=${qn[3]}&fnval=16`, STATUS: "isLogin", isvip };
94
+ }
95
+ var mixinKeyEncTab = [
96
+ 46,
97
+ 47,
98
+ 18,
99
+ 2,
100
+ 53,
101
+ 8,
102
+ 23,
103
+ 32,
104
+ 15,
105
+ 50,
106
+ 10,
107
+ 31,
108
+ 58,
109
+ 3,
110
+ 45,
111
+ 35,
112
+ 27,
113
+ 43,
114
+ 5,
115
+ 49,
116
+ 33,
117
+ 9,
118
+ 42,
119
+ 19,
120
+ 29,
121
+ 28,
122
+ 14,
123
+ 39,
124
+ 12,
125
+ 38,
126
+ 41,
127
+ 13,
128
+ 37,
129
+ 48,
130
+ 7,
131
+ 16,
132
+ 24,
133
+ 55,
134
+ 40,
135
+ 61,
136
+ 26,
137
+ 17,
138
+ 0,
139
+ 1,
140
+ 60,
141
+ 51,
142
+ 30,
143
+ 4,
144
+ 22,
145
+ 25,
146
+ 54,
147
+ 21,
148
+ 56,
149
+ 59,
150
+ 6,
151
+ 63,
152
+ 57,
153
+ 62,
154
+ 11,
155
+ 36,
156
+ 20,
157
+ 34,
158
+ 44,
159
+ 52
160
+ ];
161
+ var getMixinKey = (orig) => mixinKeyEncTab.map((n) => orig[n]).join("").slice(0, 32);
162
+ function encWbi(params, img_key, sub_key) {
163
+ const mixin_key = getMixinKey(img_key + sub_key);
164
+ const curr_time = Math.round(Date.now() / 1e3);
165
+ const chr_filter = /[!'()*]/g;
166
+ Object.assign(params, { wts: curr_time });
167
+ const query = Object.keys(params).sort().map((key) => {
168
+ const value = params[key].toString().replace(chr_filter, "");
169
+ return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
170
+ }).join("&");
171
+ const wbi_sign2 = crypto__default.default.createHash("md5").update(query + mixin_key).digest("hex");
172
+ return `&wts=${curr_time}&w_rid=${wbi_sign2}`;
173
+ }
174
+ async function getWbiKeys(cookie) {
175
+ const res = await axios__default.default("https://api.bilibili.com/x/web-interface/nav", {
176
+ headers: {
177
+ Cookie: cookie
178
+ }
179
+ });
180
+ const responseJson = res.data;
181
+ const response = responseJson;
182
+ const {
183
+ data: {
184
+ wbi_img: { img_url, sub_url }
185
+ }
186
+ } = response;
187
+ return {
188
+ img_key: img_url.slice(img_url.lastIndexOf("/") + 1, img_url.lastIndexOf(".")),
189
+ sub_key: sub_url.slice(sub_url.lastIndexOf("/") + 1, sub_url.lastIndexOf("."))
190
+ };
191
+ }
192
+ async function wbi_sign(BASEURL, cookie) {
193
+ const web_keys = await getWbiKeys(cookie);
194
+ const url = new URL(BASEURL);
195
+ const params = {};
196
+ for (const [key, value] of url.searchParams.entries()) {
197
+ params[key] = value;
198
+ }
199
+ const query = encWbi(params, web_keys.img_key, web_keys.sub_key);
200
+ return query;
201
+ }
202
+
203
+ // src/platform/bilibili/sign/bv2av.ts
204
+ var XOR_CODE = 23442827791579n;
205
+ var MASK_CODE = 2251799813685247n;
206
+ var MAX_AID = 1n << 51n;
207
+ var BASE = 58n;
208
+ var data = "FcwAPNKTMug3GV5Lj7EJnHpWsx4tb8haYeviqBz6rkCy12mUSDQX9RdoZf";
209
+ function av2bv(aid) {
210
+ const bytes = ["B", "V", "1", "0", "0", "0", "0", "0", "0", "0", "0", "0"];
211
+ let bvIndex = bytes.length - 1;
212
+ let tmp = (MAX_AID | BigInt(aid)) ^ XOR_CODE;
213
+ while (tmp > 0) {
214
+ bytes[bvIndex] = data[Number(tmp % BigInt(BASE))];
215
+ tmp = tmp / BASE;
216
+ bvIndex -= 1;
217
+ }
218
+ [bytes[3], bytes[9]] = [bytes[9], bytes[3]];
219
+ [bytes[4], bytes[7]] = [bytes[7], bytes[4]];
220
+ return bytes.join("");
221
+ }
222
+ function bv2av(bvid) {
223
+ const bvidArr = Array.from(bvid);
224
+ [bvidArr[3], bvidArr[9]] = [bvidArr[9], bvidArr[3]];
225
+ [bvidArr[4], bvidArr[7]] = [bvidArr[7], bvidArr[4]];
226
+ bvidArr.splice(0, 3);
227
+ const tmp = bvidArr.reduce((pre, bvidChar) => pre * BASE + BigInt(data.indexOf(bvidChar)), 0n);
228
+ return Number(tmp & MASK_CODE ^ XOR_CODE);
229
+ }
230
+
231
+ // src/platform/bilibili/BilibiliApi.ts
232
+ var bilibili = {
233
+ /**
234
+ * 获取单个视频作品数据
235
+ * @param options 请求参数,包含 bvid 和可选的 typeMode
236
+ * @param cookie 有效的用户 Cookie
237
+ * @returns 接口返回的原始数据
238
+ */
239
+ async getVideoInfo(options, cookie) {
240
+ const { typeMode, ...restOptions } = options;
241
+ const data2 = await BilibiliData({ ...restOptions, methodType: "\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E" }, cookie);
242
+ return data2;
243
+ },
244
+ /**
245
+ * 获取单个视频下载信息数据
246
+ * @param options 请求参数,包含 avid, cid 和可选的 typeMode
247
+ * @param cookie 有效的用户 Cookie
248
+ * @returns 接口返回的原始数据
249
+ */
250
+ async getVideoStream(options, cookie) {
251
+ const { typeMode, ...restOptions } = options;
252
+ const data2 = await BilibiliData({ ...restOptions, methodType: "\u5355\u4E2A\u89C6\u9891\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E" }, cookie);
253
+ return data2;
254
+ },
255
+ /**
256
+ * 获取评论数据
257
+ * @param options 请求参数,包含 type, oid, 可选的 number, pn 和 typeMode
258
+ * @param cookie 有效的用户 Cookie
259
+ * @returns 接口返回的原始数据
260
+ */
261
+ async getComments(options, cookie) {
262
+ const { typeMode, ...restOptions } = options;
263
+ const data2 = await BilibiliData({ ...restOptions, methodType: "\u8BC4\u8BBA\u6570\u636E" }, cookie);
264
+ return data2;
265
+ },
266
+ /**
267
+ * 获取用户主页数据
268
+ * @param options 请求参数,包含 host_mid 和可选的 typeMode
269
+ * @param cookie 有效的用户 Cookie
270
+ * @returns 接口返回的原始数据
271
+ */
272
+ async getUserProfile(options, cookie) {
273
+ const { typeMode, ...restOptions } = options;
274
+ const data2 = await BilibiliData({ ...restOptions, methodType: "\u7528\u6237\u4E3B\u9875\u6570\u636E" }, cookie);
275
+ return data2;
276
+ },
277
+ /**
278
+ * 获取用户主页动态列表数据
279
+ * @param options 请求参数,包含 host_mid 和可选的 typeMode
280
+ * @param cookie 有效的用户 Cookie
281
+ * @returns 接口返回的原始数据
282
+ */
283
+ async getUserDynamic(options, cookie) {
284
+ const { typeMode, ...restOptions } = options;
285
+ const data2 = await BilibiliData({ ...restOptions, methodType: "\u7528\u6237\u4E3B\u9875\u52A8\u6001\u5217\u8868\u6570\u636E" }, cookie);
286
+ return data2;
287
+ },
288
+ /**
289
+ * 获取 Emoji 数据
290
+ * @param options 可选的请求参数 (主要用于 typeMode)
291
+ * @param cookie 有效的用户 Cookie
292
+ * @returns 接口返回的原始数据
293
+ */
294
+ async getEmojiList(options, cookie) {
295
+ const { typeMode, ...restOptions } = options;
296
+ const data2 = await BilibiliData({ ...restOptions, methodType: "Emoji\u6570\u636E" }, cookie);
297
+ return data2;
298
+ },
299
+ /**
300
+ * 获取番剧基本信息数据
301
+ * @param options 请求参数,包含可选的 season_id, ep_id 和 typeMode
302
+ * @param cookie 有效的用户 Cookie
303
+ * @returns 接口返回的原始数据
304
+ */
305
+ async getBangumiInfo(options, cookie) {
306
+ const { typeMode, ...restOptions } = options;
307
+ const data2 = await BilibiliData({ ...restOptions, methodType: "\u756A\u5267\u57FA\u672C\u4FE1\u606F\u6570\u636E" }, cookie);
308
+ return data2;
309
+ },
310
+ /**
311
+ * 获取番剧下载信息数据
312
+ * @param options 请求参数,包含 cid, ep_id 和可选的 typeMode
313
+ * @param cookie 有效的用户 Cookie
314
+ * @returns 接口返回的原始数据
315
+ */
316
+ async getBangumiStream(options, cookie) {
317
+ const { typeMode, ...restOptions } = options;
318
+ const data2 = await BilibiliData({ ...restOptions, methodType: "\u756A\u5267\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E" }, cookie);
319
+ return data2;
320
+ },
321
+ /**
322
+ * 获取动态详情数据
323
+ * @param options 请求参数,包含 dynamic_id 和可选的 typeMode
324
+ * @param cookie 有效的用户 Cookie
325
+ * @returns 接口返回的原始数据
326
+ */
327
+ async getDynamicInfo(options, cookie) {
328
+ const { typeMode, ...restOptions } = options;
329
+ const data2 = await BilibiliData({ ...restOptions, methodType: "\u52A8\u6001\u8BE6\u60C5\u6570\u636E" }, cookie);
330
+ return data2;
331
+ },
332
+ /**
333
+ * 获取动态卡片数据
334
+ * @param options 请求参数,包含 dynamic_id 和可选的 typeMode
335
+ * @param cookie 有效的用户 Cookie
336
+ * @returns 接口返回的原始数据
337
+ */
338
+ async getDynamicCard(options, cookie) {
339
+ const { typeMode, ...restOptions } = options;
340
+ const data2 = await BilibiliData({ ...restOptions, methodType: "\u52A8\u6001\u5361\u7247\u6570\u636E" }, cookie);
341
+ return data2;
342
+ },
343
+ /**
344
+ * 获取直播间信息
345
+ * @param options 请求参数,包含 room_id 和可选的 typeMode
346
+ * @param cookie 有效的用户 Cookie
347
+ * @returns 接口返回的原始数据
348
+ */
349
+ async getLiveRoomDetail(options, cookie) {
350
+ const { typeMode, ...restOptions } = options;
351
+ const data2 = await BilibiliData({ ...restOptions, methodType: "\u76F4\u64AD\u95F4\u4FE1\u606F" }, cookie);
352
+ return data2;
353
+ },
354
+ /**
355
+ * 获取直播间初始化信息
356
+ * @param options 请求参数,包含 room_id 和可选的 typeMode
357
+ * @param cookie 有效的用户 Cookie
358
+ * @returns 接口返回的原始数据
359
+ */
360
+ async getLiveRoomInitInfo(options, cookie) {
361
+ const { typeMode, ...restOptions } = options;
362
+ const data2 = await BilibiliData({ ...restOptions, methodType: "\u76F4\u64AD\u95F4\u521D\u59CB\u5316\u4FE1\u606F" }, cookie);
363
+ return data2;
364
+ },
365
+ /**
366
+ * 获取登录基本信息
367
+ * @param options 可选的请求参数 (主要用于 typeMode)
368
+ * @param cookie 有效的用户 Cookie
369
+ * @returns 接口返回的原始数据
370
+ */
371
+ async getLoginBasicInfo(options, cookie) {
372
+ const { typeMode, ...restOptions } = options;
373
+ const data2 = await BilibiliData({ ...restOptions, methodType: "\u767B\u5F55\u57FA\u672C\u4FE1\u606F" }, cookie);
374
+ return data2;
375
+ },
376
+ /**
377
+ * 申请登录二维码
378
+ * @param options 可选的请求参数 (主要用于 typeMode)
379
+ * @param cookie 有效的用户 Cookie
380
+ * @returns 接口返回的原始数据
381
+ */
382
+ async getLoginQrcode(options, cookie) {
383
+ const { typeMode, ...restOptions } = options;
384
+ const data2 = await BilibiliData({ ...restOptions, methodType: "\u7533\u8BF7\u4E8C\u7EF4\u7801" }, cookie);
385
+ return data2;
386
+ },
387
+ /**
388
+ * 检查二维码状态
389
+ * @param options 请求参数,包含 qrcode_key 和可选的 typeMode
390
+ * @param cookie 有效的用户 Cookie
391
+ * @returns 接口返回的原始数据
392
+ */
393
+ async checkQrcodeStatus(options, cookie) {
394
+ const { typeMode, ...restOptions } = options;
395
+ const data2 = await BilibiliData({ ...restOptions, methodType: "\u4E8C\u7EF4\u7801\u72B6\u6001" }, cookie);
396
+ return data2;
397
+ },
398
+ /**
399
+ * 获取 UP 主总播放量
400
+ * @param options 请求参数,包含 host_mid 和可选的 typeMode
401
+ * @param cookie 有效的用户 Cookie
402
+ * @returns 接口返回的原始数据
403
+ */
404
+ async getUserTotalPlayCount(options, cookie) {
405
+ const { typeMode, ...restOptions } = options;
406
+ const data2 = await BilibiliData({ ...restOptions, methodType: "\u83B7\u53D6UP\u4E3B\u603B\u64AD\u653E\u91CF" }, cookie);
407
+ return data2;
408
+ },
409
+ /**
410
+ * 将 AV 号转换为 BV 号
411
+ * @param options 请求参数,包含 avid
412
+ * @param cookie 有效的用户 Cookie (此接口通常不需要)
413
+ * @returns 接口返回的原始数据
414
+ */
415
+ async convertAvToBv(options, cookie) {
416
+ const { typeMode, ...restOptions } = options;
417
+ const data2 = await BilibiliData({ ...restOptions, methodType: "AV\u8F6CBV" }, cookie);
418
+ return data2;
419
+ },
420
+ /**
421
+ * 将 BV 号转换为 AV 号
422
+ * @param options 请求参数,包含 bvid
423
+ * @param cookie 有效的用户 Cookie (此接口通常不需要)
424
+ * @returns 接口返回的原始数据
425
+ */
426
+ async convertBvToAv(options, cookie) {
427
+ const { typeMode, ...restOptions } = options;
428
+ const data2 = await BilibiliData({ ...restOptions, methodType: "BV\u8F6CAV" }, cookie);
429
+ return data2;
430
+ }
431
+ };
432
+ var registerBilibiliRoutes = (cookie) => {
433
+ const router = express__default.default.Router();
434
+ router.get("/new_login_qrcode", async (req, res) => {
435
+ const data2 = await BilibiliData({
436
+ methodType: "\u7533\u8BF7\u4E8C\u7EF4\u7801"
437
+ }, req.headers.cookie || cookie);
438
+ res.json(data2);
439
+ });
440
+ router.get("/check_qrcode", async (req, res) => {
441
+ const data2 = await BilibiliData({
442
+ methodType: "\u4E8C\u7EF4\u7801\u72B6\u6001",
443
+ qrcode_key: req.query.qrcode_key
444
+ }, req.headers.cookie || cookie);
445
+ res.json(data2);
446
+ });
447
+ router.get("/login_basic_info", async (req, res) => {
448
+ const data2 = await BilibiliData({
449
+ methodType: "\u767B\u5F55\u57FA\u672C\u4FE1\u606F"
450
+ }, req.headers.cookie || cookie);
451
+ res.json(data2);
452
+ });
453
+ router.get("/fetch_one_video", async (req, res) => {
454
+ const data2 = await BilibiliData({
455
+ methodType: "\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E",
456
+ bvid: req.query.bvid
457
+ }, req.headers.cookie || cookie);
458
+ res.json(data2);
459
+ });
460
+ router.get("/fetch_video_playurl", async (req, res) => {
461
+ const data2 = await BilibiliData({
462
+ methodType: "\u5355\u4E2A\u89C6\u9891\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E",
463
+ avid: parseInt(req.query.avid),
464
+ cid: parseInt(req.query.cid)
465
+ }, req.headers.cookie || cookie);
466
+ res.json(data2);
467
+ });
468
+ router.get("/fetch_work_comments", async (req, res) => {
469
+ const data2 = await BilibiliData({
470
+ methodType: "\u8BC4\u8BBA\u6570\u636E",
471
+ oid: Number(req.query.oid),
472
+ number: Number(req.query.number),
473
+ type: Number(req.query.type ?? 1)
474
+ }, req.headers.cookie || cookie);
475
+ res.json(data2);
476
+ });
477
+ router.get("/fetch_work_comments", async (req, res) => {
478
+ const data2 = await BilibiliData({
479
+ methodType: "Emoji\u6570\u636E"
480
+ }, req.headers.cookie || cookie);
481
+ res.json(data2);
482
+ });
483
+ router.get("/fetch_bangumi_video_info", async (req, res) => {
484
+ const data2 = await BilibiliData({
485
+ methodType: "\u756A\u5267\u57FA\u672C\u4FE1\u606F\u6570\u636E",
486
+ ep_id: req.query.ep_id
487
+ }, req.headers.cookie || cookie);
488
+ res.json(data2);
489
+ });
490
+ router.get("/fetch_bangumi_video_playurl", async (req, res) => {
491
+ const data2 = await BilibiliData({
492
+ methodType: "\u756A\u5267\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E",
493
+ cid: parseInt(req.query.cid),
494
+ ep_id: req.query.ep_id
495
+ }, req.headers.cookie || cookie);
496
+ res.json(data2);
497
+ });
498
+ router.get("/fetch_user_dynamic", async (req, res) => {
499
+ const data2 = await BilibiliData({
500
+ methodType: "\u7528\u6237\u4E3B\u9875\u52A8\u6001\u5217\u8868\u6570\u636E",
501
+ host_mid: parseInt(req.query.host_mid)
502
+ }, req.headers.cookie || cookie);
503
+ res.json(data2);
504
+ });
505
+ router.get("/fetch_dynamic_info", async (req, res) => {
506
+ const data2 = await BilibiliData({
507
+ methodType: "\u52A8\u6001\u8BE6\u60C5\u6570\u636E",
508
+ dynamic_id: req.query.dynamic_id
509
+ }, req.headers.cookie || cookie);
510
+ res.json(data2);
511
+ });
512
+ router.get("/fetch_dynamic_card", async (req, res) => {
513
+ const data2 = await BilibiliData({
514
+ methodType: "\u52A8\u6001\u5361\u7247\u6570\u636E",
515
+ dynamic_id: req.query.dynamic_id
516
+ }, req.headers.cookie || cookie);
517
+ res.json(data2);
518
+ });
519
+ router.get("/fetch_user_profile", async (req, res) => {
520
+ const data2 = await BilibiliData({
521
+ methodType: "\u7528\u6237\u4E3B\u9875\u6570\u636E",
522
+ host_mid: parseInt(req.query.host_mid)
523
+ }, req.headers.cookie || cookie);
524
+ res.json(data2);
525
+ });
526
+ router.get("/fetch_live_room_detail", async (req, res) => {
527
+ const data2 = await BilibiliData({
528
+ methodType: "\u76F4\u64AD\u95F4\u4FE1\u606F",
529
+ room_id: req.query.room_id
530
+ }, req.headers.cookie || cookie);
531
+ res.json(data2);
532
+ });
533
+ router.get("/fetch_liveroom_def", async (req, res) => {
534
+ const data2 = await BilibiliData({
535
+ methodType: "\u76F4\u64AD\u95F4\u521D\u59CB\u5316\u4FE1\u606F",
536
+ room_id: req.query.room_id
537
+ }, req.headers.cookie || cookie);
538
+ res.json(data2);
539
+ });
540
+ router.get("/bv_to_av", async (req, res) => {
541
+ const data2 = await BilibiliData({
542
+ methodType: "BV\u8F6CAV",
543
+ bvid: req.query.bvid
544
+ }, req.headers.cookie || cookie);
545
+ res.json(data2);
546
+ });
547
+ router.get("/av_to_bv", async (req, res) => {
548
+ const data2 = await BilibiliData({
549
+ methodType: "AV\u8F6CBV",
550
+ avid: parseInt(req.query.avid)
551
+ }, req.headers.cookie || cookie);
552
+ res.json(data2);
553
+ });
554
+ router.get("/fetch_user_full_view", async (req, res) => {
555
+ const data2 = await BilibiliData({
556
+ methodType: "\u83B7\u53D6UP\u4E3B\u603B\u64AD\u653E\u91CF",
557
+ host_mid: parseInt(req.query.host_mid)
558
+ }, req.headers.cookie || cookie);
559
+ res.json(data2);
560
+ });
561
+ return router;
562
+ };
563
+
564
+ // src/platform/bilibili/index.ts
565
+ var bilibiliUtils = {
566
+ sign: {
567
+ wbi_sign,
568
+ av2bv,
569
+ bv2av
570
+ },
571
+ bilibiliApiUrls,
572
+ getBilibiliData,
573
+ api: bilibili
574
+ };
81
575
 
82
576
  // src/platform/bilibili/getdata.ts
83
577
  var defheaders = {
@@ -253,447 +747,169 @@ var BilibiliData = async (data2, cookie) => {
253
747
  headers: headers2,
254
748
  ...data2
255
749
  });
256
- return dynamicINFO_CARD;
257
- }
258
- case "\u7528\u6237\u4E3B\u9875\u6570\u636E": {
259
- BilibiliValidateData(data2, ["host_mid"]);
260
- const { host_mid } = data2;
261
- const result = await GlobalGetData({
262
- url: bilibiliAPI.\u7528\u6237\u540D\u7247\u4FE1\u606F({ host_mid }),
263
- headers: headers2,
264
- ...data2
265
- });
266
- return result;
267
- }
268
- case "\u76F4\u64AD\u95F4\u4FE1\u606F": {
269
- BilibiliValidateData(data2, ["room_id"]);
270
- const result = await GlobalGetData({
271
- url: bilibiliAPI.\u76F4\u64AD\u95F4\u4FE1\u606F({ room_id: data2.room_id }),
272
- headers: headers2,
273
- ...data2
274
- });
275
- return result;
276
- }
277
- case "\u76F4\u64AD\u95F4\u521D\u59CB\u5316\u4FE1\u606F": {
278
- BilibiliValidateData(data2, ["room_id"]);
279
- const result = await GlobalGetData({
280
- url: bilibiliAPI.\u76F4\u64AD\u95F4\u521D\u59CB\u5316\u4FE1\u606F({ room_id: data2.room_id }),
281
- headers: headers2,
282
- ...data2
283
- });
284
- return result;
285
- }
286
- case "\u7533\u8BF7\u4E8C\u7EF4\u7801": {
287
- const result = await GlobalGetData({
288
- url: bilibiliAPI.\u7533\u8BF7\u4E8C\u7EF4\u7801(),
289
- headers: headers2,
290
- ...data2
291
- });
292
- return result;
293
- }
294
- case "\u4E8C\u7EF4\u7801\u72B6\u6001": {
295
- BilibiliValidateData(data2, ["qrcode_key"]);
296
- const result = await new Networks({
297
- url: bilibiliAPI.\u4E8C\u7EF4\u7801\u72B6\u6001({ qrcode_key: data2.qrcode_key }),
298
- headers: headers2,
299
- ...data2
300
- }).getHeadersAndData();
301
- return result;
302
- }
303
- case "\u767B\u5F55\u57FA\u672C\u4FE1\u606F": {
304
- const result = await GlobalGetData({
305
- url: bilibiliAPI.\u767B\u5F55\u57FA\u672C\u4FE1\u606F(),
306
- headers: headers2,
307
- ...data2
308
- });
309
- return result;
310
- }
311
- case "\u83B7\u53D6UP\u4E3B\u603B\u64AD\u653E\u91CF": {
312
- BilibiliValidateData(data2, ["host_mid"]);
313
- const result = await GlobalGetData({
314
- url: bilibiliAPI.\u83B7\u53D6UP\u4E3B\u603B\u64AD\u653E\u91CF({ host_mid: data2.host_mid }),
315
- headers: headers2,
316
- ...data2
317
- });
318
- return result;
319
- }
320
- case "AV\u8F6CBV": {
321
- BilibiliValidateData(data2, ["avid"]);
322
- const result = av2bv(Number(data2.avid.toString().replace(/^av/i, "")));
323
- return {
324
- code: 0,
325
- message: "success",
326
- data: {
327
- bvid: result
328
- }
329
- };
330
- }
331
- case "BV\u8F6CAV": {
332
- BilibiliValidateData(data2, ["bvid"]);
333
- const result = "av" + bv2av(data2.bvid);
334
- return {
335
- code: 0,
336
- message: "success",
337
- data: {
338
- aid: result
339
- }
340
- };
341
- }
342
- default:
343
- return null;
344
- }
345
- };
346
- var GlobalGetData = async (options) => {
347
- const result = await new Networks(options).getData();
348
- if (result && result.code === 0) {
349
- return result;
350
- } else if (result.code === 12061) {
351
- logger.warn(`\u83B7\u53D6\u54CD\u5E94\u6570\u636E\u5931\u8D25\uFF01
352
- \u8BF7\u6C42\u63A5\u53E3\u7C7B\u578B\uFF1A${options.methodType}
353
- \u8BF7\u6C42URL\uFF1A${options.url}
354
- \u9519\u8BEF\u4EE3\u7801\uFF1A${result.code}\uFF0C
355
- \u542B\u4E49\uFF1A${result.message}`);
356
- return result;
357
- } else {
358
- const errorMessage = errorMap[result.code] || result.message || "\u672A\u77E5\u9519\u8BEF";
359
- logger.warn(`\u83B7\u53D6\u54CD\u5E94\u6570\u636E\u5931\u8D25\uFF01
360
- \u8BF7\u6C42\u63A5\u53E3\u7C7B\u578B\uFF1A${options.methodType}
361
- \u8BF7\u6C42URL\uFF1A${options.url}
362
- \u9519\u8BEF\u4EE3\u7801\uFF1A${result.code}\uFF0C
363
- \u542B\u4E49\uFF1A${errorMessage}`);
364
- return result;
365
- }
366
- };
367
- var errorMap = {
368
- "-1": "\u5E94\u7528\u7A0B\u5E8F\u4E0D\u5B58\u5728\u6216\u5DF2\u88AB\u5C01\u7981",
369
- "-2": "Access Key \u9519\u8BEF",
370
- "-3": "API \u6821\u9A8C\u5BC6\u5319\u9519\u8BEF",
371
- "-4": "\u8C03\u7528\u65B9\u5BF9\u8BE5 Method \u6CA1\u6709\u6743\u9650",
372
- "-101": "\u8D26\u53F7\u672A\u767B\u5F55",
373
- "-102": "\u8D26\u53F7\u88AB\u5C01\u505C",
374
- "-103": "\u79EF\u5206\u4E0D\u8DB3",
375
- "-104": "\u786C\u5E01\u4E0D\u8DB3",
376
- "-105": "\u9A8C\u8BC1\u7801\u9519\u8BEF",
377
- "-106": "\u8D26\u53F7\u975E\u6B63\u5F0F\u4F1A\u5458\u6216\u5728\u9002\u5E94\u671F",
378
- "-107": "\u5E94\u7528\u4E0D\u5B58\u5728\u6216\u8005\u88AB\u5C01\u7981",
379
- "-108": "\u672A\u7ED1\u5B9A\u624B\u673A",
380
- "-110": "\u672A\u7ED1\u5B9A\u624B\u673A",
381
- "-111": "csrf \u6821\u9A8C\u5931\u8D25",
382
- "-112": "\u7CFB\u7EDF\u5347\u7EA7\u4E2D",
383
- "-113": "\u8D26\u53F7\u5C1A\u672A\u5B9E\u540D\u8BA4\u8BC1",
384
- "-114": "\u8BF7\u5148\u7ED1\u5B9A\u624B\u673A",
385
- "-115": "\u8BF7\u5148\u5B8C\u6210\u5B9E\u540D\u8BA4\u8BC1",
386
- "-304": "\u6728\u6709\u6539\u52A8",
387
- "-307": "\u649E\u8F66\u8DF3\u8F6C",
388
- "-352": "\u98CE\u63A7\u6821\u9A8C\u5931\u8D25 (UA \u6216 wbi \u53C2\u6570\u4E0D\u5408\u6CD5)",
389
- "-400": "\u8BF7\u6C42\u9519\u8BEF",
390
- "-401": "\u672A\u8BA4\u8BC1 (\u6216\u975E\u6CD5\u8BF7\u6C42)",
391
- "-403": "\u8BBF\u95EE\u6743\u9650\u4E0D\u8DB3",
392
- "-404": "\u5565\u90FD\u6728\u6709",
393
- "-405": "\u4E0D\u652F\u6301\u8BE5\u65B9\u6CD5",
394
- "-409": "\u51B2\u7A81",
395
- "-412": "\u8BF7\u6C42\u88AB\u62E6\u622A (\u5BA2\u6237\u7AEF ip \u88AB\u670D\u52A1\u7AEF\u98CE\u63A7)",
396
- "-500": "\u670D\u52A1\u5668\u9519\u8BEF",
397
- "-503": "\u8FC7\u8F7D\u4FDD\u62A4,\u670D\u52A1\u6682\u4E0D\u53EF\u7528",
398
- "-504": "\u670D\u52A1\u8C03\u7528\u8D85\u65F6",
399
- "-509": "\u8D85\u51FA\u9650\u5236",
400
- "-616": "\u4E0A\u4F20\u6587\u4EF6\u4E0D\u5B58\u5728",
401
- "-617": "\u4E0A\u4F20\u6587\u4EF6\u592A\u5927",
402
- "-625": "\u767B\u5F55\u5931\u8D25\u6B21\u6570\u592A\u591A",
403
- "-626": "\u7528\u6237\u4E0D\u5B58\u5728",
404
- "-628": "\u5BC6\u7801\u592A\u5F31",
405
- "-629": "\u7528\u6237\u540D\u6216\u5BC6\u7801\u9519\u8BEF",
406
- "-632": "\u64CD\u4F5C\u5BF9\u8C61\u6570\u91CF\u9650\u5236",
407
- "-643": "\u88AB\u9501\u5B9A",
408
- "-650": "\u7528\u6237\u7B49\u7EA7\u592A\u4F4E",
409
- "-652": "\u91CD\u590D\u7684\u7528\u6237",
410
- "-658": "Token \u8FC7\u671F",
411
- "-662": "\u5BC6\u7801\u65F6\u95F4\u6233\u8FC7\u671F",
412
- "-688": "\u5730\u7406\u533A\u57DF\u9650\u5236",
413
- "-689": "\u7248\u6743\u9650\u5236",
414
- "-701": "\u6263\u8282\u64CD\u5931\u8D25",
415
- "-799": "\u8BF7\u6C42\u8FC7\u4E8E\u9891\u7E41\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5",
416
- "-8888": "\u5BF9\u4E0D\u8D77\uFF0C\u670D\u52A1\u5668\u5F00\u5C0F\u5DEE\u4E86~ (\u0CA5\uFE4F\u0CA5)"
417
- };
418
-
419
- // src/platform/bilibili/qtparam.ts
420
- async function qtparam(BASEURL, cookie) {
421
- if (cookie === "") return { QUERY: "&platform=html5", STATUS: "!isLogin" };
422
- const logininfo = await new Networks({ url: bilibiliAPI.\u767B\u5F55\u57FA\u672C\u4FE1\u606F(), headers: { Cookie: cookie } }).getData();
423
- const sign = await wbi_sign(BASEURL, cookie);
424
- const qn = [6, 16, 32, 64, 74, 80, 112, 116, 120, 125, 126, 127];
425
- let isvip;
426
- logininfo.data.vipStatus === 1 ? isvip = true : isvip = false;
427
- if (isvip) {
428
- return { QUERY: `&fnval=16&fourk=1&${sign}`, STATUS: "isLogin", isvip };
429
- } else return { QUERY: `&qn=${qn[3]}&fnval=16`, STATUS: "isLogin", isvip };
430
- }
431
- var mixinKeyEncTab = [
432
- 46,
433
- 47,
434
- 18,
435
- 2,
436
- 53,
437
- 8,
438
- 23,
439
- 32,
440
- 15,
441
- 50,
442
- 10,
443
- 31,
444
- 58,
445
- 3,
446
- 45,
447
- 35,
448
- 27,
449
- 43,
450
- 5,
451
- 49,
452
- 33,
453
- 9,
454
- 42,
455
- 19,
456
- 29,
457
- 28,
458
- 14,
459
- 39,
460
- 12,
461
- 38,
462
- 41,
463
- 13,
464
- 37,
465
- 48,
466
- 7,
467
- 16,
468
- 24,
469
- 55,
470
- 40,
471
- 61,
472
- 26,
473
- 17,
474
- 0,
475
- 1,
476
- 60,
477
- 51,
478
- 30,
479
- 4,
480
- 22,
481
- 25,
482
- 54,
483
- 21,
484
- 56,
485
- 59,
486
- 6,
487
- 63,
488
- 57,
489
- 62,
490
- 11,
491
- 36,
492
- 20,
493
- 34,
494
- 44,
495
- 52
496
- ];
497
- var getMixinKey = (orig) => mixinKeyEncTab.map((n) => orig[n]).join("").slice(0, 32);
498
- function encWbi(params, img_key, sub_key) {
499
- const mixin_key = getMixinKey(img_key + sub_key);
500
- const curr_time = Math.round(Date.now() / 1e3);
501
- const chr_filter = /[!'()*]/g;
502
- Object.assign(params, { wts: curr_time });
503
- const query = Object.keys(params).sort().map((key) => {
504
- const value = params[key].toString().replace(chr_filter, "");
505
- return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
506
- }).join("&");
507
- const wbi_sign2 = crypto__default.default.createHash("md5").update(query + mixin_key).digest("hex");
508
- return `&wts=${curr_time}&w_rid=${wbi_sign2}`;
509
- }
510
- async function getWbiKeys(cookie) {
511
- const res = await axios__default.default("https://api.bilibili.com/x/web-interface/nav", {
512
- headers: {
513
- Cookie: cookie
750
+ return dynamicINFO_CARD;
514
751
  }
515
- });
516
- const responseJson = res.data;
517
- const response = responseJson;
518
- const {
519
- data: {
520
- wbi_img: { img_url, sub_url }
752
+ case "\u7528\u6237\u4E3B\u9875\u6570\u636E": {
753
+ BilibiliValidateData(data2, ["host_mid"]);
754
+ const { host_mid } = data2;
755
+ const result = await GlobalGetData({
756
+ url: bilibiliAPI.\u7528\u6237\u540D\u7247\u4FE1\u606F({ host_mid }),
757
+ headers: headers2,
758
+ ...data2
759
+ });
760
+ return result;
521
761
  }
522
- } = response;
523
- return {
524
- img_key: img_url.slice(img_url.lastIndexOf("/") + 1, img_url.lastIndexOf(".")),
525
- sub_key: sub_url.slice(sub_url.lastIndexOf("/") + 1, sub_url.lastIndexOf("."))
526
- };
527
- }
528
- async function wbi_sign(BASEURL, cookie) {
529
- const web_keys = await getWbiKeys(cookie);
530
- const url = new URL(BASEURL);
531
- const params = {};
532
- for (const [key, value] of url.searchParams.entries()) {
533
- params[key] = value;
762
+ case "\u76F4\u64AD\u95F4\u4FE1\u606F": {
763
+ BilibiliValidateData(data2, ["room_id"]);
764
+ const result = await GlobalGetData({
765
+ url: bilibiliAPI.\u76F4\u64AD\u95F4\u4FE1\u606F({ room_id: data2.room_id }),
766
+ headers: headers2,
767
+ ...data2
768
+ });
769
+ return result;
770
+ }
771
+ case "\u76F4\u64AD\u95F4\u521D\u59CB\u5316\u4FE1\u606F": {
772
+ BilibiliValidateData(data2, ["room_id"]);
773
+ const result = await GlobalGetData({
774
+ url: bilibiliAPI.\u76F4\u64AD\u95F4\u521D\u59CB\u5316\u4FE1\u606F({ room_id: data2.room_id }),
775
+ headers: headers2,
776
+ ...data2
777
+ });
778
+ return result;
779
+ }
780
+ case "\u7533\u8BF7\u4E8C\u7EF4\u7801": {
781
+ const result = await GlobalGetData({
782
+ url: bilibiliAPI.\u7533\u8BF7\u4E8C\u7EF4\u7801(),
783
+ headers: headers2,
784
+ ...data2
785
+ });
786
+ return result;
787
+ }
788
+ case "\u4E8C\u7EF4\u7801\u72B6\u6001": {
789
+ BilibiliValidateData(data2, ["qrcode_key"]);
790
+ const result = await new Networks({
791
+ url: bilibiliAPI.\u4E8C\u7EF4\u7801\u72B6\u6001({ qrcode_key: data2.qrcode_key }),
792
+ headers: headers2,
793
+ ...data2
794
+ }).getHeadersAndData();
795
+ return result;
796
+ }
797
+ case "\u767B\u5F55\u57FA\u672C\u4FE1\u606F": {
798
+ const result = await GlobalGetData({
799
+ url: bilibiliAPI.\u767B\u5F55\u57FA\u672C\u4FE1\u606F(),
800
+ headers: headers2,
801
+ ...data2
802
+ });
803
+ return result;
804
+ }
805
+ case "\u83B7\u53D6UP\u4E3B\u603B\u64AD\u653E\u91CF": {
806
+ BilibiliValidateData(data2, ["host_mid"]);
807
+ const result = await GlobalGetData({
808
+ url: bilibiliAPI.\u83B7\u53D6UP\u4E3B\u603B\u64AD\u653E\u91CF({ host_mid: data2.host_mid }),
809
+ headers: headers2,
810
+ ...data2
811
+ });
812
+ return result;
813
+ }
814
+ case "AV\u8F6CBV": {
815
+ BilibiliValidateData(data2, ["avid"]);
816
+ const result = av2bv(Number(data2.avid.toString().replace(/^av/i, "")));
817
+ return {
818
+ code: 0,
819
+ message: "success",
820
+ data: {
821
+ bvid: result
822
+ }
823
+ };
824
+ }
825
+ case "BV\u8F6CAV": {
826
+ BilibiliValidateData(data2, ["bvid"]);
827
+ const result = "av" + bv2av(data2.bvid);
828
+ return {
829
+ code: 0,
830
+ message: "success",
831
+ data: {
832
+ aid: result
833
+ }
834
+ };
835
+ }
836
+ default:
837
+ logger.warn(`\u672A\u77E5\u7684\u6296\u97F3\u6570\u636E\u63A5\u53E3\uFF1A\u300D${logger.red(data2.methodType)}\u300D`);
838
+ return null;
534
839
  }
535
- const query = encWbi(params, web_keys.img_key, web_keys.sub_key);
536
- return query;
537
- }
538
- var registerBilibiliRoutes = (cookie) => {
539
- const router = express__default.default.Router();
540
- router.get("/new_login_qrcode", async (req, res) => {
541
- const data2 = await BilibiliData({
542
- methodType: "\u7533\u8BF7\u4E8C\u7EF4\u7801"
543
- }, req.headers.cookie || cookie);
544
- res.json(data2);
545
- });
546
- router.get("/check_qrcode", async (req, res) => {
547
- const data2 = await BilibiliData({
548
- methodType: "\u4E8C\u7EF4\u7801\u72B6\u6001",
549
- qrcode_key: req.query.qrcode_key
550
- }, req.headers.cookie || cookie);
551
- res.json(data2);
552
- });
553
- router.get("/login_basic_info", async (req, res) => {
554
- const data2 = await BilibiliData({
555
- methodType: "\u767B\u5F55\u57FA\u672C\u4FE1\u606F"
556
- }, req.headers.cookie || cookie);
557
- res.json(data2);
558
- });
559
- router.get("/fetch_one_video", async (req, res) => {
560
- const data2 = await BilibiliData({
561
- methodType: "\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E",
562
- bvid: req.query.bvid
563
- }, req.headers.cookie || cookie);
564
- res.json(data2);
565
- });
566
- router.get("/fetch_video_playurl", async (req, res) => {
567
- const data2 = await BilibiliData({
568
- methodType: "\u5355\u4E2A\u89C6\u9891\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E",
569
- avid: parseInt(req.query.avid),
570
- cid: parseInt(req.query.cid)
571
- }, req.headers.cookie || cookie);
572
- res.json(data2);
573
- });
574
- router.get("/fetch_work_comments", async (req, res) => {
575
- const data2 = await BilibiliData({
576
- methodType: "\u8BC4\u8BBA\u6570\u636E",
577
- oid: Number(req.query.oid),
578
- number: Number(req.query.number),
579
- type: Number(req.query.type ?? 1)
580
- }, req.headers.cookie || cookie);
581
- res.json(data2);
582
- });
583
- router.get("/fetch_work_comments", async (req, res) => {
584
- const data2 = await BilibiliData({
585
- methodType: "Emoji\u6570\u636E"
586
- }, req.headers.cookie || cookie);
587
- res.json(data2);
588
- });
589
- router.get("/fetch_bangumi_video_info", async (req, res) => {
590
- const data2 = await BilibiliData({
591
- methodType: "\u756A\u5267\u57FA\u672C\u4FE1\u606F\u6570\u636E",
592
- ep_id: req.query.ep_id
593
- }, req.headers.cookie || cookie);
594
- res.json(data2);
595
- });
596
- router.get("/fetch_bangumi_video_playurl", async (req, res) => {
597
- const data2 = await BilibiliData({
598
- methodType: "\u756A\u5267\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E",
599
- cid: parseInt(req.query.cid),
600
- ep_id: req.query.ep_id
601
- }, req.headers.cookie || cookie);
602
- res.json(data2);
603
- });
604
- router.get("/fetch_user_dynamic", async (req, res) => {
605
- const data2 = await BilibiliData({
606
- methodType: "\u7528\u6237\u4E3B\u9875\u52A8\u6001\u5217\u8868\u6570\u636E",
607
- host_mid: parseInt(req.query.host_mid)
608
- }, req.headers.cookie || cookie);
609
- res.json(data2);
610
- });
611
- router.get("/fetch_dynamic_info", async (req, res) => {
612
- const data2 = await BilibiliData({
613
- methodType: "\u52A8\u6001\u8BE6\u60C5\u6570\u636E",
614
- dynamic_id: req.query.dynamic_id
615
- }, req.headers.cookie || cookie);
616
- res.json(data2);
617
- });
618
- router.get("/fetch_dynamic_card", async (req, res) => {
619
- const data2 = await BilibiliData({
620
- methodType: "\u52A8\u6001\u5361\u7247\u6570\u636E",
621
- dynamic_id: req.query.dynamic_id
622
- }, req.headers.cookie || cookie);
623
- res.json(data2);
624
- });
625
- router.get("/fetch_user_profile", async (req, res) => {
626
- const data2 = await BilibiliData({
627
- methodType: "\u7528\u6237\u4E3B\u9875\u6570\u636E",
628
- host_mid: parseInt(req.query.host_mid)
629
- }, req.headers.cookie || cookie);
630
- res.json(data2);
631
- });
632
- router.get("/fetch_live_room_detail", async (req, res) => {
633
- const data2 = await BilibiliData({
634
- methodType: "\u76F4\u64AD\u95F4\u4FE1\u606F",
635
- room_id: req.query.room_id
636
- }, req.headers.cookie || cookie);
637
- res.json(data2);
638
- });
639
- router.get("/fetch_liveroom_def", async (req, res) => {
640
- const data2 = await BilibiliData({
641
- methodType: "\u76F4\u64AD\u95F4\u521D\u59CB\u5316\u4FE1\u606F",
642
- room_id: req.query.room_id
643
- }, req.headers.cookie || cookie);
644
- res.json(data2);
645
- });
646
- router.get("/bv_to_av", async (req, res) => {
647
- const data2 = await BilibiliData({
648
- methodType: "BV\u8F6CAV",
649
- bvid: req.query.bvid
650
- }, req.headers.cookie || cookie);
651
- res.json(data2);
652
- });
653
- router.get("/av_to_bv", async (req, res) => {
654
- const data2 = await BilibiliData({
655
- methodType: "AV\u8F6CBV",
656
- avid: parseInt(req.query.avid)
657
- }, req.headers.cookie || cookie);
658
- res.json(data2);
659
- });
660
- router.get("/fetch_user_full_view", async (req, res) => {
661
- const data2 = await BilibiliData({
662
- methodType: "\u83B7\u53D6UP\u4E3B\u603B\u64AD\u653E\u91CF",
663
- host_mid: parseInt(req.query.host_mid)
664
- }, req.headers.cookie || cookie);
665
- res.json(data2);
666
- });
667
- return router;
668
840
  };
669
-
670
- // src/platform/bilibili/sign/bv2av.ts
671
- var XOR_CODE = 23442827791579n;
672
- var MASK_CODE = 2251799813685247n;
673
- var MAX_AID = 1n << 51n;
674
- var BASE = 58n;
675
- var data = "FcwAPNKTMug3GV5Lj7EJnHpWsx4tb8haYeviqBz6rkCy12mUSDQX9RdoZf";
676
- function av2bv(aid) {
677
- const bytes = ["B", "V", "1", "0", "0", "0", "0", "0", "0", "0", "0", "0"];
678
- let bvIndex = bytes.length - 1;
679
- let tmp = (MAX_AID | BigInt(aid)) ^ XOR_CODE;
680
- while (tmp > 0) {
681
- bytes[bvIndex] = data[Number(tmp % BigInt(BASE))];
682
- tmp = tmp / BASE;
683
- bvIndex -= 1;
841
+ var GlobalGetData = async (options) => {
842
+ const result = await new Networks(options).getData();
843
+ if (result && result.code === 0) {
844
+ return result;
845
+ } else if (result.code === 12061) {
846
+ logger.warn(`\u83B7\u53D6\u54CD\u5E94\u6570\u636E\u5931\u8D25\uFF01
847
+ \u8BF7\u6C42\u63A5\u53E3\u7C7B\u578B\uFF1A\u300C${options.methodType}\u300D
848
+ \u8BF7\u6C42URL\uFF1A${options.url}
849
+ \u9519\u8BEF\u4EE3\u7801\uFF1A${result.code}\uFF0C
850
+ \u542B\u4E49\uFF1A${result.message}`);
851
+ return result;
852
+ } else {
853
+ const errorMessage = errorMap[result.code] || result.message || "\u672A\u77E5\u9519\u8BEF";
854
+ logger.warn(`\u83B7\u53D6\u54CD\u5E94\u6570\u636E\u5931\u8D25\uFF01
855
+ \u8BF7\u6C42\u63A5\u53E3\u7C7B\u578B\uFF1A\u300C${options.methodType}\u300D
856
+ \u8BF7\u6C42URL\uFF1A${options.url}
857
+ \u9519\u8BEF\u4EE3\u7801\uFF1A${result.code}\uFF0C
858
+ \u542B\u4E49\uFF1A${errorMessage}`);
859
+ return result;
684
860
  }
685
- [bytes[3], bytes[9]] = [bytes[9], bytes[3]];
686
- [bytes[4], bytes[7]] = [bytes[7], bytes[4]];
687
- return bytes.join("");
688
- }
689
- function bv2av(bvid) {
690
- const bvidArr = Array.from(bvid);
691
- [bvidArr[3], bvidArr[9]] = [bvidArr[9], bvidArr[3]];
692
- [bvidArr[4], bvidArr[7]] = [bvidArr[7], bvidArr[4]];
693
- bvidArr.splice(0, 3);
694
- const tmp = bvidArr.reduce((pre, bvidChar) => pre * BASE + BigInt(data.indexOf(bvidChar)), 0n);
695
- return Number(tmp & MASK_CODE ^ XOR_CODE);
696
- }
861
+ };
862
+ var errorMap = {
863
+ "-1": "\u5E94\u7528\u7A0B\u5E8F\u4E0D\u5B58\u5728\u6216\u5DF2\u88AB\u5C01\u7981",
864
+ "-2": "Access Key \u9519\u8BEF",
865
+ "-3": "API \u6821\u9A8C\u5BC6\u5319\u9519\u8BEF",
866
+ "-4": "\u8C03\u7528\u65B9\u5BF9\u8BE5 Method \u6CA1\u6709\u6743\u9650",
867
+ "-101": "\u8D26\u53F7\u672A\u767B\u5F55",
868
+ "-102": "\u8D26\u53F7\u88AB\u5C01\u505C",
869
+ "-103": "\u79EF\u5206\u4E0D\u8DB3",
870
+ "-104": "\u786C\u5E01\u4E0D\u8DB3",
871
+ "-105": "\u9A8C\u8BC1\u7801\u9519\u8BEF",
872
+ "-106": "\u8D26\u53F7\u975E\u6B63\u5F0F\u4F1A\u5458\u6216\u5728\u9002\u5E94\u671F",
873
+ "-107": "\u5E94\u7528\u4E0D\u5B58\u5728\u6216\u8005\u88AB\u5C01\u7981",
874
+ "-108": "\u672A\u7ED1\u5B9A\u624B\u673A",
875
+ "-110": "\u672A\u7ED1\u5B9A\u624B\u673A",
876
+ "-111": "csrf \u6821\u9A8C\u5931\u8D25",
877
+ "-112": "\u7CFB\u7EDF\u5347\u7EA7\u4E2D",
878
+ "-113": "\u8D26\u53F7\u5C1A\u672A\u5B9E\u540D\u8BA4\u8BC1",
879
+ "-114": "\u8BF7\u5148\u7ED1\u5B9A\u624B\u673A",
880
+ "-115": "\u8BF7\u5148\u5B8C\u6210\u5B9E\u540D\u8BA4\u8BC1",
881
+ "-304": "\u6728\u6709\u6539\u52A8",
882
+ "-307": "\u649E\u8F66\u8DF3\u8F6C",
883
+ "-352": "\u98CE\u63A7\u6821\u9A8C\u5931\u8D25 (UA \u6216 wbi \u53C2\u6570\u4E0D\u5408\u6CD5)",
884
+ "-400": "\u8BF7\u6C42\u9519\u8BEF",
885
+ "-401": "\u672A\u8BA4\u8BC1 (\u6216\u975E\u6CD5\u8BF7\u6C42)",
886
+ "-403": "\u8BBF\u95EE\u6743\u9650\u4E0D\u8DB3",
887
+ "-404": "\u5565\u90FD\u6728\u6709",
888
+ "-405": "\u4E0D\u652F\u6301\u8BE5\u65B9\u6CD5",
889
+ "-409": "\u51B2\u7A81",
890
+ "-412": "\u8BF7\u6C42\u88AB\u62E6\u622A (\u5BA2\u6237\u7AEF ip \u88AB\u670D\u52A1\u7AEF\u98CE\u63A7)",
891
+ "-500": "\u670D\u52A1\u5668\u9519\u8BEF",
892
+ "-503": "\u8FC7\u8F7D\u4FDD\u62A4,\u670D\u52A1\u6682\u4E0D\u53EF\u7528",
893
+ "-504": "\u670D\u52A1\u8C03\u7528\u8D85\u65F6",
894
+ "-509": "\u8D85\u51FA\u9650\u5236",
895
+ "-616": "\u4E0A\u4F20\u6587\u4EF6\u4E0D\u5B58\u5728",
896
+ "-617": "\u4E0A\u4F20\u6587\u4EF6\u592A\u5927",
897
+ "-625": "\u767B\u5F55\u5931\u8D25\u6B21\u6570\u592A\u591A",
898
+ "-626": "\u7528\u6237\u4E0D\u5B58\u5728",
899
+ "-628": "\u5BC6\u7801\u592A\u5F31",
900
+ "-629": "\u7528\u6237\u540D\u6216\u5BC6\u7801\u9519\u8BEF",
901
+ "-632": "\u64CD\u4F5C\u5BF9\u8C61\u6570\u91CF\u9650\u5236",
902
+ "-643": "\u88AB\u9501\u5B9A",
903
+ "-650": "\u7528\u6237\u7B49\u7EA7\u592A\u4F4E",
904
+ "-652": "\u91CD\u590D\u7684\u7528\u6237",
905
+ "-658": "Token \u8FC7\u671F",
906
+ "-662": "\u5BC6\u7801\u65F6\u95F4\u6233\u8FC7\u671F",
907
+ "-688": "\u5730\u7406\u533A\u57DF\u9650\u5236",
908
+ "-689": "\u7248\u6743\u9650\u5236",
909
+ "-701": "\u6263\u8282\u64CD\u5931\u8D25",
910
+ "-799": "\u8BF7\u6C42\u8FC7\u4E8E\u9891\u7E41\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5",
911
+ "-8888": "\u5BF9\u4E0D\u8D77\uFF0C\u670D\u52A1\u5668\u5F00\u5C0F\u5DEE\u4E86~ (\u0CA5\uFE4F\u0CA5)"
912
+ };
697
913
 
698
914
  // src/platform/douyin/sign/a_bogus.ts
699
915
  var SM3 = class {
@@ -1054,13 +1270,21 @@ var headers = {
1054
1270
  "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"
1055
1271
  };
1056
1272
  var douyinSign = class {
1057
- /** 生成一个指定长度的随机字符串 */
1273
+ /**
1274
+ * 生成一个指定长度的随机字符串
1275
+ * @param length 字符串长度,默认为116
1276
+ * @returns
1277
+ */
1058
1278
  static Mstoken(length) {
1059
1279
  const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
1060
- const randomBytes = crypto__default.default.randomBytes(length);
1280
+ const randomBytes = crypto__default.default.randomBytes(length ?? 116);
1061
1281
  return Array.from(randomBytes, (byte) => characters[byte % characters.length]).join("");
1062
1282
  }
1063
- /** a_bogus 签名算法 */
1283
+ /**
1284
+ * a_bogus 签名算法
1285
+ * @param url 需要签名的地址
1286
+ * @returns 对此地址签名后的URL查询参数
1287
+ */
1064
1288
  static AB(url) {
1065
1289
  return a_bogus_default(url, headers["User-Agent"]);
1066
1290
  }
@@ -1085,70 +1309,339 @@ var douyinSign = class {
1085
1309
  }
1086
1310
  };
1087
1311
 
1088
- // src/platform/douyin/API.ts
1089
- var fp = douyinSign.VerifyFpManager();
1090
- var DouyinAPI = class {
1091
- \u89C6\u9891\u6216\u56FE\u96C6(data2) {
1092
- 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(
1093
- 116
1094
- )}&verifyFp=${fp}&fp=${fp}`;
1095
- }
1096
- \u8BC4\u8BBA(data2) {
1097
- 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(
1098
- 116
1099
- )}&verifyFp=${fp}&fp=${fp}`;
1100
- }
1101
- \u4E8C\u7EA7\u8BC4\u8BBA(data2) {
1102
- 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}`;
1103
- }
1104
- \u52A8\u56FE(data2) {
1105
- 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(
1106
- 116
1107
- )}&verifyFp=${fp}&fp=${fp}`;
1108
- }
1109
- \u8868\u60C5() {
1110
- return "https://www.douyin.com/aweme/v1/web/emoji/list";
1111
- }
1112
- \u7528\u6237\u4E3B\u9875\u89C6\u9891(data2) {
1113
- 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(
1114
- 116
1115
- )}&verifyFp=${fp}&fp=${fp}`;
1116
- }
1117
- \u7528\u6237\u4E3B\u9875\u4FE1\u606F(data2) {
1118
- 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(
1119
- 116
1120
- )}&verifyFp=${fp}&fp=${fp}`;
1121
- }
1122
- \u70ED\u70B9\u8BCD(data2) {
1123
- 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(
1124
- 116
1125
- )}&verifyFp=${fp}&fp=${fp}`;
1126
- }
1127
- \u641C\u7D22(data2) {
1128
- 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(
1129
- 116
1130
- )}&verifyFp=${fp}&fp=${fp}&search_id=${data2.search_id ?? ""}&count=${data2.number ?? 10}`;
1131
- }
1132
- \u4E92\u52A8\u8868\u60C5() {
1133
- 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(
1134
- 116
1135
- )}&verifyFp=${fp}&fp=${fp}`;
1136
- }
1137
- \u80CC\u666F\u97F3\u4E50(data2) {
1138
- 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(
1139
- 116
1140
- )}&verifyFp=${fp}&fp=${fp}`;
1141
- }
1142
- \u76F4\u64AD\u95F4\u4FE1\u606F(data2) {
1143
- 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(
1144
- 116
1145
- )}&verifyFp=${fp}&fp=${fp}`;
1146
- }
1147
- \u7533\u8BF7\u4E8C\u7EF4\u7801(data2) {
1148
- return `https://sso.douyin.com/get_qrcode/?verifyFp=${data2.verify_fp}&fp=${data2.verify_fp}`;
1149
- }
1312
+ // src/platform/douyin/API.ts
1313
+ var fp = douyinSign.VerifyFpManager();
1314
+ var DouyinAPI = class {
1315
+ \u89C6\u9891\u6216\u56FE\u96C6(data2) {
1316
+ 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(
1317
+ 116
1318
+ )}&verifyFp=${fp}&fp=${fp}`;
1319
+ }
1320
+ \u8BC4\u8BBA(data2) {
1321
+ 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(
1322
+ 116
1323
+ )}&verifyFp=${fp}&fp=${fp}`;
1324
+ }
1325
+ \u4E8C\u7EA7\u8BC4\u8BBA(data2) {
1326
+ 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}`;
1327
+ }
1328
+ \u52A8\u56FE(data2) {
1329
+ 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(
1330
+ 116
1331
+ )}&verifyFp=${fp}&fp=${fp}`;
1332
+ }
1333
+ \u8868\u60C5() {
1334
+ return "https://www.douyin.com/aweme/v1/web/emoji/list";
1335
+ }
1336
+ \u7528\u6237\u4E3B\u9875\u89C6\u9891(data2) {
1337
+ 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(
1338
+ 116
1339
+ )}&verifyFp=${fp}&fp=${fp}`;
1340
+ }
1341
+ \u7528\u6237\u4E3B\u9875\u4FE1\u606F(data2) {
1342
+ 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(
1343
+ 116
1344
+ )}&verifyFp=${fp}&fp=${fp}`;
1345
+ }
1346
+ \u70ED\u70B9\u8BCD(data2) {
1347
+ 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(
1348
+ 116
1349
+ )}&verifyFp=${fp}&fp=${fp}`;
1350
+ }
1351
+ \u641C\u7D22(data2) {
1352
+ 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(
1353
+ 116
1354
+ )}&verifyFp=${fp}&fp=${fp}&search_id=${data2.search_id ?? ""}&count=${data2.number ?? 10}`;
1355
+ }
1356
+ \u4E92\u52A8\u8868\u60C5() {
1357
+ 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(
1358
+ 116
1359
+ )}&verifyFp=${fp}&fp=${fp}`;
1360
+ }
1361
+ \u80CC\u666F\u97F3\u4E50(data2) {
1362
+ 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(
1363
+ 116
1364
+ )}&verifyFp=${fp}&fp=${fp}`;
1365
+ }
1366
+ \u76F4\u64AD\u95F4\u4FE1\u606F(data2) {
1367
+ 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(
1368
+ 116
1369
+ )}&verifyFp=${fp}&fp=${fp}`;
1370
+ }
1371
+ \u7533\u8BF7\u4E8C\u7EF4\u7801(data2) {
1372
+ return `https://sso.douyin.com/get_qrcode/?verifyFp=${data2.verify_fp}&fp=${data2.verify_fp}`;
1373
+ }
1374
+ };
1375
+ var douyinAPI = new DouyinAPI();
1376
+ var douyinApiUrls = new DouyinAPI();
1377
+
1378
+ // src/platform/douyin/DouyinApi.ts
1379
+ var douyin = {
1380
+ /**
1381
+ * 聚合解析 (视频/图集/合辑)
1382
+ * @param options 请求参数,包含 aweme_id 和可选的 typeMode
1383
+ * @param cookie 有效的用户 Cookie
1384
+ * @returns 接口返回的原始数据
1385
+ */
1386
+ async getWorkInfo(options, cookie) {
1387
+ const { typeMode, ...restOptions } = options;
1388
+ const data2 = await DouyinData({ ...restOptions, methodType: "\u805A\u5408\u89E3\u6790" }, cookie);
1389
+ return data2;
1390
+ },
1391
+ /**
1392
+ * 获取视频作品数据
1393
+ * @param options 请求参数,包含 aweme_id 和可选的 typeMode
1394
+ * @param cookie 有效的用户 Cookie
1395
+ * @returns 接口返回的原始数据
1396
+ */
1397
+ async getVideoWorkInfo(options, cookie) {
1398
+ const { typeMode, ...restOptions } = options;
1399
+ const data2 = await DouyinData({ ...restOptions, methodType: "\u89C6\u9891\u4F5C\u54C1\u6570\u636E" }, cookie);
1400
+ return data2;
1401
+ },
1402
+ /**
1403
+ * 获取图集作品数据
1404
+ * @param options 请求参数,包含 aweme_id 和可选的 typeMode
1405
+ * @param cookie 有效的用户 Cookie
1406
+ * @returns 接口返回的原始数据
1407
+ */
1408
+ async getImageAlbumWorkInfo(options, cookie) {
1409
+ const { typeMode, ...restOptions } = options;
1410
+ const data2 = await DouyinData({ ...restOptions, methodType: "\u56FE\u96C6\u4F5C\u54C1\u6570\u636E" }, cookie);
1411
+ return data2;
1412
+ },
1413
+ /**
1414
+ * 获取合辑作品数据
1415
+ * @param options 请求参数,包含 aweme_id 和可选的 typeMode
1416
+ * @param cookie 有效的用户 Cookie
1417
+ * @returns 接口返回的原始数据
1418
+ */
1419
+ async getSlidesWorkInfo(options, cookie) {
1420
+ const { typeMode, ...restOptions } = options;
1421
+ const data2 = await DouyinData({ ...restOptions, methodType: "\u5408\u8F91\u4F5C\u54C1\u6570\u636E" }, cookie);
1422
+ return data2;
1423
+ },
1424
+ /**
1425
+ * 获取评论数据
1426
+ * @param options 请求参数,包含 aweme_id, 可选的 number, cursor 和 typeMode
1427
+ * @param cookie 有效的用户 Cookie
1428
+ * @returns 接口返回的原始数据
1429
+ */
1430
+ async getComments(options, cookie) {
1431
+ const { typeMode, ...restOptions } = options;
1432
+ const data2 = await DouyinData({ ...restOptions, methodType: "\u8BC4\u8BBA\u6570\u636E" }, cookie);
1433
+ return data2;
1434
+ },
1435
+ /**
1436
+ * 获取指定评论回复数据
1437
+ * @param options 请求参数,包含 aweme_id, comment_id, 可选的 number, cursor 和 typeMode
1438
+ * @param cookie 有效的用户 Cookie
1439
+ * @returns 接口返回的原始数据
1440
+ */
1441
+ async getCommentReplies(options, cookie) {
1442
+ const { typeMode, ...restOptions } = options;
1443
+ const data2 = await DouyinData({ ...restOptions, methodType: "\u6307\u5B9A\u8BC4\u8BBA\u56DE\u590D\u6570\u636E" }, cookie);
1444
+ return data2;
1445
+ },
1446
+ /**
1447
+ * 获取用户主页数据
1448
+ * @param options 请求参数,包含 sec_uid 和可选的 typeMode
1449
+ * @param cookie 有效的用户 Cookie
1450
+ * @returns 接口返回的原始数据
1451
+ */
1452
+ async getUserProfile(options, cookie) {
1453
+ const { typeMode, ...restOptions } = options;
1454
+ const data2 = await DouyinData({ ...restOptions, methodType: "\u7528\u6237\u4E3B\u9875\u6570\u636E" }, cookie);
1455
+ return data2;
1456
+ },
1457
+ /**
1458
+ * 获取 Emoji 数据
1459
+ * @param options 可选的请求参数 (主要用于 typeMode)
1460
+ * @param cookie 可选的用户 Cookie
1461
+ * @returns 接口返回的原始数据
1462
+ */
1463
+ async getEmojiList(options, cookie) {
1464
+ const { typeMode, ...restOptions } = options;
1465
+ const data2 = await DouyinData({ ...restOptions, methodType: "Emoji\u6570\u636E" }, cookie);
1466
+ return data2;
1467
+ },
1468
+ /**
1469
+ * 获取动态表情数据
1470
+ * @param options 可选的请求参数 (主要用于 typeMode)
1471
+ * @param cookie 有效的用户 Cookie
1472
+ * @returns 接口返回的原始数据
1473
+ */
1474
+ async getEmojiProList(options, cookie) {
1475
+ const { typeMode, ...restOptions } = options;
1476
+ const data2 = await DouyinData({ ...restOptions, methodType: "\u52A8\u6001\u8868\u60C5\u6570\u636E" }, cookie);
1477
+ return data2;
1478
+ },
1479
+ /**
1480
+ * 获取用户主页视频列表数据
1481
+ * @param options 请求参数,包含 sec_uid, 可选的 number, max_cursor 和 typeMode
1482
+ * @param cookie 有效的用户 Cookie
1483
+ * @returns 接口返回的原始数据
1484
+ */
1485
+ async getUserVideos(options, cookie) {
1486
+ const { typeMode, ...restOptions } = options;
1487
+ const data2 = await DouyinData({ ...restOptions, methodType: "\u7528\u6237\u4E3B\u9875\u89C6\u9891\u5217\u8868\u6570\u636E" }, cookie);
1488
+ return data2;
1489
+ },
1490
+ /**
1491
+ * 获取音乐数据
1492
+ * @param options 请求参数,包含 music_id 和可选的 typeMode
1493
+ * @param cookie 有效的用户 Cookie
1494
+ * @returns 接口返回的原始数据
1495
+ */
1496
+ async getMusicInfo(options, cookie) {
1497
+ const { typeMode, ...restOptions } = options;
1498
+ const data2 = await DouyinData({ ...restOptions, methodType: "\u97F3\u4E50\u6570\u636E" }, cookie);
1499
+ return data2;
1500
+ },
1501
+ /**
1502
+ * 获取热点词数据
1503
+ * @param options 请求参数,包含 query, 可选的 number 和 typeMode
1504
+ * @param cookie 有效的用户 Cookie
1505
+ * @returns 接口返回的原始数据
1506
+ */
1507
+ async getSuggestWords(options, cookie) {
1508
+ const { typeMode, ...restOptions } = options;
1509
+ const data2 = await DouyinData({ ...restOptions, methodType: "\u70ED\u70B9\u8BCD\u6570\u636E" }, cookie);
1510
+ return data2;
1511
+ },
1512
+ /**
1513
+ * 获取搜索数据
1514
+ * @param options 请求参数,包含 query, 可选的 number, search_id, cursor 和 typeMode
1515
+ * @param cookie 有效的用户 Cookie
1516
+ * @returns 接口返回的原始数据
1517
+ */
1518
+ async search(options, cookie) {
1519
+ const { typeMode, ...restOptions } = options;
1520
+ const data2 = await DouyinData({ ...restOptions, methodType: "\u641C\u7D22\u6570\u636E" }, cookie);
1521
+ return data2;
1522
+ },
1523
+ /**
1524
+ * 获取直播间信息
1525
+ * @param options 请求参数,包含 sec_uid 和可选的 typeMode
1526
+ * @param cookie 有效的用户 Cookie
1527
+ * @returns 接口返回的原始数据
1528
+ */
1529
+ async getLiveRoomInfo(options, cookie) {
1530
+ const { typeMode, ...restOptions } = options;
1531
+ const data2 = await DouyinData({ ...restOptions, methodType: "\u76F4\u64AD\u95F4\u4FE1\u606F\u6570\u636E" }, cookie);
1532
+ return data2;
1533
+ },
1534
+ /**
1535
+ * 申请二维码数据
1536
+ * @param options 请求参数,包含 verify_fp 和可选的 typeMode
1537
+ * @param cookie 有效的用户 Cookie
1538
+ * @returns 接口返回的原始数据 (any)
1539
+ */
1540
+ async getLoginQrcode(options, cookie) {
1541
+ const { typeMode, ...restOptions } = options;
1542
+ const data2 = await DouyinData({ ...restOptions, methodType: "\u7533\u8BF7\u4E8C\u7EF4\u7801\u6570\u636E" }, cookie);
1543
+ return data2;
1544
+ }
1545
+ };
1546
+ var registerDouyinRoutes = (cookie) => {
1547
+ const router = express__default.default.Router();
1548
+ router.get("/fetch_one_work", async (req, res) => {
1549
+ const data2 = await DouyinData({
1550
+ methodType: "\u805A\u5408\u89E3\u6790",
1551
+ aweme_id: req.query.aweme_id
1552
+ }, req.headers.cookie || cookie);
1553
+ res.json(data2);
1554
+ });
1555
+ router.get("/fetch_work_comments", async (req, res) => {
1556
+ const data2 = await DouyinData({
1557
+ methodType: "\u8BC4\u8BBA\u6570\u636E",
1558
+ aweme_id: req.query.aweme_id,
1559
+ number: parseInt(req.query.number ?? "50"),
1560
+ cursor: parseInt(req.query.cursor ?? "0")
1561
+ }, req.headers.cookie || cookie);
1562
+ res.json(data2);
1563
+ });
1564
+ router.get("/fetch_video_comment_replies", async (req, res) => {
1565
+ const data2 = await DouyinData({
1566
+ methodType: "\u6307\u5B9A\u8BC4\u8BBA\u56DE\u590D\u6570\u636E",
1567
+ aweme_id: req.query.aweme_id,
1568
+ comment_id: req.query.comment_id
1569
+ }, req.headers.cookie || cookie);
1570
+ res.json(data2);
1571
+ });
1572
+ router.get("/fetch_user_info", async (req, res) => {
1573
+ const data2 = await DouyinData({
1574
+ methodType: "\u7528\u6237\u4E3B\u9875\u6570\u636E",
1575
+ sec_uid: req.query.sec_uid
1576
+ }, req.headers.cookie || cookie);
1577
+ res.json(data2);
1578
+ });
1579
+ router.get("/fetch_user_post_videos", async (req, res) => {
1580
+ const data2 = await DouyinData({
1581
+ methodType: "\u7528\u6237\u4E3B\u9875\u89C6\u9891\u5217\u8868\u6570\u636E",
1582
+ sec_uid: req.query.sec_uid
1583
+ }, req.headers.cookie || cookie);
1584
+ res.json(data2);
1585
+ });
1586
+ router.get("/fetch_suggest_words", async (req, res) => {
1587
+ const data2 = await DouyinData({
1588
+ methodType: "\u70ED\u70B9\u8BCD\u6570\u636E",
1589
+ query: req.query.query
1590
+ }, req.headers.cookie || cookie);
1591
+ res.json(data2);
1592
+ });
1593
+ router.get("/fetch_search_info", async (req, res) => {
1594
+ const data2 = await DouyinData({
1595
+ methodType: "\u641C\u7D22\u6570\u636E",
1596
+ query: req.query.query,
1597
+ number: parseInt(req.query.number ?? "10"),
1598
+ search_id: req.query.search_id
1599
+ }, req.headers.cookie || cookie);
1600
+ res.json(data2);
1601
+ });
1602
+ router.get("/fetch_emoji_list", async (req, res) => {
1603
+ const data2 = await DouyinData({
1604
+ methodType: "Emoji\u6570\u636E"
1605
+ }, req.headers.cookie || cookie);
1606
+ res.json(data2);
1607
+ });
1608
+ router.get("/fetch_emoji_pro_list", async (req, res) => {
1609
+ const data2 = await DouyinData({
1610
+ methodType: "\u52A8\u6001\u8868\u60C5\u6570\u636E"
1611
+ }, req.headers.cookie || cookie);
1612
+ res.json(data2);
1613
+ });
1614
+ router.get("/fetch_music_work", async (req, res) => {
1615
+ const data2 = await DouyinData({
1616
+ methodType: "\u97F3\u4E50\u6570\u636E",
1617
+ music_id: req.query.music_id
1618
+ }, req.headers.cookie || cookie);
1619
+ res.json(data2);
1620
+ });
1621
+ router.get("/fetch_user_mix_videos", async (req, res) => {
1622
+ const data2 = await DouyinData({
1623
+ methodType: "\u5408\u8F91\u4F5C\u54C1\u6570\u636E",
1624
+ aweme_id: req.query.aweme_id
1625
+ }, req.headers.cookie || cookie);
1626
+ res.json(data2);
1627
+ });
1628
+ router.get("/fetch_user_live_videos", async (req, res) => {
1629
+ const data2 = await DouyinData({
1630
+ methodType: "\u76F4\u64AD\u95F4\u4FE1\u606F\u6570\u636E",
1631
+ sec_uid: req.query.sec_uid
1632
+ }, req.headers.cookie || cookie);
1633
+ res.json(data2);
1634
+ });
1635
+ return router;
1636
+ };
1637
+
1638
+ // src/platform/douyin/index.ts
1639
+ var douyinUtils = {
1640
+ sign: douyinSign,
1641
+ douyinApiUrls,
1642
+ getDouyinData,
1643
+ api: douyin
1150
1644
  };
1151
- var douyinAPI = new DouyinAPI();
1152
1645
 
1153
1646
  // src/platform/douyin/getdata.ts
1154
1647
  var defheaders2 = {
@@ -1269,6 +1762,10 @@ var DouyinData = async (data2, cookie) => {
1269
1762
  },
1270
1763
  ...data2
1271
1764
  });
1765
+ if (response.data.length === 0) {
1766
+ 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);
1767
+ return false;
1768
+ }
1272
1769
  if (!response.data) {
1273
1770
  response.data = [];
1274
1771
  }
@@ -1343,6 +1840,9 @@ var DouyinData = async (data2, cookie) => {
1343
1840
  });
1344
1841
  return LoginQrcodeStatusData;
1345
1842
  }
1843
+ default:
1844
+ logger.warn(`\u672A\u77E5\u7684B\u7AD9\u6570\u636E\u63A5\u53E3\uFF1A\u300C${logger.red(data2.methodType)}\u300D`);
1845
+ return null;
1346
1846
  }
1347
1847
  };
1348
1848
  async function fetchPaginatedData(apiUrlGenerator, params, maxPageSize, headers2) {
@@ -1378,102 +1878,14 @@ async function fetchPaginatedData(apiUrlGenerator, params, maxPageSize, headers2
1378
1878
  async function GlobalGetData2(options) {
1379
1879
  const ResponseData = await new Networks(options).getData();
1380
1880
  if (ResponseData === "" || !ResponseData) {
1381
- 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);
1881
+ logger.warn(`\u83B7\u53D6\u54CD\u5E94\u6570\u636E\u5931\u8D25\uFF01\u63A5\u53E3\u8FD4\u56DE\u5185\u5BB9\u4E3A\u7A7A
1882
+ \u4F60\u7684\u6296\u97F3ck\u53EF\u80FD\u5DF2\u7ECF\u5931\u6548\uFF01
1883
+ \u8BF7\u6C42\u7C7B\u578B\uFF1A\u300C${options.methodType}\u300D
1884
+ \u8BF7\u6C42URL\uFF1A options.url`);
1382
1885
  return false;
1383
1886
  }
1384
1887
  return ResponseData;
1385
1888
  }
1386
- var registerDouyinRoutes = (cookie) => {
1387
- const router = express__default.default.Router();
1388
- router.get("/fetch_one_work", async (req, res) => {
1389
- const data2 = await DouyinData({
1390
- methodType: "\u805A\u5408\u89E3\u6790",
1391
- aweme_id: req.query.aweme_id
1392
- }, req.headers.cookie || cookie);
1393
- res.json(data2);
1394
- });
1395
- router.get("/fetch_work_comments", async (req, res) => {
1396
- const data2 = await DouyinData({
1397
- methodType: "\u8BC4\u8BBA\u6570\u636E",
1398
- aweme_id: req.query.aweme_id,
1399
- number: parseInt(req.query.number ?? "50"),
1400
- cursor: parseInt(req.query.cursor ?? "0")
1401
- }, req.headers.cookie || cookie);
1402
- res.json(data2);
1403
- });
1404
- router.get("/fetch_video_comment_replies", async (req, res) => {
1405
- const data2 = await DouyinData({
1406
- methodType: "\u6307\u5B9A\u8BC4\u8BBA\u56DE\u590D\u6570\u636E",
1407
- aweme_id: req.query.aweme_id,
1408
- comment_id: req.query.comment_id
1409
- }, req.headers.cookie || cookie);
1410
- res.json(data2);
1411
- });
1412
- router.get("/fetch_user_info", async (req, res) => {
1413
- const data2 = await DouyinData({
1414
- methodType: "\u7528\u6237\u4E3B\u9875\u6570\u636E",
1415
- sec_uid: req.query.sec_uid
1416
- }, req.headers.cookie || cookie);
1417
- res.json(data2);
1418
- });
1419
- router.get("/fetch_user_post_videos", async (req, res) => {
1420
- const data2 = await DouyinData({
1421
- methodType: "\u7528\u6237\u4E3B\u9875\u89C6\u9891\u5217\u8868\u6570\u636E",
1422
- sec_uid: req.query.sec_uid
1423
- }, req.headers.cookie || cookie);
1424
- res.json(data2);
1425
- });
1426
- router.get("/fetch_suggest_words", async (req, res) => {
1427
- const data2 = await DouyinData({
1428
- methodType: "\u70ED\u70B9\u8BCD\u6570\u636E",
1429
- query: req.query.query
1430
- }, req.headers.cookie || cookie);
1431
- res.json(data2);
1432
- });
1433
- router.get("/fetch_search_info", async (req, res) => {
1434
- const data2 = await DouyinData({
1435
- methodType: "\u641C\u7D22\u6570\u636E",
1436
- query: req.query.query,
1437
- number: parseInt(req.query.number ?? "10"),
1438
- search_id: req.query.search_id
1439
- }, req.headers.cookie || cookie);
1440
- res.json(data2);
1441
- });
1442
- router.get("/fetch_emoji_list", async (req, res) => {
1443
- const data2 = await DouyinData({
1444
- methodType: "Emoji\u6570\u636E"
1445
- }, req.headers.cookie || cookie);
1446
- res.json(data2);
1447
- });
1448
- router.get("/fetch_emoji_pro_list", async (req, res) => {
1449
- const data2 = await DouyinData({
1450
- methodType: "\u52A8\u6001\u8868\u60C5\u6570\u636E"
1451
- }, req.headers.cookie || cookie);
1452
- res.json(data2);
1453
- });
1454
- router.get("/fetch_music_work", async (req, res) => {
1455
- const data2 = await DouyinData({
1456
- methodType: "\u97F3\u4E50\u6570\u636E",
1457
- music_id: req.query.music_id
1458
- }, req.headers.cookie || cookie);
1459
- res.json(data2);
1460
- });
1461
- router.get("/fetch_user_mix_videos", async (req, res) => {
1462
- const data2 = await DouyinData({
1463
- methodType: "\u5408\u8F91\u4F5C\u54C1\u6570\u636E",
1464
- aweme_id: req.query.aweme_id
1465
- }, req.headers.cookie || cookie);
1466
- res.json(data2);
1467
- });
1468
- router.get("/fetch_user_live_videos", async (req, res) => {
1469
- const data2 = await DouyinData({
1470
- methodType: "\u76F4\u64AD\u95F4\u4FE1\u606F\u6570\u636E",
1471
- sec_uid: req.query.sec_uid
1472
- }, req.headers.cookie || cookie);
1473
- res.json(data2);
1474
- });
1475
- return router;
1476
- };
1477
1889
 
1478
1890
  // src/platform/kuaishou/API.ts
1479
1891
  var API = class {
@@ -1523,6 +1935,73 @@ var API = class {
1523
1935
  }
1524
1936
  };
1525
1937
  var KuaishouAPI = new API();
1938
+ var kuaishouAPI = new API();
1939
+ var kuaishouApiUrls = new API();
1940
+ var registerKuaishouRoutes = (cookie) => {
1941
+ const router = express__default.default.Router();
1942
+ router.get("/fetch_one_work", async (req, res) => {
1943
+ const data2 = await KuaishouData({
1944
+ methodType: "\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E",
1945
+ photoId: req.query.photoId
1946
+ }, req.headers.cookie || cookie);
1947
+ res.json(data2);
1948
+ });
1949
+ router.get("/fetch_work_comments", async (req, res) => {
1950
+ const data2 = await KuaishouData({
1951
+ methodType: "\u8BC4\u8BBA\u6570\u636E",
1952
+ photoId: req.query.photoId
1953
+ }, req.headers.cookie || cookie);
1954
+ res.json(data2);
1955
+ });
1956
+ router.get("/fetch_emoji_list", async (req, res) => {
1957
+ const data2 = await KuaishouData({
1958
+ methodType: "Emoji\u6570\u636E"
1959
+ }, req.headers.cookie || cookie);
1960
+ res.json(data2);
1961
+ });
1962
+ return router;
1963
+ };
1964
+
1965
+ // src/platform/kuaishou/KuaishouApi.ts
1966
+ var kuaishou = {
1967
+ /**
1968
+ * 获取单个视频作品数据
1969
+ * @param options 请求参数,包含 photoId 和可选的 typeMode
1970
+ * @param cookie 可选的用户 Cookie
1971
+ * @returns 接口返回的原始数据
1972
+ */
1973
+ async getWorkInfo(options, cookie) {
1974
+ const data2 = await KuaishouData({ ...options, methodType: "\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E" }, cookie);
1975
+ return data2;
1976
+ },
1977
+ /**
1978
+ * 获取评论数据
1979
+ * @param options 请求参数,包含 photoId 和可选的 typeMode
1980
+ * @param cookie 可选的用户 Cookie
1981
+ * @returns 接口返回的原始数据
1982
+ */
1983
+ async getComments(options, cookie) {
1984
+ const data2 = await KuaishouData({ ...options, methodType: "\u8BC4\u8BBA\u6570\u636E" }, cookie);
1985
+ return data2;
1986
+ },
1987
+ /**
1988
+ * 获取 Emoji 数据
1989
+ * @param options 可选的请求参数 (主要用于 typeMode)
1990
+ * @param cookie 可选的用户 Cookie
1991
+ * @returns 接口返回的原始数据
1992
+ */
1993
+ async getEmojiList(options, cookie) {
1994
+ const data2 = await KuaishouData({ ...options, methodType: "Emoji\u6570\u636E" }, cookie);
1995
+ return data2;
1996
+ }
1997
+ };
1998
+
1999
+ // src/platform/kuaishou/index.ts
2000
+ var kuaishouUtils = {
2001
+ kuaishouApiUrls,
2002
+ getKuaishouData,
2003
+ api: kuaishou
2004
+ };
1526
2005
 
1527
2006
  // src/platform/kuaishou/getdata.ts
1528
2007
  var defheaders3 = {
@@ -1541,7 +2020,7 @@ var KuaishouData = async (data2, cookie) => {
1541
2020
  switch (data2.methodType) {
1542
2021
  case "\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E": {
1543
2022
  KusiahouValidateData(data2, ["photoId"]);
1544
- const body = KuaishouAPI.\u5355\u4E2A\u4F5C\u54C1\u4FE1\u606F({ photoId: data2.photoId });
2023
+ const body = kuaishouAPI.\u5355\u4E2A\u4F5C\u54C1\u4FE1\u606F({ photoId: data2.photoId });
1545
2024
  const VideoData = await GlobalGetData3({
1546
2025
  url: body.url,
1547
2026
  method: "POST",
@@ -1553,7 +2032,7 @@ var KuaishouData = async (data2, cookie) => {
1553
2032
  }
1554
2033
  case "\u8BC4\u8BBA\u6570\u636E": {
1555
2034
  KusiahouValidateData(data2, ["photoId"]);
1556
- const body = KuaishouAPI.\u4F5C\u54C1\u8BC4\u8BBA\u4FE1\u606F({ photoId: data2.photoId });
2035
+ const body = kuaishouAPI.\u4F5C\u54C1\u8BC4\u8BBA\u4FE1\u606F({ photoId: data2.photoId });
1557
2036
  const VideoData = await GlobalGetData3({
1558
2037
  url: body.url,
1559
2038
  method: "POST",
@@ -1564,7 +2043,7 @@ var KuaishouData = async (data2, cookie) => {
1564
2043
  return VideoData;
1565
2044
  }
1566
2045
  case "Emoji\u6570\u636E": {
1567
- const body = KuaishouAPI.\u8868\u60C5();
2046
+ const body = kuaishouAPI.\u8868\u60C5();
1568
2047
  const EmojiData = await GlobalGetData3({
1569
2048
  url: body.url,
1570
2049
  method: "POST",
@@ -1574,6 +2053,9 @@ var KuaishouData = async (data2, cookie) => {
1574
2053
  });
1575
2054
  return EmojiData;
1576
2055
  }
2056
+ default:
2057
+ logger.warn(`\u672A\u77E5\u7684\u5FEB\u624B\u6570\u636E\u63A5\u53E3\uFF1A\u300C${logger.red(data2.methodType)}\u300D`);
2058
+ return null;
1577
2059
  }
1578
2060
  };
1579
2061
  async function GlobalGetData3(options) {
@@ -1588,30 +2070,6 @@ async function GlobalGetData3(options) {
1588
2070
  }
1589
2071
  return ResponseData;
1590
2072
  }
1591
- var registerKuaishouRoutes = (cookie) => {
1592
- const router = express__default.default.Router();
1593
- router.get("/fetch_one_work", async (req, res) => {
1594
- const data2 = await KuaishouData({
1595
- methodType: "\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E",
1596
- photoId: req.query.photoId
1597
- }, req.headers.cookie || cookie);
1598
- res.json(data2);
1599
- });
1600
- router.get("/fetch_work_comments", async (req, res) => {
1601
- const data2 = await KuaishouData({
1602
- methodType: "\u8BC4\u8BBA\u6570\u636E",
1603
- photoId: req.query.photoId
1604
- }, req.headers.cookie || cookie);
1605
- res.json(data2);
1606
- });
1607
- router.get("/fetch_emoji_list", async (req, res) => {
1608
- const data2 = await KuaishouData({
1609
- methodType: "Emoji\u6570\u636E"
1610
- }, req.headers.cookie || cookie);
1611
- res.json(data2);
1612
- });
1613
- return router;
1614
- };
1615
2073
 
1616
2074
  // src/model/DataFetchers.ts
1617
2075
  async function getDouyinData(type, arg2, arg3) {
@@ -1912,7 +2370,7 @@ var KusiahouValidateData = (data2, fields, atLeastOne = false) => {
1912
2370
  throw new Error(`\u83B7\u53D6\u300C${data2.methodType}\u300D${logger.red("\u7F3A\u5C11\u53C2\u6570")}: ${missingStr}`);
1913
2371
  }
1914
2372
  };
1915
- var amagi = class {
2373
+ var amagiClient = class {
1916
2374
  douyin;
1917
2375
  bilibili;
1918
2376
  kuaishou;
@@ -1920,10 +2378,10 @@ var amagi = class {
1920
2378
  *
1921
2379
  * @param cookie - 包含抖音ck、B站ck、快手ck的对象
1922
2380
  */
1923
- constructor(data2) {
1924
- this.douyin = (data2 == null ? void 0 : data2.douyin) ?? "";
1925
- this.bilibili = (data2 == null ? void 0 : data2.bilibili) ?? "";
1926
- this.kuaishou = (data2 == null ? void 0 : data2.kuaishou) ?? "";
2381
+ constructor(options) {
2382
+ this.douyin = (options == null ? void 0 : options.douyin) ?? "";
2383
+ this.bilibili = (options == null ? void 0 : options.bilibili) ?? "";
2384
+ this.kuaishou = (options == null ? void 0 : options.kuaishou) ?? "";
1927
2385
  }
1928
2386
  /**
1929
2387
  * 启动本地 HTTP 服务
@@ -1949,22 +2407,10 @@ var amagi = class {
1949
2407
  return app;
1950
2408
  }
1951
2409
  /**
1952
- * 获取抖音数据
2410
+ * 快捷获取抖音数据
1953
2411
  * @param type - 请求数据类型
1954
2412
  * @param options - 请求参数,是一个对象
1955
2413
  * @returns 返回接口的原始数据
1956
- * @example
1957
- * ```ts
1958
- * import Client from '@ikenxuan/amagi'
1959
- *
1960
- * const amagi = new Client({
1961
- * douyin: '' // 有效的抖音ck
1962
- * })
1963
- * const data = await amagi.getDouyinData('搜索数据', {
1964
- * query: '114514',
1965
- * number: 10
1966
- * })
1967
- * ```
1968
2414
  */
1969
2415
  getDouyinData = async (methodType, options) => {
1970
2416
  const fullOptions = {
@@ -1974,21 +2420,10 @@ var amagi = class {
1974
2420
  return await getDouyinData(methodType, this.douyin, fullOptions);
1975
2421
  };
1976
2422
  /**
1977
- * 获取B站数据
2423
+ * 快捷获取B站数据
1978
2424
  * @param type - 请求数据类型
1979
2425
  * @param options - 请求参数,是一个对象
1980
2426
  * @returns 返回接口的原始数据
1981
- * @example
1982
- * ```ts
1983
- * import Client from '@ikenxuan/amagi'
1984
- *
1985
- * const amagi = new Client({
1986
- * bilibili: '' // 有效的B站ck
1987
- * })
1988
- * const data = await amagi.getBilibiliData('单个视频作品数据', {
1989
- * bvid: 'BV1fK4y1q79u'
1990
- * })
1991
- * ```
1992
2427
  */
1993
2428
  getBilibiliData = async (methodType, options) => {
1994
2429
  const fullOptions = {
@@ -1998,21 +2433,10 @@ var amagi = class {
1998
2433
  return await getBilibiliData(methodType, this.bilibili, fullOptions);
1999
2434
  };
2000
2435
  /**
2001
- * 获取快手数据
2436
+ * 快捷获取快手数据
2002
2437
  * @param type - 请求数据类型
2003
2438
  * @param options - 请求参数,是一个对象
2004
2439
  * @returns 返回接口的原始数据
2005
- * @example
2006
- * ```ts
2007
- * import Client from '@ikenxuan/amagi'
2008
- *
2009
- * const amagi = new Client({
2010
- * kuaishou: '' // 有效的快手ck
2011
- * })
2012
- * const data = await amagi.getKuaishouData('单个视频作品数据', {
2013
- * photoId: '3xdpv6sfi8yjsqy'
2014
- * })
2015
- * ```
2016
2440
  */
2017
2441
  getKuaishouData = async (methodType, options) => {
2018
2442
  const fullOptions = {
@@ -2024,33 +2448,44 @@ var amagi = class {
2024
2448
  };
2025
2449
 
2026
2450
  // src/index.ts
2027
- var index_default = amagi;
2028
- function Amagi(options) {
2029
- return new amagi(options);
2030
- }
2451
+ var createAmagiClient = (data2) => {
2452
+ return new amagiClient(data2);
2453
+ };
2454
+ Object.defineProperty(createAmagiClient, "prototype", {
2455
+ value: amagiClient.prototype
2456
+ });
2457
+ var Client = createAmagiClient;
2458
+ var index_default = Client;
2031
2459
 
2032
- exports.Amagi = Amagi;
2033
- exports.BilibiliData = BilibiliData;
2034
2460
  exports.BilibiliValidateData = BilibiliValidateData;
2035
- exports.DouyinData = DouyinData;
2461
+ exports.Client = Client;
2036
2462
  exports.DouyinValidateData = DouyinValidateData;
2037
2463
  exports.KuaishouAPI = KuaishouAPI;
2038
- exports.KuaishouData = KuaishouData;
2039
2464
  exports.KusiahouValidateData = KusiahouValidateData;
2040
2465
  exports.Networks = Networks;
2041
- exports.amagi = amagi;
2466
+ exports.amagiClient = amagiClient;
2042
2467
  exports.av2bv = av2bv;
2468
+ exports.bilibili = bilibili;
2043
2469
  exports.bilibiliAPI = bilibiliAPI;
2470
+ exports.bilibiliApiUrls = bilibiliApiUrls;
2471
+ exports.bilibiliUtils = bilibiliUtils;
2044
2472
  exports.bv2av = bv2av;
2045
2473
  exports.default = index_default;
2474
+ exports.douyin = douyin;
2046
2475
  exports.douyinAPI = douyinAPI;
2476
+ exports.douyinApiUrls = douyinApiUrls;
2047
2477
  exports.douyinSign = douyinSign;
2478
+ exports.douyinUtils = douyinUtils;
2048
2479
  exports.fetchBilibiliData = fetchBilibiliData;
2049
2480
  exports.fetchDouyinData = fetchDouyinData;
2050
2481
  exports.fetchKuaishouData = fetchKuaishouData;
2051
2482
  exports.getBilibiliData = getBilibiliData;
2052
2483
  exports.getDouyinData = getDouyinData;
2053
2484
  exports.getKuaishouData = getKuaishouData;
2485
+ exports.kuaishou = kuaishou;
2486
+ exports.kuaishouAPI = kuaishouAPI;
2487
+ exports.kuaishouApiUrls = kuaishouApiUrls;
2488
+ exports.kuaishouUtils = kuaishouUtils;
2054
2489
  exports.logMiddleware = logMiddleware;
2055
2490
  exports.logger = logger;
2056
2491
  exports.qtparam = qtparam;