@ikenxuan/amagi 5.6.3 → 5.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4646 +0,0 @@
1
- import { Chalk } from 'chalk';
2
- import log4js from 'log4js';
3
- import path from 'path';
4
- import URL2, { fileURLToPath } from 'url';
5
- import fs from 'fs';
6
- import axios, { AxiosError } from 'axios';
7
- import crypto from 'crypto';
8
- import { z } from 'zod';
9
- import { Xhshow } from '@ikenxuan/xhshow-ts';
10
- import express, { Router } from 'express';
11
-
12
- /*!
13
- * @ikenxuan/amagi
14
- * Copyright(c) 2023 ikenxuan
15
- * GPL-3.0 Licensed
16
- */
17
-
18
- var getPackageLogsPath = () => {
19
- const currentFileUrl = import.meta.url;
20
- const currentFilePath = fileURLToPath(currentFileUrl);
21
- const currentDir = path.dirname(currentFilePath);
22
- let packageRoot = currentDir;
23
- while (packageRoot !== path.dirname(packageRoot)) {
24
- if (fs.existsSync(path.join(packageRoot, "package.json"))) {
25
- break;
26
- }
27
- packageRoot = path.dirname(packageRoot);
28
- }
29
- return path.join(packageRoot, "logs");
30
- };
31
- var logsPath = getPackageLogsPath();
32
- var getLogLevel = () => {
33
- const logLevel = process.env.LOG_LEVEL || "info";
34
- return logLevel;
35
- };
36
- var currentLogLevel = getLogLevel();
37
- log4js.configure({
38
- appenders: {
39
- console: {
40
- type: "stdout",
41
- layout: {
42
- type: "pattern",
43
- pattern: "%[[amagi][%d{hh:mm:ss.SSS}][%4.4p]%] %m"
44
- }
45
- },
46
- command: {
47
- type: "dateFile",
48
- filename: path.join(logsPath, "application", "command"),
49
- pattern: "yyyy-MM-dd.log",
50
- numBackups: 15,
51
- alwaysIncludePattern: true,
52
- layout: {
53
- type: "pattern",
54
- pattern: "[%d{hh:mm:ss.SSS}][%4.4p] %m"
55
- }
56
- },
57
- httpConsole: {
58
- type: "stdout",
59
- layout: {
60
- type: "pattern",
61
- pattern: "%[[amagi][%d{hh:mm:ss.SSS}][HTTP]%] %m"
62
- }
63
- },
64
- httpRequest: {
65
- type: "dateFile",
66
- filename: path.join(logsPath, "http", "requests"),
67
- pattern: "yyyy-MM-dd.log",
68
- numBackups: 30,
69
- alwaysIncludePattern: true,
70
- layout: {
71
- type: "pattern",
72
- pattern: "[%d{hh:mm:ss.SSS}][%4.4p] %m"
73
- }
74
- }
75
- },
76
- categories: {
77
- default: { appenders: ["console", "command"], level: currentLogLevel },
78
- http: { appenders: ["httpConsole", "httpRequest"], level: "debug" }
79
- },
80
- pm2: true
81
- });
82
- var CustomLogger = class {
83
- logger;
84
- chalk;
85
- red;
86
- green;
87
- yellow;
88
- blue;
89
- magenta;
90
- cyan;
91
- white;
92
- gray;
93
- constructor(name) {
94
- this.logger = log4js.getLogger(name);
95
- this.chalk = new Chalk();
96
- this.red = this.chalk.red;
97
- this.green = this.chalk.green;
98
- this.yellow = this.chalk.yellow;
99
- this.blue = this.chalk.blue;
100
- this.magenta = this.chalk.magenta;
101
- this.cyan = this.chalk.cyan;
102
- this.white = this.chalk.white;
103
- this.gray = this.chalk.gray;
104
- }
105
- // 代理 log4js.Logger 的方法
106
- info(message, ...args) {
107
- this.logger.info(message, ...args);
108
- }
109
- warn(message, ...args) {
110
- this.logger.warn(message, ...args);
111
- }
112
- error(message, ...args) {
113
- this.logger.error(message, ...args);
114
- }
115
- mark(message, ...args) {
116
- this.logger.mark(message, ...args);
117
- }
118
- debug(message, ...args) {
119
- this.logger.debug(message, ...args);
120
- }
121
- };
122
- var logger = new CustomLogger("default");
123
- var httpLogger = new CustomLogger("http");
124
- var logMiddleware = (pathsToLog) => {
125
- return (req, res, next) => {
126
- if (!pathsToLog || pathsToLog.some((path2) => req.url.startsWith(path2))) {
127
- const startTime = Date.now();
128
- const url = req.url;
129
- const method = req.method;
130
- const clientIP = req.headers["x-forwarded-for"] || req.socket.remoteAddress;
131
- const referer = req.headers["referer"] || req.headers["referrer"] || "-";
132
- const contentType = req.headers["content-type"] || "-";
133
- const requestSize = req.headers["content-length"] || "0";
134
- const protocol = req.protocol;
135
- const httpVersion = req.httpVersion;
136
- res.on("finish", () => {
137
- const responseTime = Date.now() - startTime;
138
- const statusCode = res.statusCode;
139
- const responseSize = res.get("content-length") || "0";
140
- const logData = {
141
- method,
142
- url,
143
- statusCode,
144
- responseTime: `${responseTime}ms`,
145
- clientIP,
146
- referer,
147
- contentType,
148
- requestSize: `${requestSize}B`,
149
- responseSize: `${responseSize}B`,
150
- protocol,
151
- httpVersion,
152
- timestamp: (/* @__PURE__ */ new Date()).toISOString()
153
- };
154
- httpLogger.debug(JSON.stringify(logData));
155
- });
156
- }
157
- next();
158
- };
159
- };
160
- var cleanUserAgent = (userAgent) => {
161
- return userAgent.replace(/\s+Edg\/[\d\.]+/g, "");
162
- };
163
- var fetchData = async (config) => {
164
- try {
165
- const cleanedConfig = { ...config };
166
- if (cleanedConfig.headers && cleanedConfig.headers["User-Agent"]) {
167
- cleanedConfig.headers["User-Agent"] = cleanUserAgent(cleanedConfig.headers["User-Agent"]);
168
- }
169
- const response = await axios({ ...cleanedConfig, validateStatus: () => true });
170
- return response.data;
171
- } catch (error) {
172
- if (error instanceof AxiosError) {
173
- logger.error("\u7F51\u7EDC\u8BF7\u6C42\u5931\u8D25:", error.message);
174
- throw error;
175
- }
176
- throw error;
177
- }
178
- };
179
- var normalizeHeaders = (headers) => {
180
- if (headers && typeof headers.toJSON === "function") {
181
- return headers.toJSON();
182
- }
183
- return headers || {};
184
- };
185
- var fetchResponse = async (config) => {
186
- try {
187
- const cleanedConfig = { ...config };
188
- if (cleanedConfig.headers && cleanedConfig.headers["User-Agent"]) {
189
- cleanedConfig.headers["User-Agent"] = cleanUserAgent(cleanedConfig.headers["User-Agent"]);
190
- }
191
- return await axios({ ...cleanedConfig, validateStatus: () => true });
192
- } catch (error) {
193
- if (error instanceof AxiosError) {
194
- throw error;
195
- }
196
- throw new Error("\u7F51\u7EDC\u8BF7\u6C42\u5931\u8D25");
197
- }
198
- };
199
- var getHeadersAndData = async (config) => {
200
- try {
201
- const response = await fetchResponse(config);
202
- return {
203
- headers: normalizeHeaders(response.headers),
204
- data: response.data
205
- };
206
- } catch (error) {
207
- logger.error("\u83B7\u53D6\u54CD\u5E94\u5934\u548C\u6570\u636E\u5931\u8D25:", error);
208
- return {
209
- headers: {},
210
- data: {}
211
- };
212
- }
213
- };
214
-
215
- // src/platform/bilibili/qtparam.ts
216
- var qtparam = async (BASEURL, cookie) => {
217
- if (cookie === "") return { QUERY: "&platform=html5", STATUS: "!isLogin" };
218
- const logininfo = await fetchData({ url: bilibiliApiUrls.\u767B\u5F55\u57FA\u672C\u4FE1\u606F(), headers: { Cookie: cookie } });
219
- const sign = await wbi_sign(BASEURL, cookie);
220
- const qn = [6, 16, 32, 64, 74, 80, 112, 116, 120, 125, 126, 127];
221
- let isvip;
222
- logininfo.data.vipStatus === 1 ? isvip = true : isvip = false;
223
- if (isvip) {
224
- const fnval = 4048;
225
- return {
226
- QUERY: `&fnval=${fnval}&fourk=1&${sign}`,
227
- STATUS: "isLogin",
228
- isvip
229
- };
230
- } else {
231
- return {
232
- QUERY: `&qn=${qn[3]}&fnval=16&${sign}`,
233
- STATUS: "isLogin",
234
- isvip
235
- };
236
- }
237
- };
238
-
239
- // src/platform/bilibili/sign/bv2av.ts
240
- var XOR_CODE = 23442827791579n;
241
- var MASK_CODE = 2251799813685247n;
242
- var MAX_AID = 1n << 51n;
243
- var BASE = 58n;
244
- var data = "FcwAPNKTMug3GV5Lj7EJnHpWsx4tb8haYeviqBz6rkCy12mUSDQX9RdoZf";
245
- var av2bv = (aid) => {
246
- const bytes = ["B", "V", "1", "0", "0", "0", "0", "0", "0", "0", "0", "0"];
247
- let bvIndex = bytes.length - 1;
248
- let tmp = (MAX_AID | BigInt(aid)) ^ XOR_CODE;
249
- while (tmp > 0) {
250
- bytes[bvIndex] = data[Number(tmp % BigInt(BASE))];
251
- tmp = tmp / BASE;
252
- bvIndex -= 1;
253
- }
254
- [bytes[3], bytes[9]] = [bytes[9], bytes[3]];
255
- [bytes[4], bytes[7]] = [bytes[7], bytes[4]];
256
- return bytes.join("");
257
- };
258
- var bv2av = (bvid) => {
259
- const bvidArr = Array.from(bvid);
260
- [bvidArr[3], bvidArr[9]] = [bvidArr[9], bvidArr[3]];
261
- [bvidArr[4], bvidArr[7]] = [bvidArr[7], bvidArr[4]];
262
- bvidArr.splice(0, 3);
263
- const tmp = bvidArr.reduce((pre, bvidChar) => pre * BASE + BigInt(data.indexOf(bvidChar)), 0n);
264
- return Number(tmp & MASK_CODE ^ XOR_CODE);
265
- };
266
-
267
- // src/platform/bilibili/API.ts
268
- var BiLiBiLiAPI = class {
269
- \u767B\u5F55\u57FA\u672C\u4FE1\u606F() {
270
- return "https://api.bilibili.com/x/web-interface/nav";
271
- }
272
- \u89C6\u9891\u8BE6\u7EC6\u4FE1\u606F(data2) {
273
- return `https://api.bilibili.com/x/web-interface/view?bvid=${data2.bvid}`;
274
- }
275
- \u89C6\u9891\u6D41\u4FE1\u606F(data2) {
276
- return `https://api.bilibili.com/x/player/playurl?avid=${data2.avid}&cid=${data2.cid}`;
277
- }
278
- /** 评论区类型,type参数详见 [评论区类型代码](https://github.com/SocialSisterYi/bilibili-API-collect/blob/master/docs/comment/readme.md#评论区类型代码) */
279
- \u8BC4\u8BBA\u533A\u660E\u7EC6(data2) {
280
- const params = new URLSearchParams({
281
- oid: data2.oid.toString(),
282
- type: data2.type.toString(),
283
- mode: (data2.mode ?? 3).toString(),
284
- plat: "1",
285
- seek_rpid: "",
286
- web_location: "1315875"
287
- });
288
- if (data2.pagination_str) {
289
- params.append("pagination_str", JSON.stringify({ offset: data2.pagination_str }));
290
- } else {
291
- params.append("pagination_str", JSON.stringify({ offset: "" }));
292
- }
293
- return `https://api.bilibili.com/x/v2/reply/wbi/main?${params.toString()}`;
294
- }
295
- \u8BC4\u8BBA\u533A\u72B6\u6001(data2) {
296
- return `https://api.bilibili.com/x/v2/reply/subject/description?type=${data2.type}&oid=${data2.oid}`;
297
- }
298
- \u8868\u60C5\u5217\u8868() {
299
- return "https://api.bilibili.com/x/emote/user/panel/web?business=reply&web_location=0.0";
300
- }
301
- \u756A\u5267\u660E\u7EC6(data2) {
302
- if (data2.ep_id) {
303
- return `https://api.bilibili.com/pgc/view/web/season?ep_id=${data2.ep_id}`;
304
- } else if (data2.season_id) {
305
- return `https://api.bilibili.com/pgc/view/web/season?season_id=${data2.season_id}`;
306
- } else {
307
- throw new Error("\u62DF\u9020\u63A5\u53E3\u5730\u5740\u51FA\u9519\uFF0C\u7F3A\u5C11 ep_id \u6216 season_id \u53C2\u6570");
308
- }
309
- }
310
- \u756A\u5267\u89C6\u9891\u6D41\u4FE1\u606F(data2) {
311
- return `https://api.bilibili.com/pgc/player/web/playurl?cid=${data2.cid}&ep_id=${data2.ep_id}`;
312
- }
313
- \u7528\u6237\u7A7A\u95F4\u52A8\u6001(data2) {
314
- return `https://api.bilibili.com/x/polymer/web-dynamic/v1/feed/space?host_mid=${data2.host_mid}&features=itemOpusStyle,listOnlyfans,opusBigCover,onlyfansVote,forwardListHidden,decorationCard,commentsNewVersion,onlyfansAssetsV2,ugcDelete,onlyfansQaCard`;
315
- }
316
- \u52A8\u6001\u8BE6\u60C5(data2) {
317
- return `https://api.bilibili.com/x/polymer/web-dynamic/v1/detail?id=${data2.dynamic_id}&features=itemOpusStyle,opusBigCover,onlyfansVote,endFooterHidden,decorationCard,onlyfansAssetsV2,ugcDelete,onlyfansQaCard,editable,opusPrivateVisible,avatarAutoTheme`;
318
- }
319
- \u52A8\u6001\u5361\u7247\u4FE1\u606F(data2) {
320
- return `https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/get_dynamic_detail?dynamic_id=${data2.dynamic_id}`;
321
- }
322
- \u7528\u6237\u540D\u7247\u4FE1\u606F(data2) {
323
- return `https://api.bilibili.com/x/web-interface/card?mid=${data2.host_mid}&photo=true`;
324
- }
325
- \u76F4\u64AD\u95F4\u4FE1\u606F(data2) {
326
- return `https://api.live.bilibili.com/room/v1/Room/get_info?room_id=${data2.room_id}`;
327
- }
328
- \u76F4\u64AD\u95F4\u521D\u59CB\u5316\u4FE1\u606F(data2) {
329
- return `https://api.live.bilibili.com/room/v1/Room/room_init?id=${data2.room_id}`;
330
- }
331
- \u7533\u8BF7\u4E8C\u7EF4\u7801() {
332
- return "https://passport.bilibili.com/x/passport-login/web/qrcode/generate";
333
- }
334
- \u4E8C\u7EF4\u7801\u72B6\u6001(data2) {
335
- return `https://passport.bilibili.com/x/passport-login/web/qrcode/poll?qrcode_key=${data2.qrcode_key}`;
336
- }
337
- \u83B7\u53D6UP\u4E3B\u603B\u64AD\u653E\u91CF(data2) {
338
- return `https://api.bilibili.com/x/space/upstat?mid=${data2.host_mid}`;
339
- }
340
- };
341
- var bilibiliApiUrls = new BiLiBiLiAPI();
342
-
343
- // src/types/NetworksConfigType.ts
344
- var kuaishouAPIErrorCode = /* @__PURE__ */ ((kuaishouAPIErrorCode2) => {
345
- kuaishouAPIErrorCode2["COOKIE"] = "INVALID_COOKIE";
346
- kuaishouAPIErrorCode2["UNKNOWN"] = "UNKNOWN_ERROR" /* UNKNOWN */;
347
- return kuaishouAPIErrorCode2;
348
- })(kuaishouAPIErrorCode || {});
349
- var xiaohongshuAPIErrorCode = /* @__PURE__ */ ((xiaohongshuAPIErrorCode2) => {
350
- xiaohongshuAPIErrorCode2["COOKIE"] = "INVALID_COOKIE";
351
- xiaohongshuAPIErrorCode2["UNKNOWN"] = "UNKNOWN_ERROR" /* UNKNOWN */;
352
- xiaohongshuAPIErrorCode2[xiaohongshuAPIErrorCode2["ILLEGAL_REQUEST"] = 500] = "ILLEGAL_REQUEST";
353
- xiaohongshuAPIErrorCode2[xiaohongshuAPIErrorCode2["ACCOUNT_ABNORMAL"] = 300011] = "ACCOUNT_ABNORMAL";
354
- xiaohongshuAPIErrorCode2[xiaohongshuAPIErrorCode2["NETWORK_ERROR"] = 300012] = "NETWORK_ERROR";
355
- xiaohongshuAPIErrorCode2[xiaohongshuAPIErrorCode2["FREQUENCY_ERROR"] = 300013] = "FREQUENCY_ERROR";
356
- xiaohongshuAPIErrorCode2[xiaohongshuAPIErrorCode2["BROWSER_ERROR"] = 300015] = "BROWSER_ERROR";
357
- return xiaohongshuAPIErrorCode2;
358
- })(xiaohongshuAPIErrorCode || {});
359
- var mixinKeyEncTab = [
360
- 46,
361
- 47,
362
- 18,
363
- 2,
364
- 53,
365
- 8,
366
- 23,
367
- 32,
368
- 15,
369
- 50,
370
- 10,
371
- 31,
372
- 58,
373
- 3,
374
- 45,
375
- 35,
376
- 27,
377
- 43,
378
- 5,
379
- 49,
380
- 33,
381
- 9,
382
- 42,
383
- 19,
384
- 29,
385
- 28,
386
- 14,
387
- 39,
388
- 12,
389
- 38,
390
- 41,
391
- 13,
392
- 37,
393
- 48,
394
- 7,
395
- 16,
396
- 24,
397
- 55,
398
- 40,
399
- 61,
400
- 26,
401
- 17,
402
- 0,
403
- 1,
404
- 60,
405
- 51,
406
- 30,
407
- 4,
408
- 22,
409
- 25,
410
- 54,
411
- 21,
412
- 56,
413
- 59,
414
- 6,
415
- 63,
416
- 57,
417
- 62,
418
- 11,
419
- 36,
420
- 20,
421
- 34,
422
- 44,
423
- 52
424
- ];
425
- var getMixinKey = (orig) => mixinKeyEncTab.map((n) => orig[n]).join("").slice(0, 32);
426
- var encWbi = (params, img_key, sub_key) => {
427
- const mixin_key = getMixinKey(img_key + sub_key);
428
- const curr_time = Math.round(Date.now() / 1e3);
429
- const chr_filter = /[!'()*]/g;
430
- Object.assign(params, { wts: curr_time });
431
- const query = Object.keys(params).sort().map((key) => {
432
- const value = params[key].toString().replace(chr_filter, "");
433
- return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
434
- }).join("&");
435
- const wbi_sign2 = crypto.createHash("md5").update(query + mixin_key).digest("hex");
436
- return `&wts=${curr_time}&w_rid=${wbi_sign2}`;
437
- };
438
- var getWbiKeys = async (cookie) => {
439
- const res = await axios("https://api.bilibili.com/x/web-interface/nav", {
440
- headers: {
441
- Cookie: cookie
442
- }
443
- });
444
- const response = res.data;
445
- const {
446
- data: {
447
- wbi_img: { img_url, sub_url }
448
- }
449
- } = response;
450
- return {
451
- img_key: img_url.slice(img_url.lastIndexOf("/") + 1, img_url.lastIndexOf(".")),
452
- sub_key: sub_url.slice(sub_url.lastIndexOf("/") + 1, sub_url.lastIndexOf("."))
453
- };
454
- };
455
- var wbi_sign = async (BASEURL, cookie) => {
456
- const web_keys = await getWbiKeys(cookie);
457
- const url = new URL(BASEURL);
458
- const params = {};
459
- for (const [key, value] of url.searchParams.entries()) {
460
- params[key] = value;
461
- }
462
- const query = encWbi(params, web_keys.img_key, web_keys.sub_key);
463
- return query;
464
- };
465
-
466
- // src/platform/defaultConfigs.ts
467
- var generateSecChUa = (userAgent) => {
468
- const chromeMatch = userAgent.match(/Chrome\/(\d+)/);
469
- const chromeVersion = chromeMatch ? chromeMatch[1] : "125";
470
- return `"Not)A;Brand";v="8", "Chromium";v="${chromeVersion}", "Google Chrome";v="${chromeVersion}"`;
471
- };
472
- var getDouyinDefaultConfig = (cookie, requestConfig) => {
473
- var _a;
474
- let finalUserAgent = ((_a = void 0 ) == null ? void 0 : _a["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";
475
- finalUserAgent = finalUserAgent.replace(/\s+Edg\/[\d\.]+/g, "");
476
- const defHeaders = {
477
- Accept: "application/json, text/plain, */*",
478
- "Accept-Encoding": "gzip, deflate, br, zstd",
479
- "Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
480
- Cookie: cookie ? cookie.replace(/\s+/g, "") : "",
481
- Priority: "u=1, i",
482
- Referer: "https://www.douyin.com/",
483
- "Sec-Ch-Ua": generateSecChUa(finalUserAgent),
484
- "Sec-Ch-Ua-Mobile": "?0",
485
- "Sec-Ch-Ua-Platform": '"Windows"',
486
- "Sec-Fetch-Dest": "empty",
487
- "Sec-Fetch-Mode": "cors",
488
- "Sec-Fetch-Site": "same-origin",
489
- "User-Agent": finalUserAgent
490
- };
491
- return {
492
- method: "GET",
493
- timeout: 1e4,
494
- ...requestConfig,
495
- headers: {
496
- ...defHeaders,
497
- ...{}
498
- }
499
- };
500
- };
501
- var getBilibiliDefaultConfig = (cookie, requestConfig) => {
502
- const defHeaders = {
503
- Accept: "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
504
- "Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
505
- "Cache-Control": "max-age=0",
506
- Priority: "u=0, i",
507
- "Sec-Ch-Ua": '"Microsoft Edge";v="131", "Chromium";v="131", "Not_A Brand";v="24"',
508
- "Sec-Ch-Ua-Mobile": "?0",
509
- "Sec-Ch-Ua-Platform": '"Windows"',
510
- "Sec-Fetch-Dest": "document",
511
- "Sec-Fetch-Mode": "navigate",
512
- "Sec-Fetch-Site": "none",
513
- "Sec-Fetch-User": "?1",
514
- "Upgrade-Insecure-Requests": "1",
515
- Referer: "https://www.bilibili.com/",
516
- Cookie: cookie ? cookie.replace(/\s+/g, "") : ""
517
- };
518
- return {
519
- method: "GET",
520
- timeout: 1e4,
521
- ...requestConfig,
522
- headers: {
523
- ...defHeaders,
524
- ...{}
525
- }
526
- };
527
- };
528
- var getKuaishouDefaultConfig = (cookie, requestConfig) => {
529
- const defHeaders = {
530
- Referer: "https://www.kuaishou.com/new-reco",
531
- Origin: "https://www.kuaishou.com",
532
- Accept: "application/json, text/plain, */*",
533
- "Accept-Encoding": "gzip, deflate, br, zstd",
534
- "Content-Type": "application/json",
535
- "Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
536
- Priority: "u=0, i",
537
- "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36 Edg/130.0.0.0",
538
- Cookie: cookie ? cookie.replace(/\s+/g, "") : ""
539
- };
540
- return {
541
- method: "POST",
542
- timeout: 1e4,
543
- ...requestConfig,
544
- headers: {
545
- ...defHeaders,
546
- ...{}
547
- }
548
- };
549
- };
550
- var getXiaohongshuDefaultConfig = (cookie) => {
551
- return {
552
- headers: {
553
- "accept": "application/json, text/plain, */*",
554
- "accept-language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
555
- "cache-control": "no-cache",
556
- "content-type": "application/json;charset=UTF-8",
557
- "pragma": "no-cache",
558
- "priority": "u=1, i",
559
- "referer": "https://www.xiaohongshu.com/",
560
- "sec-ch-ua": '"Microsoft Edge";v="141", "Not?A_Brand";v="8", "Chromium";v="141"',
561
- "sec-ch-ua-mobile": "?0",
562
- "sec-ch-ua-platform": '"Windows"',
563
- "sec-fetch-dest": "empty",
564
- "sec-fetch-mode": "cors",
565
- "sec-fetch-site": "same-site",
566
- "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36 Edg/141.0.0.0",
567
- "cookie": cookie || ""
568
- }
569
- };
570
- };
571
-
572
- // src/platform/bilibili/getdata.ts
573
- var fetchBilibili = async (data2, cookie, requestConfig) => {
574
- var _a, _b, _c, _d, _e, _f;
575
- const defHeaders = getBilibiliDefaultConfig(cookie)["headers"];
576
- const baseRequestConfig = {
577
- method: "GET",
578
- timeout: 1e4,
579
- ...requestConfig,
580
- headers: {
581
- ...defHeaders,
582
- ...{}
583
- }
584
- };
585
- switch (data2.methodType) {
586
- case "\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E": {
587
- const INFODATA = await GlobalGetData(data2.methodType, {
588
- ...baseRequestConfig,
589
- url: bilibiliApiUrls.\u89C6\u9891\u8BE6\u7EC6\u4FE1\u606F({ bvid: data2.bvid })
590
- });
591
- return INFODATA;
592
- }
593
- case "\u5355\u4E2A\u89C6\u9891\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E": {
594
- const BASEURL = bilibiliApiUrls.\u89C6\u9891\u6D41\u4FE1\u606F({ avid: data2.avid, cid: data2.cid });
595
- const SIGN = await qtparam(BASEURL, (_a = baseRequestConfig.headers) == null ? void 0 : _a.Cookie);
596
- const DATA = await GlobalGetData(data2.methodType, {
597
- ...baseRequestConfig,
598
- url: bilibiliApiUrls.\u89C6\u9891\u6D41\u4FE1\u606F({ avid: data2.avid, cid: data2.cid }) + SIGN.QUERY
599
- });
600
- return DATA;
601
- }
602
- case "\u8BC4\u8BBA\u6570\u636E": {
603
- let { oid, number, type, mode, pagination_str, plat, seek_rpid, web_location } = data2;
604
- let fetchedComments = [];
605
- const maxRequestCount = 100;
606
- let requestCount = 0;
607
- let tmpresp;
608
- let nextPaginationStr = pagination_str;
609
- let isEnd = false;
610
- const checkStatusUrl = bilibiliApiUrls.\u8BC4\u8BBA\u533A\u72B6\u6001({ oid, type });
611
- const checkStatusRes = await GlobalGetData(data2.methodType, {
612
- ...baseRequestConfig,
613
- url: checkStatusUrl
614
- });
615
- if (checkStatusRes.data === null) {
616
- logger.error("\u8BC4\u8BBA\u533A\u672A\u5F00\u653E");
617
- return {
618
- code: 404,
619
- message: "\u8BC4\u8BBA\u533A\u672A\u5F00\u653E",
620
- data: null
621
- };
622
- }
623
- while (fetchedComments.length < Number(number ?? 20) && requestCount < maxRequestCount && !isEnd) {
624
- const baseUrl = bilibiliApiUrls.\u8BC4\u8BBA\u533A\u660E\u7EC6({
625
- type,
626
- oid,
627
- mode: mode ?? 3,
628
- pagination_str: nextPaginationStr,
629
- plat: plat ?? 1,
630
- seek_rpid,
631
- web_location: web_location ?? "1315875"
632
- });
633
- const wbiSignQuery = await wbi_sign(baseUrl, (_b = baseRequestConfig.headers) == null ? void 0 : _b.cookie);
634
- const finalUrl = baseUrl + wbiSignQuery;
635
- const response = await GlobalGetData(data2.methodType, {
636
- ...baseRequestConfig,
637
- url: finalUrl
638
- });
639
- tmpresp = response;
640
- const currentComments = ((_c = response.data) == null ? void 0 : _c.replies) || [];
641
- fetchedComments.push(...currentComments);
642
- if ((_d = response.data) == null ? void 0 : _d.cursor) {
643
- nextPaginationStr = (_e = response.data.cursor.pagination_reply) == null ? void 0 : _e.next_offset;
644
- isEnd = response.data.cursor.is_end;
645
- } else {
646
- isEnd = true;
647
- }
648
- requestCount++;
649
- if (isEnd || currentComments.length === 0 || !nextPaginationStr) {
650
- logger.info("\u5DF2\u5230\u8FBE\u8BC4\u8BBA\u672B\u5C3E\u6216\u65E0\u66F4\u591A\u8BC4\u8BBA");
651
- break;
652
- }
653
- }
654
- const finalResponse = {
655
- ...tmpresp,
656
- data: {
657
- ...tmpresp.data,
658
- // 去重并限制数量
659
- replies: Array.from(new Map(fetchedComments.map((item) => [item.rpid, item])).values()).slice(0, Number(data2.number || 20))
660
- }
661
- };
662
- return finalResponse;
663
- }
664
- case "Emoji\u6570\u636E": {
665
- return await GlobalGetData(data2.methodType, {
666
- ...baseRequestConfig,
667
- url: bilibiliApiUrls.\u8868\u60C5\u5217\u8868()
668
- });
669
- }
670
- case "\u756A\u5267\u57FA\u672C\u4FE1\u606F\u6570\u636E": {
671
- let id = data2.ep_id ? data2.ep_id : data2.season_id;
672
- if (!id) {
673
- return false;
674
- }
675
- const idType = id ? id.startsWith("ep") ? "ep_id" : "season_id" : "ep_id";
676
- const newId = idType === "ep_id" ? id.replace("ep", "") : id.replace("ss", "");
677
- const INFO = await GlobalGetData(data2.methodType, {
678
- ...baseRequestConfig,
679
- url: bilibiliApiUrls.\u756A\u5267\u660E\u7EC6({ [idType]: newId })
680
- });
681
- return INFO;
682
- }
683
- case "\u756A\u5267\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E": {
684
- const BASEURL = bilibiliApiUrls.\u756A\u5267\u89C6\u9891\u6D41\u4FE1\u606F({ cid: data2.cid, ep_id: data2.ep_id.replace("ep", "") });
685
- const SIGN = await qtparam(BASEURL, (_f = baseRequestConfig.headers) == null ? void 0 : _f.cookie);
686
- const DATA = await GlobalGetData(data2.methodType, {
687
- ...baseRequestConfig,
688
- url: bilibiliApiUrls.\u756A\u5267\u89C6\u9891\u6D41\u4FE1\u606F({ cid: data2.cid, ep_id: data2.ep_id.replace("ep", "") }) + SIGN.QUERY
689
- });
690
- return DATA;
691
- }
692
- case "\u7528\u6237\u4E3B\u9875\u52A8\u6001\u5217\u8868\u6570\u636E": {
693
- const customConfig = {
694
- ...baseRequestConfig,
695
- headers: {
696
- ...baseRequestConfig.headers,
697
- // 只有在外部配置没有referer时才删除内部的referer
698
- ...{
699
- referer: void 0
700
- }
701
- }
702
- };
703
- const { host_mid } = data2;
704
- const result = await GlobalGetData(data2.methodType, {
705
- ...customConfig,
706
- url: bilibiliApiUrls.\u7528\u6237\u7A7A\u95F4\u52A8\u6001({ host_mid })
707
- });
708
- return result;
709
- }
710
- case "\u52A8\u6001\u8BE6\u60C5\u6570\u636E": {
711
- const customConfig = {
712
- ...baseRequestConfig,
713
- headers: {
714
- ...baseRequestConfig.headers,
715
- // 只有在外部配置没有referer时才删除内部的referer
716
- ...{
717
- referer: void 0
718
- }
719
- }
720
- };
721
- const dynamicINFO = await GlobalGetData(data2.methodType, {
722
- ...customConfig,
723
- url: bilibiliApiUrls.\u52A8\u6001\u8BE6\u60C5({ dynamic_id: data2.dynamic_id })
724
- });
725
- return dynamicINFO;
726
- }
727
- case "\u52A8\u6001\u5361\u7247\u6570\u636E": {
728
- const customConfig = {
729
- ...baseRequestConfig,
730
- headers: {
731
- ...baseRequestConfig.headers,
732
- // 只有在外部配置没有referer时才删除内部的referer
733
- ...{
734
- referer: void 0
735
- }
736
- }
737
- };
738
- const { dynamic_id } = data2;
739
- const dynamicINFO_CARD = await GlobalGetData(data2.methodType, {
740
- ...customConfig,
741
- url: bilibiliApiUrls.\u52A8\u6001\u5361\u7247\u4FE1\u606F({ dynamic_id })
742
- });
743
- return dynamicINFO_CARD;
744
- }
745
- case "\u7528\u6237\u4E3B\u9875\u6570\u636E": {
746
- const { host_mid } = data2;
747
- const result = await GlobalGetData(data2.methodType, {
748
- ...baseRequestConfig,
749
- url: bilibiliApiUrls.\u7528\u6237\u540D\u7247\u4FE1\u606F({ host_mid })
750
- });
751
- return result;
752
- }
753
- case "\u76F4\u64AD\u95F4\u4FE1\u606F": {
754
- const result = await GlobalGetData(data2.methodType, {
755
- ...baseRequestConfig,
756
- url: bilibiliApiUrls.\u76F4\u64AD\u95F4\u4FE1\u606F({ room_id: data2.room_id })
757
- });
758
- return result;
759
- }
760
- case "\u76F4\u64AD\u95F4\u521D\u59CB\u5316\u4FE1\u606F": {
761
- const result = await GlobalGetData(data2.methodType, {
762
- ...baseRequestConfig,
763
- url: bilibiliApiUrls.\u76F4\u64AD\u95F4\u521D\u59CB\u5316\u4FE1\u606F({ room_id: data2.room_id })
764
- });
765
- return result;
766
- }
767
- case "\u7533\u8BF7\u4E8C\u7EF4\u7801": {
768
- const result = await GlobalGetData(data2.methodType, {
769
- ...baseRequestConfig,
770
- url: bilibiliApiUrls.\u7533\u8BF7\u4E8C\u7EF4\u7801()
771
- });
772
- return result;
773
- }
774
- case "\u4E8C\u7EF4\u7801\u72B6\u6001": {
775
- try {
776
- const result = await getHeadersAndData({
777
- ...baseRequestConfig,
778
- url: bilibiliApiUrls.\u4E8C\u7EF4\u7801\u72B6\u6001({ qrcode_key: data2.qrcode_key })
779
- });
780
- if (result.data.code !== 0) {
781
- const errorMessage = bilibiliErrorCodeMap[String(result.data.code)] || result.data.message || "\u672A\u77E5\u9519\u8BEF";
782
- const Err = {
783
- errorDescription: `\u83B7\u53D6\u54CD\u5E94\u6570\u636E\u5931\u8D25\uFF01\u539F\u56E0\uFF1A${errorMessage}\uFF01`,
784
- requestType: data2.methodType,
785
- requestUrl: bilibiliApiUrls.\u4E8C\u7EF4\u7801\u72B6\u6001({ qrcode_key: data2.qrcode_key })
786
- };
787
- return {
788
- code: result.data.code,
789
- data: result.data,
790
- amagiError: Err
791
- };
792
- }
793
- return {
794
- code: 0,
795
- data: {
796
- data: result.data.data,
797
- headers: result.headers
798
- },
799
- message: "0"
800
- };
801
- } catch (error) {
802
- if (error && typeof error === "object") {
803
- return error;
804
- }
805
- return {
806
- code: "UNKNOWN_ERROR" /* UNKNOWN */,
807
- data: error.data,
808
- amagiError: {
809
- errorDescription: "\u672A\u77E5\u9519\u8BEF",
810
- requestType: data2.methodType,
811
- requestUrl: bilibiliApiUrls.\u4E8C\u7EF4\u7801\u72B6\u6001({ qrcode_key: data2.qrcode_key })
812
- }
813
- };
814
- }
815
- }
816
- case "\u767B\u5F55\u57FA\u672C\u4FE1\u606F": {
817
- const result = await GlobalGetData(data2.methodType, {
818
- ...baseRequestConfig,
819
- url: bilibiliApiUrls.\u767B\u5F55\u57FA\u672C\u4FE1\u606F()
820
- });
821
- return result;
822
- }
823
- case "\u83B7\u53D6UP\u4E3B\u603B\u64AD\u653E\u91CF": {
824
- const result = await GlobalGetData(data2.methodType, {
825
- ...baseRequestConfig,
826
- url: bilibiliApiUrls.\u83B7\u53D6UP\u4E3B\u603B\u64AD\u653E\u91CF({ host_mid: data2.host_mid })
827
- });
828
- return result;
829
- }
830
- case "AV\u8F6CBV": {
831
- const result = av2bv(Number(data2.avid.toString().replace(/^av/i, "")));
832
- return {
833
- code: 0,
834
- message: "success",
835
- data: {
836
- bvid: result
837
- }
838
- };
839
- }
840
- case "BV\u8F6CAV": {
841
- const result = "av" + bv2av(data2.bvid);
842
- return {
843
- code: 0,
844
- message: "success",
845
- data: {
846
- aid: result
847
- }
848
- };
849
- }
850
- default:
851
- logger.warn(`\u672A\u77E5\u7684B\u7AD9\u6570\u636E\u63A5\u53E3\uFF1A\u300C${logger.red(data2.methodType)}\u300D`);
852
- return null;
853
- }
854
- };
855
- var GlobalGetData = async (type, options) => {
856
- let warningMessage = "";
857
- try {
858
- const result = await fetchData(options);
859
- if (!result || result === "") {
860
- const Err = {
861
- errorDescription: "\u83B7\u53D6\u54CD\u5E94\u6570\u636E\u5931\u8D25\uFF01\u63A5\u53E3\u8FD4\u56DE\u5185\u5BB9\u4E3A\u7A7A\uFF0C\u4F60\u7684B\u7AD9ck\u53EF\u80FD\u5DF2\u7ECF\u5931\u6548\uFF01",
862
- requestType: type ?? "\u672A\u77E5\u8BF7\u6C42\u7C7B\u578B",
863
- requestUrl: options.url
864
- };
865
- warningMessage = `
866
- \u83B7\u53D6\u54CD\u5E94\u6570\u636E\u5931\u8D25\uFF01\u539F\u56E0\uFF1A${logger.yellow("\u63A5\u53E3\u8FD4\u56DE\u5185\u5BB9\u4E3A\u7A7A\uFF0C\u4F60\u7684B\u7AD9ck\u53EF\u80FD\u5DF2\u7ECF\u5931\u6548\uFF01")}
867
- \u8BF7\u6C42\u7C7B\u578B\uFF1A\u300C${type}\u300D
868
- \u8BF7\u6C42URL\uFF1A${options.url}
869
- `;
870
- logger.warn(warningMessage);
871
- throw {
872
- code: "-352" /* RISK_CONTROL_FAILED */,
873
- data: result,
874
- amagiError: Err
875
- };
876
- }
877
- if (result.code !== 0) {
878
- const errorMessage = bilibiliErrorCodeMap[result.code] || result.message || "\u672A\u77E5\u9519\u8BEF";
879
- const Err = {
880
- errorDescription: `\u83B7\u53D6\u54CD\u5E94\u6570\u636E\u5931\u8D25\uFF01\u539F\u56E0\uFF1A${errorMessage}\uFF01`,
881
- requestType: type ?? "\u672A\u77E5\u8BF7\u6C42\u7C7B\u578B",
882
- requestUrl: options.url
883
- };
884
- warningMessage = `
885
- \u83B7\u53D6\u54CD\u5E94\u6570\u636E\u5931\u8D25\uFF01\u539F\u56E0\uFF1A${logger.yellow(errorMessage)}
886
- \u9519\u8BEF\u4EE3\u7801\uFF1A${result.code}
887
- \u8BF7\u6C42\u7C7B\u578B\uFF1A\u300C${type}\u300D
888
- \u8BF7\u6C42URL\uFF1A${options.url}
889
- `;
890
- logger.warn(warningMessage);
891
- throw {
892
- code: result.code,
893
- data: result,
894
- amagiError: Err
895
- };
896
- }
897
- return result;
898
- } catch (error) {
899
- if (error && typeof error === "object") {
900
- const err = error;
901
- return { ...err, amagiMessage: warningMessage };
902
- }
903
- return {
904
- code: "UNKNOWN_ERROR" /* UNKNOWN */,
905
- data: error.data,
906
- amagiError: {
907
- errorDescription: "\u672A\u77E5\u9519\u8BEF",
908
- requestType: type,
909
- requestUrl: options.url
910
- },
911
- amagiMessage: warningMessage
912
- };
913
- }
914
- };
915
- var bilibiliErrorCodeMap = {
916
- "-1": "\u5E94\u7528\u7A0B\u5E8F\u4E0D\u5B58\u5728\u6216\u5DF2\u88AB\u5C01\u7981",
917
- "-2": "Access Key \u9519\u8BEF",
918
- "-3": "API \u6821\u9A8C\u5BC6\u5319\u9519\u8BEF",
919
- "-4": "\u8C03\u7528\u65B9\u5BF9\u8BE5 Method \u6CA1\u6709\u6743\u9650",
920
- "-101": "\u8D26\u53F7\u672A\u767B\u5F55",
921
- "-102": "\u8D26\u53F7\u88AB\u5C01\u505C",
922
- "-103": "\u79EF\u5206\u4E0D\u8DB3",
923
- "-104": "\u786C\u5E01\u4E0D\u8DB3",
924
- "-105": "\u9A8C\u8BC1\u7801\u9519\u8BEF",
925
- "-106": "\u8D26\u53F7\u975E\u6B63\u5F0F\u4F1A\u5458\u6216\u5728\u9002\u5E94\u671F",
926
- "-107": "\u5E94\u7528\u4E0D\u5B58\u5728\u6216\u8005\u88AB\u5C01\u7981",
927
- "-108": "\u672A\u7ED1\u5B9A\u624B\u673A",
928
- "-110": "\u672A\u7ED1\u5B9A\u624B\u673A",
929
- "-111": "csrf \u6821\u9A8C\u5931\u8D25",
930
- "-112": "\u7CFB\u7EDF\u5347\u7EA7\u4E2D",
931
- "-113": "\u8D26\u53F7\u5C1A\u672A\u5B9E\u540D\u8BA4\u8BC1",
932
- "-114": "\u8BF7\u5148\u7ED1\u5B9A\u624B\u673A",
933
- "-115": "\u8BF7\u5148\u5B8C\u6210\u5B9E\u540D\u8BA4\u8BC1",
934
- "-304": "\u6728\u6709\u6539\u52A8",
935
- "-307": "\u649E\u8F66\u8DF3\u8F6C",
936
- "-352": "\u98CE\u63A7\u6821\u9A8C\u5931\u8D25 (UA \u6216 wbi \u53C2\u6570\u4E0D\u5408\u6CD5)",
937
- "-400": "\u8BF7\u6C42\u9519\u8BEF",
938
- "-401": "\u672A\u8BA4\u8BC1 (\u6216\u975E\u6CD5\u8BF7\u6C42)",
939
- "-403": "\u8BBF\u95EE\u6743\u9650\u4E0D\u8DB3",
940
- "-404": "\u5565\u90FD\u6728\u6709",
941
- "-405": "\u4E0D\u652F\u6301\u8BE5\u65B9\u6CD5",
942
- "-409": "\u51B2\u7A81",
943
- "-412": "\u8BF7\u6C42\u88AB\u62E6\u622A (\u5BA2\u6237\u7AEF ip \u88AB\u670D\u52A1\u7AEF\u98CE\u63A7)",
944
- "-500": "\u670D\u52A1\u5668\u9519\u8BEF",
945
- "-503": "\u8FC7\u8F7D\u4FDD\u62A4,\u670D\u52A1\u6682\u4E0D\u53EF\u7528",
946
- "-504": "\u670D\u52A1\u8C03\u7528\u8D85\u65F6",
947
- "-509": "\u8D85\u51FA\u9650\u5236",
948
- "-616": "\u4E0A\u4F20\u6587\u4EF6\u4E0D\u5B58\u5728",
949
- "-617": "\u4E0A\u4F20\u6587\u4EF6\u592A\u5927",
950
- "-625": "\u767B\u5F55\u5931\u8D25\u6B21\u6570\u592A\u591A",
951
- "-626": "\u7528\u6237\u4E0D\u5B58\u5728",
952
- "-628": "\u5BC6\u7801\u592A\u5F31",
953
- "-629": "\u7528\u6237\u540D\u6216\u5BC6\u7801\u9519\u8BEF",
954
- "-632": "\u64CD\u4F5C\u5BF9\u8C61\u6570\u91CF\u9650\u5236",
955
- "-643": "\u88AB\u9501\u5B9A",
956
- "-650": "\u7528\u6237\u7B49\u7EA7\u592A\u4F4E",
957
- "-652": "\u91CD\u590D\u7684\u7528\u6237",
958
- "-658": "Token \u8FC7\u671F",
959
- "-662": "\u5BC6\u7801\u65F6\u95F4\u6233\u8FC7\u671F",
960
- "-688": "\u5730\u7406\u533A\u57DF\u9650\u5236",
961
- "-689": "\u7248\u6743\u9650\u5236",
962
- "-701": "\u6263\u8282\u64CD\u5931\u8D25",
963
- "-799": "\u8BF7\u6C42\u8FC7\u4E8E\u9891\u7E41\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5",
964
- "-8888": "\u5BF9\u4E0D\u8D77\uFF0C\u670D\u52A1\u5668\u5F00\u5C0F\u5DEE\u4E86~ (\u0CA5\uFE4F\u0CA5)"
965
- };
966
-
967
- // src/platform/douyin/sign/a_bogus.ts
968
- var SM3 = class {
969
- reg;
970
- chunk;
971
- size;
972
- constructor() {
973
- this.reg = [];
974
- this.chunk = [];
975
- this.size = 0;
976
- this.reset();
977
- }
978
- reset() {
979
- this.reg[0] = 1937774191;
980
- this.reg[1] = 1226093241;
981
- this.reg[2] = 388252375;
982
- this.reg[3] = 3666478592;
983
- this.reg[4] = 2842636476;
984
- this.reg[5] = 372324522;
985
- this.reg[6] = 3817729613;
986
- this.reg[7] = 2969243214;
987
- this.chunk = [];
988
- this.size = 0;
989
- }
990
- write(e) {
991
- const a = typeof e === "string" ? this.stringToBytes(e) : e;
992
- this.size += a.length;
993
- let f = 64 - this.chunk.length;
994
- if (a.length < f) {
995
- this.chunk = this.chunk.concat(a);
996
- } else {
997
- this.chunk = this.chunk.concat(a.slice(0, f));
998
- while (this.chunk.length >= 64) {
999
- this._compress(this.chunk);
1000
- f < a.length ? this.chunk = a.slice(f, Math.min(f + 64, a.length)) : this.chunk = [];
1001
- f += 64;
1002
- }
1003
- }
1004
- }
1005
- sum(e, t) {
1006
- if (e) {
1007
- this.reset();
1008
- this.write(e);
1009
- }
1010
- this._fill();
1011
- for (let f = 0; f < this.chunk.length; f += 64) {
1012
- this._compress(this.chunk.slice(f, f + 64));
1013
- }
1014
- let i = null;
1015
- if (t === "hex") {
1016
- i = "";
1017
- for (let f = 0; f < 8; f++) {
1018
- i += this.padHex(this.reg[f].toString(16), 8);
1019
- }
1020
- } else {
1021
- i = new Array(32);
1022
- for (let f = 0; f < 8; f++) {
1023
- let c = this.reg[f];
1024
- i[4 * f + 3] = (255 & c) >>> 0;
1025
- c >>>= 8;
1026
- i[4 * f + 2] = (255 & c) >>> 0;
1027
- c >>>= 8;
1028
- i[4 * f + 1] = (255 & c) >>> 0;
1029
- c >>>= 8;
1030
- i[4 * f] = (255 & c) >>> 0;
1031
- }
1032
- }
1033
- this.reset();
1034
- return i;
1035
- }
1036
- _compress(t) {
1037
- if (t.length < 64) {
1038
- console.error("compress error: not enough data");
1039
- } else {
1040
- for (var f = ((e) => {
1041
- for (var r = new Array(132), t2 = 0; t2 < 16; t2++) {
1042
- r[t2] = e[4 * t2] << 24, r[t2] |= e[4 * t2 + 1] << 16, r[t2] |= e[4 * t2 + 2] << 8, r[t2] |= e[4 * t2 + 3], r[t2] >>>= 0;
1043
- }
1044
- for (var n = 16; n < 68; n++) {
1045
- let a = r[n - 16] ^ r[n - 9] ^ this.le(r[n - 3], 15);
1046
- a = a ^ this.le(a, 15) ^ this.le(a, 23), r[n] = (a ^ this.le(r[n - 13], 7) ^ r[n - 6]) >>> 0;
1047
- }
1048
- for (n = 0; n < 64; n++) r[n + 68] = (r[n] ^ r[n + 4]) >>> 0;
1049
- return r;
1050
- })(t), i = this.reg.slice(0), c = 0; c < 64; c++) {
1051
- let o = this.le(i[0], 12) + i[4] + this.le(this.de(c), c);
1052
- const s = ((o = this.le(o = (4294967295 & o) >>> 0, 7)) ^ this.le(i[0], 12)) >>> 0;
1053
- let u = this.pe(c, i[0], i[1], i[2]);
1054
- u = (4294967295 & (u = u + i[3] + s + f[c + 68])) >>> 0;
1055
- let b = this.he(c, i[4], i[5], i[6]);
1056
- b = (4294967295 & (b = b + i[7] + o + f[c])) >>> 0, i[3] = i[2], i[2] = this.le(i[1], 9), i[1] = i[0], i[0] = u, i[7] = i[6], i[6] = this.le(i[5], 19), i[5] = i[4], i[4] = (b ^ this.le(b, 9) ^ this.le(b, 17)) >>> 0;
1057
- }
1058
- for (let l = 0; l < 8; l++) this.reg[l] = (this.reg[l] ^ i[l]) >>> 0;
1059
- }
1060
- }
1061
- _fill() {
1062
- let a = 8 * this.size;
1063
- let f = this.chunk.push(128) % 64;
1064
- while (64 - f < 8) {
1065
- f -= 64;
1066
- }
1067
- while (f < 56) {
1068
- this.chunk.push(0);
1069
- f++;
1070
- }
1071
- for (let i = 0; i < 4; i++) {
1072
- const c = Math.floor(a / 4294967296);
1073
- this.chunk.push(c >>> 8 * (3 - i) & 255);
1074
- }
1075
- for (let i = 0; i < 4; i++) {
1076
- this.chunk.push(a >>> 8 * (3 - i) & 255);
1077
- }
1078
- }
1079
- de(e) {
1080
- return e >= 0 && e < 16 ? 2043430169 : e >= 16 && e < 64 ? 2055708042 : (console.error("invalid j for constant Tj"), 0);
1081
- }
1082
- pe(e, r, t, n) {
1083
- return e >= 0 && e < 16 ? (r ^ t ^ n) >>> 0 : e >= 16 && e < 64 ? (r & t | r & n | t & n) >>> 0 : (console.error("invalid j for bool function FF"), 0);
1084
- }
1085
- he(e, r, t, n) {
1086
- return e >= 0 && e < 16 ? (r ^ t ^ n) >>> 0 : e >= 16 && e < 64 ? (r & t | ~r & n) >>> 0 : (console.error("invalid j for bool function GG"), 0);
1087
- }
1088
- le(e, r) {
1089
- return (e << (r %= 32) | e >>> 32 - r) >>> 0;
1090
- }
1091
- stringToBytes(str) {
1092
- const n = encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, (_, r) => String.fromCharCode(parseInt(r, 16)));
1093
- const a = new Array(n.length);
1094
- for (let i = 0; i < n.length; i++) {
1095
- a[i] = n.charCodeAt(i);
1096
- }
1097
- return a;
1098
- }
1099
- padHex(num, size) {
1100
- return num.padStart(size, "0");
1101
- }
1102
- };
1103
- function rc4_encrypt(plaintext, key) {
1104
- const s = [];
1105
- for (var i = 0; i < 256; i++) {
1106
- s[i] = i;
1107
- }
1108
- var j = 0;
1109
- for (var i = 0; i < 256; i++) {
1110
- j = (j + s[i] + key.charCodeAt(i % key.length)) % 256;
1111
- var temp = s[i];
1112
- s[i] = s[j];
1113
- s[j] = temp;
1114
- }
1115
- var i = 0;
1116
- var j = 0;
1117
- const cipher = [];
1118
- for (let k = 0; k < plaintext.length; k++) {
1119
- i = (i + 1) % 256;
1120
- j = (j + s[i]) % 256;
1121
- var temp = s[i];
1122
- s[i] = s[j];
1123
- s[j] = temp;
1124
- const t = (s[i] + s[j]) % 256;
1125
- cipher.push(String.fromCharCode(s[t] ^ plaintext.charCodeAt(k)));
1126
- }
1127
- return cipher.join("");
1128
- }
1129
- function result_encrypt(long_str, num) {
1130
- const s_obj = {
1131
- s0: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
1132
- s1: "Dkdpgh4ZKsQB80/Mfvw36XI1R25+WUAlEi7NLboqYTOPuzmFjJnryx9HVGcaStCe=",
1133
- s2: "Dkdpgh4ZKsQB80/Mfvw36XI1R25-WUAlEi7NLboqYTOPuzmFjJnryx9HVGcaStCe=",
1134
- s3: "ckdp1h4ZKsUB80/Mfvw36XIgR25+WQAlEi7NLboqYTOPuzmFjJnryx9HVGDaStCe",
1135
- s4: "Dkdpgh2ZmsQB80/MfvV36XI1R45-WUAlEixNLwoqYTOPuzKFjJnry79HbGcaStCe"
1136
- };
1137
- const constant = {
1138
- 0: 16515072,
1139
- 1: 258048,
1140
- 2: 4032,
1141
- str: s_obj[num]
1142
- };
1143
- let result = "";
1144
- let lound = 0;
1145
- let long_int = get_long_int(lound, long_str);
1146
- for (let i = 0; i < long_str.length / 3 * 4; i++) {
1147
- if (Math.floor(i / 4) !== lound) {
1148
- lound += 1;
1149
- long_int = get_long_int(lound, long_str);
1150
- }
1151
- let key = i % 4;
1152
- let temp_int;
1153
- switch (key) {
1154
- case 0:
1155
- temp_int = (long_int & constant["0"]) >> 18;
1156
- result += constant["str"].charAt(temp_int);
1157
- break;
1158
- case 1:
1159
- temp_int = (long_int & constant["1"]) >> 12;
1160
- result += constant["str"].charAt(temp_int);
1161
- break;
1162
- case 2:
1163
- temp_int = (long_int & constant["2"]) >> 6;
1164
- result += constant["str"].charAt(temp_int);
1165
- break;
1166
- case 3:
1167
- temp_int = long_int & 63;
1168
- result += constant["str"].charAt(temp_int);
1169
- break;
1170
- }
1171
- }
1172
- return result;
1173
- }
1174
- function get_long_int(round, long_str) {
1175
- round = round * 3;
1176
- return long_str.charCodeAt(round) << 16 | long_str.charCodeAt(round + 1) << 8 | long_str.charCodeAt(round + 2);
1177
- }
1178
- function gener_random(random, option) {
1179
- return [
1180
- random & 255 & 170 | option[0] & 85,
1181
- // 163
1182
- random & 255 & 85 | option[0] & 170,
1183
- // 87
1184
- random >> 8 & 255 & 170 | option[1] & 85,
1185
- // 37
1186
- random >> 8 & 255 & 85 | option[1] & 170
1187
- // 41
1188
- ];
1189
- }
1190
- function generate_rc4_bb_str(url_search_params, user_agent, window_env_str, suffix = "cus", Arguments = [0, 1, 14]) {
1191
- let sm3 = new SM3();
1192
- let start_time = Date.now();
1193
- const url_search_params_list = sm3.sum(sm3.sum(url_search_params + suffix));
1194
- const cus = sm3.sum(sm3.sum(suffix));
1195
- const ua = sm3.sum(result_encrypt(rc4_encrypt(user_agent, String.fromCharCode.apply(null, [390625e-8, 1, 14])), "s3"));
1196
- const end_time = Date.now();
1197
- let b = {
1198
- 8: 3,
1199
- // 固定
1200
- 10: end_time,
1201
- // 3次加密结束时间
1202
- 15: {
1203
- aid: 6383,
1204
- pageId: 6241},
1205
- 16: start_time,
1206
- // 3次加密开始时间
1207
- 18: 44};
1208
- b[20] = b[16] >> 24 & 255;
1209
- b[21] = b[16] >> 16 & 255;
1210
- b[22] = b[16] >> 8 & 255;
1211
- b[23] = b[16] & 255;
1212
- b[24] = b[16] / 256 / 256 / 256 / 256 >> 0;
1213
- b[25] = b[16] / 256 / 256 / 256 / 256 / 256 >> 0;
1214
- b[26] = Arguments[0] >> 24 & 255;
1215
- b[27] = Arguments[0] >> 16 & 255;
1216
- b[28] = Arguments[0] >> 8 & 255;
1217
- b[29] = Arguments[0] & 255;
1218
- b[30] = Arguments[1] / 256 & 255;
1219
- b[31] = Arguments[1] % 256 & 255;
1220
- b[32] = Arguments[1] >> 24 & 255;
1221
- b[33] = Arguments[1] >> 16 & 255;
1222
- b[34] = Arguments[2] >> 24 & 255;
1223
- b[35] = Arguments[2] >> 16 & 255;
1224
- b[36] = Arguments[2] >> 8 & 255;
1225
- b[37] = Arguments[2] & 255;
1226
- b[38] = url_search_params_list[21];
1227
- b[39] = url_search_params_list[22];
1228
- b[40] = cus[21];
1229
- b[41] = cus[22];
1230
- b[42] = ua[23];
1231
- b[43] = ua[24];
1232
- b[44] = b[10] >> 24 & 255;
1233
- b[45] = b[10] >> 16 & 255;
1234
- b[46] = b[10] >> 8 & 255;
1235
- b[47] = b[10] & 255;
1236
- b[48] = b[8];
1237
- b[49] = b[10] / 256 / 256 / 256 / 256 >> 0;
1238
- b[50] = b[10] / 256 / 256 / 256 / 256 / 256 >> 0;
1239
- b[51] = b[15].pageId;
1240
- b[52] = b[15].pageId >> 24 & 255;
1241
- b[53] = b[15].pageId >> 16 & 255;
1242
- b[54] = b[15].pageId >> 8 & 255;
1243
- b[55] = b[15].pageId & 255;
1244
- b[56] = b[15].aid;
1245
- b[57] = b[15].aid & 255;
1246
- b[58] = b[15].aid >> 8 & 255;
1247
- b[59] = b[15].aid >> 16 & 255;
1248
- b[60] = b[15].aid >> 24 & 255;
1249
- const window_env_list = [];
1250
- for (let index = 0; index < window_env_str.length; index++) {
1251
- window_env_list.push(window_env_str.charCodeAt(index));
1252
- }
1253
- b[64] = window_env_list.length;
1254
- b[65] = b[64] & 255;
1255
- b[66] = b[64] >> 8 & 255;
1256
- b[69] = [].length;
1257
- b[70] = b[69] & 255;
1258
- b[71] = b[69] >> 8 & 255;
1259
- b[72] = b[18] ^ b[20] ^ b[26] ^ b[30] ^ b[38] ^ b[40] ^ b[42] ^ b[21] ^ b[27] ^ b[31] ^ b[35] ^ b[39] ^ b[41] ^ b[43] ^ b[22] ^ b[28] ^ b[32] ^ b[36] ^ b[23] ^ b[29] ^ b[33] ^ b[37] ^ b[44] ^ b[45] ^ b[46] ^ b[47] ^ b[48] ^ b[49] ^ b[50] ^ b[24] ^ b[25] ^ b[52] ^ b[53] ^ b[54] ^ b[55] ^ b[57] ^ b[58] ^ b[59] ^ b[60] ^ b[65] ^ b[66] ^ b[70] ^ b[71];
1260
- let bb = [
1261
- b[18],
1262
- b[20],
1263
- b[52],
1264
- b[26],
1265
- b[30],
1266
- b[34],
1267
- b[58],
1268
- b[38],
1269
- b[40],
1270
- b[53],
1271
- b[42],
1272
- b[21],
1273
- b[27],
1274
- b[54],
1275
- b[55],
1276
- b[31],
1277
- b[35],
1278
- b[57],
1279
- b[39],
1280
- b[41],
1281
- b[43],
1282
- b[22],
1283
- b[28],
1284
- b[32],
1285
- b[60],
1286
- b[36],
1287
- b[23],
1288
- b[29],
1289
- b[33],
1290
- b[37],
1291
- b[44],
1292
- b[45],
1293
- b[59],
1294
- b[46],
1295
- b[47],
1296
- b[48],
1297
- b[49],
1298
- b[50],
1299
- b[24],
1300
- b[25],
1301
- b[65],
1302
- b[66],
1303
- b[70],
1304
- b[71]
1305
- ];
1306
- bb = bb.concat(window_env_list).concat(b[72]);
1307
- return rc4_encrypt(String.fromCharCode.apply(null, bb), String.fromCharCode.apply(null, [121]));
1308
- }
1309
- function generate_random_str() {
1310
- let random_str_list = [];
1311
- random_str_list = random_str_list.concat(gener_random(Math.random() * 1e4, [3, 45]));
1312
- random_str_list = random_str_list.concat(gener_random(Math.random() * 1e4, [1, 0]));
1313
- random_str_list = random_str_list.concat(gener_random(Math.random() * 1e4, [1, 5]));
1314
- return String.fromCharCode.apply(null, random_str_list);
1315
- }
1316
- var cleanUserAgentForSigning = (userAgent) => {
1317
- return userAgent.replace(/\s+Edg\/[\d\.]+/g, "");
1318
- };
1319
- var a_bogus_default = (url, user_agent) => {
1320
- const cleanedUserAgent = cleanUserAgentForSigning(user_agent);
1321
- let result_str = generate_random_str() + generate_rc4_bb_str(new URLSearchParams(new URL(url).search).toString(), cleanedUserAgent, "1536|747|1536|834|0|30|0|0|1536|834|1536|864|1525|747|24|24|Win32");
1322
- return result_encrypt(result_str, "s4") + "=";
1323
- };
1324
- var XBogus = class {
1325
- charMap;
1326
- base64Charset;
1327
- uaKey;
1328
- defaultUa;
1329
- params;
1330
- xb;
1331
- constructor() {
1332
- this.charMap = new Array(128).fill(null);
1333
- for (let i = 48; i <= 57; i++) {
1334
- this.charMap[i] = i - 48;
1335
- }
1336
- for (let i = 65; i <= 70; i++) {
1337
- this.charMap[i] = i - 55;
1338
- }
1339
- for (let i = 97; i <= 102; i++) {
1340
- this.charMap[i] = i - 87;
1341
- }
1342
- this.base64Charset = "Dkdpgh4ZKsQB80/Mfvw36XI1R25-WUAlEi7NLboqYTOPuzmFjJnryx9HVGcaStCe=";
1343
- this.uaKey = Buffer.from([0, 1, 12]);
1344
- this.defaultUa = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0";
1345
- }
1346
- md5StrToArray(md5Str) {
1347
- const result = [];
1348
- if (md5Str.length > 32) {
1349
- for (const char of md5Str) {
1350
- result.push(char.charCodeAt(0));
1351
- }
1352
- return result;
1353
- }
1354
- let idx = 0;
1355
- while (idx < md5Str.length) {
1356
- const leftCharCode = md5Str.charCodeAt(idx);
1357
- const rightCharCode = md5Str.charCodeAt(idx + 1);
1358
- const left = this.charMap[leftCharCode];
1359
- const right = this.charMap[rightCharCode];
1360
- if (left === null || right === null) {
1361
- throw new Error(`Invalid MD5 character: ${md5Str[idx]}${md5Str[idx + 1]}`);
1362
- }
1363
- result.push(left << 4 | right);
1364
- idx += 2;
1365
- }
1366
- return result;
1367
- }
1368
- md5(input) {
1369
- const dataArray = typeof input === "string" ? this.md5StrToArray(input) : input;
1370
- const dataBuffer = Buffer.from(dataArray);
1371
- return crypto.createHash("md5").update(dataBuffer).digest("hex");
1372
- }
1373
- md5Encrypt(urlPath) {
1374
- const firstMd5 = this.md5(urlPath);
1375
- const firstArray = this.md5StrToArray(firstMd5);
1376
- const secondMd5 = this.md5(firstArray);
1377
- return this.md5StrToArray(secondMd5);
1378
- }
1379
- encodingConversion(...params) {
1380
- const byteList = [];
1381
- for (const param of params) {
1382
- if (typeof param === "number") {
1383
- byteList.push(Math.floor(param));
1384
- } else if (typeof param === "string") {
1385
- for (const char of param) {
1386
- byteList.push(char.charCodeAt(0));
1387
- }
1388
- }
1389
- }
1390
- return Buffer.from(byteList).toString("latin1");
1391
- }
1392
- encodingConversion2(a, b, c) {
1393
- return String.fromCharCode(a) + String.fromCharCode(b) + c;
1394
- }
1395
- rc4Encrypt(key, data2) {
1396
- const keyBuffer = typeof key === "string" ? Buffer.from(key, "latin1") : key;
1397
- const dataBuffer = Buffer.from(data2, "latin1");
1398
- const S = Array.from({ length: 256 }, (_, i2) => i2);
1399
- let j = 0;
1400
- for (let i2 = 0; i2 < 256; i2++) {
1401
- j = (j + S[i2] + keyBuffer[i2 % keyBuffer.length]) % 256;
1402
- [S[i2], S[j]] = [S[j], S[i2]];
1403
- }
1404
- const encryptedBuffer = Buffer.alloc(dataBuffer.length);
1405
- let i = 0;
1406
- j = 0;
1407
- for (let k = 0; k < dataBuffer.length; k++) {
1408
- i = (i + 1) % 256;
1409
- j = (j + S[i]) % 256;
1410
- [S[i], S[j]] = [S[j], S[i]];
1411
- const t = (S[i] + S[j]) % 256;
1412
- encryptedBuffer[k] = dataBuffer[k] ^ S[t];
1413
- }
1414
- return encryptedBuffer.toString("latin1");
1415
- }
1416
- calculation(a1, a2, a3) {
1417
- const x1 = (a1 & 255) << 16;
1418
- const x2 = (a2 & 255) << 8;
1419
- const x3 = x1 | x2 | a3 & 255;
1420
- const c1 = this.base64Charset[(x3 & 16760832) >> 18];
1421
- const c2 = this.base64Charset[(x3 & 258048) >> 12];
1422
- const c3 = this.base64Charset[(x3 & 4032) >> 6];
1423
- const c4 = this.base64Charset[x3 & 63];
1424
- return c1 + c2 + c3 + c4;
1425
- }
1426
- /**
1427
- * 生成X-Bogus签名
1428
- * @param url 完整的URL地址
1429
- * @param ua 可选的User-Agent,不提供则使用默认值
1430
- * @returns 包含完整URL、X-Bogus值和使用的User-Agent的元组
1431
- */
1432
- getXBogus(url, ua) {
1433
- const parsedUrl = new URL2.URL(url);
1434
- const urlPath = parsedUrl.pathname + parsedUrl.search;
1435
- const currentUa = ua || this.defaultUa;
1436
- const rc4EncryptedUa = this.rc4Encrypt(this.uaKey, currentUa);
1437
- const base64Ua = Buffer.from(rc4EncryptedUa, "latin1").toString("base64");
1438
- const md5Ua = this.md5(base64Ua);
1439
- const array1 = this.md5StrToArray(md5Ua);
1440
- const emptyStrMd5 = "d41d8cd98f00b204e9800998ecf8427e";
1441
- const array2 = this.md5StrToArray(this.md5(this.md5StrToArray(emptyStrMd5)));
1442
- const urlEncryptedArray = this.md5Encrypt(urlPath);
1443
- const timestamp = Math.floor(Date.now() / 1e3);
1444
- const ct = 536919696;
1445
- const newArray = [
1446
- 64,
1447
- 1,
1448
- 1,
1449
- 12,
1450
- urlEncryptedArray[14],
1451
- urlEncryptedArray[15],
1452
- array2[14],
1453
- array2[15],
1454
- array1[14],
1455
- array1[15],
1456
- timestamp >> 24 & 255,
1457
- timestamp >> 16 & 255,
1458
- timestamp >> 8 & 255,
1459
- timestamp & 255,
1460
- ct >> 24 & 255,
1461
- ct >> 16 & 255,
1462
- ct >> 8 & 255,
1463
- ct & 255
1464
- ];
1465
- let xorResult = newArray[0];
1466
- for (let i = 1; i < newArray.length; i++) {
1467
- xorResult ^= newArray[i];
1468
- }
1469
- newArray.push(xorResult);
1470
- const array3 = [];
1471
- const array4 = [];
1472
- let idx = 0;
1473
- while (idx < newArray.length) {
1474
- array3.push(newArray[idx]);
1475
- if (idx + 1 < newArray.length) {
1476
- array4.push(newArray[idx + 1]);
1477
- }
1478
- idx += 2;
1479
- }
1480
- const mergedArray = [...array3, ...array4];
1481
- const firstConversion = this.encodingConversion(...mergedArray);
1482
- const rc4Garbled = this.rc4Encrypt("\xFF", firstConversion);
1483
- const garbledCode = this.encodingConversion2(2, 255, rc4Garbled);
1484
- let xb = "";
1485
- idx = 0;
1486
- while (idx < garbledCode.length) {
1487
- if (idx + 2 >= garbledCode.length) break;
1488
- const a1 = garbledCode.charCodeAt(idx);
1489
- const a2 = garbledCode.charCodeAt(idx + 1);
1490
- const a3 = garbledCode.charCodeAt(idx + 2);
1491
- xb += this.calculation(a1, a2, a3);
1492
- idx += 3;
1493
- }
1494
- const fullUrl = url.includes("?") ? `${url}&X-Bogus=${xb}` : `${url}?X-Bogus=${xb}`;
1495
- return {
1496
- fullUrl,
1497
- xbogus: xb,
1498
- userAgent: currentUa
1499
- };
1500
- }
1501
- };
1502
-
1503
- // src/platform/douyin/sign/index.ts
1504
- var defaultUserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36";
1505
- var douyinSign = class {
1506
- /**
1507
- * 生成一个指定长度的随机字符串
1508
- * @param length 字符串长度,默认为116
1509
- * @returns
1510
- */
1511
- static Mstoken(length) {
1512
- const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
1513
- const randomBytes = crypto.randomBytes(length ?? 116);
1514
- return Array.from(randomBytes, (byte) => characters[byte % characters.length]).join("");
1515
- }
1516
- /**
1517
- * a_bogus 签名算法
1518
- * @param url 需要签名的地址
1519
- * @returns 对此地址签名后的URL查询参数
1520
- */
1521
- static AB(url, userAgent) {
1522
- return a_bogus_default(url, userAgent || defaultUserAgent);
1523
- }
1524
- /**
1525
- * X-Bogus 签名算法
1526
- * @param url 需要签名的地址
1527
- * @returns 对此地址签名后的URL查询参数
1528
- */
1529
- static XB(url, userAgent) {
1530
- const xbogusResult = new XBogus().getXBogus(url, userAgent || defaultUserAgent);
1531
- return xbogusResult.xbogus;
1532
- }
1533
- /** 生成一个唯一的验证字符串 */
1534
- static VerifyFpManager() {
1535
- const e = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split("");
1536
- const t = e.length;
1537
- const n = (/* @__PURE__ */ new Date()).getTime().toString(36);
1538
- const r = [];
1539
- r[8] = "_";
1540
- r[13] = "_";
1541
- r[18] = "_";
1542
- r[23] = "_";
1543
- r[14] = "4";
1544
- for (let o, i = 0; i < 36; i++) {
1545
- if (!r[i]) {
1546
- o = 0 | Math.random() * t;
1547
- r[i] = e[i === 19 ? 3 & o | 8 : o];
1548
- }
1549
- }
1550
- return "verify_" + n + "_" + r.join("");
1551
- }
1552
- };
1553
-
1554
- // src/platform/douyin/API.ts
1555
- var extractBrowserVersion = (userAgent) => {
1556
- if (!userAgent) return "125.0.0.0";
1557
- const chromeMatch = userAgent.match(/Chrome\/(\d+\.\d+\.\d+\.\d+)/);
1558
- if (chromeMatch) {
1559
- return chromeMatch[1];
1560
- }
1561
- const edgeMatch = userAgent.match(/Edg\/(\d+\.\d+\.\d+\.\d+)/);
1562
- if (edgeMatch) {
1563
- return edgeMatch[1];
1564
- }
1565
- return "125.0.0.0";
1566
- };
1567
- var buildQueryString = (params) => {
1568
- return Object.entries(params).filter(([_, value]) => value !== void 0 && value !== null).map(([key, value]) => `${key}=${encodeURIComponent(value)}`).join("&");
1569
- };
1570
- var fp = douyinSign.VerifyFpManager();
1571
- var DouyinAPI = class {
1572
- browserVersion;
1573
- /**
1574
- * 构造函数
1575
- * @param userAgent - 用户代理字符串,用于提取浏览器版本信息
1576
- */
1577
- constructor(userAgent) {
1578
- this.browserVersion = extractBrowserVersion(userAgent);
1579
- }
1580
- /**
1581
- * 获取通用的基础参数
1582
- * @returns 通用基础参数对象
1583
- */
1584
- getBaseParams() {
1585
- return {
1586
- device_platform: "webapp",
1587
- aid: "6383",
1588
- channel: "channel_pc_web",
1589
- pc_client_type: "1",
1590
- cookie_enabled: "true",
1591
- browser_language: "zh-CN",
1592
- browser_platform: "Win32",
1593
- browser_name: "Chrome",
1594
- browser_version: this.browserVersion,
1595
- browser_online: "true",
1596
- engine_name: "Blink",
1597
- engine_version: this.browserVersion,
1598
- os_name: "Windows",
1599
- os_version: "10",
1600
- cpu_core_num: "16",
1601
- device_memory: "8",
1602
- platform: "PC",
1603
- downlink: "10",
1604
- effective_type: "4g",
1605
- msToken: douyinSign.Mstoken(116),
1606
- verifyFp: fp,
1607
- fp
1608
- };
1609
- }
1610
- /**
1611
- * 获取视频或图集数据的接口地址
1612
- * @param data - 请求参数,包含aweme_id
1613
- * @returns 完整的接口URL
1614
- */
1615
- \u89C6\u9891\u6216\u56FE\u96C6(data2) {
1616
- const baseUrl = "https://www.douyin.com/aweme/v1/web/aweme/detail/";
1617
- const params = {
1618
- ...this.getBaseParams(),
1619
- aweme_id: data2.aweme_id,
1620
- update_version_code: "170400",
1621
- version_code: "190500",
1622
- version_name: "19.5.0",
1623
- screen_width: "2328",
1624
- screen_height: "1310",
1625
- round_trip_time: "150",
1626
- webid: "7351848354471872041"
1627
- };
1628
- return `${baseUrl}?${buildQueryString(params)}`;
1629
- }
1630
- /**
1631
- * 获取评论数据的接口地址
1632
- * @param data - 请求参数,包含aweme_id、cursor、number等
1633
- * @returns 完整的接口URL
1634
- */
1635
- \u8BC4\u8BBA(data2) {
1636
- const baseUrl = "https://www.douyin.com/aweme/v1/web/comment/list/";
1637
- const params = {
1638
- ...this.getBaseParams(),
1639
- aweme_id: data2.aweme_id,
1640
- cursor: data2.cursor ?? 0,
1641
- count: data2.number ?? 50,
1642
- item_type: "0",
1643
- insert_ids: "",
1644
- whale_cut_token: "",
1645
- cut_version: "1",
1646
- rcFT: "",
1647
- version_code: "170400",
1648
- version_name: "17.4.0",
1649
- screen_width: "1552",
1650
- screen_height: "970",
1651
- round_trip_time: "50"
1652
- };
1653
- return `${baseUrl}?${buildQueryString(params)}`;
1654
- }
1655
- /**
1656
- * 获取二级评论数据的接口地址
1657
- * @param data - 请求参数,包含aweme_id、comment_id等
1658
- * @returns 完整的接口URL
1659
- */
1660
- \u4E8C\u7EA7\u8BC4\u8BBA(data2) {
1661
- const baseUrl = "https://www-hj.douyin.com/aweme/v1/web/comment/list/reply/";
1662
- const params = {
1663
- device_platform: "webapp",
1664
- aid: "6383",
1665
- channel: "channel_pc_web",
1666
- item_id: data2.aweme_id,
1667
- comment_id: data2.comment_id,
1668
- cut_version: "1",
1669
- cursor: data2.cursor,
1670
- count: data2.number,
1671
- item_type: "0",
1672
- update_version_code: "170400",
1673
- pc_client_type: "1",
1674
- pc_libra_divert: "Windows",
1675
- support_h265: "1",
1676
- support_dash: "1",
1677
- version_code: "170400",
1678
- version_name: "17.4.0",
1679
- cookie_enabled: "true",
1680
- screen_width: "1552",
1681
- screen_height: "970",
1682
- browser_language: "zh-CN",
1683
- browser_platform: "Win32",
1684
- browser_name: "Edge",
1685
- browser_version: this.browserVersion,
1686
- browser_online: "true",
1687
- engine_name: "Blink",
1688
- engine_version: this.browserVersion,
1689
- os_name: "Windows",
1690
- os_version: "10",
1691
- cpu_core_num: "16",
1692
- device_memory: "8",
1693
- platform: "PC",
1694
- downlink: "10",
1695
- effective_type: "4g",
1696
- round_trip_time: "50",
1697
- webid: "7487210762873685515",
1698
- verifyFp: fp,
1699
- fp
1700
- };
1701
- return `${baseUrl}?${buildQueryString(params)}`;
1702
- }
1703
- /**
1704
- * 获取动图数据的接口地址
1705
- * @param data - 请求参数,包含aweme_id
1706
- * @returns 完整的接口URL
1707
- */
1708
- \u52A8\u56FE(data2) {
1709
- const baseUrl = "https://www.iesdouyin.com/web/api/v2/aweme/slidesinfo/";
1710
- const params = {
1711
- reflow_source: "reflow_page",
1712
- web_id: "7326472315356857893",
1713
- device_id: "7326472315356857893",
1714
- aweme_ids: `[${data2.aweme_id}]`,
1715
- request_source: "200",
1716
- msToken: douyinSign.Mstoken(116),
1717
- verifyFp: fp,
1718
- fp
1719
- };
1720
- return `${baseUrl}?${buildQueryString(params)}`;
1721
- }
1722
- /**
1723
- * 获取表情数据的接口地址
1724
- * @returns 完整的接口URL
1725
- */
1726
- \u8868\u60C5() {
1727
- return "https://www.douyin.com/aweme/v1/web/emoji/list";
1728
- }
1729
- /**
1730
- * 获取用户主页视频数据的接口地址
1731
- * @param data - 请求参数,包含sec_uid
1732
- * @returns 完整的接口URL
1733
- */
1734
- \u7528\u6237\u4E3B\u9875\u89C6\u9891(data2) {
1735
- const baseUrl = "https://www.douyin.com/aweme/v1/web/aweme/post/";
1736
- const params = {
1737
- ...this.getBaseParams(),
1738
- sec_user_id: data2.sec_uid,
1739
- max_cursor: "0",
1740
- locate_query: "false",
1741
- show_live_replay_strategy: "1",
1742
- need_time_list: "1",
1743
- time_list_query: "0",
1744
- whale_cut_token: "",
1745
- cut_version: "1",
1746
- count: "18",
1747
- publish_video_strategy_type: "2",
1748
- version_code: "170400",
1749
- version_name: "17.4.0",
1750
- screen_width: "1552",
1751
- screen_height: "970",
1752
- round_trip_time: "50",
1753
- webid: "7338423850134226495"
1754
- };
1755
- return `${baseUrl}?${buildQueryString(params)}`;
1756
- }
1757
- /**
1758
- * 获取用户主页信息的接口地址
1759
- * @param data - 请求参数,包含sec_uid
1760
- * @returns 完整的接口URL
1761
- */
1762
- \u7528\u6237\u4E3B\u9875\u4FE1\u606F(data2) {
1763
- const baseUrl = "https://www.douyin.com/aweme/v1/web/user/profile/other/";
1764
- const params = {
1765
- ...this.getBaseParams(),
1766
- publish_video_strategy_type: "2",
1767
- source: "channel_pc_web",
1768
- sec_user_id: data2.sec_uid,
1769
- personal_center_strategy: "1",
1770
- version_code: "170400",
1771
- version_name: "17.4.0",
1772
- screen_width: "1552",
1773
- screen_height: "970",
1774
- round_trip_time: "0",
1775
- webid: "7327957959955580467"
1776
- };
1777
- return `${baseUrl}?${buildQueryString(params)}`;
1778
- }
1779
- /**
1780
- * 获取热点词数据的接口地址
1781
- * @param data - 请求参数,包含query
1782
- * @returns 完整的接口URL
1783
- */
1784
- \u70ED\u70B9\u8BCD(data2) {
1785
- const baseUrl = "https://www.douyin.com/aweme/v1/web/api/suggest_words/";
1786
- const params = {
1787
- ...this.getBaseParams(),
1788
- query: data2.query,
1789
- business_id: "30088",
1790
- from_group_id: "7129543174929812767",
1791
- version_code: "170400",
1792
- version_name: "17.4.0",
1793
- screen_width: "1552",
1794
- screen_height: "970",
1795
- round_trip_time: "50",
1796
- webid: "7327957959955580467"
1797
- };
1798
- return `${baseUrl}?${buildQueryString(params)}`;
1799
- }
1800
- /**
1801
- * 获取搜索数据的接口地址
1802
- * @param data - 请求参数,包含query、number、search_id等
1803
- * @returns 完整的接口URL
1804
- */
1805
- \u641C\u7D22(data2) {
1806
- const baseUrl = "https://www.douyin.com/aweme/v1/web/general/search/single/";
1807
- const params = {
1808
- ...this.getBaseParams(),
1809
- search_channel: "aweme_general",
1810
- sort_type: "0",
1811
- publish_time: "0",
1812
- keyword: data2.query,
1813
- search_source: "normal_search",
1814
- query_correct_type: "1",
1815
- is_filter_search: "0",
1816
- from_group_id: "",
1817
- offset: "0",
1818
- version_code: "190600",
1819
- version_name: "19.6.0",
1820
- screen_width: "1552",
1821
- screen_height: "970",
1822
- round_trip_time: "50",
1823
- webid: "7338423850134226495",
1824
- search_id: data2.search_id ?? "",
1825
- count: data2.number ?? 10
1826
- };
1827
- return `${baseUrl}?${buildQueryString(params)}`;
1828
- }
1829
- /**
1830
- * 获取互动表情数据的接口地址
1831
- * @returns 完整的接口URL
1832
- */
1833
- \u4E92\u52A8\u8868\u60C5() {
1834
- const baseUrl = "https://www.douyin.com/aweme/v1/web/im/strategy/config";
1835
- const params = {
1836
- device_platform: "webapp",
1837
- aid: "1128",
1838
- channel: "channel_pc_web",
1839
- publish_video_strategy_type: "2",
1840
- app_id: "1128",
1841
- scenes: "[%22interactive_resources%22]",
1842
- pc_client_type: "1",
1843
- version_code: "170400",
1844
- version_name: "17.4.0",
1845
- cookie_enabled: "true",
1846
- screen_width: "2328",
1847
- screen_height: "1310",
1848
- browser_language: "zh-CN",
1849
- browser_platform: "Win32",
1850
- browser_name: "Chrome",
1851
- browser_version: "126.0.0.0",
1852
- browser_online: "true",
1853
- engine_name: "Blink",
1854
- engine_version: "126.0.0.0",
1855
- os_name: "Windows",
1856
- os_version: "10",
1857
- cpu_core_num: "16",
1858
- device_memory: "8",
1859
- platform: "PC",
1860
- downlink: "1.5",
1861
- effective_type: "4g",
1862
- round_trip_time: "350",
1863
- webid: "7347329698282833447",
1864
- msToken: douyinSign.Mstoken(116),
1865
- verifyFp: fp,
1866
- fp
1867
- };
1868
- return `${baseUrl}?${buildQueryString(params)}`;
1869
- }
1870
- /**
1871
- * 获取背景音乐数据的接口地址
1872
- * @param data - 请求参数,包含music_id
1873
- * @returns 完整的接口URL
1874
- */
1875
- \u80CC\u666F\u97F3\u4E50(data2) {
1876
- const baseUrl = "https://www.douyin.com/aweme/v1/web/music/detail/";
1877
- const params = {
1878
- device_platform: "webapp",
1879
- aid: "6383",
1880
- channel: "channel_pc_web",
1881
- music_id: data2.music_id,
1882
- scene: "1",
1883
- pc_client_type: "1",
1884
- version_code: "170400",
1885
- version_name: "17.4.0",
1886
- cookie_enabled: "true",
1887
- screen_width: "2328",
1888
- screen_height: "1310",
1889
- browser_language: "zh-CN",
1890
- browser_platform: "Win32",
1891
- browser_name: "Chrome",
1892
- browser_version: "126.0.0.0",
1893
- browser_online: "true",
1894
- engine_name: "Blink",
1895
- engine_version: "126.0.0.0",
1896
- os_name: "Windows",
1897
- os_version: "10",
1898
- cpu_core_num: "16",
1899
- device_memory: "8",
1900
- platform: "PC",
1901
- downlink: "1.5",
1902
- effective_type: "4g",
1903
- round_trip_time: "350",
1904
- webid: "7347329698282833447",
1905
- msToken: douyinSign.Mstoken(116),
1906
- verifyFp: fp,
1907
- fp
1908
- };
1909
- return `${baseUrl}?${buildQueryString(params)}`;
1910
- }
1911
- /**
1912
- * 获取直播间信息的接口地址
1913
- * @param data - 请求参数,包含web_rid、room_id
1914
- * @returns 完整的接口URL
1915
- */
1916
- \u76F4\u64AD\u95F4\u4FE1\u606F(data2) {
1917
- const baseUrl = "https://live.douyin.com/webcast/room/web/enter/";
1918
- const params = {
1919
- aid: "6383",
1920
- app_name: "douyin_web",
1921
- live_id: "1",
1922
- device_platform: "web",
1923
- language: "zh-CN",
1924
- enter_from: "web_share_link",
1925
- cookie_enabled: "true",
1926
- screen_width: "2048",
1927
- screen_height: "1152",
1928
- browser_language: "zh-CN",
1929
- browser_platform: "Win32",
1930
- browser_name: "Chrome",
1931
- browser_version: "125.0.0.0",
1932
- web_rid: data2.web_rid,
1933
- room_id_str: data2.room_id,
1934
- enter_source: "",
1935
- is_need_double_stream: "false",
1936
- insert_task_id: "",
1937
- live_reason: "",
1938
- msToken: douyinSign.Mstoken(116),
1939
- verifyFp: fp,
1940
- fp
1941
- };
1942
- return `${baseUrl}?${buildQueryString(params)}`;
1943
- }
1944
- /**
1945
- * 获取申请二维码的接口地址
1946
- * @param data - 请求参数,包含verify_fp
1947
- * @returns 完整的接口URL
1948
- */
1949
- \u7533\u8BF7\u4E8C\u7EF4\u7801(data2) {
1950
- const baseUrl = "https://sso.douyin.com/get_qrcode/";
1951
- const params = {
1952
- verifyFp: data2.verify_fp,
1953
- fp: data2.verify_fp
1954
- };
1955
- return `${baseUrl}?${buildQueryString(params)}`;
1956
- }
1957
- /**
1958
- * 获取弹幕数据的接口地址
1959
- * @param data - 请求参数,包含group_id、item_id等
1960
- * @returns 完整的接口URL
1961
- */
1962
- \u5F39\u5E55(data2) {
1963
- const baseUrl = "https://www-hj.douyin.com/aweme/v1/web/danmaku/get_v2/";
1964
- const params = {
1965
- ...this.getBaseParams(),
1966
- app_name: "aweme",
1967
- format: "json",
1968
- group_id: data2.aweme_id,
1969
- item_id: data2.aweme_id,
1970
- start_time: data2.start_time ?? "0",
1971
- end_time: data2.end_time ?? "32000",
1972
- duration: data2.duration,
1973
- update_version_code: "170400",
1974
- pc_libra_divert: "Windows",
1975
- support_h265: "1",
1976
- support_dash: "1",
1977
- version_code: "170400",
1978
- version_name: "17.4.0",
1979
- screen_width: "2328",
1980
- screen_height: "1310",
1981
- browser_name: "Edge",
1982
- browser_version: "140.0.0.0",
1983
- engine_name: "Blink",
1984
- engine_version: "140.0.0.0",
1985
- downlink: "1.55",
1986
- round_trip_time: "200",
1987
- webid: "7487210762873685515",
1988
- msToken: douyinSign.Mstoken(116),
1989
- verifyFp: fp,
1990
- fp
1991
- };
1992
- return `${baseUrl}?${buildQueryString(params)}`;
1993
- }
1994
- };
1995
- var createDouyinApiUrls = (userAgent) => {
1996
- return new DouyinAPI(userAgent);
1997
- };
1998
- var douyinApiUrls = new DouyinAPI();
1999
-
2000
- // src/platform/douyin/getdata.ts
2001
- var getSignature = (url, signType = "a_bogus", userAgent) => {
2002
- switch (signType) {
2003
- case "x_bogus":
2004
- return douyinSign.XB(url, userAgent);
2005
- case "a_bogus":
2006
- default:
2007
- return douyinSign.AB(url, userAgent);
2008
- }
2009
- };
2010
- var getSignParamName = (signType = "a_bogus") => {
2011
- switch (signType) {
2012
- case "x_bogus":
2013
- return "X-Bogus";
2014
- case "a_bogus":
2015
- default:
2016
- return "a_bogus";
2017
- }
2018
- };
2019
- var buildSignedUrl = (url, signType = "a_bogus", userAgent) => {
2020
- const signature = getSignature(url, signType, userAgent);
2021
- const paramName = getSignParamName(signType);
2022
- return `${url}&${paramName}=${signature}`;
2023
- };
2024
- var DouyinData = async (data2, cookie, requestConfig) => {
2025
- var _a, _b, _c, _d, _e;
2026
- const defHeaders = getDouyinDefaultConfig(cookie)["headers"];
2027
- const baseRequestConfig = {
2028
- method: "GET",
2029
- timeout: 1e4,
2030
- ...requestConfig,
2031
- headers: {
2032
- ...defHeaders,
2033
- ...(requestConfig == null ? void 0 : requestConfig.headers) || {}
2034
- }
2035
- };
2036
- const userAgent = (_a = baseRequestConfig.headers) == null ? void 0 : _a["User-Agent"];
2037
- const douyinApiUrls2 = createDouyinApiUrls(userAgent);
2038
- const signType = data2.signType || "a_bogus";
2039
- switch (data2.methodType) {
2040
- case "\u6587\u5B57\u4F5C\u54C1\u6570\u636E":
2041
- case "\u805A\u5408\u89E3\u6790":
2042
- case "\u89C6\u9891\u4F5C\u54C1\u6570\u636E":
2043
- case "\u56FE\u96C6\u4F5C\u54C1\u6570\u636E":
2044
- case "\u5408\u8F91\u4F5C\u54C1\u6570\u636E": {
2045
- const url = douyinApiUrls2.\u89C6\u9891\u6216\u56FE\u96C6({ aweme_id: data2.aweme_id });
2046
- const VideoData = await GlobalGetData2(data2.methodType, {
2047
- ...baseRequestConfig,
2048
- url: buildSignedUrl(url, signType, userAgent)
2049
- });
2050
- return VideoData;
2051
- }
2052
- case "\u8BC4\u8BBA\u6570\u636E": {
2053
- const urlGenerator = (params) => douyinApiUrls2.\u8BC4\u8BBA(params);
2054
- const response = await fetchPaginatedData(
2055
- data2.methodType,
2056
- urlGenerator,
2057
- data2,
2058
- 50,
2059
- baseRequestConfig,
2060
- signType
2061
- );
2062
- return response;
2063
- }
2064
- case "\u6307\u5B9A\u8BC4\u8BBA\u56DE\u590D\u6570\u636E": {
2065
- const urlGenerator = (params) => douyinApiUrls2.\u4E8C\u7EA7\u8BC4\u8BBA(params);
2066
- const response = await fetchPaginatedData(
2067
- data2.methodType,
2068
- urlGenerator,
2069
- data2,
2070
- 3,
2071
- baseRequestConfig,
2072
- "x_bogus"
2073
- );
2074
- return response;
2075
- }
2076
- case "\u7528\u6237\u4E3B\u9875\u6570\u636E": {
2077
- const url = douyinApiUrls2.\u7528\u6237\u4E3B\u9875\u4FE1\u606F({ sec_uid: data2.sec_uid });
2078
- const customConfig = {
2079
- ...baseRequestConfig,
2080
- headers: {
2081
- ...baseRequestConfig.headers,
2082
- // 只有在外部配置没有Referer时才设置内部的Referer
2083
- ...(!(requestConfig == null ? void 0 : requestConfig.headers) || !("Referer" in requestConfig.headers)) && {
2084
- Referer: `https://www.douyin.com/user/${data2.sec_uid}`
2085
- }
2086
- }
2087
- };
2088
- const UserInfoData = await GlobalGetData2(data2.methodType, {
2089
- ...customConfig,
2090
- url: buildSignedUrl(url, signType, userAgent)
2091
- });
2092
- return UserInfoData;
2093
- }
2094
- case "Emoji\u6570\u636E": {
2095
- const url = douyinApiUrls2.\u8868\u60C5();
2096
- const EmojiData = await GlobalGetData2(data2.methodType, {
2097
- ...baseRequestConfig,
2098
- url
2099
- });
2100
- return EmojiData;
2101
- }
2102
- case "\u7528\u6237\u4E3B\u9875\u89C6\u9891\u5217\u8868\u6570\u636E": {
2103
- const url = douyinApiUrls2.\u7528\u6237\u4E3B\u9875\u89C6\u9891({ sec_uid: data2.sec_uid });
2104
- const customConfig = {
2105
- ...baseRequestConfig,
2106
- headers: {
2107
- ...baseRequestConfig.headers,
2108
- ...(!(requestConfig == null ? void 0 : requestConfig.headers) || !("Referer" in requestConfig.headers)) && {
2109
- Referer: `https://www.douyin.com/user/${data2.sec_uid}`
2110
- }
2111
- }
2112
- };
2113
- const UserVideoListData = await GlobalGetData2(data2.methodType, {
2114
- ...customConfig,
2115
- url: buildSignedUrl(url, signType, userAgent)
2116
- });
2117
- return UserVideoListData;
2118
- }
2119
- case "\u70ED\u70B9\u8BCD\u6570\u636E": {
2120
- const url = douyinApiUrls2.\u70ED\u70B9\u8BCD({ query: data2.query, number: data2.number ?? 10 });
2121
- const customConfig = {
2122
- ...baseRequestConfig,
2123
- headers: {
2124
- ...baseRequestConfig.headers,
2125
- ...(!(requestConfig == null ? void 0 : requestConfig.headers) || !("Referer" in requestConfig.headers)) && {
2126
- Referer: `https://www.douyin.com/search/${encodeURIComponent(String(data2.query))}`
2127
- }
2128
- }
2129
- };
2130
- const SuggestWordsData = await GlobalGetData2(data2.methodType, {
2131
- ...customConfig,
2132
- url: buildSignedUrl(url, signType, userAgent)
2133
- });
2134
- return SuggestWordsData;
2135
- }
2136
- case "\u641C\u7D22\u6570\u636E": {
2137
- let search_id = "";
2138
- const maxPageSize = 15;
2139
- let fetchedSearchList = [];
2140
- let tmpresp = {};
2141
- const customConfig = {
2142
- ...baseRequestConfig,
2143
- headers: {
2144
- ...baseRequestConfig.headers,
2145
- ...(!(requestConfig == null ? void 0 : requestConfig.headers) || !("Referer" in requestConfig.headers)) && {
2146
- Referer: `https://www.douyin.com/search/${encodeURIComponent(String(data2.query))}`
2147
- }
2148
- }
2149
- };
2150
- while (fetchedSearchList.length < Number(data2.number ?? 10)) {
2151
- const requestCount = Math.min(Number(data2.number ?? 50) - fetchedSearchList.length, maxPageSize);
2152
- const url = douyinApiUrls2.\u641C\u7D22({
2153
- query: data2.query,
2154
- number: requestCount,
2155
- search_id: search_id === "" ? void 0 : search_id
2156
- });
2157
- const response = await GlobalGetData2(data2.methodType, {
2158
- ...customConfig,
2159
- url: buildSignedUrl(url, signType, userAgent)
2160
- });
2161
- if (((_b = response.data) == null ? void 0 : _b.length) === 0) {
2162
- 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);
2163
- return false;
2164
- }
2165
- if (!response.data) {
2166
- response.data = [];
2167
- }
2168
- fetchedSearchList.push(...response.data);
2169
- tmpresp = response;
2170
- search_id = (_c = response.log_pb) == null ? void 0 : _c.impr_id;
2171
- }
2172
- const finalResponse = {
2173
- ...tmpresp,
2174
- data: data2.number === 0 ? [] : fetchedSearchList.slice(0, Number(data2.number ?? 10))
2175
- };
2176
- return finalResponse;
2177
- }
2178
- case "\u52A8\u6001\u8868\u60C5\u6570\u636E": {
2179
- const url = douyinApiUrls2.\u4E92\u52A8\u8868\u60C5();
2180
- const ExpressionPlusData = await GlobalGetData2(data2.methodType, {
2181
- ...baseRequestConfig,
2182
- url: buildSignedUrl(url, signType, userAgent)
2183
- });
2184
- return ExpressionPlusData;
2185
- }
2186
- case "\u97F3\u4E50\u6570\u636E": {
2187
- const url = douyinApiUrls2.\u80CC\u666F\u97F3\u4E50({ music_id: data2.music_id });
2188
- const MusicData = await GlobalGetData2(data2.methodType, {
2189
- ...baseRequestConfig,
2190
- url: buildSignedUrl(url, signType, userAgent)
2191
- });
2192
- return MusicData;
2193
- }
2194
- case "\u76F4\u64AD\u95F4\u4FE1\u606F\u6570\u636E": {
2195
- let url = douyinApiUrls2.\u7528\u6237\u4E3B\u9875\u4FE1\u606F({ sec_uid: data2.sec_uid });
2196
- const fetchUrl = buildSignedUrl(url, signType, userAgent);
2197
- const customConfig = {
2198
- ...baseRequestConfig,
2199
- headers: {
2200
- ...baseRequestConfig.headers,
2201
- ...(!(requestConfig == null ? void 0 : requestConfig.headers) || !("Referer" in requestConfig.headers)) && {
2202
- Referer: `https://www.douyin.com/user/${data2.sec_uid}`
2203
- }
2204
- }
2205
- };
2206
- const UserInfoData = await GlobalGetData2(data2.methodType, {
2207
- ...customConfig,
2208
- url: fetchUrl
2209
- });
2210
- if (!((_d = UserInfoData == null ? void 0 : UserInfoData.user) == null ? void 0 : _d.live_status) || UserInfoData.user.live_status !== 1) {
2211
- logger.error((((_e = UserInfoData == null ? void 0 : UserInfoData.user) == null ? void 0 : _e.nickname) || "\u7528\u6237") + "\u5F53\u524D\u672A\u5728\u76F4\u64AD");
2212
- const Err = {
2213
- errorDescription: "\u68C0\u67E5\u5931\u8D25\uFF01\u8BE5\u7528\u6237\u5F53\u524D\u672A\u5728\u76F4\u64AD\uFF01 TypeError: Cannot read properties of undefined (reading 'live_status')",
2214
- requestType: data2.methodType ?? "\u672A\u77E5\u8BF7\u6C42\u7C7B\u578B",
2215
- requestUrl: fetchUrl
2216
- };
2217
- return {
2218
- code: "USER_NOT_LIVE" /* NOT_LIVE */,
2219
- data: UserInfoData,
2220
- amagiError: Err,
2221
- amagiMessage: Err.errorDescription
2222
- };
2223
- }
2224
- if (!UserInfoData.user.room_data) {
2225
- logger.error("\u672A\u83B7\u53D6\u5230\u76F4\u64AD\u95F4\u4FE1\u606F\uFF01");
2226
- return {
2227
- code: 500,
2228
- message: "\u672A\u83B7\u53D6\u5230\u76F4\u64AD\u95F4\u4FE1\u606F\uFF01",
2229
- data: null
2230
- };
2231
- }
2232
- const room_data = JSON.parse(UserInfoData.user.room_data);
2233
- url = douyinApiUrls2.\u76F4\u64AD\u95F4\u4FE1\u606F({ room_id: UserInfoData.user.room_id_str, web_rid: room_data.owner.web_rid });
2234
- const liveCustomConfig = {
2235
- ...baseRequestConfig,
2236
- headers: {
2237
- ...baseRequestConfig.headers,
2238
- ...(!(requestConfig == null ? void 0 : requestConfig.headers) || !("Referer" in requestConfig.headers)) && {
2239
- Referer: `https://live.douyin.com/${room_data.owner.web_rid}`
2240
- }
2241
- }
2242
- };
2243
- const LiveRoomData = await GlobalGetData2(data2.methodType, {
2244
- ...liveCustomConfig,
2245
- url: buildSignedUrl(url, signType, userAgent)
2246
- });
2247
- return LiveRoomData;
2248
- }
2249
- case "\u7533\u8BF7\u4E8C\u7EF4\u7801\u6570\u636E": {
2250
- const url = douyinApiUrls2.\u7533\u8BF7\u4E8C\u7EF4\u7801({ verify_fp: data2.verify_fp });
2251
- const LoginQrcodeStatusData = await GlobalGetData2(data2.methodType, {
2252
- ...baseRequestConfig,
2253
- url: buildSignedUrl(url, signType, userAgent)
2254
- });
2255
- return LoginQrcodeStatusData;
2256
- }
2257
- case "\u5F39\u5E55\u6570\u636E": {
2258
- const MAX_SEGMENT_DURATION = 32e3;
2259
- const startTime = data2.start_time ?? 0;
2260
- const endTime = data2.end_time ?? data2.duration;
2261
- const totalDuration = endTime - startTime;
2262
- if (totalDuration <= MAX_SEGMENT_DURATION) {
2263
- const url = douyinApiUrls2.\u5F39\u5E55({
2264
- aweme_id: data2.aweme_id,
2265
- start_time: startTime,
2266
- end_time: endTime,
2267
- duration: data2.duration
2268
- });
2269
- const DanmakuData = await GlobalGetData2(data2.methodType, {
2270
- ...baseRequestConfig,
2271
- url: buildSignedUrl(url, signType, userAgent)
2272
- });
2273
- return DanmakuData;
2274
- }
2275
- const segments = [];
2276
- let currentStart = startTime;
2277
- while (currentStart < endTime) {
2278
- const currentEnd = Math.min(currentStart + MAX_SEGMENT_DURATION, endTime);
2279
- segments.push({ start: currentStart, end: currentEnd });
2280
- currentStart = currentEnd;
2281
- }
2282
- logger.debug(`\u5F39\u5E55\u6570\u636E\u9700\u8981\u5206${segments.length}\u6BB5\u83B7\u53D6\uFF0C\u603B\u65F6\u957F\uFF1A${totalDuration}ms`);
2283
- const segmentPromises = segments.map(async (segment, index) => {
2284
- const url = douyinApiUrls2.\u5F39\u5E55({
2285
- aweme_id: data2.aweme_id,
2286
- start_time: segment.start,
2287
- end_time: segment.end,
2288
- duration: data2.duration
2289
- });
2290
- try {
2291
- const segmentData = await GlobalGetData2(`${data2.methodType}-\u6BB5${index + 1}`, {
2292
- ...baseRequestConfig,
2293
- url: buildSignedUrl(url, signType, userAgent)
2294
- });
2295
- logger.debug(`\u5F39\u5E55\u7B2C${index + 1}\u6BB5\u83B7\u53D6\u6210\u529F (${segment.start}ms-${segment.end}ms)`);
2296
- return segmentData;
2297
- } catch (error) {
2298
- logger.debug(`\u5F39\u5E55\u7B2C${index + 1}\u6BB5\u83B7\u53D6\u5931\u8D25 (${segment.start}ms-${segment.end}ms):`, error);
2299
- return null;
2300
- }
2301
- });
2302
- const segmentResults = await Promise.all(segmentPromises);
2303
- const mergedDanmakuList = [];
2304
- let totalCount = 0;
2305
- let finalStartTime = startTime;
2306
- let finalEndTime = endTime;
2307
- let finalExtra = null;
2308
- let finalLogPb = null;
2309
- let finalStatusCode = 0;
2310
- segmentResults.forEach((segmentData, index) => {
2311
- if (segmentData && segmentData.danmaku_list) {
2312
- mergedDanmakuList.push(...segmentData.danmaku_list);
2313
- totalCount += segmentData.total || 0;
2314
- if (index === 0) {
2315
- finalExtra = segmentData.extra;
2316
- finalLogPb = segmentData.log_pb;
2317
- finalStatusCode = segmentData.status_code;
2318
- }
2319
- }
2320
- });
2321
- mergedDanmakuList.sort((a, b) => (a.offset_time || 0) - (b.offset_time || 0));
2322
- const finalDanmakuData = {
2323
- danmaku_list: mergedDanmakuList,
2324
- start_time: finalStartTime,
2325
- end_time: finalEndTime,
2326
- total: mergedDanmakuList.length,
2327
- // 使用实际合并后的数量
2328
- status_code: finalStatusCode,
2329
- extra: finalExtra,
2330
- log_pb: finalLogPb
2331
- };
2332
- logger.debug(`\u5F39\u5E55\u6570\u636E\u5408\u5E76\u5B8C\u6210\uFF0C\u5171\u83B7\u53D6${mergedDanmakuList.length}\u6761\u5F39\u5E55`);
2333
- return finalDanmakuData;
2334
- }
2335
- default: {
2336
- logger.warn(`\u672A\u77E5\u7684\u6296\u97F3\u6570\u636E\u63A5\u53E3\uFF1A\u300C${logger.red(data2.methodType)}\u300D`);
2337
- return null;
2338
- }
2339
- }
2340
- };
2341
- var fetchPaginatedData = async (type, apiUrlGenerator, params, maxPageSize, requestConfig, signType = "a_bogus") => {
2342
- var _a;
2343
- let cursor = params.cursor ?? 0;
2344
- let fetchedData = [];
2345
- let tmpresp = {};
2346
- const userAgent = (_a = requestConfig.headers) == null ? void 0 : _a["User-Agent"];
2347
- while (fetchedData.length < Number(params.number ?? maxPageSize)) {
2348
- const requestCount = Math.min(Number(params.number ?? maxPageSize) - fetchedData.length, maxPageSize);
2349
- const url = apiUrlGenerator({
2350
- ...params,
2351
- number: requestCount,
2352
- cursor
2353
- });
2354
- const response = await GlobalGetData2(type, {
2355
- ...requestConfig,
2356
- url: buildSignedUrl(url, signType, userAgent)
2357
- });
2358
- fetchedData.push(...response.comments || response.data || []);
2359
- tmpresp = response;
2360
- if ((response.comments || response.data || []).length < requestCount) {
2361
- break;
2362
- }
2363
- cursor = response.cursor;
2364
- }
2365
- const finalResponse = {
2366
- ...tmpresp,
2367
- comments: params.number === 0 ? [] : fetchedData.slice(0, Number(params.number ?? maxPageSize)),
2368
- cursor: params.number === 0 ? 0 : fetchedData.length
2369
- };
2370
- return finalResponse;
2371
- };
2372
- var GlobalGetData2 = async (type, config) => {
2373
- let warningMessage = "";
2374
- try {
2375
- const result = await fetchData(config);
2376
- if (!result || result === "") {
2377
- const Err = {
2378
- errorDescription: "\u83B7\u53D6\u54CD\u5E94\u6570\u636E\u5931\u8D25\uFF01\u63A5\u53E3\u8FD4\u56DE\u5185\u5BB9\u4E3A\u7A7A\uFF0C\u4F60\u7684\u6296\u97F3ck\u53EF\u80FD\u5DF2\u7ECF\u5931\u6548\uFF01",
2379
- requestType: type ?? "\u672A\u77E5\u8BF7\u6C42\u7C7B\u578B",
2380
- requestUrl: config.url
2381
- };
2382
- warningMessage = `
2383
- \u83B7\u53D6\u54CD\u5E94\u6570\u636E\u5931\u8D25\uFF01\u539F\u56E0\uFF1A${logger.yellow("\u63A5\u53E3\u8FD4\u56DE\u5185\u5BB9\u4E3A\u7A7A\uFF0C\u4F60\u7684\u6296\u97F3ck\u53EF\u80FD\u5DF2\u7ECF\u5931\u6548\uFF01")}
2384
- \u8BF7\u6C42\u7C7B\u578B\uFF1A\u300C${type}\u300D
2385
- \u8BF7\u6C42URL\uFF1A${config.url}
2386
- `;
2387
- logger.warn(warningMessage);
2388
- throw {
2389
- code: "INVALID_COOKIE" /* COOKIE */,
2390
- data: result,
2391
- amagiError: Err
2392
- };
2393
- }
2394
- if (result.filter_detail && result.filter_detail.filter_reason) {
2395
- const filterReason = result.filter_detail.filter_reason;
2396
- const Err = {
2397
- errorDescription: `\u83B7\u53D6\u54CD\u5E94\u6570\u636E\u5931\u8D25\uFF01\u539F\u56E0\uFF1A${filterReason}\uFF01`,
2398
- requestType: type ?? "\u672A\u77E5\u8BF7\u6C42\u7C7B\u578B",
2399
- requestUrl: config.url
2400
- };
2401
- warningMessage = `
2402
- \u83B7\u53D6\u54CD\u5E94\u6570\u636E\u5931\u8D25\uFF01\u539F\u56E0\uFF1A${logger.yellow(filterReason)}
2403
- \u8BF7\u6C42\u7C7B\u578B\uFF1A\u300C${type}\u300D
2404
- \u8BF7\u6C42URL\uFF1A${config.url}
2405
- `;
2406
- logger.warn(warningMessage);
2407
- throw {
2408
- code: "CONTENT_FILTERED" /* FILTER */,
2409
- data: result,
2410
- amagiError: Err
2411
- };
2412
- }
2413
- return result;
2414
- } catch (error) {
2415
- if (error && typeof error === "object") {
2416
- const err = error;
2417
- return { ...err, amagiMessage: warningMessage };
2418
- }
2419
- return {
2420
- code: "UNKNOWN_ERROR" /* UNKNOWN */,
2421
- data: null,
2422
- amagiError: {
2423
- errorDescription: "\u672A\u77E5\u9519\u8BEF",
2424
- requestType: type,
2425
- requestUrl: config.url
2426
- },
2427
- amagiMessage: warningMessage
2428
- };
2429
- }
2430
- };
2431
-
2432
- // src/platform/kuaishou/API.ts
2433
- var API = class {
2434
- \u5355\u4E2A\u4F5C\u54C1\u4FE1\u606F(data2) {
2435
- return {
2436
- /** 接口类型 */
2437
- type: "visionVideoDetail",
2438
- /** 请求url */
2439
- url: "https://www.kuaishou.com/graphql",
2440
- /** 请求参数 */
2441
- body: {
2442
- /** 接口类型 */
2443
- operationName: "visionVideoDetail",
2444
- variables: {
2445
- /** 作品ID */
2446
- photoId: data2.photoId,
2447
- page: "detail"
2448
- },
2449
- query: "query visionVideoDetail($photoId: String, $type: String, $page: String, $webPageArea: String) {\n visionVideoDetail(photoId: $photoId, type: $type, page: $page, webPageArea: $webPageArea) {\n status\n type\n author {\n id\n name\n following\n headerUrl\n __typename\n }\n photo {\n id\n duration\n caption\n likeCount\n realLikeCount\n coverUrl\n photoUrl\n liked\n timestamp\n expTag\n llsid\n viewCount\n videoRatio\n stereoType\n musicBlocked\n manifest {\n mediaType\n businessType\n version\n adaptationSet {\n id\n duration\n representation {\n id\n defaultSelect\n backupUrl\n codecs\n url\n height\n width\n avgBitrate\n maxBitrate\n m3u8Slice\n qualityType\n qualityLabel\n frameRate\n featureP2sp\n hidden\n disableAdaptive\n __typename\n }\n __typename\n }\n __typename\n }\n manifestH265\n photoH265Url\n coronaCropManifest\n coronaCropManifestH265\n croppedPhotoH265Url\n croppedPhotoUrl\n videoResource\n __typename\n }\n tags {\n type\n name\n __typename\n }\n commentLimit {\n canAddComment\n __typename\n }\n llsid\n danmakuSwitch\n __typename\n }\n}\n"
2450
- }
2451
- };
2452
- }
2453
- \u4F5C\u54C1\u8BC4\u8BBA\u4FE1\u606F(data2) {
2454
- return {
2455
- type: "commentListQuery",
2456
- url: "https://www.kuaishou.com/graphql",
2457
- body: {
2458
- operationName: "commentListQuery",
2459
- variables: {
2460
- photoId: data2.photoId,
2461
- pcursor: ""
2462
- },
2463
- query: "query commentListQuery($photoId: String, $pcursor: String) {\n visionCommentList(photoId: $photoId, pcursor: $pcursor) {\n commentCount\n pcursor\n rootComments {\n commentId\n authorId\n authorName\n content\n headurl\n timestamp\n likedCount\n realLikedCount\n liked\n status\n authorLiked\n subCommentCount\n subCommentsPcursor\n subComments {\n commentId\n authorId\n authorName\n content\n headurl\n timestamp\n likedCount\n realLikedCount\n liked\n status\n authorLiked\n replyToUserName\n replyTo\n __typename\n }\n __typename\n }\n __typename\n }\n}\n"
2464
- }
2465
- };
2466
- }
2467
- \u8868\u60C5() {
2468
- return {
2469
- type: "visionBaseEmoticons",
2470
- url: "https://www.kuaishou.com/graphql",
2471
- body: {
2472
- operationName: "visionBaseEmoticons",
2473
- variables: {},
2474
- query: "query visionBaseEmoticons {\n visionBaseEmoticons {\n iconUrls\n __typename\n }\n}\n"
2475
- }
2476
- };
2477
- }
2478
- };
2479
- var kuaishouApiUrls = new API();
2480
-
2481
- // src/platform/kuaishou/getdata.ts
2482
- var KuaishouData = async (data2, cookie, requestConfig) => {
2483
- const defHeaders = getKuaishouDefaultConfig(cookie)["headers"];
2484
- const baseRequestConfig = {
2485
- method: "POST",
2486
- timeout: 1e4,
2487
- ...requestConfig,
2488
- headers: {
2489
- ...defHeaders,
2490
- ...{}
2491
- }
2492
- };
2493
- switch (data2.methodType) {
2494
- case "\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E": {
2495
- const body = kuaishouApiUrls.\u5355\u4E2A\u4F5C\u54C1\u4FE1\u606F({ photoId: data2.photoId });
2496
- const VideoData = await GlobalGetData3(data2.methodType, {
2497
- ...baseRequestConfig,
2498
- url: body.url,
2499
- data: body.body
2500
- });
2501
- return VideoData;
2502
- }
2503
- case "\u8BC4\u8BBA\u6570\u636E": {
2504
- const body = kuaishouApiUrls.\u4F5C\u54C1\u8BC4\u8BBA\u4FE1\u606F({ photoId: data2.photoId });
2505
- const VideoData = await GlobalGetData3(data2.methodType, {
2506
- ...baseRequestConfig,
2507
- url: body.url,
2508
- data: body.body
2509
- });
2510
- return VideoData;
2511
- }
2512
- case "Emoji\u6570\u636E": {
2513
- const body = kuaishouApiUrls.\u8868\u60C5();
2514
- const EmojiData = await GlobalGetData3(data2.methodType, {
2515
- ...baseRequestConfig,
2516
- url: body.url,
2517
- data: body.body
2518
- });
2519
- return EmojiData;
2520
- }
2521
- default:
2522
- logger.warn(`\u672A\u77E5\u7684\u5FEB\u624B\u6570\u636E\u63A5\u53E3\uFF1A\u300C${logger.red(data2.methodType)}\u300D`);
2523
- return null;
2524
- }
2525
- };
2526
- var GlobalGetData3 = async (type, options) => {
2527
- let warningMessage = "";
2528
- try {
2529
- const result = await fetchData(options);
2530
- if (result === "" || !result || result.result === 2) {
2531
- const Err = {
2532
- errorDescription: `\u83B7\u53D6\u54CD\u5E94\u6570\u636E\u5931\u8D25\uFF01\u63A5\u53E3\u8FD4\u56DE\u5185\u5BB9\u4E3A\u7A7A\uFF01`,
2533
- requestType: type ?? "\u672A\u77E5\u8BF7\u6C42\u7C7B\u578B",
2534
- requestUrl: options.url,
2535
- requestBody: JSON.stringify(options.data)
2536
- };
2537
- warningMessage = `
2538
- \u83B7\u53D6\u54CD\u5E94\u6570\u636E\u5931\u8D25\uFF01\u539F\u56E0\uFF1A${logger.yellow("\u63A5\u53E3\u8FD4\u56DE\u5185\u5BB9\u4E3A\u7A7A\uFF0C\u4F60\u7684\u5FEB\u624Bck\u53EF\u80FD\u5DF2\u7ECF\u5931\u6548\uFF01")}
2539
- \u8BF7\u6C42\u7C7B\u578B\uFF1A\u300C${type}\u300D
2540
- \u8BF7\u6C42URL\uFF1A${options.url}
2541
- \u8BF7\u6C42\u53C2\u6570\uFF1A${JSON.stringify(options.data, null, 2)}
2542
- `;
2543
- logger.warn(warningMessage);
2544
- throw {
2545
- code: "INVALID_COOKIE" /* COOKIE */,
2546
- data: result,
2547
- amagiError: Err
2548
- };
2549
- }
2550
- return result;
2551
- } catch (error) {
2552
- if (error && typeof error === "object") {
2553
- const err = error;
2554
- return { ...err, amagiMessage: warningMessage };
2555
- }
2556
- return {
2557
- code: "UNKNOWN_ERROR" /* UNKNOWN */,
2558
- data: null,
2559
- amagiError: {
2560
- errorDescription: "\u672A\u77E5\u9519\u8BEF",
2561
- requestType: type,
2562
- requestUrl: options.url
2563
- },
2564
- amagiMessage: warningMessage
2565
- };
2566
- }
2567
- };
2568
- function smartNumber(errorMessage, minValue = 1, isInteger = false) {
2569
- if (isInteger) {
2570
- return z.coerce.number({ error: errorMessage }).int({ error: `${errorMessage.replace("\u4E0D\u80FD\u4E3A\u7A7A", "")}\u5FC5\u987B\u662F\u6574\u6570\uFF0C\u4E0D\u80FD\u5305\u542B\u5C0F\u6570` }).min(minValue, { error: `${errorMessage.replace("\u4E0D\u80FD\u4E3A\u7A7A", "")}\u5FC5\u987B\u5927\u4E8E\u7B49\u4E8E${minValue}` });
2571
- } else {
2572
- return z.coerce.number({ error: errorMessage }).min(minValue, { error: `${errorMessage.replace("\u4E0D\u80FD\u4E3A\u7A7A", "")}\u5FC5\u987B\u5927\u4E8E\u7B49\u4E8E${minValue}` });
2573
- }
2574
- }
2575
- var smartPositiveInteger = (errorMessage) => {
2576
- return smartNumber(errorMessage, 1, true);
2577
- };
2578
- var extractCreatorInfoFromHtml = (html) => {
2579
- var _a;
2580
- const match = html.match(/<script>window\.__INITIAL_STATE__=(.+)<\/script>/m);
2581
- if (!match) {
2582
- return null;
2583
- }
2584
- try {
2585
- const jsonStr = match[1].replace(/:undefined/g, ":null");
2586
- const info = JSON.parse(jsonStr);
2587
- return ((_a = info == null ? void 0 : info.user) == null ? void 0 : _a.userPageData) || null;
2588
- } catch (error) {
2589
- console.error("\u89E3\u6790\u7528\u6237\u4FE1\u606F\u5931\u8D25:", error);
2590
- return null;
2591
- }
2592
- };
2593
-
2594
- // src/validation/douyin.ts
2595
- var DouyinWorkParamsSchema = z.object({
2596
- methodType: z.enum(["\u6587\u5B57\u4F5C\u54C1\u6570\u636E", "\u89C6\u9891\u4F5C\u54C1\u6570\u636E", "\u56FE\u96C6\u4F5C\u54C1\u6570\u636E", "\u5408\u8F91\u4F5C\u54C1\u6570\u636E", "\u805A\u5408\u89E3\u6790"], {
2597
- error: "\u65B9\u6CD5\u7C7B\u578B\u5FC5\u987B\u662F\u6307\u5B9A\u7684\u679A\u4E3E\u503C\u4E4B\u4E00"
2598
- }),
2599
- aweme_id: z.string({ error: "\u89C6\u9891ID\u5FC5\u987B\u662F\u5B57\u7B26\u4E32" }).min(1, { error: "\u89C6\u9891ID\u4E0D\u80FD\u4E3A\u7A7A" })
2600
- });
2601
- var DouyinCommentParamsSchema = z.object({
2602
- methodType: z.literal("\u8BC4\u8BBA\u6570\u636E", { error: '\u65B9\u6CD5\u7C7B\u578B\u5FC5\u987B\u662F"\u8BC4\u8BBA\u6570\u636E"' }),
2603
- aweme_id: z.string({ error: "\u89C6\u9891ID\u5FC5\u987B\u662F\u5B57\u7B26\u4E32" }).min(1, { error: "\u89C6\u9891ID\u4E0D\u80FD\u4E3A\u7A7A" }),
2604
- number: smartPositiveInteger("\u8BC4\u8BBA\u6570\u91CF\u5FC5\u987B\u662F\u6B63\u6574\u6570").optional().default(50),
2605
- cursor: z.coerce.number({ error: "\u6E38\u6807\u5FC5\u987B\u662F\u6570\u5B57" }).int({ error: "\u6E38\u6807\u5FC5\u987B\u662F\u6574\u6570" }).min(0, { error: "\u6E38\u6807\u4E0D\u80FD\u5C0F\u4E8E0" }).default(0).optional()
2606
- });
2607
- var DouyinSearchParamsSchema = z.object({
2608
- methodType: z.enum(["\u70ED\u70B9\u8BCD\u6570\u636E", "\u641C\u7D22\u6570\u636E"], {
2609
- error: '\u65B9\u6CD5\u7C7B\u578B\u5FC5\u987B\u662F"\u70ED\u70B9\u8BCD\u6570\u636E"\u6216"\u641C\u7D22\u6570\u636E"'
2610
- }),
2611
- query: z.string({ error: "\u641C\u7D22\u8BCD\u5FC5\u987B\u662F\u5B57\u7B26\u4E32" }).min(1, { error: "\u641C\u7D22\u8BCD\u4E0D\u80FD\u4E3A\u7A7A" }),
2612
- number: smartPositiveInteger("\u641C\u7D22\u6570\u91CF\u5FC5\u987B\u662F\u6B63\u6574\u6570").optional().default(10),
2613
- search_id: z.string({ error: "\u641C\u7D22ID\u5FC5\u987B\u662F\u5B57\u7B26\u4E32" }).optional()
2614
- });
2615
- var DouyinCommentReplyParamsSchema = z.object({
2616
- methodType: z.literal("\u6307\u5B9A\u8BC4\u8BBA\u56DE\u590D\u6570\u636E", { error: '\u65B9\u6CD5\u7C7B\u578B\u5FC5\u987B\u662F"\u6307\u5B9A\u8BC4\u8BBA\u56DE\u590D\u6570\u636E"' }),
2617
- aweme_id: z.string({ error: "\u89C6\u9891ID\u5FC5\u987B\u662F\u5B57\u7B26\u4E32" }).min(1, { error: "\u89C6\u9891ID\u4E0D\u80FD\u4E3A\u7A7A" }),
2618
- comment_id: z.string({ error: "\u8BC4\u8BBAID\u5FC5\u987B\u662F\u5B57\u7B26\u4E32" }).min(1, { error: "\u8BC4\u8BBAID\u4E0D\u80FD\u4E3A\u7A7A" }),
2619
- number: smartPositiveInteger("\u8BC4\u8BBA\u6570\u91CF\u5FC5\u987B\u662F\u6B63\u6574\u6570").optional().default(5),
2620
- cursor: z.coerce.number({ error: "\u6E38\u6807\u5FC5\u987B\u662F\u6570\u5B57" }).int({ error: "\u6E38\u6807\u5FC5\u987B\u662F\u6574\u6570" }).min(0, { error: "\u6E38\u6807\u4E0D\u80FD\u5C0F\u4E8E0" }).default(0).optional()
2621
- });
2622
- var DouyinUserParamsSchema = z.object({
2623
- methodType: z.enum(["\u7528\u6237\u4E3B\u9875\u6570\u636E", "\u7528\u6237\u4E3B\u9875\u89C6\u9891\u5217\u8868\u6570\u636E", "\u76F4\u64AD\u95F4\u4FE1\u606F\u6570\u636E"], {
2624
- error: "\u65B9\u6CD5\u7C7B\u578B\u5FC5\u987B\u662F\u6307\u5B9A\u7684\u679A\u4E3E\u503C\u4E4B\u4E00"
2625
- }),
2626
- sec_uid: z.string({ error: "\u7528\u6237ID\u5FC5\u987B\u662F\u5B57\u7B26\u4E32" }).min(1, { error: "\u7528\u6237ID\u4E0D\u80FD\u4E3A\u7A7A" })
2627
- });
2628
- var DouyinMusicParamsSchema = z.object({
2629
- methodType: z.literal("\u97F3\u4E50\u6570\u636E", { error: '\u65B9\u6CD5\u7C7B\u578B\u5FC5\u987B\u662F"\u97F3\u4E50\u6570\u636E"' }),
2630
- music_id: z.string({ error: "\u97F3\u4E50ID\u5FC5\u987B\u662F\u5B57\u7B26\u4E32" }).min(1, { error: "\u97F3\u4E50ID\u4E0D\u80FD\u4E3A\u7A7A" })
2631
- });
2632
- var DouyinQrcodeParamsSchema = z.object({
2633
- methodType: z.literal("\u7533\u8BF7\u4E8C\u7EF4\u7801\u6570\u636E", { error: '\u65B9\u6CD5\u7C7B\u578B\u5FC5\u987B\u662F"\u7533\u8BF7\u4E8C\u7EF4\u7801\u6570\u636E"' }),
2634
- verify_fp: z.string({ error: "fp\u6307\u7EB9\u5FC5\u987B\u662F\u5B57\u7B26\u4E32" }).min(1, { error: "fp\u6307\u7EB9\u4E0D\u80FD\u4E3A\u7A7A" })
2635
- });
2636
- var DouyinEmojiListParamsSchema = z.object({
2637
- methodType: z.literal("Emoji\u6570\u636E", { error: '\u65B9\u6CD5\u7C7B\u578B\u5FC5\u987B\u662F"Emoji\u6570\u636E"' })
2638
- });
2639
- var DouyinEmojiProParamsSchema = z.object({
2640
- methodType: z.literal("\u52A8\u6001\u8868\u60C5\u6570\u636E", { error: '\u65B9\u6CD5\u7C7B\u578B\u5FC5\u987B\u662F"\u52A8\u6001\u8868\u60C5\u6570\u636E"' })
2641
- });
2642
- var DouyinDanmakuParamsSchema = z.object({
2643
- methodType: z.literal("\u5F39\u5E55\u6570\u636E", { error: '\u65B9\u6CD5\u7C7B\u578B\u5FC5\u987B\u662F"\u5F39\u5E55\u6570\u636E"' }),
2644
- aweme_id: z.string({ error: "\u89C6\u9891ID\u5FC5\u987B\u662F\u5B57\u7B26\u4E32" }).min(1, { error: "\u89C6\u9891ID\u4E0D\u80FD\u4E3A\u7A7A" }),
2645
- start_time: z.coerce.number({ error: "\u5F00\u59CB\u65F6\u95F4\u5FC5\u987B\u662F\u6570\u5B57" }).int({ error: "\u5F00\u59CB\u65F6\u95F4\u5FC5\u987B\u662F\u6574\u6570" }).min(0, { error: "\u5F00\u59CB\u65F6\u95F4\u4E0D\u80FD\u5C0F\u4E8E0" }).optional(),
2646
- end_time: z.coerce.number({ error: "\u7ED3\u675F\u65F6\u95F4\u5FC5\u987B\u662F\u6570\u5B57" }).int({ error: "\u7ED3\u675F\u65F6\u95F4\u5FC5\u987B\u662F\u6574\u6570" }).min(0, { error: "\u7ED3\u675F\u65F6\u95F4\u4E0D\u80FD\u5C0F\u4E8E0" }).optional(),
2647
- duration: z.coerce.number({ error: "\u89C6\u9891\u65F6\u957F\u5FC5\u987B\u662F\u6570\u5B57" }).int({ error: "\u89C6\u9891\u65F6\u957F\u5FC5\u987B\u662F\u6574\u6570" }).min(0, { error: "\u89C6\u9891\u65F6\u957F\u4E0D\u80FD\u5C0F\u4E8E0" })
2648
- }).refine(
2649
- (data2) => {
2650
- if (data2.end_time !== void 0) {
2651
- return data2.end_time <= data2.duration;
2652
- }
2653
- return true;
2654
- },
2655
- {
2656
- error: "\u83B7\u53D6\u5F39\u5E55\u533A\u95F4\u7684\u7ED3\u675F\u65F6\u95F4\u4E0D\u80FD\u8D85\u8FC7\u89C6\u9891\u603B\u65F6\u957F",
2657
- path: ["end_time"]
2658
- }
2659
- ).refine(
2660
- (data2) => {
2661
- if (data2.start_time !== void 0 && data2.end_time !== void 0) {
2662
- return data2.start_time < data2.end_time;
2663
- }
2664
- return true;
2665
- },
2666
- {
2667
- error: "\u83B7\u53D6\u5F39\u5E55\u533A\u95F4\u7684\u5F00\u59CB\u65F6\u95F4\u5FC5\u987B\u5C0F\u4E8E\u7ED3\u675F\u65F6\u95F4",
2668
- path: ["start_time"]
2669
- }
2670
- );
2671
- var DouyinValidationSchemas2 = {
2672
- "\u6587\u5B57\u4F5C\u54C1\u6570\u636E": DouyinWorkParamsSchema,
2673
- "\u805A\u5408\u89E3\u6790": DouyinWorkParamsSchema,
2674
- "\u89C6\u9891\u4F5C\u54C1\u6570\u636E": DouyinWorkParamsSchema,
2675
- "\u56FE\u96C6\u4F5C\u54C1\u6570\u636E": DouyinWorkParamsSchema,
2676
- "\u5408\u8F91\u4F5C\u54C1\u6570\u636E": DouyinWorkParamsSchema,
2677
- "\u8BC4\u8BBA\u6570\u636E": DouyinCommentParamsSchema,
2678
- "\u7528\u6237\u4E3B\u9875\u6570\u636E": DouyinUserParamsSchema,
2679
- "\u7528\u6237\u4E3B\u9875\u89C6\u9891\u5217\u8868\u6570\u636E": DouyinUserParamsSchema,
2680
- "\u70ED\u70B9\u8BCD\u6570\u636E": DouyinSearchParamsSchema,
2681
- "\u641C\u7D22\u6570\u636E": DouyinSearchParamsSchema,
2682
- "\u97F3\u4E50\u6570\u636E": DouyinMusicParamsSchema,
2683
- "\u76F4\u64AD\u95F4\u4FE1\u606F\u6570\u636E": DouyinUserParamsSchema,
2684
- "\u7533\u8BF7\u4E8C\u7EF4\u7801\u6570\u636E": DouyinQrcodeParamsSchema,
2685
- "Emoji\u6570\u636E": DouyinEmojiListParamsSchema,
2686
- "\u52A8\u6001\u8868\u60C5\u6570\u636E": DouyinEmojiProParamsSchema,
2687
- "\u6307\u5B9A\u8BC4\u8BBA\u56DE\u590D\u6570\u636E": DouyinCommentReplyParamsSchema,
2688
- "\u5F39\u5E55\u6570\u636E": DouyinDanmakuParamsSchema
2689
- };
2690
- var BilibiliVideoParamsSchema = z.object({
2691
- methodType: z.literal("\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E", { error: '\u65B9\u6CD5\u7C7B\u578B\u5FC5\u987B\u662F"\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E"' }),
2692
- bvid: z.string({ error: "BVID\u5FC5\u987B\u662F\u5B57\u7B26\u4E32" }).min(1, { error: "BVID\u4E0D\u80FD\u4E3A\u7A7A" })
2693
- });
2694
- var BilibiliVideoDownloadParamsSchema = z.object({
2695
- methodType: z.literal("\u5355\u4E2A\u89C6\u9891\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E", { error: '\u65B9\u6CD5\u7C7B\u578B\u5FC5\u987B\u662F"\u5355\u4E2A\u89C6\u9891\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E"' }),
2696
- avid: smartNumber("AVID\u4E0D\u80FD\u4E3A\u7A7A", 1, true),
2697
- cid: smartNumber("CID\u4E0D\u80FD\u4E3A\u7A7A", 1, true)
2698
- });
2699
- var BilibiliCommentParamsSchema = z.object({
2700
- methodType: z.literal("\u8BC4\u8BBA\u6570\u636E", { error: '\u65B9\u6CD5\u7C7B\u578B\u5FC5\u987B\u662F"\u8BC4\u8BBA\u6570\u636E"' }),
2701
- oid: z.string({ error: "OID\u5FC5\u987B\u662F\u5B57\u7B26\u4E32" }).min(1, { error: "OID\u4E0D\u80FD\u4E3A\u7A7A" }),
2702
- type: smartNumber("\u8BC4\u8BBA\u7C7B\u578B\u4E0D\u80FD\u4E3A\u7A7A", 1, true).refine(
2703
- (val) => [1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 33].includes(val),
2704
- { error: "\u65E0\u6548\u7684\u8BC4\u8BBA\u533A\u7C7B\u578B" }
2705
- ),
2706
- number: z.coerce.number({ error: "\u8BC4\u8BBA\u6570\u91CF\u5FC5\u987B\u662F\u6570\u5B57" }).int({ error: "\u8BC4\u8BBA\u6570\u91CF\u5FC5\u987B\u662F\u6574\u6570" }).positive({ error: "\u8BC4\u8BBA\u6570\u91CF\u5FC5\u987B\u662F\u6B63\u6570" }).default(20).optional(),
2707
- pn: z.coerce.number({ error: "\u9875\u7801\u5FC5\u987B\u662F\u6570\u5B57" }).int({ error: "\u9875\u7801\u5FC5\u987B\u662F\u6574\u6570" }).positive({ error: "\u9875\u7801\u5FC5\u987B\u662F\u6B63\u6570" }).default(1).optional()
2708
- });
2709
- var BilibiliUserParamsSchema = z.object({
2710
- methodType: z.enum(["\u7528\u6237\u4E3B\u9875\u6570\u636E", "\u7528\u6237\u4E3B\u9875\u52A8\u6001\u5217\u8868\u6570\u636E", "\u83B7\u53D6UP\u4E3B\u603B\u64AD\u653E\u91CF"], {
2711
- error: "\u65B9\u6CD5\u7C7B\u578B\u5FC5\u987B\u662F\u6307\u5B9A\u7684\u679A\u4E3E\u503C\u4E4B\u4E00"
2712
- }),
2713
- host_mid: smartNumber("UP\u4E3BUID\u4E0D\u80FD\u4E3A\u7A7A", 1, true)
2714
- });
2715
- var BilibiliEmojiParamsSchema = z.object({
2716
- methodType: z.literal("Emoji\u6570\u636E", { error: '\u65B9\u6CD5\u7C7B\u578B\u5FC5\u987B\u662F"Emoji\u6570\u636E"' })
2717
- });
2718
- var BilibiliBangumiInfoParamsSchema = z.object({
2719
- methodType: z.literal("\u756A\u5267\u57FA\u672C\u4FE1\u606F\u6570\u636E", { error: '\u65B9\u6CD5\u7C7B\u578B\u5FC5\u987B\u662F"\u756A\u5267\u57FA\u672C\u4FE1\u606F\u6570\u636E"' }),
2720
- ep_id: z.string({ error: "\u756A\u5267EP ID\u5FC5\u987B\u662F\u5B57\u7B26\u4E32" }).min(1, { error: "\u756A\u5267EP ID\u4E0D\u80FD\u4E3A\u7A7A" }).optional(),
2721
- season_id: z.string({ error: "\u756A\u5267\u5B63\u5EA6ID\u5FC5\u987B\u662F\u5B57\u7B26\u4E32" }).optional()
2722
- }).refine(
2723
- (data2) => data2.ep_id || data2.season_id,
2724
- {
2725
- error: "ep_id \u548C season_id \u81F3\u5C11\u9700\u8981\u63D0\u4F9B\u4E00\u4E2A",
2726
- path: ["ep_id"]
2727
- }
2728
- );
2729
- var BilibiliBangumiStreamParamsSchema = z.object({
2730
- methodType: z.literal("\u756A\u5267\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E", { error: '\u65B9\u6CD5\u7C7B\u578B\u5FC5\u987B\u662F"\u756A\u5267\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E"' }),
2731
- cid: smartNumber("CID\u4E0D\u80FD\u4E3A\u7A7A", 1, true),
2732
- ep_id: z.string({ error: "\u756A\u5267EP ID\u5FC5\u987B\u662F\u5B57\u7B26\u4E32" }).min(1, { error: "\u756A\u5267EP ID\u4E0D\u80FD\u4E3A\u7A7A" })
2733
- });
2734
- var BilibiliDynamicParamsSchema = z.object({
2735
- methodType: z.enum(["\u52A8\u6001\u8BE6\u60C5\u6570\u636E", "\u52A8\u6001\u5361\u7247\u6570\u636E"], {
2736
- error: '\u65B9\u6CD5\u7C7B\u578B\u5FC5\u987B\u662F"\u52A8\u6001\u8BE6\u60C5\u6570\u636E"\u6216"\u52A8\u6001\u5361\u7247\u6570\u636E"'
2737
- }),
2738
- dynamic_id: z.string({ error: "\u52A8\u6001ID\u5FC5\u987B\u662F\u5B57\u7B26\u4E32" }).min(1, { error: "\u52A8\u6001ID\u4E0D\u80FD\u4E3A\u7A7A" })
2739
- });
2740
- var BilibiliLiveParamsSchema = z.object({
2741
- methodType: z.enum(["\u76F4\u64AD\u95F4\u4FE1\u606F", "\u76F4\u64AD\u95F4\u521D\u59CB\u5316\u4FE1\u606F"], {
2742
- error: '\u65B9\u6CD5\u7C7B\u578B\u5FC5\u987B\u662F"\u76F4\u64AD\u95F4\u4FE1\u606F"\u6216"\u76F4\u64AD\u95F4\u521D\u59CB\u5316\u4FE1\u606F"'
2743
- }),
2744
- room_id: z.string({ error: "\u76F4\u64AD\u95F4ID\u5FC5\u987B\u662F\u5B57\u7B26\u4E32" }).min(1, { error: "\u76F4\u64AD\u95F4ID\u4E0D\u80FD\u4E3A\u7A7A" })
2745
- });
2746
- var BilibiliLoginParamsSchema = z.object({
2747
- methodType: z.literal("\u767B\u5F55\u57FA\u672C\u4FE1\u606F", { error: '\u65B9\u6CD5\u7C7B\u578B\u5FC5\u987B\u662F"\u767B\u5F55\u57FA\u672C\u4FE1\u606F"' })
2748
- });
2749
- var BilibiliQrcodeParamsSchema = z.object({
2750
- methodType: z.literal("\u7533\u8BF7\u4E8C\u7EF4\u7801", { error: '\u65B9\u6CD5\u7C7B\u578B\u5FC5\u987B\u662F"\u7533\u8BF7\u4E8C\u7EF4\u7801"' })
2751
- });
2752
- var BilibiliQrcodeStatusParamsSchema = z.object({
2753
- methodType: z.literal("\u4E8C\u7EF4\u7801\u72B6\u6001", { error: '\u65B9\u6CD5\u7C7B\u578B\u5FC5\u987B\u662F"\u4E8C\u7EF4\u7801\u72B6\u6001"' }),
2754
- qrcode_key: z.string({ error: "\u4E8C\u7EF4\u7801key\u5FC5\u987B\u662F\u5B57\u7B26\u4E32" }).min(1, { error: "\u4E8C\u7EF4\u7801key\u4E0D\u80FD\u4E3A\u7A7A" })
2755
- });
2756
- var BilibiliAv2BvParamsSchema = z.object({
2757
- methodType: z.literal("AV\u8F6CBV", { error: '\u65B9\u6CD5\u7C7B\u578B\u5FC5\u987B\u662F"AV\u8F6CBV"' }),
2758
- avid: z.coerce.number({ error: "AVID\u5FC5\u987B\u662F\u6570\u5B57" }).int({ error: "AVID\u5FC5\u987B\u662F\u6574\u6570" }).positive({ error: "AVID\u5FC5\u987B\u662F\u6B63\u6570" })
2759
- });
2760
- var BilibiliBv2AvParamsSchema = z.object({
2761
- methodType: z.literal("BV\u8F6CAV", { error: '\u65B9\u6CD5\u7C7B\u578B\u5FC5\u987B\u662F"BV\u8F6CAV"' }),
2762
- bvid: z.string({ error: "BVID\u5FC5\u987B\u662F\u5B57\u7B26\u4E32" }).min(1, { error: "BVID\u4E0D\u80FD\u4E3A\u7A7A" })
2763
- });
2764
- var BilibiliValidationSchemas2 = {
2765
- "\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E": BilibiliVideoParamsSchema,
2766
- "\u5355\u4E2A\u89C6\u9891\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E": BilibiliVideoDownloadParamsSchema,
2767
- "\u8BC4\u8BBA\u6570\u636E": BilibiliCommentParamsSchema,
2768
- "\u7528\u6237\u4E3B\u9875\u6570\u636E": BilibiliUserParamsSchema,
2769
- "\u7528\u6237\u4E3B\u9875\u52A8\u6001\u5217\u8868\u6570\u636E": BilibiliUserParamsSchema,
2770
- "Emoji\u6570\u636E": BilibiliEmojiParamsSchema,
2771
- "\u756A\u5267\u57FA\u672C\u4FE1\u606F\u6570\u636E": BilibiliBangumiInfoParamsSchema,
2772
- "\u756A\u5267\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E": BilibiliBangumiStreamParamsSchema,
2773
- "\u52A8\u6001\u8BE6\u60C5\u6570\u636E": BilibiliDynamicParamsSchema,
2774
- "\u52A8\u6001\u5361\u7247\u6570\u636E": BilibiliDynamicParamsSchema,
2775
- "\u76F4\u64AD\u95F4\u4FE1\u606F": BilibiliLiveParamsSchema,
2776
- "\u76F4\u64AD\u95F4\u521D\u59CB\u5316\u4FE1\u606F": BilibiliLiveParamsSchema,
2777
- "\u767B\u5F55\u57FA\u672C\u4FE1\u606F": BilibiliLoginParamsSchema,
2778
- "\u7533\u8BF7\u4E8C\u7EF4\u7801": BilibiliQrcodeParamsSchema,
2779
- "\u4E8C\u7EF4\u7801\u72B6\u6001": BilibiliQrcodeStatusParamsSchema,
2780
- "\u83B7\u53D6UP\u4E3B\u603B\u64AD\u653E\u91CF": BilibiliUserParamsSchema,
2781
- "AV\u8F6CBV": BilibiliAv2BvParamsSchema,
2782
- "BV\u8F6CAV": BilibiliBv2AvParamsSchema
2783
- };
2784
- var KuaishouVideoParamsSchema = z.object({
2785
- methodType: z.literal("\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E", { error: '\u65B9\u6CD5\u7C7B\u578B\u5FC5\u987B\u662F"\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E"' }),
2786
- photoId: z.string({ error: "\u89C6\u9891ID\u5FC5\u987B\u662F\u5B57\u7B26\u4E32" }).min(1, { error: "\u89C6\u9891ID\u4E0D\u80FD\u4E3A\u7A7A" })
2787
- });
2788
- var KuaishouCommentParamsSchema = z.object({
2789
- methodType: z.literal("\u8BC4\u8BBA\u6570\u636E", { error: '\u65B9\u6CD5\u7C7B\u578B\u5FC5\u987B\u662F"\u8BC4\u8BBA\u6570\u636E"' }),
2790
- photoId: z.string({ error: "\u89C6\u9891ID\u5FC5\u987B\u662F\u5B57\u7B26\u4E32" }).min(1, { error: "\u89C6\u9891ID\u4E0D\u80FD\u4E3A\u7A7A" })
2791
- });
2792
- var KuaishouEmojiParamsSchema = z.object({
2793
- methodType: z.literal("Emoji\u6570\u636E", { error: '\u65B9\u6CD5\u7C7B\u578B\u5FC5\u987B\u662F"Emoji\u6570\u636E"' })
2794
- });
2795
- var KuaishouValidationSchemas2 = {
2796
- "\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E": KuaishouVideoParamsSchema,
2797
- "\u8BC4\u8BBA\u6570\u636E": KuaishouCommentParamsSchema,
2798
- "Emoji\u6570\u636E": KuaishouEmojiParamsSchema
2799
- };
2800
- var xiaohongshuSign = class {
2801
- static client = new Xhshow();
2802
- /**
2803
- * 生成GET请求的X-S签名
2804
- * @param path - API路径
2805
- * @param a1Cookie - a1 cookie值
2806
- * @param clientType - 客户端类型,默认为 'xhs-pc-web'
2807
- * @param params - 查询参数对象
2808
- * @returns X-S签名
2809
- */
2810
- static generateXSGet(path2, a1Cookie, clientType = "xhs-pc-web", params = {}) {
2811
- return this.client.signXsGet(path2, a1Cookie, clientType, params);
2812
- }
2813
- /**
2814
- * 生成POST请求的X-S签名
2815
- * @param path - API路径
2816
- * @param a1Cookie - a1 cookie值
2817
- * @param clientType - 客户端类型,默认为 'xhs-pc-web'
2818
- * @param body - 请求体对象
2819
- * @returns X-S签名
2820
- */
2821
- static generateXSPost(path2, a1Cookie, clientType = "xhs-pc-web", body = {}) {
2822
- return this.client.signXsPost(path2, a1Cookie, clientType, body);
2823
- }
2824
- /**
2825
- * 生成X-S签名(兼容旧接口)
2826
- * @param url - 请求URL
2827
- * @param body - 请求体
2828
- * @param userAgent - User-Agent(暂未使用)
2829
- * @param method - 请求方法,默认为 'POST'
2830
- * @param a1Cookie - a1 cookie值
2831
- * @returns X-S签名
2832
- */
2833
- static generateXS(url, body, userAgent, method = "POST", a1Cookie = "") {
2834
- try {
2835
- const urlObj = new URL(url);
2836
- const path2 = urlObj.pathname + urlObj.search;
2837
- if (method.toUpperCase() === "GET") {
2838
- const params = typeof body === "object" ? body : {};
2839
- return this.generateXSGet(path2, a1Cookie, "xhs-pc-web", params);
2840
- } else {
2841
- const requestBody = typeof body === "object" ? body : {};
2842
- return this.generateXSPost(path2, a1Cookie, "xhs-pc-web", requestBody);
2843
- }
2844
- } catch (error) {
2845
- console.error("\u751F\u6210X-S\u7B7E\u540D\u5931\u8D25:", error);
2846
- throw new Error(`\u7B7E\u540D\u751F\u6210\u5931\u8D25: ${error}`);
2847
- }
2848
- }
2849
- /**
2850
- * 生成X-S-Common参数
2851
- * @param length - 长度
2852
- * @returns Base64编码的随机字符串
2853
- */
2854
- static generateXSCommon(length = 945) {
2855
- return crypto.randomBytes(length).toString("base64").replace(/=+$/, "");
2856
- }
2857
- /**
2858
- * 生成X-T时间戳
2859
- * @returns 当前时间戳字符串
2860
- */
2861
- static generateXT() {
2862
- return Date.now().toString();
2863
- }
2864
- /**
2865
- * 生成X-B3-Traceid
2866
- * @returns 16位随机字符串
2867
- */
2868
- static generateXB3Traceid() {
2869
- return Array.from({ length: 16 }, () => "abcdef0123456789"[Math.floor(Math.random() * 16)]).join("");
2870
- }
2871
- /**
2872
- * 从cookie字符串中提取a1值
2873
- * @param cookieString - 完整的cookie字符串
2874
- * @returns a1 cookie值
2875
- */
2876
- static extractA1FromCookie(cookieString) {
2877
- const match = cookieString.match(/a1=([^;]+)/);
2878
- return match ? match[1] : "";
2879
- }
2880
- /**
2881
- * 生成搜索ID
2882
- * @returns 搜索ID字符串
2883
- */
2884
- static getSearchId = () => (BigInt(Date.now()) << 64n) + BigInt(Math.floor(Math.random() * 2147483646)).toString(36);
2885
- };
2886
-
2887
- // src/platform/xiaohongshu/API.ts
2888
- var SearchSortType = /* @__PURE__ */ ((SearchSortType2) => {
2889
- SearchSortType2["GENERAL"] = "general";
2890
- SearchSortType2["MOST_POPULAR"] = "popularity_descending";
2891
- SearchSortType2["LATEST"] = "time_descending";
2892
- return SearchSortType2;
2893
- })(SearchSortType || {});
2894
- var SearchNoteType = /* @__PURE__ */ ((SearchNoteType2) => {
2895
- SearchNoteType2[SearchNoteType2["ALL"] = 0] = "ALL";
2896
- SearchNoteType2[SearchNoteType2["VIDEO"] = 1] = "VIDEO";
2897
- SearchNoteType2[SearchNoteType2["IMAGE"] = 2] = "IMAGE";
2898
- return SearchNoteType2;
2899
- })(SearchNoteType || {});
2900
- var buildQueryString2 = (params) => {
2901
- return Object.entries(params).filter(([_, value]) => value !== void 0 && value !== null).map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`).join("&");
2902
- };
2903
- var xiaohongshuApiUrls = {
2904
- /**
2905
- * 获取首页推荐数据的接口地址
2906
- * @param data - 请求参数
2907
- * @returns 完整的接口URL
2908
- */
2909
- \u9996\u9875\u63A8\u8350\u6570\u636E(data2 = {}) {
2910
- return {
2911
- apiPath: "/api/sns/web/v1/homefeed",
2912
- Url: "https://edith.xiaohongshu.com/api/sns/web/v1/homefeed",
2913
- Body: {
2914
- cursor_score: data2.cursor_score || "1.7599348899670024E9",
2915
- num: data2.num || 33,
2916
- refresh_type: data2.refresh_type || 3,
2917
- note_index: data2.note_index || 33,
2918
- category: data2.category || "homefeed_recommend",
2919
- search_key: data2.search_key || "",
2920
- image_formats: ["jpg", "webp", "avif"]
2921
- }
2922
- };
2923
- },
2924
- /**
2925
- * 获取单个笔记数据的接口地址
2926
- * @param data - 请求参数
2927
- * @returns 完整的接口URL
2928
- */
2929
- \u5355\u4E2A\u7B14\u8BB0\u6570\u636E(data2) {
2930
- return {
2931
- apiPath: "/api/sns/web/v1/feed",
2932
- Url: "https://edith.xiaohongshu.com/api/sns/web/v1/feed",
2933
- Body: {
2934
- source_note_id: data2.note_id,
2935
- image_formats: ["jpg", "webp", "avif"],
2936
- extra: {
2937
- need_body_topic: "1"
2938
- },
2939
- xsec_source: "pc_feed",
2940
- xsec_token: data2.xsec_token
2941
- }
2942
- };
2943
- },
2944
- /**
2945
- * 获取评论数据的接口地址
2946
- * @param data - 请求参数
2947
- * @returns 完整的接口URL
2948
- */
2949
- \u8BC4\u8BBA\u6570\u636E(data2) {
2950
- const baseUrl = "https://edith.xiaohongshu.com/api/sns/web/v2/comment/page";
2951
- const params = {
2952
- note_id: data2.note_id,
2953
- cursor: data2.cursor || "",
2954
- image_formats: ["jpg", "webp", "avif"].join(","),
2955
- xsec_token: data2.xsec_token
2956
- };
2957
- return {
2958
- apiPath: "/api/sns/web/v2/comment/page",
2959
- Url: `${baseUrl}?${buildQueryString2(params)}`
2960
- };
2961
- },
2962
- /**
2963
- * 获取用户数据的接口地址
2964
- * @param data - 请求参数
2965
- * @returns 完整的接口URL
2966
- */
2967
- \u7528\u6237\u6570\u636E(data2) {
2968
- return {
2969
- apiPath: "/api/sns/web/v1/user/otherinfo",
2970
- Url: `https://www.xiaohongshu.com/user/profile/${data2.user_id}`
2971
- };
2972
- },
2973
- /**
2974
- * 获取用户笔记数据的接口地址
2975
- * @param data - 请求参数
2976
- * @returns 完整的接口URL
2977
- */
2978
- \u7528\u6237\u7B14\u8BB0\u6570\u636E(data2) {
2979
- const baseUrl = "https://edith.xiaohongshu.com/api/sns/web/v1/user_posted";
2980
- const params = {
2981
- user_id: data2.user_id,
2982
- cursor: data2.cursor || "",
2983
- num: data2.num || 30,
2984
- image_formats: ["jpg", "webp", "avif"].join(","),
2985
- xsec_source: "pc_feed"
2986
- };
2987
- return {
2988
- apiPath: "/api/sns/web/v1/user_posted",
2989
- Url: `${baseUrl}?${buildQueryString2(params)}`
2990
- };
2991
- },
2992
- /**
2993
- * 获取笔记表情列表的接口地址
2994
- * @param data - 请求参数
2995
- * @returns 完整的接口URL
2996
- */
2997
- \u8868\u60C5\u5217\u8868(data2) {
2998
- return {
2999
- apiPath: "/api/im/redmoji/detail",
3000
- Url: "https://edith.xiaohongshu.com/api/im/redmoji/detail"
3001
- };
3002
- },
3003
- /**
3004
- * 搜索笔记的接口地址
3005
- * @param data - 请求参数
3006
- * @returns 完整的接口URL
3007
- */
3008
- \u641C\u7D22\u7B14\u8BB0(data2) {
3009
- return {
3010
- apiPath: "/api/sns/web/v1/search/notes",
3011
- Body: {
3012
- keyword: data2.keyword,
3013
- page: data2.page || 1,
3014
- page_size: data2.page_size || 20,
3015
- sort: "general" /* GENERAL */,
3016
- note_type: 0 /* ALL */,
3017
- search_id: xiaohongshuSign.getSearchId(),
3018
- image_formats: ["jpg", "webp", "avif"]
3019
- },
3020
- Url: "https://edith.xiaohongshu.com/api/sns/web/v1/search/notes"
3021
- };
3022
- }
3023
- };
3024
- var createXiaohongshuApiUrls = () => {
3025
- return xiaohongshuApiUrls;
3026
- };
3027
- var SearchSortTypeValues = Object.values(SearchSortType).filter((v) => typeof v === "string");
3028
- var SearchNoteTypeValues = Object.values(SearchNoteType).filter((v) => typeof v === "string");
3029
- var HomeFeedParamsSchema = z.object({
3030
- methodType: z.literal("\u9996\u9875\u63A8\u8350\u6570\u636E", { error: '\u65B9\u6CD5\u7C7B\u578B\u5FC5\u987B\u662F"\u9996\u9875\u63A8\u8350\u6570\u636E"' }),
3031
- cursor_score: z.string({ error: "cursor_score\u5FC5\u987B\u662F\u5B57\u7B26\u4E32" }).optional(),
3032
- num: z.number({ error: "\u6570\u91CF\u5FC5\u987B\u662F\u6570\u5B57" }).min(1, { error: "\u6570\u91CF\u4E0D\u80FD\u5C0F\u4E8E1" }).max(100, { error: "\u6570\u91CF\u4E0D\u80FD\u5927\u4E8E100" }).optional(),
3033
- refresh_type: z.number({ error: "refresh_type\u5FC5\u987B\u662F\u6570\u5B57" }).optional(),
3034
- note_index: z.number({ error: "note_index\u5FC5\u987B\u662F\u6570\u5B57" }).optional(),
3035
- category: z.string({ error: "category\u5FC5\u987B\u662F\u5B57\u7B26\u4E32" }).optional(),
3036
- search_key: z.string({ error: "search_key\u5FC5\u987B\u662F\u5B57\u7B26\u4E32" }).optional()
3037
- });
3038
- var NoteParamsSchema = z.object({
3039
- methodType: z.literal("\u5355\u4E2A\u7B14\u8BB0\u6570\u636E", { error: '\u65B9\u6CD5\u7C7B\u578B\u5FC5\u987B\u662F"\u5355\u4E2A\u7B14\u8BB0\u6570\u636E"' }),
3040
- note_id: z.string({ error: "note_id\u5FC5\u987B\u662F\u5B57\u7B26\u4E32" }),
3041
- xsec_token: z.string({ error: "xsec_token\u5FC5\u987B\u662F\u5B57\u7B26\u4E32" })
3042
- });
3043
- var CommentParamsSchema = z.object({
3044
- methodType: z.literal("\u8BC4\u8BBA\u6570\u636E", { error: '\u65B9\u6CD5\u7C7B\u578B\u5FC5\u987B\u662F"\u8BC4\u8BBA\u6570\u636E"' }),
3045
- note_id: z.string({ error: "note_id\u5FC5\u987B\u662F\u5B57\u7B26\u4E32" }),
3046
- cursor: z.string({ error: "cursor\u5FC5\u987B\u662F\u5B57\u7B26\u4E32" }).optional(),
3047
- xsec_token: z.string({ error: "xsec_token\u5FC5\u987B\u662F\u5B57\u7B26\u4E32" })
3048
- });
3049
- var UserParamsSchema = z.object({
3050
- methodType: z.literal("\u7528\u6237\u6570\u636E", { error: '\u65B9\u6CD5\u7C7B\u578B\u5FC5\u987B\u662F"\u7528\u6237\u6570\u636E"' }),
3051
- user_id: z.string({ error: "user_id\u5FC5\u987B\u662F\u5B57\u7B26\u4E32" })
3052
- });
3053
- var UserNoteParamsSchema = z.object({
3054
- methodType: z.literal("\u7528\u6237\u7B14\u8BB0\u6570\u636E", { error: '\u65B9\u6CD5\u7C7B\u578B\u5FC5\u987B\u662F"\u7528\u6237\u7B14\u8BB0\u6570\u636E"' }),
3055
- user_id: z.string({ error: "user_id\u5FC5\u987B\u662F\u5B57\u7B26\u4E32" }),
3056
- cursor: z.string({ error: "cursor\u5FC5\u987B\u662F\u5B57\u7B26\u4E32" }).optional(),
3057
- num: z.number({ error: "\u6570\u91CF\u5FC5\u987B\u662F\u6570\u5B57" }).min(1, { error: "\u6570\u91CF\u4E0D\u80FD\u5C0F\u4E8E1" }).max(100, { error: "\u6570\u91CF\u4E0D\u80FD\u5927\u4E8E100" }).optional()
3058
- });
3059
- var EmojiListParamsSchema = z.object({
3060
- methodType: z.literal("\u8868\u60C5\u5217\u8868", { error: '\u65B9\u6CD5\u7C7B\u578B\u5FC5\u987B\u662F"\u8868\u60C5\u5217\u8868"' })
3061
- });
3062
- var SearchNoteParamsSchema = z.object({
3063
- methodType: z.literal("\u641C\u7D22\u7B14\u8BB0", { error: '\u65B9\u6CD5\u7C7B\u578B\u5FC5\u987B\u662F"\u641C\u7D22\u7B14\u8BB0"' }),
3064
- keyword: z.string({ error: "keyword\u5FC5\u987B\u662F\u5B57\u7B26\u4E32" }),
3065
- page: z.number({ error: "page\u5FC5\u987B\u662F\u6570\u5B57" }).min(1, { error: "page\u4E0D\u80FD\u5C0F\u4E8E1" }).optional(),
3066
- page_size: z.number({ error: "page_size\u5FC5\u987B\u662F\u6570\u5B57" }).min(1, { error: "page_size\u4E0D\u80FD\u5C0F\u4E8E1" }).max(100, { error: "page_size\u4E0D\u80FD\u5927\u4E8E100" }).optional(),
3067
- sort: z.enum(SearchSortTypeValues, { error: "\u6392\u5E8F\u7C7B\u578B\u4E0D\u5408\u6CD5" }).optional(),
3068
- note_type: z.enum(SearchNoteTypeValues, { error: "\u7B14\u8BB0\u7C7B\u578B\u4E0D\u5408\u6CD5" }).optional()
3069
- });
3070
- var XiaohongshuValidationSchemas = {
3071
- \u9996\u9875\u63A8\u8350\u6570\u636E: HomeFeedParamsSchema,
3072
- \u5355\u4E2A\u7B14\u8BB0\u6570\u636E: NoteParamsSchema,
3073
- \u8BC4\u8BBA\u6570\u636E: CommentParamsSchema,
3074
- \u7528\u6237\u6570\u636E: UserParamsSchema,
3075
- \u7528\u6237\u7B14\u8BB0\u6570\u636E: UserNoteParamsSchema,
3076
- \u8868\u60C5\u5217\u8868: EmojiListParamsSchema,
3077
- \u641C\u7D22\u7B14\u8BB0: SearchNoteParamsSchema
3078
- };
3079
- var validateXiaohongshuParams = (methodType, params) => {
3080
- const schema = XiaohongshuValidationSchemas[methodType];
3081
- const validated = schema.parse(
3082
- typeof params === "object" && params !== null ? { methodType, ...params } : { methodType, params }
3083
- );
3084
- return validated;
3085
- };
3086
-
3087
- // src/validation/index.ts
3088
- var validateDouyinParams = (methodType, params) => {
3089
- const schema = DouyinValidationSchemas2[methodType];
3090
- const validated = schema.parse(
3091
- typeof params === "object" && params !== null ? { methodType, ...params } : { methodType, params }
3092
- );
3093
- return validated;
3094
- };
3095
- var validateBilibiliParams = (methodType, params) => {
3096
- const schema = BilibiliValidationSchemas2[methodType];
3097
- const validated = schema.parse(
3098
- typeof params === "object" && params !== null ? { methodType, ...params } : { methodType, params }
3099
- );
3100
- return validated;
3101
- };
3102
- var validateKuaishouParams = (methodType, params) => {
3103
- const schema = KuaishouValidationSchemas2[methodType];
3104
- const validated = schema.parse(
3105
- typeof params === "object" && params !== null ? { methodType, ...params } : { methodType, params }
3106
- );
3107
- return validated;
3108
- };
3109
- var createSuccessResponse = (data2, message, code = 200) => {
3110
- return {
3111
- success: true,
3112
- data: data2,
3113
- message,
3114
- code,
3115
- error: void 0
3116
- };
3117
- };
3118
- var createErrorResponse = (error, message, code = 500) => {
3119
- return {
3120
- success: false,
3121
- error,
3122
- message,
3123
- code,
3124
- data: void 0
3125
- };
3126
- };
3127
-
3128
- // src/platform/xiaohongshu/getdata.ts
3129
- var XiaohongshuData = async (data2, cookie, requestConfig) => {
3130
- const defHeaders = getXiaohongshuDefaultConfig(cookie)["headers"];
3131
- const baseRequestConfig = {
3132
- method: "POST",
3133
- timeout: 1e4,
3134
- ...requestConfig,
3135
- headers: {
3136
- ...defHeaders,
3137
- ...{}
3138
- }
3139
- };
3140
- const xiaohongshuApiUrls2 = createXiaohongshuApiUrls();
3141
- switch (data2.methodType) {
3142
- case "\u9996\u9875\u63A8\u8350\u6570\u636E": {
3143
- const homeFeedData = await GlobalGetData4(data2.methodType, {
3144
- ...baseRequestConfig,
3145
- url: xiaohongshuApiUrls2.\u9996\u9875\u63A8\u8350\u6570\u636E(data2).Url,
3146
- data: JSON.stringify(xiaohongshuApiUrls2.\u9996\u9875\u63A8\u8350\u6570\u636E(data2).Body),
3147
- headers: {
3148
- ...baseRequestConfig.headers,
3149
- "x-s": xiaohongshuSign.generateXSPost(
3150
- xiaohongshuApiUrls2.\u9996\u9875\u63A8\u8350\u6570\u636E(data2).apiPath,
3151
- xiaohongshuSign.extractA1FromCookie(cookie || ""),
3152
- "xhs-pc-web",
3153
- xiaohongshuApiUrls2.\u9996\u9875\u63A8\u8350\u6570\u636E(data2).Body
3154
- ),
3155
- "x-s-common": xiaohongshuSign.generateXSCommon(),
3156
- "x-t": xiaohongshuSign.generateXT()
3157
- }
3158
- });
3159
- return homeFeedData;
3160
- }
3161
- case "\u5355\u4E2A\u7B14\u8BB0\u6570\u636E": {
3162
- const noteData = await GlobalGetData4(data2.methodType, {
3163
- ...baseRequestConfig,
3164
- url: xiaohongshuApiUrls2.\u5355\u4E2A\u7B14\u8BB0\u6570\u636E(data2).Url,
3165
- data: xiaohongshuApiUrls2.\u5355\u4E2A\u7B14\u8BB0\u6570\u636E(data2).Body,
3166
- headers: {
3167
- ...baseRequestConfig.headers,
3168
- "x-s": xiaohongshuSign.generateXSPost(
3169
- xiaohongshuApiUrls2.\u5355\u4E2A\u7B14\u8BB0\u6570\u636E(data2).apiPath,
3170
- xiaohongshuSign.extractA1FromCookie(cookie || ""),
3171
- "xhs-pc-web",
3172
- xiaohongshuApiUrls2.\u5355\u4E2A\u7B14\u8BB0\u6570\u636E(data2).Body
3173
- ),
3174
- "x-s-common": xiaohongshuSign.generateXSCommon(),
3175
- "x-t": xiaohongshuSign.generateXT()
3176
- }
3177
- });
3178
- return noteData;
3179
- }
3180
- case "\u8BC4\u8BBA\u6570\u636E": {
3181
- const baseRequestConfig2 = {
3182
- method: "GET",
3183
- timeout: 1e4,
3184
- ...requestConfig,
3185
- headers: {
3186
- ...defHeaders,
3187
- ...{}
3188
- }
3189
- };
3190
- const commentData = await GlobalGetData4(data2.methodType, {
3191
- ...baseRequestConfig2,
3192
- url: xiaohongshuApiUrls2.\u8BC4\u8BBA\u6570\u636E(data2).Url,
3193
- headers: {
3194
- ...baseRequestConfig2.headers,
3195
- "x-s": xiaohongshuSign.generateXSGet(
3196
- xiaohongshuApiUrls2.\u8BC4\u8BBA\u6570\u636E(data2).apiPath,
3197
- xiaohongshuSign.extractA1FromCookie(cookie || ""),
3198
- "xhs-pc-web"
3199
- ),
3200
- "x-s-common": xiaohongshuSign.generateXSCommon(),
3201
- "x-t": xiaohongshuSign.generateXT()
3202
- }
3203
- });
3204
- return commentData;
3205
- }
3206
- case "\u7528\u6237\u6570\u636E": {
3207
- const baseRequestConfig2 = {
3208
- method: "GET",
3209
- timeout: 1e4,
3210
- ...requestConfig,
3211
- headers: {
3212
- ...defHeaders,
3213
- ...{}
3214
- }
3215
- };
3216
- const userData = await GlobalGetData4(data2.methodType, {
3217
- ...baseRequestConfig2,
3218
- url: xiaohongshuApiUrls2.\u7528\u6237\u6570\u636E(data2).Url,
3219
- headers: {
3220
- ...baseRequestConfig2.headers,
3221
- "x-s": xiaohongshuSign.generateXSGet(
3222
- xiaohongshuApiUrls2.\u7528\u6237\u6570\u636E(data2).apiPath,
3223
- xiaohongshuSign.extractA1FromCookie(cookie || ""),
3224
- "xhs-pc-web"
3225
- ),
3226
- "x-s-common": xiaohongshuSign.generateXSCommon(),
3227
- "x-t": xiaohongshuSign.generateXT()
3228
- }
3229
- });
3230
- const pageData = extractCreatorInfoFromHtml(userData);
3231
- return {
3232
- code: 0,
3233
- data: pageData,
3234
- msg: "\u6210\u529F"
3235
- };
3236
- }
3237
- case "\u7528\u6237\u7B14\u8BB0\u6570\u636E": {
3238
- const userNoteData = await GlobalGetData4(data2.methodType, {
3239
- ...baseRequestConfig,
3240
- method: "GET",
3241
- url: xiaohongshuApiUrls2.\u7528\u6237\u7B14\u8BB0\u6570\u636E(data2).Url,
3242
- headers: {
3243
- ...baseRequestConfig.headers,
3244
- "x-b3-traceid": xiaohongshuSign.generateXB3Traceid(),
3245
- "x-s": xiaohongshuSign.generateXSGet(
3246
- xiaohongshuApiUrls2.\u7528\u6237\u7B14\u8BB0\u6570\u636E(data2).apiPath,
3247
- xiaohongshuSign.extractA1FromCookie(cookie || ""),
3248
- "xhs-pc-web"
3249
- ),
3250
- "x-s-common": xiaohongshuSign.generateXSCommon(),
3251
- "x-t": xiaohongshuSign.generateXT()
3252
- }
3253
- });
3254
- return userNoteData;
3255
- }
3256
- case "\u8868\u60C5\u5217\u8868": {
3257
- const baseRequestConfig2 = {
3258
- method: "GET",
3259
- timeout: 1e4,
3260
- ...requestConfig,
3261
- headers: {
3262
- ...defHeaders,
3263
- ...{}
3264
- }
3265
- };
3266
- const emojiListData = await GlobalGetData4(data2.methodType, {
3267
- ...baseRequestConfig2,
3268
- url: xiaohongshuApiUrls2.\u8868\u60C5\u5217\u8868(data2).Url,
3269
- headers: {
3270
- ...baseRequestConfig2.headers,
3271
- "x-s": xiaohongshuSign.generateXSGet(
3272
- xiaohongshuApiUrls2.\u8868\u60C5\u5217\u8868(data2).apiPath,
3273
- xiaohongshuSign.extractA1FromCookie(cookie || ""),
3274
- "xhs-pc-web"
3275
- ),
3276
- "x-s-common": xiaohongshuSign.generateXSCommon(),
3277
- "x-t": xiaohongshuSign.generateXT()
3278
- }
3279
- });
3280
- return emojiListData;
3281
- }
3282
- case "\u641C\u7D22\u7B14\u8BB0": {
3283
- const searchNoteData = await GlobalGetData4(data2.methodType, {
3284
- ...baseRequestConfig,
3285
- url: xiaohongshuApiUrls2.\u641C\u7D22\u7B14\u8BB0(data2).Url,
3286
- data: xiaohongshuApiUrls2.\u641C\u7D22\u7B14\u8BB0(data2).Body,
3287
- headers: {
3288
- ...baseRequestConfig.headers,
3289
- "x-s": xiaohongshuSign.generateXSPost(
3290
- xiaohongshuApiUrls2.\u641C\u7D22\u7B14\u8BB0(data2).apiPath,
3291
- xiaohongshuSign.extractA1FromCookie(cookie || ""),
3292
- "xhs-pc-web"
3293
- ),
3294
- "x-s-common": xiaohongshuSign.generateXSCommon(),
3295
- "x-t": xiaohongshuSign.generateXT()
3296
- }
3297
- });
3298
- return searchNoteData;
3299
- }
3300
- default:
3301
- throw new Error(`\u672A\u77E5\u7684\u5C0F\u7EA2\u4E66\u6570\u636E\u63A5\u53E3: \u300C${logger.red(data2.methodType)}\u300D`);
3302
- }
3303
- };
3304
- var GlobalGetData4 = async (methodType, config) => {
3305
- var _a;
3306
- try {
3307
- const response = await fetchData(config);
3308
- if (typeof response === "string" && response.includes("<html>")) {
3309
- return response;
3310
- }
3311
- if (response.code !== 0) {
3312
- throw new Error(`API\u8BF7\u6C42\u5931\u8D25: ${((_a = response.data) == null ? void 0 : _a.msg) || response.msg || "\u672A\u77E5\u9519\u8BEF"}, code: ${response.code}`);
3313
- }
3314
- return response;
3315
- } catch (error) {
3316
- logger.error(`\u5C0F\u7EA2\u4E66API\u8BF7\u6C42\u5931\u8D25 [${methodType}]:`, error.message);
3317
- const errorDetail = {
3318
- errorDescription: error.message || "\u672A\u77E5\u9519\u8BEF",
3319
- requestType: methodType,
3320
- requestUrl: config.url || ""
3321
- };
3322
- return {
3323
- code: 500,
3324
- message: "error",
3325
- data: null,
3326
- amagiError: errorDetail,
3327
- amagiMessage: `\u5C0F\u7EA2\u4E66API\u8BF7\u6C42\u5931\u8D25: ${error.message}`
3328
- };
3329
- }
3330
- };
3331
-
3332
- // src/model/DataFetchers.ts
3333
- async function getDouyinData(methodType, optionsOrCookie, cookieOrOptions, requestConfig) {
3334
- try {
3335
- let options;
3336
- let cookie;
3337
- let config;
3338
- if (typeof optionsOrCookie === "string") {
3339
- cookie = optionsOrCookie;
3340
- options = cookieOrOptions;
3341
- config = requestConfig;
3342
- } else {
3343
- options = optionsOrCookie;
3344
- cookie = cookieOrOptions;
3345
- config = requestConfig;
3346
- }
3347
- const { typeMode: _, ...validationOptions } = options || {};
3348
- const validatedParams = validateDouyinParams(methodType, validationOptions);
3349
- const apiParams = {
3350
- ...validatedParams
3351
- };
3352
- const rawData = await DouyinData(apiParams, cookie, config);
3353
- if (rawData.data === "" || rawData.status_code !== 0) {
3354
- return createErrorResponse(rawData.amagiError, rawData.status_msg || "\u6296\u97F3\u6570\u636E\u83B7\u53D6\u5931\u8D25");
3355
- }
3356
- return createSuccessResponse(rawData, "\u83B7\u53D6\u6210\u529F", 200);
3357
- } catch (error) {
3358
- const errorMessage = error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF";
3359
- throw new Error(`\u6296\u97F3\u6570\u636E\u83B7\u53D6\u5931\u8D25: ${errorMessage}`);
3360
- }
3361
- }
3362
- async function getBilibiliData(methodType, optionsOrCookie, cookieOrOptions, requestConfig) {
3363
- try {
3364
- let options;
3365
- let cookie;
3366
- if (typeof optionsOrCookie === "string") {
3367
- cookie = optionsOrCookie;
3368
- options = cookieOrOptions;
3369
- } else {
3370
- options = optionsOrCookie;
3371
- cookie = cookieOrOptions;
3372
- }
3373
- const { typeMode: _, ...validationOptions } = options || {};
3374
- const validatedParams = validateBilibiliParams(methodType, validationOptions);
3375
- const apiParams = {
3376
- ...validatedParams
3377
- };
3378
- const rawData = await fetchBilibili(apiParams, cookie);
3379
- if (rawData.code !== 0) {
3380
- return createErrorResponse(rawData.amagiError, "B\u7AD9\u6570\u636E\u83B7\u53D6\u5931\u8D25");
3381
- }
3382
- return createSuccessResponse(rawData, "\u83B7\u53D6\u6210\u529F", 200);
3383
- } catch (error) {
3384
- const errorMessage = error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF";
3385
- throw new Error(`B\u7AD9\u6570\u636E\u83B7\u53D6\u5931\u8D25: ${errorMessage}`);
3386
- }
3387
- }
3388
- async function getKuaishouData(methodType, optionsOrCookie, cookieOrOptions, requestConfig) {
3389
- try {
3390
- let options;
3391
- let cookie;
3392
- if (typeof optionsOrCookie === "string") {
3393
- cookie = optionsOrCookie;
3394
- options = cookieOrOptions;
3395
- } else {
3396
- options = optionsOrCookie;
3397
- cookie = cookieOrOptions;
3398
- }
3399
- const { typeMode: _, ...validationOptions } = options || {};
3400
- const validatedParams = validateKuaishouParams(methodType, validationOptions);
3401
- const apiParams = {
3402
- ...validatedParams
3403
- };
3404
- const rawData = await KuaishouData(apiParams, cookie);
3405
- if (rawData.code && Object.values(kuaishouAPIErrorCode).includes(rawData.code)) {
3406
- return createErrorResponse(rawData.amagiError, "\u5FEB\u624B\u6570\u636E\u83B7\u53D6\u5931\u8D25");
3407
- }
3408
- return createSuccessResponse(rawData, "\u83B7\u53D6\u6210\u529F", 200);
3409
- } catch (error) {
3410
- const errorMessage = error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF";
3411
- throw new Error(`\u5FEB\u624B\u6570\u636E\u83B7\u53D6\u5931\u8D25: ${errorMessage}`);
3412
- }
3413
- }
3414
- async function getXiaohongshuData(methodType, optionsOrCookie, cookieOrOptions, requestConfig) {
3415
- try {
3416
- let options;
3417
- let cookie;
3418
- if (typeof optionsOrCookie === "string") {
3419
- cookie = optionsOrCookie;
3420
- options = cookieOrOptions;
3421
- } else {
3422
- options = optionsOrCookie;
3423
- cookie = cookieOrOptions;
3424
- }
3425
- const { typeMode: _, ...validationOptions } = options || {};
3426
- const validatedParams = validateXiaohongshuParams(methodType, validationOptions);
3427
- const apiParams = {
3428
- ...validatedParams
3429
- };
3430
- const rawData = await XiaohongshuData(apiParams, cookie);
3431
- if (rawData.code && Object.values(xiaohongshuAPIErrorCode).includes(rawData.code)) {
3432
- return createErrorResponse(rawData.amagiError, "\u5C0F\u7EA2\u4E66\u6570\u636E\u83B7\u53D6\u5931\u8D25");
3433
- }
3434
- return createSuccessResponse(rawData, "\u83B7\u53D6\u6210\u529F", 200);
3435
- } catch (error) {
3436
- const errorMessage = error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF";
3437
- throw new Error(`\u5C0F\u7EA2\u4E66\u6570\u636E\u83B7\u53D6\u5931\u8D25: ${errorMessage}`);
3438
- }
3439
- }
3440
-
3441
- // src/platform/bilibili/BilibiliApi.ts
3442
- var createBilibiliApiMethod = (methodType) => {
3443
- return async (options, cookie) => {
3444
- return await getBilibiliData(methodType, options, cookie);
3445
- };
3446
- };
3447
- var createBoundBilibiliApiMethod = (methodType, cookie) => {
3448
- return async (options) => {
3449
- return await getBilibiliData(methodType, options, cookie);
3450
- };
3451
- };
3452
- var bilibili = {
3453
- /**
3454
- * 获取单个视频作品数据
3455
- * @param options 请求参数,包含 bvid 和可选的 typeMode
3456
- * @param cookie 有效的用户 Cookie
3457
- * @returns 统一格式的API响应
3458
- */
3459
- getVideoInfo: createBilibiliApiMethod("\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E"),
3460
- /**
3461
- * 获取单个视频下载信息数据
3462
- * @param options 请求参数,包含 avid, cid 和可选的 typeMode
3463
- * @param cookie 有效的用户 Cookie
3464
- * @returns 统一格式的API响应
3465
- */
3466
- getVideoStream: createBilibiliApiMethod("\u5355\u4E2A\u89C6\u9891\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E"),
3467
- /**
3468
- * 获取评论数据
3469
- * @param options 请求参数,包含 type, oid, 可选的 number, pn 和 typeMode
3470
- * @param cookie 有效的用户 Cookie
3471
- * @returns 统一格式的API响应
3472
- */
3473
- getComments: createBilibiliApiMethod("\u8BC4\u8BBA\u6570\u636E"),
3474
- /**
3475
- * 获取用户主页数据
3476
- * @param options 请求参数,包含 host_mid 和可选的 typeMode
3477
- * @param cookie 有效的用户 Cookie
3478
- * @returns 统一格式的API响应
3479
- */
3480
- getUserProfile: createBilibiliApiMethod("\u7528\u6237\u4E3B\u9875\u6570\u636E"),
3481
- /**
3482
- * 获取用户主页动态列表数据
3483
- * @param options 请求参数,包含 host_mid 和可选的 typeMode
3484
- * @param cookie 有效的用户 Cookie
3485
- * @returns 统一格式的API响应
3486
- */
3487
- getUserDynamic: createBilibiliApiMethod("\u7528\u6237\u4E3B\u9875\u52A8\u6001\u5217\u8868\u6570\u636E"),
3488
- /**
3489
- * 获取 Emoji 数据
3490
- * @param options 可选的请求参数 (主要用于 typeMode)
3491
- * @param cookie 有效的用户 Cookie
3492
- * @returns 统一格式的API响应
3493
- */
3494
- getEmojiList: createBilibiliApiMethod("Emoji\u6570\u636E"),
3495
- /**
3496
- * 获取番剧基本信息数据
3497
- * @param options 请求参数,包含可选的 season_id, ep_id 和 typeMode
3498
- * @param cookie 有效的用户 Cookie
3499
- * @returns 统一格式的API响应
3500
- */
3501
- getBangumiInfo: createBilibiliApiMethod("\u756A\u5267\u57FA\u672C\u4FE1\u606F\u6570\u636E"),
3502
- /**
3503
- * 获取番剧下载信息数据
3504
- * @param options 请求参数,包含 cid, ep_id 和可选的 typeMode
3505
- * @param cookie 有效的用户 Cookie
3506
- * @returns 统一格式的API响应
3507
- */
3508
- getBangumiStream: createBilibiliApiMethod("\u756A\u5267\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E"),
3509
- /**
3510
- * 获取动态详情数据
3511
- * @param options 请求参数,包含 dynamic_id 和可选的 typeMode
3512
- * @param cookie 有效的用户 Cookie
3513
- * @returns 统一格式的API响应
3514
- */
3515
- getDynamicInfo: createBilibiliApiMethod("\u52A8\u6001\u8BE6\u60C5\u6570\u636E"),
3516
- /**
3517
- * 获取动态卡片数据
3518
- * @param options 请求参数,包含 dynamic_id 和可选的 typeMode
3519
- * @param cookie 有效的用户 Cookie
3520
- * @returns 统一格式的API响应
3521
- */
3522
- getDynamicCard: createBilibiliApiMethod("\u52A8\u6001\u5361\u7247\u6570\u636E"),
3523
- /**
3524
- * 获取直播间信息
3525
- * @param options 请求参数,包含 room_id 和可选的 typeMode
3526
- * @param cookie 有效的用户 Cookie
3527
- * @returns 统一格式的API响应
3528
- */
3529
- getLiveRoomDetail: createBilibiliApiMethod("\u76F4\u64AD\u95F4\u4FE1\u606F"),
3530
- /**
3531
- * 获取直播间初始化信息
3532
- * @param options 请求参数,包含 room_id 和可选的 typeMode
3533
- * @param cookie 有效的用户 Cookie
3534
- * @returns 统一格式的API响应
3535
- */
3536
- getLiveRoomInitInfo: createBilibiliApiMethod("\u76F4\u64AD\u95F4\u521D\u59CB\u5316\u4FE1\u606F"),
3537
- /**
3538
- * 获取登录基本信息
3539
- * @param options 可选的请求参数 (主要用于 typeMode)
3540
- * @param cookie 有效的用户 Cookie
3541
- * @returns 统一格式的API响应
3542
- */
3543
- getLoginBasicInfo: createBilibiliApiMethod("\u767B\u5F55\u57FA\u672C\u4FE1\u606F"),
3544
- /**
3545
- * 申请登录二维码
3546
- * @param options 可选的请求参数 (主要用于 typeMode)
3547
- * @param cookie 有效的用户 Cookie
3548
- * @returns 统一格式的API响应
3549
- */
3550
- getLoginQrcode: createBilibiliApiMethod("\u7533\u8BF7\u4E8C\u7EF4\u7801"),
3551
- /**
3552
- * 检查二维码状态
3553
- * @param options 请求参数,包含 qrcode_key 和可选的 typeMode
3554
- * @param cookie 有效的用户 Cookie
3555
- * @returns 统一格式的API响应
3556
- */
3557
- checkQrcodeStatus: createBilibiliApiMethod("\u4E8C\u7EF4\u7801\u72B6\u6001"),
3558
- /**
3559
- * 获取 UP 主总播放量
3560
- * @param options 请求参数,包含 host_mid 和可选的 typeMode
3561
- * @param cookie 有效的用户 Cookie
3562
- * @returns 统一格式的API响应
3563
- */
3564
- getUserTotalPlayCount: createBilibiliApiMethod("\u83B7\u53D6UP\u4E3B\u603B\u64AD\u653E\u91CF"),
3565
- /**
3566
- * 将 AV 号转换为 BV 号
3567
- * @param options 请求参数,包含 avid 和可选的 typeMode
3568
- * @param cookie 有效的用户 Cookie (此接口通常不需要)
3569
- * @returns 统一格式的API响应
3570
- */
3571
- convertAvToBv: createBilibiliApiMethod("AV\u8F6CBV"),
3572
- /**
3573
- * 将 BV 号转换为 AV 号
3574
- * @param options 请求参数,包含 bvid 和可选的 typeMode
3575
- * @param cookie 有效的用户 Cookie (此接口通常不需要)
3576
- * @returns 统一格式的API响应
3577
- */
3578
- convertBvToAv: createBilibiliApiMethod("BV\u8F6CAV")
3579
- };
3580
- var createBoundBilibiliApi = (cookie, requestConfig) => {
3581
- return {
3582
- /**
3583
- * 获取单个视频作品数据
3584
- * @param options 请求参数,包含 bvid 和可选的 typeMode
3585
- * @returns 统一格式的API响应
3586
- */
3587
- getVideoInfo: createBoundBilibiliApiMethod("\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E", cookie),
3588
- /**
3589
- * 获取单个视频下载信息数据
3590
- * @param options 请求参数,包含 avid, cid 和可选的 typeMode
3591
- * @returns 统一格式的API响应
3592
- */
3593
- getVideoStream: createBoundBilibiliApiMethod("\u5355\u4E2A\u89C6\u9891\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E", cookie),
3594
- /**
3595
- * 获取评论数据
3596
- * @param options 请求参数,包含 type, oid, 可选的 number, pn 和 typeMode
3597
- * @returns 统一格式的API响应
3598
- */
3599
- getComments: createBoundBilibiliApiMethod("\u8BC4\u8BBA\u6570\u636E", cookie),
3600
- /**
3601
- * 获取用户主页数据
3602
- * @param options 请求参数,包含 host_mid 和可选的 typeMode
3603
- * @returns 统一格式的API响应
3604
- */
3605
- getUserProfile: createBoundBilibiliApiMethod("\u7528\u6237\u4E3B\u9875\u6570\u636E", cookie),
3606
- /**
3607
- * 获取用户主页动态列表数据
3608
- * @param options 请求参数,包含 host_mid 和可选的 typeMode
3609
- * @returns 统一格式的API响应
3610
- */
3611
- getUserDynamic: createBoundBilibiliApiMethod("\u7528\u6237\u4E3B\u9875\u52A8\u6001\u5217\u8868\u6570\u636E", cookie),
3612
- /**
3613
- * 获取 Emoji 数据
3614
- * @param options 可选的请求参数 (主要用于 typeMode)
3615
- * @returns 统一格式的API响应
3616
- */
3617
- getEmojiList: createBoundBilibiliApiMethod("Emoji\u6570\u636E", cookie),
3618
- /**
3619
- * 获取番剧基本信息数据
3620
- * @param options 请求参数,包含可选的 season_id, ep_id 和 typeMode
3621
- * @returns 统一格式的API响应
3622
- */
3623
- getBangumiInfo: createBoundBilibiliApiMethod("\u756A\u5267\u57FA\u672C\u4FE1\u606F\u6570\u636E", cookie),
3624
- /**
3625
- * 获取番剧下载信息数据
3626
- * @param options 请求参数,包含 cid, ep_id 和可选的 typeMode
3627
- * @returns 统一格式的API响应
3628
- */
3629
- getBangumiStream: createBoundBilibiliApiMethod("\u756A\u5267\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E", cookie),
3630
- /**
3631
- * 获取动态详情数据
3632
- * @param options 请求参数,包含 dynamic_id 和可选的 typeMode
3633
- * @returns 统一格式的API响应
3634
- */
3635
- getDynamicInfo: createBoundBilibiliApiMethod("\u52A8\u6001\u8BE6\u60C5\u6570\u636E", cookie),
3636
- /**
3637
- * 获取动态卡片数据
3638
- * @param options 请求参数,包含 dynamic_id 和可选的 typeMode
3639
- * @returns 统一格式的API响应
3640
- */
3641
- getDynamicCard: createBoundBilibiliApiMethod("\u52A8\u6001\u5361\u7247\u6570\u636E", cookie),
3642
- /**
3643
- * 获取直播间信息
3644
- * @param options 请求参数,包含 room_id 和可选的 typeMode
3645
- * @returns 统一格式的API响应
3646
- */
3647
- getLiveRoomDetail: createBoundBilibiliApiMethod("\u76F4\u64AD\u95F4\u4FE1\u606F", cookie),
3648
- /**
3649
- * 获取直播间初始化信息
3650
- * @param options 请求参数,包含 room_id 和可选的 typeMode
3651
- * @returns 统一格式的API响应
3652
- */
3653
- getLiveRoomInitInfo: createBoundBilibiliApiMethod("\u76F4\u64AD\u95F4\u521D\u59CB\u5316\u4FE1\u606F", cookie),
3654
- /**
3655
- * 获取登录基本信息
3656
- * @param options 可选的请求参数 (主要用于 typeMode)
3657
- * @returns 统一格式的API响应
3658
- */
3659
- getLoginBasicInfo: createBoundBilibiliApiMethod("\u767B\u5F55\u57FA\u672C\u4FE1\u606F", cookie),
3660
- /**
3661
- * 申请登录二维码
3662
- * @param options 可选的请求参数 (主要用于 typeMode)
3663
- * @returns 统一格式的API响应
3664
- */
3665
- getLoginQrcode: createBoundBilibiliApiMethod("\u7533\u8BF7\u4E8C\u7EF4\u7801", cookie),
3666
- /**
3667
- * 检查二维码状态
3668
- * @param options 请求参数,包含 qrcode_key 和可选的 typeMode
3669
- * @returns 统一格式的API响应
3670
- */
3671
- checkQrcodeStatus: createBoundBilibiliApiMethod("\u4E8C\u7EF4\u7801\u72B6\u6001", cookie),
3672
- /**
3673
- * 获取 UP 主总播放量
3674
- * @param options 请求参数,包含 host_mid 和可选的 typeMode
3675
- * @returns 统一格式的API响应
3676
- */
3677
- getUserTotalPlayCount: createBoundBilibiliApiMethod("\u83B7\u53D6UP\u4E3B\u603B\u64AD\u653E\u91CF", cookie),
3678
- /**
3679
- * 将 AV 号转换为 BV 号
3680
- * @param options 请求参数,包含 avid 和可选的 typeMode
3681
- * @returns 统一格式的API响应
3682
- */
3683
- convertAvToBv: createBoundBilibiliApiMethod("AV\u8F6CBV", cookie),
3684
- /**
3685
- * 将 BV 号转换为 AV 号
3686
- * @param options 请求参数,包含 bvid 和可选的 typeMode
3687
- * @returns 统一格式的API响应
3688
- */
3689
- convertBvToAv: createBoundBilibiliApiMethod("BV\u8F6CAV", cookie)
3690
- };
3691
- };
3692
- var ApiError = class extends Error {
3693
- code;
3694
- platform;
3695
- /**
3696
- * 构造API错误
3697
- * @param message - 错误消息
3698
- * @param code - 错误代码
3699
- * @param platform - 平台名称
3700
- */
3701
- constructor(message, code = 500, platform = "unknown") {
3702
- super(message);
3703
- this.name = "ApiError";
3704
- this.code = code;
3705
- this.platform = platform;
3706
- }
3707
- };
3708
- var ValidationError = class _ValidationError extends Error {
3709
- errors;
3710
- requestPath;
3711
- /**
3712
- * 构造参数验证错误
3713
- * @param message - 错误消息
3714
- * @param errors - 详细错误信息
3715
- * @param requestPath - HTTP请求路径
3716
- */
3717
- constructor(message, errors, requestPath) {
3718
- super(message);
3719
- this.name = "ValidationError";
3720
- this.errors = errors;
3721
- this.requestPath = requestPath;
3722
- }
3723
- /**
3724
- * 从Zod错误创建验证错误
3725
- * @param zodError - Zod验证错误
3726
- * @param requestPath - HTTP请求路径
3727
- * @returns 验证错误实例
3728
- */
3729
- static fromZodError(zodError, requestPath) {
3730
- const errors = zodError.issues.map((err) => ({
3731
- field: err.path.join("."),
3732
- message: err.message
3733
- }));
3734
- return new _ValidationError("\u53C2\u6570\u9A8C\u8BC1\u5931\u8D25", errors, requestPath);
3735
- }
3736
- };
3737
- var handleError = (error, requestPath) => {
3738
- if (error instanceof ValidationError) {
3739
- return {
3740
- code: 400,
3741
- message: error.message,
3742
- data: null,
3743
- errors: error.errors,
3744
- requestPath: error.requestPath || requestPath
3745
- };
3746
- }
3747
- if (error instanceof ApiError) {
3748
- return {
3749
- code: error.code,
3750
- message: error.message,
3751
- data: null,
3752
- platform: error.platform,
3753
- requestPath
3754
- };
3755
- }
3756
- if (error instanceof z.ZodError) {
3757
- const validationError = ValidationError.fromZodError(error, requestPath);
3758
- return handleError(validationError, requestPath);
3759
- }
3760
- const errorMessage = error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF";
3761
- return {
3762
- code: 500,
3763
- message: errorMessage,
3764
- data: null,
3765
- requestPath
3766
- };
3767
- };
3768
-
3769
- // src/middleware/validation.ts
3770
- var createValidationMiddleware = (validateFn, methodType) => {
3771
- return (req, res, next) => {
3772
- try {
3773
- const params = { ...req.query, ...req.body };
3774
- const validatedParams = validateFn(methodType, params);
3775
- req.validatedParams = validatedParams;
3776
- next();
3777
- } catch (error) {
3778
- const errorResponse = handleError(error, req.originalUrl);
3779
- res.status(errorResponse.code || 500).json(errorResponse);
3780
- }
3781
- };
3782
- };
3783
- var createDouyinValidationMiddleware = (methodType) => createValidationMiddleware(validateDouyinParams, methodType);
3784
- var createBilibiliValidationMiddleware = (methodType) => createValidationMiddleware(validateBilibiliParams, methodType);
3785
- var createKuaishouValidationMiddleware = (methodType) => createValidationMiddleware(validateKuaishouParams, methodType);
3786
- var createXiaohongshuValidationMiddleware = (methodType) => createValidationMiddleware(validateXiaohongshuParams, methodType);
3787
- var createBilibiliRouteHandler = (dataFetcher, methodType, cookie, requestConfig = getBilibiliDefaultConfig(cookie)) => {
3788
- return async (req, res) => {
3789
- try {
3790
- const result = await dataFetcher(methodType, req.validatedParams, cookie, requestConfig);
3791
- res.json({
3792
- ...result,
3793
- requestPath: req.originalUrl
3794
- });
3795
- } catch (error) {
3796
- const errorResponse = handleError(error);
3797
- res.status(errorResponse.code || 500).json({
3798
- ...errorResponse,
3799
- requestPath: req.originalUrl
3800
- });
3801
- }
3802
- };
3803
- };
3804
- var createBilibiliRoutes = (cookie, requestConfig = getBilibiliDefaultConfig(cookie)) => {
3805
- const router = Router();
3806
- router.get(
3807
- "/fetch_one_video",
3808
- createBilibiliValidationMiddleware("\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E"),
3809
- createBilibiliRouteHandler(getBilibiliData, "\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E", cookie, requestConfig)
3810
- );
3811
- router.get(
3812
- "/fetch_video_playurl",
3813
- createBilibiliValidationMiddleware("\u5355\u4E2A\u89C6\u9891\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E"),
3814
- createBilibiliRouteHandler(getBilibiliData, "\u5355\u4E2A\u89C6\u9891\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E", cookie, requestConfig)
3815
- );
3816
- router.get(
3817
- "/fetch_work_comments",
3818
- createBilibiliValidationMiddleware("\u8BC4\u8BBA\u6570\u636E"),
3819
- createBilibiliRouteHandler(getBilibiliData, "\u8BC4\u8BBA\u6570\u636E", cookie, requestConfig)
3820
- );
3821
- router.get(
3822
- "/fetch_user_profile",
3823
- createBilibiliValidationMiddleware("\u7528\u6237\u4E3B\u9875\u6570\u636E"),
3824
- createBilibiliRouteHandler(getBilibiliData, "\u7528\u6237\u4E3B\u9875\u6570\u636E", cookie, requestConfig)
3825
- );
3826
- router.get(
3827
- "/fetch_user_dynamic",
3828
- createBilibiliValidationMiddleware("\u7528\u6237\u4E3B\u9875\u52A8\u6001\u5217\u8868\u6570\u636E"),
3829
- createBilibiliRouteHandler(getBilibiliData, "\u7528\u6237\u4E3B\u9875\u52A8\u6001\u5217\u8868\u6570\u636E", cookie, requestConfig)
3830
- );
3831
- router.get(
3832
- "/fetch_emoji_list",
3833
- createBilibiliValidationMiddleware("Emoji\u6570\u636E"),
3834
- createBilibiliRouteHandler(getBilibiliData, "Emoji\u6570\u636E", cookie, requestConfig)
3835
- );
3836
- router.get(
3837
- "/fetch_bangumi_video_info",
3838
- createBilibiliValidationMiddleware("\u756A\u5267\u57FA\u672C\u4FE1\u606F\u6570\u636E"),
3839
- createBilibiliRouteHandler(getBilibiliData, "\u756A\u5267\u57FA\u672C\u4FE1\u606F\u6570\u636E", cookie, requestConfig)
3840
- );
3841
- router.get(
3842
- "/fetch_bangumi_video_playurl",
3843
- createBilibiliValidationMiddleware("\u756A\u5267\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E"),
3844
- createBilibiliRouteHandler(getBilibiliData, "\u756A\u5267\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E", cookie, requestConfig)
3845
- );
3846
- router.get(
3847
- "/fetch_dynamic_info",
3848
- createBilibiliValidationMiddleware("\u52A8\u6001\u8BE6\u60C5\u6570\u636E"),
3849
- createBilibiliRouteHandler(getBilibiliData, "\u52A8\u6001\u8BE6\u60C5\u6570\u636E", cookie, requestConfig)
3850
- );
3851
- router.get(
3852
- "/fetch_dynamic_card",
3853
- createBilibiliValidationMiddleware("\u52A8\u6001\u5361\u7247\u6570\u636E"),
3854
- createBilibiliRouteHandler(getBilibiliData, "\u52A8\u6001\u5361\u7247\u6570\u636E", cookie, requestConfig)
3855
- );
3856
- router.get(
3857
- "/fetch_live_room_detail",
3858
- createBilibiliValidationMiddleware("\u76F4\u64AD\u95F4\u4FE1\u606F"),
3859
- createBilibiliRouteHandler(getBilibiliData, "\u76F4\u64AD\u95F4\u4FE1\u606F", cookie, requestConfig)
3860
- );
3861
- router.get(
3862
- "/fetch_liveroom_def",
3863
- createBilibiliValidationMiddleware("\u76F4\u64AD\u95F4\u521D\u59CB\u5316\u4FE1\u606F"),
3864
- createBilibiliRouteHandler(getBilibiliData, "\u76F4\u64AD\u95F4\u521D\u59CB\u5316\u4FE1\u606F", cookie, requestConfig)
3865
- );
3866
- router.get(
3867
- "/login_basic_info",
3868
- createBilibiliValidationMiddleware("\u767B\u5F55\u57FA\u672C\u4FE1\u606F"),
3869
- createBilibiliRouteHandler(getBilibiliData, "\u767B\u5F55\u57FA\u672C\u4FE1\u606F", cookie, requestConfig)
3870
- );
3871
- router.get(
3872
- "/new_login_qrcode",
3873
- createBilibiliValidationMiddleware("\u7533\u8BF7\u4E8C\u7EF4\u7801"),
3874
- createBilibiliRouteHandler(getBilibiliData, "\u7533\u8BF7\u4E8C\u7EF4\u7801", cookie, requestConfig)
3875
- );
3876
- router.get(
3877
- "/check_qrcode",
3878
- createBilibiliValidationMiddleware("\u4E8C\u7EF4\u7801\u72B6\u6001"),
3879
- createBilibiliRouteHandler(getBilibiliData, "\u4E8C\u7EF4\u7801\u72B6\u6001", cookie, requestConfig)
3880
- );
3881
- router.get(
3882
- "/fetch_user_full_view",
3883
- createBilibiliValidationMiddleware("\u83B7\u53D6UP\u4E3B\u603B\u64AD\u653E\u91CF"),
3884
- createBilibiliRouteHandler(getBilibiliData, "\u83B7\u53D6UP\u4E3B\u603B\u64AD\u653E\u91CF", cookie, requestConfig)
3885
- );
3886
- router.get(
3887
- "/av_to_bv",
3888
- createBilibiliValidationMiddleware("AV\u8F6CBV"),
3889
- createBilibiliRouteHandler(getBilibiliData, "AV\u8F6CBV", cookie, requestConfig)
3890
- );
3891
- router.get(
3892
- "/bv_to_av",
3893
- createBilibiliValidationMiddleware("BV\u8F6CAV"),
3894
- createBilibiliRouteHandler(getBilibiliData, "BV\u8F6CAV", cookie, requestConfig)
3895
- );
3896
- return router;
3897
- };
3898
-
3899
- // src/platform/bilibili/index.ts
3900
- var bilibiliUtils = {
3901
- sign: {
3902
- wbi_sign,
3903
- av2bv,
3904
- bv2av
3905
- },
3906
- bilibiliApiUrls,
3907
- api: bilibili
3908
- };
3909
-
3910
- // src/platform/douyin/DouyinApi.ts
3911
- var createDouyinApiMethod = (methodType) => {
3912
- return async (options, cookie, requestConfig) => {
3913
- return await getDouyinData(methodType, options, cookie, requestConfig);
3914
- };
3915
- };
3916
- var createBoundDouyinApiMethod = (methodType, cookie, requestConfig) => {
3917
- return async (options) => {
3918
- return await getDouyinData(methodType, options, cookie, requestConfig);
3919
- };
3920
- };
3921
- var douyin = {
3922
- /**
3923
- * 获取文字作品数据
3924
- * @param options 请求参数,包含 aweme_id 和可选的 typeMode
3925
- * @param cookie 有效的用户 Cookie
3926
- * @returns 统一格式的API响应,包含文字作品详细信息
3927
- */
3928
- getTextWorkInfo: createDouyinApiMethod("\u6587\u5B57\u4F5C\u54C1\u6570\u636E"),
3929
- /**
3930
- * 聚合解析 (视频/图集/合辑)
3931
- * @param options 请求参数,包含 aweme_id 和可选的 typeMode
3932
- * @param cookie 有效的用户 Cookie
3933
- * @returns 统一格式的API响应,包含视频、图集或合辑数据
3934
- */
3935
- getWorkInfo: createDouyinApiMethod("\u805A\u5408\u89E3\u6790"),
3936
- /**
3937
- * 获取视频作品数据
3938
- * @param options 请求参数,包含 aweme_id 和可选的 typeMode
3939
- * @param cookie 有效的用户 Cookie
3940
- * @returns 统一格式的API响应,包含视频作品详细信息
3941
- */
3942
- getVideoWorkInfo: createDouyinApiMethod("\u89C6\u9891\u4F5C\u54C1\u6570\u636E"),
3943
- /**
3944
- * 获取图集作品数据
3945
- * @param options 请求参数,包含 aweme_id 和可选的 typeMode
3946
- * @param cookie 有效的用户 Cookie
3947
- * @returns 统一格式的API响应,包含图集作品详细信息
3948
- */
3949
- getImageAlbumWorkInfo: createDouyinApiMethod("\u56FE\u96C6\u4F5C\u54C1\u6570\u636E"),
3950
- /**
3951
- * 获取合辑作品数据
3952
- * @param options 请求参数,包含 aweme_id 和可选的 typeMode
3953
- * @param cookie 有效的用户 Cookie
3954
- * @returns 统一格式的API响应,包含合辑作品详细信息
3955
- */
3956
- getSlidesWorkInfo: createDouyinApiMethod("\u5408\u8F91\u4F5C\u54C1\u6570\u636E"),
3957
- /**
3958
- * 获取评论数据
3959
- * @param options 请求参数,包含 aweme_id, 可选的 number, cursor 和 typeMode
3960
- * @param cookie 有效的用户 Cookie
3961
- * @returns 统一格式的API响应,包含评论列表数据
3962
- */
3963
- getComments: createDouyinApiMethod("\u8BC4\u8BBA\u6570\u636E"),
3964
- /**
3965
- * 获取指定评论回复数据
3966
- * @param options 请求参数,包含 aweme_id, comment_id, 可选的 number, cursor 和 typeMode
3967
- * @param cookie 有效的用户 Cookie
3968
- * @returns 统一格式的API响应,包含评论回复数据
3969
- */
3970
- getCommentReplies: createDouyinApiMethod("\u6307\u5B9A\u8BC4\u8BBA\u56DE\u590D\u6570\u636E"),
3971
- /**
3972
- * 获取用户主页数据
3973
- * @param options 请求参数,包含 sec_uid 和可选的 typeMode
3974
- * @param cookie 有效的用户 Cookie
3975
- * @returns 统一格式的API响应,包含用户详细信息
3976
- */
3977
- getUserProfile: createDouyinApiMethod("\u7528\u6237\u4E3B\u9875\u6570\u636E"),
3978
- /**
3979
- * 获取 Emoji 数据
3980
- * @param options 可选的请求参数 (主要用于 typeMode)
3981
- * @param cookie 可选的用户 Cookie
3982
- * @returns 统一格式的API响应,包含Emoji列表数据
3983
- */
3984
- getEmojiList: createDouyinApiMethod("Emoji\u6570\u636E"),
3985
- /**
3986
- * 获取动态表情数据
3987
- * @param options 可选的请求参数 (主要用于 typeMode)
3988
- * @param cookie 有效的用户 Cookie
3989
- * @returns 统一格式的API响应,包含动态表情数据
3990
- */
3991
- getEmojiProList: createDouyinApiMethod("\u52A8\u6001\u8868\u60C5\u6570\u636E"),
3992
- /**
3993
- * 获取用户主页视频列表数据
3994
- * @param options 请求参数,包含 sec_uid, 可选的 number, max_cursor 和 typeMode
3995
- * @param cookie 有效的用户 Cookie
3996
- * @returns 统一格式的API响应,包含用户发布的视频列表
3997
- */
3998
- getUserVideos: createDouyinApiMethod("\u7528\u6237\u4E3B\u9875\u89C6\u9891\u5217\u8868\u6570\u636E"),
3999
- /**
4000
- * 获取音乐数据
4001
- * @param options 请求参数,包含 music_id 和可选的 typeMode
4002
- * @param cookie 有效的用户 Cookie
4003
- * @returns 统一格式的API响应,包含音乐详细信息
4004
- */
4005
- getMusicInfo: createDouyinApiMethod("\u97F3\u4E50\u6570\u636E"),
4006
- /**
4007
- * 获取热点词数据
4008
- * @param options 请求参数,包含 query, 可选的 number 和 typeMode
4009
- * @param cookie 有效的用户 Cookie
4010
- * @returns 统一格式的API响应,包含热点搜索词列表
4011
- */
4012
- getSuggestWords: createDouyinApiMethod("\u70ED\u70B9\u8BCD\u6570\u636E"),
4013
- /**
4014
- * 获取搜索数据
4015
- * @param options 请求参数,包含 query, 可选的 number, search_id, cursor 和 typeMode
4016
- * @param cookie 有效的用户 Cookie
4017
- * @returns 统一格式的API响应,包含搜索结果数据
4018
- */
4019
- search: createDouyinApiMethod("\u641C\u7D22\u6570\u636E"),
4020
- /**
4021
- * 获取直播间信息
4022
- * @param options 请求参数,包含 sec_uid 和可选的 typeMode
4023
- * @param cookie 有效的用户 Cookie
4024
- * @returns 统一格式的API响应,包含直播间详细信息
4025
- */
4026
- getLiveRoomInfo: createDouyinApiMethod("\u76F4\u64AD\u95F4\u4FE1\u606F\u6570\u636E"),
4027
- /**
4028
- * 获取弹幕数据
4029
- * @param options 请求参数,包含 aweme_id, 可选的 start_time, end_time, duration 和 typeMode
4030
- * @returns 统一格式的API响应,包含弹幕数据
4031
- */
4032
- getDanmaku: createDouyinApiMethod("\u5F39\u5E55\u6570\u636E")
4033
- };
4034
- var createBoundDouyinApi = (cookie, requestConfig) => {
4035
- return {
4036
- /**
4037
- * 获取文字作品数据
4038
- * @param options 请求参数,包含 aweme_id 和可选的 typeMode
4039
- * @returns 统一格式的API响应,包含文字作品详细信息
4040
- */
4041
- getTextWorkInfo: createBoundDouyinApiMethod("\u6587\u5B57\u4F5C\u54C1\u6570\u636E", cookie, requestConfig),
4042
- /**
4043
- * 聚合解析 (视频/图集/合辑)
4044
- * @param options 请求参数,包含 aweme_id 和可选的 typeMode
4045
- * @returns 统一格式的API响应,包含视频、图集或合辑数据
4046
- */
4047
- getWorkInfo: createBoundDouyinApiMethod("\u805A\u5408\u89E3\u6790", cookie, requestConfig),
4048
- /**
4049
- * 获取视频作品数据
4050
- * @param options 请求参数,包含 aweme_id 和可选的 typeMode
4051
- * @returns 统一格式的API响应,包含视频作品详细信息
4052
- */
4053
- getVideoWorkInfo: createBoundDouyinApiMethod("\u89C6\u9891\u4F5C\u54C1\u6570\u636E", cookie, requestConfig),
4054
- /**
4055
- * 获取图集作品数据
4056
- * @param options 请求参数,包含 aweme_id 和可选的 typeMode
4057
- * @returns 统一格式的API响应,包含图集作品详细信息
4058
- */
4059
- getImageAlbumWorkInfo: createBoundDouyinApiMethod("\u56FE\u96C6\u4F5C\u54C1\u6570\u636E", cookie, requestConfig),
4060
- /**
4061
- * 获取合辑作品数据
4062
- * @param options 请求参数,包含 aweme_id 和可选的 typeMode
4063
- * @returns 统一格式的API响应,包含合辑作品详细信息
4064
- */
4065
- getSlidesWorkInfo: createBoundDouyinApiMethod("\u5408\u8F91\u4F5C\u54C1\u6570\u636E", cookie, requestConfig),
4066
- /**
4067
- * 获取评论数据
4068
- * @param options 请求参数,包含 aweme_id, 可选的 number, cursor 和 typeMode
4069
- * @returns 统一格式的API响应,包含评论列表数据
4070
- */
4071
- getComments: createBoundDouyinApiMethod("\u8BC4\u8BBA\u6570\u636E", cookie, requestConfig),
4072
- /**
4073
- * 获取指定评论回复数据
4074
- * @param options 请求参数,包含 aweme_id, comment_id, 可选的 number, cursor 和 typeMode
4075
- * @returns 统一格式的API响应,包含评论回复数据
4076
- */
4077
- getCommentReplies: createBoundDouyinApiMethod("\u6307\u5B9A\u8BC4\u8BBA\u56DE\u590D\u6570\u636E", cookie, requestConfig),
4078
- /**
4079
- * 获取用户主页数据
4080
- * @param options 请求参数,包含 sec_uid 和可选的 typeMode
4081
- * @returns 统一格式的API响应,包含用户详细信息
4082
- */
4083
- getUserProfile: createBoundDouyinApiMethod("\u7528\u6237\u4E3B\u9875\u6570\u636E", cookie, requestConfig),
4084
- /**
4085
- * 获取 Emoji 数据
4086
- * @param options 可选的请求参数 (主要用于 typeMode)
4087
- * @returns 统一格式的API响应,包含Emoji列表数据
4088
- */
4089
- getEmojiList: createBoundDouyinApiMethod("Emoji\u6570\u636E", cookie, requestConfig),
4090
- /**
4091
- * 获取动态表情数据
4092
- * @param options 可选的请求参数 (主要用于 typeMode)
4093
- * @returns 统一格式的API响应,包含动态表情数据
4094
- */
4095
- getEmojiProList: createBoundDouyinApiMethod("\u52A8\u6001\u8868\u60C5\u6570\u636E", cookie, requestConfig),
4096
- /**
4097
- * 获取用户主页视频列表数据
4098
- * @param options 请求参数,包含 sec_uid, 可选的 number, max_cursor 和 typeMode
4099
- * @returns 统一格式的API响应,包含用户发布的视频列表
4100
- */
4101
- getUserVideos: createBoundDouyinApiMethod("\u7528\u6237\u4E3B\u9875\u89C6\u9891\u5217\u8868\u6570\u636E", cookie, requestConfig),
4102
- /**
4103
- * 获取音乐数据
4104
- * @param options 请求参数,包含 music_id 和可选的 typeMode
4105
- * @returns 统一格式的API响应,包含音乐详细信息
4106
- */
4107
- getMusicInfo: createBoundDouyinApiMethod("\u97F3\u4E50\u6570\u636E", cookie, requestConfig),
4108
- /**
4109
- * 获取热点词数据
4110
- * @param options 请求参数,包含 query, 可选的 number 和 typeMode
4111
- * @returns 统一格式的API响应,包含热点搜索词列表
4112
- */
4113
- getSuggestWords: createBoundDouyinApiMethod("\u70ED\u70B9\u8BCD\u6570\u636E", cookie, requestConfig),
4114
- /**
4115
- * 获取搜索数据
4116
- * @param options 请求参数,包含 query, 可选的 number, search_id, cursor 和 typeMode
4117
- * @returns 统一格式的API响应,包含搜索结果数据
4118
- */
4119
- search: createBoundDouyinApiMethod("\u641C\u7D22\u6570\u636E", cookie, requestConfig),
4120
- /**
4121
- * 获取直播间信息
4122
- * @param options 请求参数,包含 sec_uid 和可选的 typeMode
4123
- * @returns 统一格式的API响应,包含直播间详细信息
4124
- */
4125
- getLiveRoomInfo: createBoundDouyinApiMethod("\u76F4\u64AD\u95F4\u4FE1\u606F\u6570\u636E", cookie, requestConfig),
4126
- /**
4127
- * 获取弹幕数据
4128
- * @param options 请求参数,包含 aweme_id, 可选的 start_time, end_time, duration 和 typeMode
4129
- * @returns 统一格式的API响应,包含弹幕数据
4130
- */
4131
- getDanmaku: createBoundDouyinApiMethod("\u5F39\u5E55\u6570\u636E", cookie, requestConfig)
4132
- };
4133
- };
4134
- var createDouyinRouteHandler = (dataFetcher, methodType, cookie, requestConfig = getDouyinDefaultConfig(cookie)) => {
4135
- return async (req, res) => {
4136
- try {
4137
- const result = await dataFetcher(methodType, req.validatedParams, cookie, requestConfig);
4138
- res.json({
4139
- ...result,
4140
- requestPath: req.originalUrl
4141
- });
4142
- } catch (error) {
4143
- const errorResponse = handleError(error);
4144
- res.status(errorResponse.code || 500).json({
4145
- ...errorResponse,
4146
- requestPath: req.originalUrl
4147
- });
4148
- }
4149
- };
4150
- };
4151
- var createDouyinRoutes = (cookie, requestConfig = getDouyinDefaultConfig(cookie)) => {
4152
- const router = Router();
4153
- router.get(
4154
- "/fetch_one_work",
4155
- createDouyinValidationMiddleware("\u805A\u5408\u89E3\u6790"),
4156
- createDouyinRouteHandler(getDouyinData, "\u805A\u5408\u89E3\u6790", cookie, requestConfig)
4157
- );
4158
- router.get(
4159
- "/fetch_one_work",
4160
- createDouyinValidationMiddleware("\u89C6\u9891\u4F5C\u54C1\u6570\u636E"),
4161
- createDouyinRouteHandler(getDouyinData, "\u89C6\u9891\u4F5C\u54C1\u6570\u636E", cookie, requestConfig)
4162
- );
4163
- router.get(
4164
- "/fetch_one_work",
4165
- createDouyinValidationMiddleware("\u56FE\u96C6\u4F5C\u54C1\u6570\u636E"),
4166
- createDouyinRouteHandler(getDouyinData, "\u56FE\u96C6\u4F5C\u54C1\u6570\u636E", cookie, requestConfig)
4167
- );
4168
- router.get(
4169
- "/fetch_one_work",
4170
- createDouyinValidationMiddleware("\u5408\u8F91\u4F5C\u54C1\u6570\u636E"),
4171
- createDouyinRouteHandler(getDouyinData, "\u5408\u8F91\u4F5C\u54C1\u6570\u636E", cookie, requestConfig)
4172
- );
4173
- router.get(
4174
- "/fetch_work_comments",
4175
- createDouyinValidationMiddleware("\u8BC4\u8BBA\u6570\u636E"),
4176
- createDouyinRouteHandler(getDouyinData, "\u8BC4\u8BBA\u6570\u636E", cookie, requestConfig)
4177
- );
4178
- router.get(
4179
- "/fetch_user_info",
4180
- createDouyinValidationMiddleware("\u7528\u6237\u4E3B\u9875\u6570\u636E"),
4181
- createDouyinRouteHandler(getDouyinData, "\u7528\u6237\u4E3B\u9875\u6570\u636E", cookie, requestConfig)
4182
- );
4183
- router.get(
4184
- "/fetch_user_post_videos",
4185
- createDouyinValidationMiddleware("\u7528\u6237\u4E3B\u9875\u89C6\u9891\u5217\u8868\u6570\u636E"),
4186
- createDouyinRouteHandler(getDouyinData, "\u7528\u6237\u4E3B\u9875\u89C6\u9891\u5217\u8868\u6570\u636E", cookie, requestConfig)
4187
- );
4188
- router.get(
4189
- "/fetch_search_info",
4190
- createDouyinValidationMiddleware("\u641C\u7D22\u6570\u636E"),
4191
- createDouyinRouteHandler(getDouyinData, "\u641C\u7D22\u6570\u636E", cookie, requestConfig)
4192
- );
4193
- router.get(
4194
- "/fetch_suggest_words",
4195
- createDouyinValidationMiddleware("\u70ED\u70B9\u8BCD\u6570\u636E"),
4196
- createDouyinRouteHandler(getDouyinData, "\u70ED\u70B9\u8BCD\u6570\u636E", cookie, requestConfig)
4197
- );
4198
- router.get(
4199
- "/fetch_music_work",
4200
- createDouyinValidationMiddleware("\u97F3\u4E50\u6570\u636E"),
4201
- createDouyinRouteHandler(getDouyinData, "\u97F3\u4E50\u6570\u636E", cookie, requestConfig)
4202
- );
4203
- router.get(
4204
- "/fetch_emoji_list",
4205
- createDouyinValidationMiddleware("Emoji\u6570\u636E"),
4206
- createDouyinRouteHandler(getDouyinData, "Emoji\u6570\u636E", cookie, requestConfig)
4207
- );
4208
- router.get(
4209
- "/fetch_emoji_pro_list",
4210
- createDouyinValidationMiddleware("\u52A8\u6001\u8868\u60C5\u6570\u636E"),
4211
- createDouyinRouteHandler(getDouyinData, "\u52A8\u6001\u8868\u60C5\u6570\u636E", cookie, requestConfig)
4212
- );
4213
- router.get(
4214
- "/fetch_user_live_videos",
4215
- createDouyinValidationMiddleware("\u76F4\u64AD\u95F4\u4FE1\u606F\u6570\u636E"),
4216
- createDouyinRouteHandler(getDouyinData, "\u76F4\u64AD\u95F4\u4FE1\u606F\u6570\u636E", cookie, requestConfig)
4217
- );
4218
- router.get(
4219
- "/fetch_video_comment_replies",
4220
- createDouyinValidationMiddleware("\u6307\u5B9A\u8BC4\u8BBA\u56DE\u590D\u6570\u636E"),
4221
- createDouyinRouteHandler(getDouyinData, "\u6307\u5B9A\u8BC4\u8BBA\u56DE\u590D\u6570\u636E", cookie, requestConfig)
4222
- );
4223
- router.get(
4224
- "/fetch_work_danmaku",
4225
- createDouyinValidationMiddleware("\u5F39\u5E55\u6570\u636E"),
4226
- createDouyinRouteHandler(getDouyinData, "\u5F39\u5E55\u6570\u636E", cookie, requestConfig)
4227
- );
4228
- return router;
4229
- };
4230
-
4231
- // src/platform/douyin/index.ts
4232
- var douyinUtils = {
4233
- sign: douyinSign,
4234
- douyinApiUrls,
4235
- api: douyin
4236
- };
4237
- var createKuaishouRouteHandler = (dataFetcher, methodType, cookie, requestConfig = getKuaishouDefaultConfig(cookie)) => {
4238
- return async (req, res) => {
4239
- try {
4240
- const result = await dataFetcher(methodType, req.validatedParams, cookie, requestConfig);
4241
- res.json({
4242
- ...result,
4243
- requestPath: req.originalUrl
4244
- });
4245
- } catch (error) {
4246
- const errorResponse = handleError(error);
4247
- res.status(errorResponse.code || 500).json({
4248
- ...errorResponse,
4249
- requestPath: req.originalUrl
4250
- });
4251
- }
4252
- };
4253
- };
4254
- var createKuaishouRoutes = (cookie, requestConfig = getKuaishouDefaultConfig(cookie)) => {
4255
- const router = Router();
4256
- router.get(
4257
- "/fetch_one_work",
4258
- createKuaishouValidationMiddleware("\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E"),
4259
- createKuaishouRouteHandler(getKuaishouData, "\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E", cookie, requestConfig)
4260
- );
4261
- router.get(
4262
- "/fetch_work_comments",
4263
- createKuaishouValidationMiddleware("\u8BC4\u8BBA\u6570\u636E"),
4264
- createKuaishouRouteHandler(getKuaishouData, "\u8BC4\u8BBA\u6570\u636E", cookie, requestConfig)
4265
- );
4266
- router.get(
4267
- "/fetch_emoji_list",
4268
- createKuaishouValidationMiddleware("Emoji\u6570\u636E"),
4269
- createKuaishouRouteHandler(getKuaishouData, "Emoji\u6570\u636E", cookie, requestConfig)
4270
- );
4271
- return router;
4272
- };
4273
-
4274
- // src/platform/kuaishou/KuaishouApi.ts
4275
- var createKuaishouApiMethod = (methodType) => {
4276
- return async (options, cookie) => {
4277
- return await getKuaishouData(methodType, options, cookie);
4278
- };
4279
- };
4280
- var createBoundKuaishouApiMethod = (methodType, cookie) => {
4281
- return async (options) => {
4282
- return await getKuaishouData(methodType, options, cookie);
4283
- };
4284
- };
4285
- var kuaishou = {
4286
- /**
4287
- * 获取单个视频作品数据
4288
- * @param options 请求参数,包含 photoId 和可选的 typeMode
4289
- * @param cookie 可选的用户 Cookie
4290
- * @returns 统一格式的API响应
4291
- */
4292
- getWorkInfo: createKuaishouApiMethod("\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E"),
4293
- /**
4294
- * 获取评论数据
4295
- * @param options 请求参数,包含 photoId 和可选的 typeMode
4296
- * @param cookie 可选的用户 Cookie
4297
- * @returns 统一格式的API响应
4298
- */
4299
- getComments: createKuaishouApiMethod("\u8BC4\u8BBA\u6570\u636E"),
4300
- /**
4301
- * 获取 Emoji 数据
4302
- * @param options 可选的请求参数 (主要用于 typeMode)
4303
- * @param cookie 可选的用户 Cookie
4304
- * @returns 统一格式的API响应
4305
- */
4306
- getEmojiList: createKuaishouApiMethod("Emoji\u6570\u636E")
4307
- };
4308
- var createBoundKuaishouApi = (cookie, requestConfig) => {
4309
- return {
4310
- /**
4311
- * 获取单个视频作品数据
4312
- * @param options 请求参数,包含 photoId 和可选的 typeMode
4313
- * @returns 统一格式的API响应
4314
- */
4315
- getWorkInfo: createBoundKuaishouApiMethod("\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E", cookie),
4316
- /**
4317
- * 获取评论数据
4318
- * @param options 请求参数,包含 photoId 和可选的 typeMode
4319
- * @returns 统一格式的API响应
4320
- */
4321
- getComments: createBoundKuaishouApiMethod("\u8BC4\u8BBA\u6570\u636E", cookie),
4322
- /**
4323
- * 获取 Emoji 数据
4324
- * @param options 可选的请求参数 (主要用于 typeMode)
4325
- * @returns 统一格式的API响应
4326
- */
4327
- getEmojiList: createBoundKuaishouApiMethod("Emoji\u6570\u636E", cookie)
4328
- };
4329
- };
4330
-
4331
- // src/platform/kuaishou/index.ts
4332
- var kuaishouUtils = {
4333
- kuaishouApiUrls,
4334
- api: kuaishou
4335
- };
4336
-
4337
- // src/platform/xiaohongshu/XiaohongshuApi.ts
4338
- var createXiaohongshuApiMethod = (methodType) => {
4339
- return async (options, cookie, requestConfig) => {
4340
- return await getXiaohongshuData(methodType, options, cookie);
4341
- };
4342
- };
4343
- var createBoundXiaohongshuApiMethod = (methodType, cookie, requestConfig) => {
4344
- return async (options) => {
4345
- return await getXiaohongshuData(methodType, options, cookie);
4346
- };
4347
- };
4348
- var xiaohongshu = {
4349
- /**
4350
- * 获取首页推荐数据
4351
- * @param options 请求参数,包含分页和过滤选项
4352
- * @param cookie 有效的用户 Cookie
4353
- * @returns 统一格式的API响应,包含首页推荐笔记列表
4354
- */
4355
- getHomeFeed: createXiaohongshuApiMethod("\u9996\u9875\u63A8\u8350\u6570\u636E"),
4356
- /**
4357
- * 获取单个笔记数据
4358
- * @param options 请求参数,包含笔记ID
4359
- * @param cookie 有效的用户 Cookie
4360
- * @returns 统一格式的API响应,包含指定笔记的详细信息
4361
- */
4362
- getNote: createXiaohongshuApiMethod("\u5355\u4E2A\u7B14\u8BB0\u6570\u636E"),
4363
- /**
4364
- * 获取评论数据
4365
- * @param options 请求参数,包含笔记ID和分页选项
4366
- * @param cookie 有效的用户 Cookie
4367
- * @returns 统一格式的API响应,包含指定笔记的评论列表
4368
- */
4369
- getComments: createXiaohongshuApiMethod("\u8BC4\u8BBA\u6570\u636E"),
4370
- /**
4371
- * 获取用户数据
4372
- * @param options 请求参数,包含用户ID
4373
- * @param cookie 有效的用户 Cookie
4374
- * @returns 统一格式的API响应,包含指定用户的详细信息
4375
- */
4376
- getUser: createXiaohongshuApiMethod("\u7528\u6237\u6570\u636E"),
4377
- /**
4378
- * 获取用户笔记数据
4379
- * @param options 请求参数,包含用户ID和分页选项
4380
- * @param cookie 有效的用户 Cookie
4381
- * @returns 统一格式的API响应,包含指定用户的笔记列表
4382
- */
4383
- getUserNotes: createXiaohongshuApiMethod("\u7528\u6237\u7B14\u8BB0\u6570\u636E"),
4384
- /**
4385
- * 获取搜索笔记数据
4386
- * @param options 请求参数,包含搜索关键词和分页选项
4387
- * @param cookie 有效的用户 Cookie
4388
- * @returns 统一格式的API响应,包含搜索到的笔记列表
4389
- */
4390
- getSearchNotes: createXiaohongshuApiMethod("\u641C\u7D22\u7B14\u8BB0"),
4391
- /**
4392
- * 获取表情列表数据
4393
- * @param options 请求参数,包含分页和过滤选项
4394
- * @param cookie 有效的用户 Cookie
4395
- * @returns 统一格式的API响应,包含表情列表
4396
- */
4397
- getEmojiList: createXiaohongshuApiMethod("\u8868\u60C5\u5217\u8868")
4398
- };
4399
- var createBoundXiaohongshuApi = (cookie, requestConfig) => {
4400
- return {
4401
- /**
4402
- * 获取首页推荐数据
4403
- * @param options 请求参数,包含分页和过滤选项
4404
- * @returns 统一格式的API响应,包含首页推荐笔记列表
4405
- */
4406
- getHomeFeed: createBoundXiaohongshuApiMethod("\u9996\u9875\u63A8\u8350\u6570\u636E", cookie),
4407
- /**
4408
- * 获取单个笔记数据
4409
- * @param options 请求参数,包含笔记ID
4410
- * @returns 统一格式的API响应,包含指定笔记的详细信息
4411
- */
4412
- getNote: createBoundXiaohongshuApiMethod("\u5355\u4E2A\u7B14\u8BB0\u6570\u636E", cookie),
4413
- /**
4414
- * 获取评论数据
4415
- * @param options 请求参数,包含笔记ID和分页选项
4416
- * @returns 统一格式的API响应,包含指定笔记的评论列表
4417
- */
4418
- getComments: createBoundXiaohongshuApiMethod("\u8BC4\u8BBA\u6570\u636E", cookie),
4419
- /**
4420
- * 获取用户数据
4421
- * @param options 请求参数,包含用户ID
4422
- * @returns 统一格式的API响应,包含指定用户的详细信息
4423
- */
4424
- getUser: createBoundXiaohongshuApiMethod("\u7528\u6237\u6570\u636E", cookie),
4425
- /**
4426
- * 获取用户笔记数据
4427
- * @param options 请求参数,包含用户ID和分页选项
4428
- * @returns 统一格式的API响应,包含指定用户的笔记列表
4429
- */
4430
- getUserNotes: createBoundXiaohongshuApiMethod("\u7528\u6237\u7B14\u8BB0\u6570\u636E", cookie),
4431
- /**
4432
- * 获取搜索笔记数据
4433
- * @param options 请求参数,包含搜索关键词和分页选项
4434
- * @returns 统一格式的API响应,包含搜索到的笔记列表
4435
- */
4436
- getSearchNotes: createBoundXiaohongshuApiMethod("\u641C\u7D22\u7B14\u8BB0", cookie),
4437
- /**
4438
- * 获取表情列表数据
4439
- * @param options 请求参数,包含分页和过滤选项
4440
- * @returns 统一格式的API响应,包含表情列表
4441
- */
4442
- getEmojiList: createBoundXiaohongshuApiMethod("\u8868\u60C5\u5217\u8868", cookie)
4443
- };
4444
- };
4445
- var createXiaohongshuRouteHandler = (dataFetcher, methodType, cookie, requestConfig = getXiaohongshuDefaultConfig(cookie)) => {
4446
- return async (req, res) => {
4447
- try {
4448
- const result = await dataFetcher(methodType, req.validatedParams, cookie, requestConfig);
4449
- res.json({
4450
- ...result,
4451
- requestPath: req.originalUrl
4452
- });
4453
- } catch (error) {
4454
- const errorResponse = handleError(error);
4455
- res.status(errorResponse.code || 500).json({
4456
- ...errorResponse,
4457
- requestPath: req.originalUrl
4458
- });
4459
- }
4460
- };
4461
- };
4462
- var createXiaohongshuRoutes = (cookie, requestConfig = getXiaohongshuDefaultConfig(cookie)) => {
4463
- const router = Router();
4464
- router.get(
4465
- "/fetch_home_feed",
4466
- createXiaohongshuValidationMiddleware("\u9996\u9875\u63A8\u8350\u6570\u636E"),
4467
- createXiaohongshuRouteHandler(getXiaohongshuData, "\u9996\u9875\u63A8\u8350\u6570\u636E", cookie, requestConfig)
4468
- );
4469
- router.get(
4470
- "/fetch_one_note",
4471
- createXiaohongshuValidationMiddleware("\u5355\u4E2A\u7B14\u8BB0\u6570\u636E"),
4472
- createXiaohongshuRouteHandler(getXiaohongshuData, "\u5355\u4E2A\u7B14\u8BB0\u6570\u636E", cookie, requestConfig)
4473
- );
4474
- router.get(
4475
- "/fetch_note_comments",
4476
- createXiaohongshuValidationMiddleware("\u8BC4\u8BBA\u6570\u636E"),
4477
- createXiaohongshuRouteHandler(getXiaohongshuData, "\u8BC4\u8BBA\u6570\u636E", cookie, requestConfig)
4478
- );
4479
- router.get(
4480
- "/fetch_user_profile",
4481
- createXiaohongshuValidationMiddleware("\u7528\u6237\u6570\u636E"),
4482
- createXiaohongshuRouteHandler(getXiaohongshuData, "\u7528\u6237\u6570\u636E", cookie, requestConfig)
4483
- );
4484
- router.get(
4485
- "/fetch_user_notes",
4486
- createXiaohongshuValidationMiddleware("\u7528\u6237\u7B14\u8BB0\u6570\u636E"),
4487
- createXiaohongshuRouteHandler(getXiaohongshuData, "\u7528\u6237\u7B14\u8BB0\u6570\u636E", cookie, requestConfig)
4488
- );
4489
- router.get(
4490
- "/fetch_emoji_list",
4491
- createXiaohongshuValidationMiddleware("\u8868\u60C5\u5217\u8868"),
4492
- createXiaohongshuRouteHandler(getXiaohongshuData, "\u8868\u60C5\u5217\u8868", cookie, requestConfig)
4493
- );
4494
- router.get(
4495
- "/fetch_search_notes",
4496
- createXiaohongshuValidationMiddleware("\u641C\u7D22\u7B14\u8BB0"),
4497
- createXiaohongshuRouteHandler(getXiaohongshuData, "\u641C\u7D22\u7B14\u8BB0", cookie, requestConfig)
4498
- );
4499
- return router;
4500
- };
4501
-
4502
- // src/platform/xiaohongshu/index.ts
4503
- var xiaohongshuUtils = {
4504
- sign: xiaohongshuSign,
4505
- xiaohongshuApiUrls,
4506
- api: xiaohongshu
4507
- };
4508
- var createAmagiClient = (options) => {
4509
- var _a, _b, _c, _d;
4510
- const douyinCookie = ((_a = options == null ? void 0 : options.cookies) == null ? void 0 : _a.douyin) ?? "";
4511
- const bilibiliCookie = ((_b = options == null ? void 0 : options.cookies) == null ? void 0 : _b.bilibili) ?? "";
4512
- const kuaishouCookie = ((_c = options == null ? void 0 : options.cookies) == null ? void 0 : _c.kuaishou) ?? "";
4513
- const xiaohongshuCookie = ((_d = options == null ? void 0 : options.cookies) == null ? void 0 : _d.xiaohongshu) ?? "";
4514
- const requestConfig = (options == null ? void 0 : options.request) ?? {};
4515
- const startServer = (port = 4567) => {
4516
- const app = express();
4517
- app.use(express.json());
4518
- app.use(express.urlencoded({ extended: true }));
4519
- app.get("/", (_req, res) => {
4520
- res.redirect(301, "https://amagi.apifox.cn");
4521
- });
4522
- app.get("/docs", (_req, res) => {
4523
- res.redirect(301, "https://amagi.apifox.cn");
4524
- });
4525
- app.use("/api/douyin", createDouyinRoutes(douyinCookie, requestConfig));
4526
- app.use("/api/bilibili", createBilibiliRoutes(bilibiliCookie, requestConfig));
4527
- app.use("/api/kuaishou", createKuaishouRoutes(kuaishouCookie, requestConfig));
4528
- app.use("/api/xiaohongshu", createXiaohongshuRoutes(xiaohongshuCookie, requestConfig));
4529
- app.listen(port, "::", () => {
4530
- logger.mark(`Amagi server listening on ${logger.green(`http://localhost:${port}`)} ${logger.yellow("API docs: https://amagi.apifox.cn ")}`);
4531
- });
4532
- return app;
4533
- };
4534
- const getDouyinDataWithCookie = async (methodType, options2) => {
4535
- return await getDouyinData(methodType, options2, douyinCookie, requestConfig);
4536
- };
4537
- const getBilibiliDataWithCookie = async (methodType, options2) => {
4538
- return await getBilibiliData(methodType, options2, bilibiliCookie);
4539
- };
4540
- const getKuaishouDataWithCookie = async (methodType, options2) => {
4541
- return await getKuaishouData(methodType, options2, kuaishouCookie);
4542
- };
4543
- const getXiaohongshuDataWithCookie = async (methodType, options2) => {
4544
- return await getXiaohongshuData(methodType, options2, xiaohongshuCookie);
4545
- };
4546
- return {
4547
- /** 启动本地HTTP服务 */
4548
- startServer,
4549
- getDouyinData: getDouyinDataWithCookie,
4550
- getBilibiliData: getBilibiliDataWithCookie,
4551
- getKuaishouData: getKuaishouDataWithCookie,
4552
- getXiaohongshuData: getXiaohongshuDataWithCookie,
4553
- douyin: {
4554
- ...douyinUtils,
4555
- /** 绑定了cookie和请求配置的抖音API对象,调用时不需要传递cookie */
4556
- api: createBoundDouyinApi(douyinCookie, requestConfig)
4557
- },
4558
- bilibili: {
4559
- ...bilibiliUtils,
4560
- /** 绑定了cookie和请求配置的B站API对象,调用时不需要传递cookie */
4561
- api: createBoundBilibiliApi(bilibiliCookie)
4562
- },
4563
- kuaishou: {
4564
- ...kuaishouUtils,
4565
- /** 绑定了cookie和请求配置的快手API对象,调用时不需要传递cookie */
4566
- api: createBoundKuaishouApi(kuaishouCookie)
4567
- },
4568
- xiaohongshu: {
4569
- ...xiaohongshuUtils,
4570
- /** 绑定了cookie和请求配置的小红书API对象,调用时不需要传递cookie */
4571
- api: createBoundXiaohongshuApi(xiaohongshuCookie)
4572
- }
4573
- };
4574
- };
4575
-
4576
- // src/types/ReturnDataType/Bilibili/DynamicInfo.ts
4577
- var DynamicType = /* @__PURE__ */ ((DynamicType2) => {
4578
- DynamicType2["AV"] = "DYNAMIC_TYPE_AV";
4579
- DynamicType2["DRAW"] = "DYNAMIC_TYPE_DRAW";
4580
- DynamicType2["WORD"] = "DYNAMIC_TYPE_WORD";
4581
- DynamicType2["LIVE_RCMD"] = "DYNAMIC_TYPE_LIVE_RCMD";
4582
- DynamicType2["FORWARD"] = "DYNAMIC_TYPE_FORWARD";
4583
- return DynamicType2;
4584
- })(DynamicType || {});
4585
-
4586
- // src/types/ReturnDataType/Bilibili/Dynamic/index.ts
4587
- var MajorType = /* @__PURE__ */ ((MajorType2) => {
4588
- MajorType2["NONE"] = "MAJOR_TYPE_NONE";
4589
- MajorType2["OPUS"] = "MAJOR_TYPE_OPUS";
4590
- MajorType2["ARCHIVE"] = "MAJOR_TYPE_ARCHIVE";
4591
- MajorType2["PGC"] = "MAJOR_TYPE_PGC";
4592
- MajorType2["COURSES"] = "MAJOR_TYPE_COURSES";
4593
- MajorType2["DRAW"] = "MAJOR_TYPE_DRAW";
4594
- MajorType2["ARTICLE"] = "MAJOR_TYPE_ARTICLE";
4595
- MajorType2["MUSIC"] = "MAJOR_TYPE_MUSIC";
4596
- MajorType2["COMMON"] = "MAJOR_TYPE_COMMON";
4597
- MajorType2["LIVE"] = "MAJOR_TYPE_LIVE";
4598
- MajorType2["MEDIALIST"] = "MAJOR_TYPE_MEDIALIST";
4599
- MajorType2["APPLET"] = "MAJOR_TYPE_APPLET";
4600
- MajorType2["SUBSCRIPTION"] = "MAJOR_TYPE_SUBSCRIPTION";
4601
- MajorType2["LIVE_RCMD"] = "MAJOR_TYPE_LIVE_RCMD";
4602
- MajorType2["UGC_SEASON"] = "MAJOR_TYPE_UGC_SEASON";
4603
- MajorType2["SUBSCRIPTION_NEW"] = "MAJOR_TYPE_SUBSCRIPTION_NEW";
4604
- MajorType2["UPOWER_COMMON"] = "MAJOR_TYPE_UPOWER_COMMON";
4605
- return MajorType2;
4606
- })(MajorType || {});
4607
- var AdditionalType = /* @__PURE__ */ ((AdditionalType2) => {
4608
- AdditionalType2["NONE"] = "ADDITIONAL_TYPE_NONE";
4609
- AdditionalType2["PGC"] = "ADDITIONAL_TYPE_PGC";
4610
- AdditionalType2["GOODS"] = "ADDITIONAL_TYPE_GOODS";
4611
- AdditionalType2["VOTE"] = "ADDITIONAL_TYPE_VOTE";
4612
- AdditionalType2["COMMON"] = "ADDITIONAL_TYPE_COMMON";
4613
- AdditionalType2["MATCH"] = "ADDITIONAL_TYPE_MATCH";
4614
- AdditionalType2["UP_RCMD"] = "ADDITIONAL_TYPE_UP_RCMD";
4615
- AdditionalType2["UGC"] = "ADDITIONAL_TYPE_UGC";
4616
- AdditionalType2["RESERVE"] = "ADDITIONAL_TYPE_RESERVE";
4617
- AdditionalType2["UPOWER_LOTTERY"] = "ADDITIONAL_TYPE_UPOWER_LOTTERY";
4618
- return AdditionalType2;
4619
- })(AdditionalType || {});
4620
-
4621
- // src/index.ts
4622
- var amagiClient = createAmagiClient;
4623
- function CreateAmagiApp(options = {}) {
4624
- if (!(this instanceof CreateAmagiApp)) {
4625
- return createAmagiClient(options);
4626
- }
4627
- return createAmagiClient(options);
4628
- }
4629
- CreateAmagiApp.douyin = douyinUtils;
4630
- CreateAmagiApp.bilibili = bilibiliUtils;
4631
- CreateAmagiApp.kuaishou = kuaishouUtils;
4632
- CreateAmagiApp.xiaohongshu = xiaohongshuUtils;
4633
- CreateAmagiApp.getDouyinData = getDouyinData;
4634
- CreateAmagiApp.getBilibiliData = getBilibiliData;
4635
- CreateAmagiApp.getKuaishouData = getKuaishouData;
4636
- CreateAmagiApp.getXiaohongshuData = getXiaohongshuData;
4637
- var CreateApp = CreateAmagiApp;
4638
- var Client = CreateApp;
4639
- var amagi = Client;
4640
- /*!
4641
- * @ikenxuan/amagi
4642
- * Copyright(c) 2023 ikenxuan
4643
- * GPL-3.0 Licensed
4644
- */
4645
-
4646
- export { AdditionalType, ApiError, BilibiliAv2BvParamsSchema, BilibiliBangumiInfoParamsSchema, BilibiliBangumiStreamParamsSchema, BilibiliBv2AvParamsSchema, BilibiliCommentParamsSchema, BilibiliDynamicParamsSchema, BilibiliEmojiParamsSchema, BilibiliLiveParamsSchema, BilibiliLoginParamsSchema, BilibiliQrcodeParamsSchema, BilibiliQrcodeStatusParamsSchema, BilibiliUserParamsSchema, BilibiliValidationSchemas2 as BilibiliValidationSchemas, BilibiliVideoDownloadParamsSchema, BilibiliVideoParamsSchema, CreateApp, DouyinCommentParamsSchema, DouyinCommentReplyParamsSchema, DouyinDanmakuParamsSchema, DouyinEmojiListParamsSchema, DouyinEmojiProParamsSchema, DouyinMusicParamsSchema, DouyinQrcodeParamsSchema, DouyinSearchParamsSchema, DouyinUserParamsSchema, DouyinValidationSchemas2 as DouyinValidationSchemas, DouyinWorkParamsSchema, DynamicType, KuaishouCommentParamsSchema, KuaishouEmojiParamsSchema, KuaishouValidationSchemas2 as KuaishouValidationSchemas, KuaishouVideoParamsSchema, MajorType, ValidationError, XiaohongshuValidationSchemas, amagi, amagiClient, av2bv, bilibili, bilibiliApiUrls, bilibiliErrorCodeMap, bilibiliUtils, bv2av, createAmagiClient, createBilibiliRoutes, createBoundBilibiliApi, createBoundDouyinApi, createBoundKuaishouApi, createBoundXiaohongshuApi, createDouyinRoutes, createErrorResponse, createKuaishouRoutes, createSuccessResponse, createXiaohongshuRoutes, Client as default, douyin, douyinApiUrls, douyinSign, douyinUtils, fetchData, fetchResponse, getBilibiliData, getDouyinData, getHeadersAndData, getKuaishouData, handleError, httpLogger, kuaishou, kuaishouApiUrls, kuaishouUtils, logMiddleware, logger, qtparam, createBilibiliRoutes as registerBilibiliRoutes, createDouyinRoutes as registerDouyinRoutes, createKuaishouRoutes as registerKuaishouRoutes, createXiaohongshuRoutes as registerXiaohongshuRoutes, validateBilibiliParams, validateDouyinParams, validateKuaishouParams, validateXiaohongshuParams, wbi_sign, xiaohongshu, xiaohongshuApiUrls, xiaohongshuSign, xiaohongshuUtils };