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