@ikenxuan/amagi 4.4.19 → 4.4.20-pr117.7783399
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.
- package/dist/default/cjs/index.cjs +1677 -1206
- package/dist/default/cjs/v5.cjs +3109 -0
- package/dist/default/esm/index.mjs +1703 -1231
- package/dist/default/esm/v5.mjs +3023 -0
- package/dist/default/index-DvWdflTJ.d.cts +14631 -0
- package/dist/default/index-DvWdflTJ.d.ts +14631 -0
- package/dist/default/index.d.cts +173 -0
- package/dist/default/index.d.ts +75 -14162
- package/dist/default/v5.d.cts +220 -0
- package/dist/default/v5.d.ts +220 -0
- package/dist/exports/express.cjs +1 -26
- package/dist/exports/express.d.ts +1 -1
- package/dist/exports/express.js +1 -1
- package/package.json +12 -22
|
@@ -2,211 +2,315 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var axios = require('axios');
|
|
6
|
-
var crypto = require('crypto');
|
|
7
|
-
var express = require('express');
|
|
8
5
|
var chalk = require('chalk');
|
|
9
6
|
var log4js = require('log4js');
|
|
10
7
|
var path = require('path');
|
|
11
8
|
var url = require('url');
|
|
12
9
|
var fs = require('fs');
|
|
10
|
+
var axios = require('axios');
|
|
11
|
+
var crypto = require('crypto');
|
|
12
|
+
var zod = require('zod');
|
|
13
|
+
var express = require('express');
|
|
13
14
|
|
|
14
15
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
16
|
|
|
16
|
-
var axios__default = /*#__PURE__*/_interopDefault(axios);
|
|
17
|
-
var crypto__default = /*#__PURE__*/_interopDefault(crypto);
|
|
18
|
-
var express__default = /*#__PURE__*/_interopDefault(express);
|
|
19
17
|
var log4js__default = /*#__PURE__*/_interopDefault(log4js);
|
|
20
18
|
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
21
19
|
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
20
|
+
var axios__default = /*#__PURE__*/_interopDefault(axios);
|
|
21
|
+
var crypto__default = /*#__PURE__*/_interopDefault(crypto);
|
|
22
|
+
var express__default = /*#__PURE__*/_interopDefault(express);
|
|
23
|
+
|
|
24
|
+
/*!
|
|
25
|
+
* @ikenxuan/amagi
|
|
26
|
+
* Copyright(c) 2023 ikenxuan
|
|
27
|
+
* GPL-3.0 Licensed
|
|
28
|
+
*/
|
|
22
29
|
|
|
23
30
|
// node_modules/tsup/assets/cjs_shims.js
|
|
24
31
|
var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
|
|
25
32
|
var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
\u89C6\u9891\u6D41\u4FE1\u606F(data2) {
|
|
36
|
-
return `https://api.bilibili.com/x/player/playurl?avid=${data2.avid}&cid=${data2.cid}`;
|
|
37
|
-
}
|
|
38
|
-
/** 评论区类型,type参数详见 [评论区类型代码](https://github.com/SocialSisterYi/bilibili-API-collect/blob/master/docs/comment/readme.md#评论区类型代码) */
|
|
39
|
-
\u8BC4\u8BBA\u533A\u660E\u7EC6(data2) {
|
|
40
|
-
return `https://api.bilibili.com/x/v2/reply?sort=1&ps=${data2.number ?? 20}&type=${data2.type}&oid=${data2.oid}&pn=${data2.pn}`;
|
|
41
|
-
}
|
|
42
|
-
\u8BC4\u8BBA\u533A\u72B6\u6001(data2) {
|
|
43
|
-
return `https://api.bilibili.com/x/v2/reply/subject/description?type=${data2.type}&oid=${data2.oid}`;
|
|
44
|
-
}
|
|
45
|
-
\u8868\u60C5\u5217\u8868() {
|
|
46
|
-
return "https://api.bilibili.com/x/emote/user/panel/web?business=reply&web_location=0.0";
|
|
47
|
-
}
|
|
48
|
-
\u756A\u5267\u660E\u7EC6(data2) {
|
|
49
|
-
if (data2.ep_id) {
|
|
50
|
-
return `https://api.bilibili.com/pgc/view/web/season?ep_id=${data2.ep_id}`;
|
|
51
|
-
} else if (data2.season_id) {
|
|
52
|
-
return `https://api.bilibili.com/pgc/view/web/season?season_id=${data2.season_id}`;
|
|
53
|
-
} else {
|
|
54
|
-
throw new Error("\u62DF\u9020\u63A5\u53E3\u5730\u5740\u51FA\u9519\uFF0C\u7F3A\u5C11 ep_id \u6216 season_id \u53C2\u6570");
|
|
33
|
+
var getPackageLogsPath = () => {
|
|
34
|
+
const currentFileUrl = importMetaUrl;
|
|
35
|
+
const currentFilePath = url.fileURLToPath(currentFileUrl);
|
|
36
|
+
const currentDir = path__default.default.dirname(currentFilePath);
|
|
37
|
+
let packageRoot = currentDir;
|
|
38
|
+
while (packageRoot !== path__default.default.dirname(packageRoot)) {
|
|
39
|
+
if (fs__default.default.existsSync(path__default.default.join(packageRoot, "package.json"))) {
|
|
40
|
+
break;
|
|
55
41
|
}
|
|
42
|
+
packageRoot = path__default.default.dirname(packageRoot);
|
|
56
43
|
}
|
|
57
|
-
|
|
58
|
-
|
|
44
|
+
return path__default.default.join(packageRoot, "logs");
|
|
45
|
+
};
|
|
46
|
+
var logsPath = getPackageLogsPath();
|
|
47
|
+
log4js__default.default.configure({
|
|
48
|
+
appenders: {
|
|
49
|
+
console: {
|
|
50
|
+
type: "stdout",
|
|
51
|
+
layout: {
|
|
52
|
+
type: "pattern",
|
|
53
|
+
pattern: "%[[amagi][%d{hh:mm:ss.SSS}][%4.4p]%] %m"
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
command: {
|
|
57
|
+
type: "dateFile",
|
|
58
|
+
filename: path__default.default.join(logsPath, "application", "command"),
|
|
59
|
+
pattern: "yyyy-MM-dd.log",
|
|
60
|
+
numBackups: 15,
|
|
61
|
+
alwaysIncludePattern: true,
|
|
62
|
+
layout: {
|
|
63
|
+
type: "pattern",
|
|
64
|
+
pattern: "[%d{hh:mm:ss.SSS}][%4.4p] %m"
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
httpConsole: {
|
|
68
|
+
type: "stdout",
|
|
69
|
+
layout: {
|
|
70
|
+
type: "pattern",
|
|
71
|
+
pattern: "%[[amagi][%d{hh:mm:ss.SSS}][HTTP]%] %m"
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
httpRequest: {
|
|
75
|
+
type: "dateFile",
|
|
76
|
+
filename: path__default.default.join(logsPath, "http", "requests"),
|
|
77
|
+
pattern: "yyyy-MM-dd.log",
|
|
78
|
+
numBackups: 30,
|
|
79
|
+
alwaysIncludePattern: true,
|
|
80
|
+
layout: {
|
|
81
|
+
type: "pattern",
|
|
82
|
+
pattern: "[%d{hh:mm:ss.SSS}][%4.4p] %m"
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
categories: {
|
|
87
|
+
default: { appenders: ["console", "command"], level: "info" },
|
|
88
|
+
http: { appenders: ["httpConsole", "httpRequest"], level: "debug" }
|
|
89
|
+
},
|
|
90
|
+
pm2: true
|
|
91
|
+
});
|
|
92
|
+
var CustomLogger = class {
|
|
93
|
+
logger;
|
|
94
|
+
chalk;
|
|
95
|
+
red;
|
|
96
|
+
green;
|
|
97
|
+
yellow;
|
|
98
|
+
blue;
|
|
99
|
+
magenta;
|
|
100
|
+
cyan;
|
|
101
|
+
white;
|
|
102
|
+
gray;
|
|
103
|
+
constructor(name) {
|
|
104
|
+
this.logger = log4js__default.default.getLogger(name);
|
|
105
|
+
this.chalk = new chalk.Chalk();
|
|
106
|
+
this.red = this.chalk.red;
|
|
107
|
+
this.green = this.chalk.green;
|
|
108
|
+
this.yellow = this.chalk.yellow;
|
|
109
|
+
this.blue = this.chalk.blue;
|
|
110
|
+
this.magenta = this.chalk.magenta;
|
|
111
|
+
this.cyan = this.chalk.cyan;
|
|
112
|
+
this.white = this.chalk.white;
|
|
113
|
+
this.gray = this.chalk.gray;
|
|
59
114
|
}
|
|
60
|
-
|
|
61
|
-
|
|
115
|
+
// 代理 log4js.Logger 的方法
|
|
116
|
+
info(message, ...args) {
|
|
117
|
+
this.logger.info(message, ...args);
|
|
62
118
|
}
|
|
63
|
-
|
|
64
|
-
|
|
119
|
+
warn(message, ...args) {
|
|
120
|
+
this.logger.warn(message, ...args);
|
|
65
121
|
}
|
|
66
|
-
|
|
67
|
-
|
|
122
|
+
error(message, ...args) {
|
|
123
|
+
this.logger.error(message, ...args);
|
|
68
124
|
}
|
|
69
|
-
|
|
70
|
-
|
|
125
|
+
mark(message, ...args) {
|
|
126
|
+
this.logger.mark(message, ...args);
|
|
71
127
|
}
|
|
72
|
-
|
|
73
|
-
|
|
128
|
+
debug(message, ...args) {
|
|
129
|
+
this.logger.debug(message, ...args);
|
|
74
130
|
}
|
|
75
|
-
|
|
76
|
-
|
|
131
|
+
};
|
|
132
|
+
var logger = new CustomLogger("default");
|
|
133
|
+
var httpLogger = new CustomLogger("http");
|
|
134
|
+
var logMiddleware = (pathsToLog) => {
|
|
135
|
+
return (req, res, next) => {
|
|
136
|
+
if (!pathsToLog || pathsToLog.some((path2) => req.url.startsWith(path2))) {
|
|
137
|
+
const startTime = Date.now();
|
|
138
|
+
const url = req.url;
|
|
139
|
+
const method = req.method;
|
|
140
|
+
const clientIP = req.headers["x-forwarded-for"] || req.socket.remoteAddress;
|
|
141
|
+
const referer = req.headers["referer"] || req.headers["referrer"] || "-";
|
|
142
|
+
const contentType = req.headers["content-type"] || "-";
|
|
143
|
+
const requestSize = req.headers["content-length"] || "0";
|
|
144
|
+
const protocol = req.protocol;
|
|
145
|
+
const httpVersion = req.httpVersion;
|
|
146
|
+
res.on("finish", () => {
|
|
147
|
+
const responseTime = Date.now() - startTime;
|
|
148
|
+
const statusCode = res.statusCode;
|
|
149
|
+
const responseSize = res.get("content-length") || "0";
|
|
150
|
+
const logData = {
|
|
151
|
+
method,
|
|
152
|
+
url,
|
|
153
|
+
statusCode,
|
|
154
|
+
responseTime: `${responseTime}ms`,
|
|
155
|
+
clientIP,
|
|
156
|
+
referer,
|
|
157
|
+
contentType,
|
|
158
|
+
requestSize: `${requestSize}B`,
|
|
159
|
+
responseSize: `${responseSize}B`,
|
|
160
|
+
protocol,
|
|
161
|
+
httpVersion,
|
|
162
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
163
|
+
};
|
|
164
|
+
httpLogger.debug(JSON.stringify(logData));
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
next();
|
|
168
|
+
};
|
|
169
|
+
};
|
|
170
|
+
var Networks = class {
|
|
171
|
+
url;
|
|
172
|
+
method;
|
|
173
|
+
headers;
|
|
174
|
+
type;
|
|
175
|
+
body;
|
|
176
|
+
axiosInstance;
|
|
177
|
+
isGetResult;
|
|
178
|
+
timeout;
|
|
179
|
+
timer;
|
|
180
|
+
data;
|
|
181
|
+
constructor(data2) {
|
|
182
|
+
this.headers = data2.headers ?? {};
|
|
183
|
+
this.url = data2.url ?? "";
|
|
184
|
+
this.type = data2.responseType ?? "json";
|
|
185
|
+
this.method = data2.method ?? "GET";
|
|
186
|
+
this.body = data2.body ?? null;
|
|
187
|
+
this.data = {};
|
|
188
|
+
this.timeout = data2.timeout ?? 15e3;
|
|
189
|
+
this.isGetResult = false;
|
|
190
|
+
this.timer = void 0;
|
|
191
|
+
this.axiosInstance = axios__default.default.create({
|
|
192
|
+
timeout: this.timeout,
|
|
193
|
+
headers: this.headers,
|
|
194
|
+
maxRedirects: 5,
|
|
195
|
+
validateStatus: (status) => {
|
|
196
|
+
return status >= 200 && status < 600;
|
|
197
|
+
}
|
|
198
|
+
});
|
|
77
199
|
}
|
|
78
|
-
|
|
79
|
-
|
|
200
|
+
get config() {
|
|
201
|
+
let config = {
|
|
202
|
+
url: this.url,
|
|
203
|
+
method: this.method,
|
|
204
|
+
headers: this.headers
|
|
205
|
+
};
|
|
206
|
+
if (this.method === "POST" && this.body) {
|
|
207
|
+
config.data = this.body;
|
|
208
|
+
}
|
|
209
|
+
return config;
|
|
80
210
|
}
|
|
81
|
-
|
|
82
|
-
|
|
211
|
+
async getfetch() {
|
|
212
|
+
try {
|
|
213
|
+
const result = await this.returnResult();
|
|
214
|
+
if (result.status === 504) {
|
|
215
|
+
return result;
|
|
216
|
+
}
|
|
217
|
+
this.isGetResult = true;
|
|
218
|
+
return result;
|
|
219
|
+
} catch (error) {
|
|
220
|
+
logger.info(error);
|
|
221
|
+
return false;
|
|
222
|
+
}
|
|
83
223
|
}
|
|
84
|
-
|
|
85
|
-
return
|
|
224
|
+
async returnResult() {
|
|
225
|
+
return await this.axiosInstance(this.config);
|
|
86
226
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
return { QUERY: `&fnval=16&fourk=1&${sign}`, STATUS: "isLogin", isvip };
|
|
101
|
-
} else return { QUERY: `&qn=${qn[3]}&fnval=16`, STATUS: "isLogin", isvip };
|
|
102
|
-
}
|
|
103
|
-
var mixinKeyEncTab = [
|
|
104
|
-
46,
|
|
105
|
-
47,
|
|
106
|
-
18,
|
|
107
|
-
2,
|
|
108
|
-
53,
|
|
109
|
-
8,
|
|
110
|
-
23,
|
|
111
|
-
32,
|
|
112
|
-
15,
|
|
113
|
-
50,
|
|
114
|
-
10,
|
|
115
|
-
31,
|
|
116
|
-
58,
|
|
117
|
-
3,
|
|
118
|
-
45,
|
|
119
|
-
35,
|
|
120
|
-
27,
|
|
121
|
-
43,
|
|
122
|
-
5,
|
|
123
|
-
49,
|
|
124
|
-
33,
|
|
125
|
-
9,
|
|
126
|
-
42,
|
|
127
|
-
19,
|
|
128
|
-
29,
|
|
129
|
-
28,
|
|
130
|
-
14,
|
|
131
|
-
39,
|
|
132
|
-
12,
|
|
133
|
-
38,
|
|
134
|
-
41,
|
|
135
|
-
13,
|
|
136
|
-
37,
|
|
137
|
-
48,
|
|
138
|
-
7,
|
|
139
|
-
16,
|
|
140
|
-
24,
|
|
141
|
-
55,
|
|
142
|
-
40,
|
|
143
|
-
61,
|
|
144
|
-
26,
|
|
145
|
-
17,
|
|
146
|
-
0,
|
|
147
|
-
1,
|
|
148
|
-
60,
|
|
149
|
-
51,
|
|
150
|
-
30,
|
|
151
|
-
4,
|
|
152
|
-
22,
|
|
153
|
-
25,
|
|
154
|
-
54,
|
|
155
|
-
21,
|
|
156
|
-
56,
|
|
157
|
-
59,
|
|
158
|
-
6,
|
|
159
|
-
63,
|
|
160
|
-
57,
|
|
161
|
-
62,
|
|
162
|
-
11,
|
|
163
|
-
36,
|
|
164
|
-
20,
|
|
165
|
-
34,
|
|
166
|
-
44,
|
|
167
|
-
52
|
|
168
|
-
];
|
|
169
|
-
var getMixinKey = (orig) => mixinKeyEncTab.map((n) => orig[n]).join("").slice(0, 32);
|
|
170
|
-
function encWbi(params, img_key, sub_key) {
|
|
171
|
-
const mixin_key = getMixinKey(img_key + sub_key);
|
|
172
|
-
const curr_time = Math.round(Date.now() / 1e3);
|
|
173
|
-
const chr_filter = /[!'()*]/g;
|
|
174
|
-
Object.assign(params, { wts: curr_time });
|
|
175
|
-
const query = Object.keys(params).sort().map((key) => {
|
|
176
|
-
const value = params[key].toString().replace(chr_filter, "");
|
|
177
|
-
return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
|
|
178
|
-
}).join("&");
|
|
179
|
-
const wbi_sign2 = crypto__default.default.createHash("md5").update(query + mixin_key).digest("hex");
|
|
180
|
-
return `&wts=${curr_time}&w_rid=${wbi_sign2}`;
|
|
181
|
-
}
|
|
182
|
-
async function getWbiKeys(cookie) {
|
|
183
|
-
const res = await axios__default.default("https://api.bilibili.com/x/web-interface/nav", {
|
|
184
|
-
headers: {
|
|
185
|
-
Cookie: cookie
|
|
227
|
+
/** 最终地址(跟随重定向) */
|
|
228
|
+
async getLongLink() {
|
|
229
|
+
try {
|
|
230
|
+
const response = await this.axiosInstance({
|
|
231
|
+
method: "GET",
|
|
232
|
+
url: this.url
|
|
233
|
+
});
|
|
234
|
+
return response.request.res.responseUrl;
|
|
235
|
+
} catch (error) {
|
|
236
|
+
if (error instanceof axios.AxiosError) {
|
|
237
|
+
throw new Error(error.stack);
|
|
238
|
+
}
|
|
239
|
+
return "";
|
|
186
240
|
}
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
241
|
+
}
|
|
242
|
+
/** 获取首个302 */
|
|
243
|
+
async getLocation() {
|
|
244
|
+
try {
|
|
245
|
+
const response = await this.axiosInstance({
|
|
246
|
+
method: "GET",
|
|
247
|
+
url: this.url,
|
|
248
|
+
maxRedirects: 0,
|
|
249
|
+
// 禁止跟随重定向
|
|
250
|
+
validateStatus: (status) => status >= 300 && status < 400
|
|
251
|
+
// 仅处理3xx响应
|
|
252
|
+
});
|
|
253
|
+
return response.headers["location"];
|
|
254
|
+
} catch (error) {
|
|
255
|
+
if (error instanceof axios.AxiosError) {
|
|
256
|
+
throw new Error(error.stack);
|
|
257
|
+
}
|
|
258
|
+
return "";
|
|
193
259
|
}
|
|
194
|
-
} = response;
|
|
195
|
-
return {
|
|
196
|
-
img_key: img_url.slice(img_url.lastIndexOf("/") + 1, img_url.lastIndexOf(".")),
|
|
197
|
-
sub_key: sub_url.slice(sub_url.lastIndexOf("/") + 1, sub_url.lastIndexOf("."))
|
|
198
|
-
};
|
|
199
|
-
}
|
|
200
|
-
async function wbi_sign(BASEURL, cookie) {
|
|
201
|
-
const web_keys = await getWbiKeys(cookie);
|
|
202
|
-
const url = new URL(BASEURL);
|
|
203
|
-
const params = {};
|
|
204
|
-
for (const [key, value] of url.searchParams.entries()) {
|
|
205
|
-
params[key] = value;
|
|
206
260
|
}
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
261
|
+
/** 获取数据并处理数据的格式化,默认json */
|
|
262
|
+
async getData(new_fetch = "") {
|
|
263
|
+
try {
|
|
264
|
+
if (!new_fetch) {
|
|
265
|
+
const result = await this.returnResult();
|
|
266
|
+
if (result.status === 504) {
|
|
267
|
+
return result;
|
|
268
|
+
}
|
|
269
|
+
if (result.status === 429) {
|
|
270
|
+
logger.error("HTTP \u54CD\u5E94\u72B6\u6001\u7801: 429");
|
|
271
|
+
throw new Error("ratelimit triggered, \u89E6\u53D1 https://www.douyin.com/ \u7684\u901F\u7387\u9650\u5236\uFF01\uFF01\uFF01");
|
|
272
|
+
}
|
|
273
|
+
this.axiosInstance = result;
|
|
274
|
+
this.isGetResult = true;
|
|
275
|
+
} else {
|
|
276
|
+
this.axiosInstance = new_fetch;
|
|
277
|
+
}
|
|
278
|
+
return this.axiosInstance.data;
|
|
279
|
+
} catch (error) {
|
|
280
|
+
if (error instanceof axios.AxiosError) {
|
|
281
|
+
throw new Error(error.stack);
|
|
282
|
+
}
|
|
283
|
+
return false;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
async getHeadersAndData() {
|
|
287
|
+
try {
|
|
288
|
+
const result = await this.axiosInstance(this.config);
|
|
289
|
+
let headers2 = {};
|
|
290
|
+
const fetchHeaders = result.headers;
|
|
291
|
+
for (const [key, value] of Object.entries(fetchHeaders)) {
|
|
292
|
+
headers2[key] = value;
|
|
293
|
+
}
|
|
294
|
+
return { headers: headers2, data: result.data };
|
|
295
|
+
} catch (error) {
|
|
296
|
+
console.error("\u83B7\u53D6\u54CD\u5E94\u5934\u548C\u6570\u636E\u5931\u8D25:", error);
|
|
297
|
+
return { headers: null, data: null };
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
};
|
|
301
|
+
|
|
302
|
+
// src/platform/bilibili/qtparam.ts
|
|
303
|
+
var qtparam = async (BASEURL, cookie) => {
|
|
304
|
+
if (cookie === "") return { QUERY: "&platform=html5", STATUS: "!isLogin" };
|
|
305
|
+
const logininfo = await new Networks({ url: bilibiliApiUrls.\u767B\u5F55\u57FA\u672C\u4FE1\u606F(), headers: { Cookie: cookie } }).getData();
|
|
306
|
+
const sign = await wbi_sign(BASEURL, cookie);
|
|
307
|
+
const qn = [6, 16, 32, 64, 74, 80, 112, 116, 120, 125, 126, 127];
|
|
308
|
+
let isvip;
|
|
309
|
+
logininfo.data.vipStatus === 1 ? isvip = true : isvip = false;
|
|
310
|
+
if (isvip) {
|
|
311
|
+
return { QUERY: `&fnval=16&fourk=1&${sign}`, STATUS: "isLogin", isvip };
|
|
312
|
+
} else return { QUERY: `&qn=${qn[3]}&fnval=16`, STATUS: "isLogin", isvip };
|
|
313
|
+
};
|
|
210
314
|
|
|
211
315
|
// src/platform/bilibili/sign/bv2av.ts
|
|
212
316
|
var XOR_CODE = 23442827791579n;
|
|
@@ -214,7 +318,7 @@ var MASK_CODE = 2251799813685247n;
|
|
|
214
318
|
var MAX_AID = 1n << 51n;
|
|
215
319
|
var BASE = 58n;
|
|
216
320
|
var data = "FcwAPNKTMug3GV5Lj7EJnHpWsx4tb8haYeviqBz6rkCy12mUSDQX9RdoZf";
|
|
217
|
-
|
|
321
|
+
var av2bv = (aid) => {
|
|
218
322
|
const bytes = ["B", "V", "1", "0", "0", "0", "0", "0", "0", "0", "0", "0"];
|
|
219
323
|
let bvIndex = bytes.length - 1;
|
|
220
324
|
let tmp = (MAX_AID | BigInt(aid)) ^ XOR_CODE;
|
|
@@ -226,360 +330,79 @@ function av2bv(aid) {
|
|
|
226
330
|
[bytes[3], bytes[9]] = [bytes[9], bytes[3]];
|
|
227
331
|
[bytes[4], bytes[7]] = [bytes[7], bytes[4]];
|
|
228
332
|
return bytes.join("");
|
|
229
|
-
}
|
|
230
|
-
|
|
333
|
+
};
|
|
334
|
+
var bv2av = (bvid) => {
|
|
231
335
|
const bvidArr = Array.from(bvid);
|
|
232
336
|
[bvidArr[3], bvidArr[9]] = [bvidArr[9], bvidArr[3]];
|
|
233
337
|
[bvidArr[4], bvidArr[7]] = [bvidArr[7], bvidArr[4]];
|
|
234
338
|
bvidArr.splice(0, 3);
|
|
235
339
|
const tmp = bvidArr.reduce((pre, bvidChar) => pre * BASE + BigInt(data.indexOf(bvidChar)), 0n);
|
|
236
340
|
return Number(tmp & MASK_CODE ^ XOR_CODE);
|
|
237
|
-
}
|
|
341
|
+
};
|
|
238
342
|
|
|
239
|
-
// src/platform/bilibili/
|
|
240
|
-
var
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
return data2
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
* @param options 可选的请求参数 (主要用于 typeMode)
|
|
299
|
-
* @param cookie 有效的用户 Cookie
|
|
300
|
-
* @returns 接口返回的原始数据
|
|
301
|
-
*/
|
|
302
|
-
getEmojiList: async (options, cookie) => {
|
|
303
|
-
const { typeMode, ...restOptions } = options;
|
|
304
|
-
const data2 = await fetchBilibili({ ...restOptions, methodType: "Emoji\u6570\u636E" }, cookie);
|
|
305
|
-
return data2;
|
|
306
|
-
},
|
|
307
|
-
/**
|
|
308
|
-
* 获取番剧基本信息数据
|
|
309
|
-
* @param options 请求参数,包含可选的 season_id, ep_id 和 typeMode
|
|
310
|
-
* @param cookie 有效的用户 Cookie
|
|
311
|
-
* @returns 接口返回的原始数据
|
|
312
|
-
*/
|
|
313
|
-
getBangumiInfo: async (options, cookie) => {
|
|
314
|
-
const { typeMode, ...restOptions } = options;
|
|
315
|
-
const data2 = await fetchBilibili({ ...restOptions, methodType: "\u756A\u5267\u57FA\u672C\u4FE1\u606F\u6570\u636E" }, cookie);
|
|
316
|
-
return data2;
|
|
317
|
-
},
|
|
318
|
-
/**
|
|
319
|
-
* 获取番剧下载信息数据
|
|
320
|
-
* @param options 请求参数,包含 cid, ep_id 和可选的 typeMode
|
|
321
|
-
* @param cookie 有效的用户 Cookie
|
|
322
|
-
* @returns 接口返回的原始数据
|
|
323
|
-
*/
|
|
324
|
-
getBangumiStream: async (options, cookie) => {
|
|
325
|
-
const { typeMode, ...restOptions } = options;
|
|
326
|
-
const data2 = await fetchBilibili({ ...restOptions, methodType: "\u756A\u5267\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E" }, cookie);
|
|
327
|
-
return data2;
|
|
328
|
-
},
|
|
329
|
-
/**
|
|
330
|
-
* 获取动态详情数据
|
|
331
|
-
* @param options 请求参数,包含 dynamic_id 和可选的 typeMode
|
|
332
|
-
* @param cookie 有效的用户 Cookie
|
|
333
|
-
* @returns 接口返回的原始数据
|
|
334
|
-
*/
|
|
335
|
-
getDynamicInfo: async (options, cookie) => {
|
|
336
|
-
const { typeMode, ...restOptions } = options;
|
|
337
|
-
const data2 = await fetchBilibili({ ...restOptions, methodType: "\u52A8\u6001\u8BE6\u60C5\u6570\u636E" }, cookie);
|
|
338
|
-
return data2;
|
|
339
|
-
},
|
|
340
|
-
/**
|
|
341
|
-
* 获取动态卡片数据
|
|
342
|
-
* @param options 请求参数,包含 dynamic_id 和可选的 typeMode
|
|
343
|
-
* @param cookie 有效的用户 Cookie
|
|
344
|
-
* @returns 接口返回的原始数据
|
|
345
|
-
*/
|
|
346
|
-
getDynamicCard: async (options, cookie) => {
|
|
347
|
-
const { typeMode, ...restOptions } = options;
|
|
348
|
-
const data2 = await fetchBilibili({ ...restOptions, methodType: "\u52A8\u6001\u5361\u7247\u6570\u636E" }, cookie);
|
|
349
|
-
return data2;
|
|
350
|
-
},
|
|
351
|
-
/**
|
|
352
|
-
* 获取直播间信息
|
|
353
|
-
* @param options 请求参数,包含 room_id 和可选的 typeMode
|
|
354
|
-
* @param cookie 有效的用户 Cookie
|
|
355
|
-
* @returns 接口返回的原始数据
|
|
356
|
-
*/
|
|
357
|
-
getLiveRoomDetail: async (options, cookie) => {
|
|
358
|
-
const { typeMode, ...restOptions } = options;
|
|
359
|
-
const data2 = await fetchBilibili({ ...restOptions, methodType: "\u76F4\u64AD\u95F4\u4FE1\u606F" }, cookie);
|
|
360
|
-
return data2;
|
|
361
|
-
},
|
|
362
|
-
/**
|
|
363
|
-
* 获取直播间初始化信息
|
|
364
|
-
* @param options 请求参数,包含 room_id 和可选的 typeMode
|
|
365
|
-
* @param cookie 有效的用户 Cookie
|
|
366
|
-
* @returns 接口返回的原始数据
|
|
367
|
-
*/
|
|
368
|
-
getLiveRoomInitInfo: async (options, cookie) => {
|
|
369
|
-
const { typeMode, ...restOptions } = options;
|
|
370
|
-
const data2 = await fetchBilibili({ ...restOptions, methodType: "\u76F4\u64AD\u95F4\u521D\u59CB\u5316\u4FE1\u606F" }, cookie);
|
|
371
|
-
return data2;
|
|
372
|
-
},
|
|
373
|
-
/**
|
|
374
|
-
* 获取登录基本信息
|
|
375
|
-
* @param options 可选的请求参数 (主要用于 typeMode)
|
|
376
|
-
* @param cookie 有效的用户 Cookie
|
|
377
|
-
* @returns 接口返回的原始数据
|
|
378
|
-
*/
|
|
379
|
-
getLoginBasicInfo: async (options, cookie) => {
|
|
380
|
-
const { typeMode, ...restOptions } = options;
|
|
381
|
-
const data2 = await fetchBilibili({ ...restOptions, methodType: "\u767B\u5F55\u57FA\u672C\u4FE1\u606F" }, cookie);
|
|
382
|
-
return data2;
|
|
383
|
-
},
|
|
384
|
-
/**
|
|
385
|
-
* 申请登录二维码
|
|
386
|
-
* @param options 可选的请求参数 (主要用于 typeMode)
|
|
387
|
-
* @param cookie 有效的用户 Cookie
|
|
388
|
-
* @returns 接口返回的原始数据
|
|
389
|
-
*/
|
|
390
|
-
getLoginQrcode: async (options, cookie) => {
|
|
391
|
-
const { typeMode, ...restOptions } = options;
|
|
392
|
-
const data2 = await fetchBilibili({ ...restOptions, methodType: "\u7533\u8BF7\u4E8C\u7EF4\u7801" }, cookie);
|
|
393
|
-
return data2;
|
|
394
|
-
},
|
|
395
|
-
/**
|
|
396
|
-
* 检查二维码状态
|
|
397
|
-
* @param options 请求参数,包含 qrcode_key 和可选的 typeMode
|
|
398
|
-
* @param cookie 有效的用户 Cookie
|
|
399
|
-
* @returns 接口返回的原始数据
|
|
400
|
-
*/
|
|
401
|
-
checkQrcodeStatus: async (options, cookie) => {
|
|
402
|
-
const { typeMode, ...restOptions } = options;
|
|
403
|
-
const data2 = await fetchBilibili({ ...restOptions, methodType: "\u4E8C\u7EF4\u7801\u72B6\u6001" }, cookie);
|
|
404
|
-
return data2;
|
|
405
|
-
},
|
|
406
|
-
/**
|
|
407
|
-
* 获取 UP 主总播放量
|
|
408
|
-
* @param options 请求参数,包含 host_mid 和可选的 typeMode
|
|
409
|
-
* @param cookie 有效的用户 Cookie
|
|
410
|
-
* @returns 接口返回的原始数据
|
|
411
|
-
*/
|
|
412
|
-
getUserTotalPlayCount: async (options, cookie) => {
|
|
413
|
-
const { typeMode, ...restOptions } = options;
|
|
414
|
-
const data2 = await fetchBilibili({ ...restOptions, methodType: "\u83B7\u53D6UP\u4E3B\u603B\u64AD\u653E\u91CF" }, cookie);
|
|
415
|
-
return data2;
|
|
416
|
-
},
|
|
417
|
-
/**
|
|
418
|
-
* 将 AV 号转换为 BV 号
|
|
419
|
-
* @param options 请求参数,包含 avid
|
|
420
|
-
* @param cookie 有效的用户 Cookie (此接口通常不需要)
|
|
421
|
-
* @returns 接口返回的原始数据
|
|
422
|
-
*/
|
|
423
|
-
convertAvToBv: async (options, cookie) => {
|
|
424
|
-
const { typeMode, ...restOptions } = options;
|
|
425
|
-
const data2 = await fetchBilibili({ ...restOptions, methodType: "AV\u8F6CBV" }, cookie);
|
|
426
|
-
return data2;
|
|
427
|
-
},
|
|
428
|
-
/**
|
|
429
|
-
* 将 BV 号转换为 AV 号
|
|
430
|
-
* @param options 请求参数,包含 bvid
|
|
431
|
-
* @param cookie 有效的用户 Cookie (此接口通常不需要)
|
|
432
|
-
* @returns 接口返回的原始数据
|
|
433
|
-
*/
|
|
434
|
-
convertBvToAv: async (options, cookie) => {
|
|
435
|
-
const { typeMode, ...restOptions } = options;
|
|
436
|
-
const data2 = await fetchBilibili({ ...restOptions, methodType: "BV\u8F6CAV" }, cookie);
|
|
437
|
-
return data2;
|
|
343
|
+
// src/platform/bilibili/API.ts
|
|
344
|
+
var BiLiBiLiAPI = class {
|
|
345
|
+
\u767B\u5F55\u57FA\u672C\u4FE1\u606F() {
|
|
346
|
+
return "https://api.bilibili.com/x/web-interface/nav";
|
|
347
|
+
}
|
|
348
|
+
\u89C6\u9891\u8BE6\u7EC6\u4FE1\u606F(data2) {
|
|
349
|
+
return `https://api.bilibili.com/x/web-interface/view?bvid=${data2.bvid}`;
|
|
350
|
+
}
|
|
351
|
+
\u89C6\u9891\u6D41\u4FE1\u606F(data2) {
|
|
352
|
+
return `https://api.bilibili.com/x/player/playurl?avid=${data2.avid}&cid=${data2.cid}`;
|
|
353
|
+
}
|
|
354
|
+
/** 评论区类型,type参数详见 [评论区类型代码](https://github.com/SocialSisterYi/bilibili-API-collect/blob/master/docs/comment/readme.md#评论区类型代码) */
|
|
355
|
+
\u8BC4\u8BBA\u533A\u660E\u7EC6(data2) {
|
|
356
|
+
return `https://api.bilibili.com/x/v2/reply?sort=1&ps=${data2.number ?? 20}&type=${data2.type}&oid=${data2.oid}&pn=${data2.pn}`;
|
|
357
|
+
}
|
|
358
|
+
\u8BC4\u8BBA\u533A\u72B6\u6001(data2) {
|
|
359
|
+
return `https://api.bilibili.com/x/v2/reply/subject/description?type=${data2.type}&oid=${data2.oid}`;
|
|
360
|
+
}
|
|
361
|
+
\u8868\u60C5\u5217\u8868() {
|
|
362
|
+
return "https://api.bilibili.com/x/emote/user/panel/web?business=reply&web_location=0.0";
|
|
363
|
+
}
|
|
364
|
+
\u756A\u5267\u660E\u7EC6(data2) {
|
|
365
|
+
if (data2.ep_id) {
|
|
366
|
+
return `https://api.bilibili.com/pgc/view/web/season?ep_id=${data2.ep_id}`;
|
|
367
|
+
} else if (data2.season_id) {
|
|
368
|
+
return `https://api.bilibili.com/pgc/view/web/season?season_id=${data2.season_id}`;
|
|
369
|
+
} else {
|
|
370
|
+
throw new Error("\u62DF\u9020\u63A5\u53E3\u5730\u5740\u51FA\u9519\uFF0C\u7F3A\u5C11 ep_id \u6216 season_id \u53C2\u6570");
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
\u756A\u5267\u89C6\u9891\u6D41\u4FE1\u606F(data2) {
|
|
374
|
+
return `https://api.bilibili.com/pgc/player/web/playurl?cid=${data2.cid}&ep_id=${data2.ep_id}`;
|
|
375
|
+
}
|
|
376
|
+
\u7528\u6237\u7A7A\u95F4\u52A8\u6001(data2) {
|
|
377
|
+
return `https://api.bilibili.com/x/polymer/web-dynamic/v1/feed/space?host_mid=${data2.host_mid}`;
|
|
378
|
+
}
|
|
379
|
+
\u52A8\u6001\u8BE6\u60C5(data2) {
|
|
380
|
+
return `https://api.bilibili.com/x/polymer/web-dynamic/v1/detail?id=${data2.dynamic_id}`;
|
|
381
|
+
}
|
|
382
|
+
\u52A8\u6001\u5361\u7247\u4FE1\u606F(data2) {
|
|
383
|
+
return `https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/get_dynamic_detail?dynamic_id=${data2.dynamic_id}`;
|
|
384
|
+
}
|
|
385
|
+
\u7528\u6237\u540D\u7247\u4FE1\u606F(data2) {
|
|
386
|
+
return `https://api.bilibili.com/x/web-interface/card?mid=${data2.host_mid}&photo=true`;
|
|
387
|
+
}
|
|
388
|
+
\u76F4\u64AD\u95F4\u4FE1\u606F(data2) {
|
|
389
|
+
return `https://api.live.bilibili.com/room/v1/Room/get_info?room_id=${data2.room_id}`;
|
|
390
|
+
}
|
|
391
|
+
\u76F4\u64AD\u95F4\u521D\u59CB\u5316\u4FE1\u606F(data2) {
|
|
392
|
+
return `https://api.live.bilibili.com/room/v1/Room/room_init?id=${data2.room_id}`;
|
|
393
|
+
}
|
|
394
|
+
\u7533\u8BF7\u4E8C\u7EF4\u7801() {
|
|
395
|
+
return "https://passport.bilibili.com/x/passport-login/web/qrcode/generate";
|
|
396
|
+
}
|
|
397
|
+
\u4E8C\u7EF4\u7801\u72B6\u6001(data2) {
|
|
398
|
+
return `https://passport.bilibili.com/x/passport-login/web/qrcode/poll?qrcode_key=${data2.qrcode_key}`;
|
|
399
|
+
}
|
|
400
|
+
\u83B7\u53D6UP\u4E3B\u603B\u64AD\u653E\u91CF(data2) {
|
|
401
|
+
return `https://api.bilibili.com/x/space/upstat?mid=${data2.host_mid}`;
|
|
438
402
|
}
|
|
439
403
|
};
|
|
440
|
-
var
|
|
441
|
-
|
|
442
|
-
router.get("/new_login_qrcode", async (req, res) => {
|
|
443
|
-
const data2 = await fetchBilibili({
|
|
444
|
-
methodType: "\u7533\u8BF7\u4E8C\u7EF4\u7801"
|
|
445
|
-
}, req.headers.cookie || cookie);
|
|
446
|
-
res.json(data2);
|
|
447
|
-
});
|
|
448
|
-
router.get("/check_qrcode", async (req, res) => {
|
|
449
|
-
const data2 = await fetchBilibili({
|
|
450
|
-
methodType: "\u4E8C\u7EF4\u7801\u72B6\u6001",
|
|
451
|
-
qrcode_key: req.query.qrcode_key
|
|
452
|
-
}, req.headers.cookie || cookie);
|
|
453
|
-
res.json(data2);
|
|
454
|
-
});
|
|
455
|
-
router.get("/login_basic_info", async (req, res) => {
|
|
456
|
-
const data2 = await fetchBilibili({
|
|
457
|
-
methodType: "\u767B\u5F55\u57FA\u672C\u4FE1\u606F"
|
|
458
|
-
}, req.headers.cookie || cookie);
|
|
459
|
-
res.json(data2);
|
|
460
|
-
});
|
|
461
|
-
router.get("/fetch_one_video", async (req, res) => {
|
|
462
|
-
const data2 = await fetchBilibili({
|
|
463
|
-
methodType: "\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E",
|
|
464
|
-
bvid: req.query.bvid
|
|
465
|
-
}, req.headers.cookie || cookie);
|
|
466
|
-
res.json(data2);
|
|
467
|
-
});
|
|
468
|
-
router.get("/fetch_video_playurl", async (req, res) => {
|
|
469
|
-
const data2 = await fetchBilibili({
|
|
470
|
-
methodType: "\u5355\u4E2A\u89C6\u9891\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E",
|
|
471
|
-
avid: parseInt(req.query.avid),
|
|
472
|
-
cid: parseInt(req.query.cid)
|
|
473
|
-
}, req.headers.cookie || cookie);
|
|
474
|
-
res.json(data2);
|
|
475
|
-
});
|
|
476
|
-
router.get("/fetch_work_comments", async (req, res) => {
|
|
477
|
-
const data2 = await fetchBilibili({
|
|
478
|
-
methodType: "\u8BC4\u8BBA\u6570\u636E",
|
|
479
|
-
oid: Number(req.query.oid),
|
|
480
|
-
number: Number(req.query.number),
|
|
481
|
-
type: Number(req.query.type ?? 1)
|
|
482
|
-
}, req.headers.cookie || cookie);
|
|
483
|
-
res.json(data2);
|
|
484
|
-
});
|
|
485
|
-
router.get("/fetch_emoji_list", async (req, res) => {
|
|
486
|
-
const data2 = await fetchBilibili({
|
|
487
|
-
methodType: "Emoji\u6570\u636E"
|
|
488
|
-
}, req.headers.cookie || cookie);
|
|
489
|
-
res.json(data2);
|
|
490
|
-
});
|
|
491
|
-
router.get("/fetch_bangumi_video_info", async (req, res) => {
|
|
492
|
-
const data2 = await fetchBilibili({
|
|
493
|
-
methodType: "\u756A\u5267\u57FA\u672C\u4FE1\u606F\u6570\u636E",
|
|
494
|
-
ep_id: req.query.ep_id
|
|
495
|
-
}, req.headers.cookie || cookie);
|
|
496
|
-
res.json(data2);
|
|
497
|
-
});
|
|
498
|
-
router.get("/fetch_bangumi_video_playurl", async (req, res) => {
|
|
499
|
-
const data2 = await fetchBilibili({
|
|
500
|
-
methodType: "\u756A\u5267\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E",
|
|
501
|
-
cid: parseInt(req.query.cid),
|
|
502
|
-
ep_id: req.query.ep_id
|
|
503
|
-
}, req.headers.cookie || cookie);
|
|
504
|
-
res.json(data2);
|
|
505
|
-
});
|
|
506
|
-
router.get("/fetch_user_dynamic", async (req, res) => {
|
|
507
|
-
const data2 = await fetchBilibili({
|
|
508
|
-
methodType: "\u7528\u6237\u4E3B\u9875\u52A8\u6001\u5217\u8868\u6570\u636E",
|
|
509
|
-
host_mid: parseInt(req.query.host_mid)
|
|
510
|
-
}, req.headers.cookie || cookie);
|
|
511
|
-
res.json(data2);
|
|
512
|
-
});
|
|
513
|
-
router.get("/fetch_dynamic_info", async (req, res) => {
|
|
514
|
-
const data2 = await fetchBilibili({
|
|
515
|
-
methodType: "\u52A8\u6001\u8BE6\u60C5\u6570\u636E",
|
|
516
|
-
dynamic_id: req.query.dynamic_id
|
|
517
|
-
}, req.headers.cookie || cookie);
|
|
518
|
-
res.json(data2);
|
|
519
|
-
});
|
|
520
|
-
router.get("/fetch_dynamic_card", async (req, res) => {
|
|
521
|
-
const data2 = await fetchBilibili({
|
|
522
|
-
methodType: "\u52A8\u6001\u5361\u7247\u6570\u636E",
|
|
523
|
-
dynamic_id: req.query.dynamic_id
|
|
524
|
-
}, req.headers.cookie || cookie);
|
|
525
|
-
res.json(data2);
|
|
526
|
-
});
|
|
527
|
-
router.get("/fetch_user_profile", async (req, res) => {
|
|
528
|
-
const data2 = await fetchBilibili({
|
|
529
|
-
methodType: "\u7528\u6237\u4E3B\u9875\u6570\u636E",
|
|
530
|
-
host_mid: parseInt(req.query.host_mid)
|
|
531
|
-
}, req.headers.cookie || cookie);
|
|
532
|
-
res.json(data2);
|
|
533
|
-
});
|
|
534
|
-
router.get("/fetch_live_room_detail", async (req, res) => {
|
|
535
|
-
const data2 = await fetchBilibili({
|
|
536
|
-
methodType: "\u76F4\u64AD\u95F4\u4FE1\u606F",
|
|
537
|
-
room_id: req.query.room_id
|
|
538
|
-
}, req.headers.cookie || cookie);
|
|
539
|
-
res.json(data2);
|
|
540
|
-
});
|
|
541
|
-
router.get("/fetch_liveroom_def", async (req, res) => {
|
|
542
|
-
const data2 = await fetchBilibili({
|
|
543
|
-
methodType: "\u76F4\u64AD\u95F4\u521D\u59CB\u5316\u4FE1\u606F",
|
|
544
|
-
room_id: req.query.room_id
|
|
545
|
-
}, req.headers.cookie || cookie);
|
|
546
|
-
res.json(data2);
|
|
547
|
-
});
|
|
548
|
-
router.get("/bv_to_av", async (req, res) => {
|
|
549
|
-
const data2 = await fetchBilibili({
|
|
550
|
-
methodType: "BV\u8F6CAV",
|
|
551
|
-
bvid: req.query.bvid
|
|
552
|
-
}, req.headers.cookie || cookie);
|
|
553
|
-
res.json(data2);
|
|
554
|
-
});
|
|
555
|
-
router.get("/av_to_bv", async (req, res) => {
|
|
556
|
-
const data2 = await fetchBilibili({
|
|
557
|
-
methodType: "AV\u8F6CBV",
|
|
558
|
-
avid: req.query.avid
|
|
559
|
-
}, req.headers.cookie || cookie);
|
|
560
|
-
res.json(data2);
|
|
561
|
-
});
|
|
562
|
-
router.get("/fetch_user_full_view", async (req, res) => {
|
|
563
|
-
const data2 = await fetchBilibili({
|
|
564
|
-
methodType: "\u83B7\u53D6UP\u4E3B\u603B\u64AD\u653E\u91CF",
|
|
565
|
-
host_mid: parseInt(req.query.host_mid)
|
|
566
|
-
}, req.headers.cookie || cookie);
|
|
567
|
-
res.json(data2);
|
|
568
|
-
});
|
|
569
|
-
return router;
|
|
570
|
-
};
|
|
571
|
-
|
|
572
|
-
// src/platform/bilibili/index.ts
|
|
573
|
-
var bilibiliUtils = {
|
|
574
|
-
sign: {
|
|
575
|
-
wbi_sign,
|
|
576
|
-
av2bv,
|
|
577
|
-
bv2av
|
|
578
|
-
},
|
|
579
|
-
bilibiliApiUrls,
|
|
580
|
-
getBilibiliData,
|
|
581
|
-
api: bilibili
|
|
582
|
-
};
|
|
404
|
+
var bilibiliAPI = new BiLiBiLiAPI();
|
|
405
|
+
var bilibiliApiUrls = new BiLiBiLiAPI();
|
|
583
406
|
|
|
584
407
|
// src/platform/bilibili/getdata.ts
|
|
585
408
|
var defheaders = {
|
|
@@ -604,7 +427,6 @@ var fetchBilibili = async (data2, cookie) => {
|
|
|
604
427
|
};
|
|
605
428
|
switch (data2.methodType) {
|
|
606
429
|
case "\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E": {
|
|
607
|
-
BilibiliValidateData(data2, ["bvid"]);
|
|
608
430
|
const INFODATA = await GlobalGetData({
|
|
609
431
|
url: bilibiliApiUrls.\u89C6\u9891\u8BE6\u7EC6\u4FE1\u606F({ bvid: data2.bvid }),
|
|
610
432
|
...data2
|
|
@@ -612,7 +434,6 @@ var fetchBilibili = async (data2, cookie) => {
|
|
|
612
434
|
return INFODATA;
|
|
613
435
|
}
|
|
614
436
|
case "\u5355\u4E2A\u89C6\u9891\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E": {
|
|
615
|
-
BilibiliValidateData(data2, ["avid", "cid"]);
|
|
616
437
|
const BASEURL = bilibiliApiUrls.\u89C6\u9891\u6D41\u4FE1\u606F({ avid: data2.avid, cid: data2.cid });
|
|
617
438
|
const SIGN = await qtparam(BASEURL, headers2.cookie);
|
|
618
439
|
const DATA = await GlobalGetData({
|
|
@@ -623,7 +444,6 @@ var fetchBilibili = async (data2, cookie) => {
|
|
|
623
444
|
return DATA;
|
|
624
445
|
}
|
|
625
446
|
case "\u8BC4\u8BBA\u6570\u636E": {
|
|
626
|
-
BilibiliValidateData(data2, ["oid", "type"]);
|
|
627
447
|
let { oid, number, pn, type } = data2;
|
|
628
448
|
let fetchedComments = [];
|
|
629
449
|
pn = pn ?? 1;
|
|
@@ -698,7 +518,6 @@ var fetchBilibili = async (data2, cookie) => {
|
|
|
698
518
|
case "\u756A\u5267\u57FA\u672C\u4FE1\u606F\u6570\u636E": {
|
|
699
519
|
let id = data2.ep_id ? data2.ep_id : data2.season_id;
|
|
700
520
|
if (!id) {
|
|
701
|
-
BilibiliValidateData(data2, ["ep_id"]);
|
|
702
521
|
return false;
|
|
703
522
|
}
|
|
704
523
|
const idType = id ? id.startsWith("ep") ? "ep_id" : "season_id" : "ep_id";
|
|
@@ -711,7 +530,6 @@ var fetchBilibili = async (data2, cookie) => {
|
|
|
711
530
|
return INFO;
|
|
712
531
|
}
|
|
713
532
|
case "\u756A\u5267\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E": {
|
|
714
|
-
BilibiliValidateData(data2, ["cid", "ep_id"]);
|
|
715
533
|
const BASEURL = bilibiliApiUrls.\u756A\u5267\u89C6\u9891\u6D41\u4FE1\u606F({ cid: data2.cid, ep_id: data2.ep_id.replace("ep", "") });
|
|
716
534
|
const SIGN = await qtparam(BASEURL, headers2.cookie);
|
|
717
535
|
const DATA = await GlobalGetData({
|
|
@@ -722,7 +540,6 @@ var fetchBilibili = async (data2, cookie) => {
|
|
|
722
540
|
return DATA;
|
|
723
541
|
}
|
|
724
542
|
case "\u7528\u6237\u4E3B\u9875\u52A8\u6001\u5217\u8868\u6570\u636E": {
|
|
725
|
-
BilibiliValidateData(data2, ["host_mid"]);
|
|
726
543
|
delete headers2.referer;
|
|
727
544
|
const { host_mid } = data2;
|
|
728
545
|
const result = await GlobalGetData({
|
|
@@ -733,7 +550,6 @@ var fetchBilibili = async (data2, cookie) => {
|
|
|
733
550
|
return result;
|
|
734
551
|
}
|
|
735
552
|
case "\u52A8\u6001\u8BE6\u60C5\u6570\u636E": {
|
|
736
|
-
BilibiliValidateData(data2, ["dynamic_id"]);
|
|
737
553
|
delete headers2.referer;
|
|
738
554
|
const dynamicINFO = await GlobalGetData({
|
|
739
555
|
url: bilibiliApiUrls.\u52A8\u6001\u8BE6\u60C5({ dynamic_id: data2.dynamic_id }),
|
|
@@ -743,7 +559,6 @@ var fetchBilibili = async (data2, cookie) => {
|
|
|
743
559
|
return dynamicINFO;
|
|
744
560
|
}
|
|
745
561
|
case "\u52A8\u6001\u5361\u7247\u6570\u636E": {
|
|
746
|
-
BilibiliValidateData(data2, ["dynamic_id"]);
|
|
747
562
|
delete headers2.referer;
|
|
748
563
|
const { dynamic_id } = data2;
|
|
749
564
|
const dynamicINFO_CARD = await GlobalGetData({
|
|
@@ -754,7 +569,6 @@ var fetchBilibili = async (data2, cookie) => {
|
|
|
754
569
|
return dynamicINFO_CARD;
|
|
755
570
|
}
|
|
756
571
|
case "\u7528\u6237\u4E3B\u9875\u6570\u636E": {
|
|
757
|
-
BilibiliValidateData(data2, ["host_mid"]);
|
|
758
572
|
const { host_mid } = data2;
|
|
759
573
|
const result = await GlobalGetData({
|
|
760
574
|
url: bilibiliApiUrls.\u7528\u6237\u540D\u7247\u4FE1\u606F({ host_mid }),
|
|
@@ -764,7 +578,6 @@ var fetchBilibili = async (data2, cookie) => {
|
|
|
764
578
|
return result;
|
|
765
579
|
}
|
|
766
580
|
case "\u76F4\u64AD\u95F4\u4FE1\u606F": {
|
|
767
|
-
BilibiliValidateData(data2, ["room_id"]);
|
|
768
581
|
const result = await GlobalGetData({
|
|
769
582
|
url: bilibiliApiUrls.\u76F4\u64AD\u95F4\u4FE1\u606F({ room_id: data2.room_id }),
|
|
770
583
|
headers: headers2,
|
|
@@ -773,7 +586,6 @@ var fetchBilibili = async (data2, cookie) => {
|
|
|
773
586
|
return result;
|
|
774
587
|
}
|
|
775
588
|
case "\u76F4\u64AD\u95F4\u521D\u59CB\u5316\u4FE1\u606F": {
|
|
776
|
-
BilibiliValidateData(data2, ["room_id"]);
|
|
777
589
|
const result = await GlobalGetData({
|
|
778
590
|
url: bilibiliApiUrls.\u76F4\u64AD\u95F4\u521D\u59CB\u5316\u4FE1\u606F({ room_id: data2.room_id }),
|
|
779
591
|
headers: headers2,
|
|
@@ -790,7 +602,6 @@ var fetchBilibili = async (data2, cookie) => {
|
|
|
790
602
|
return result;
|
|
791
603
|
}
|
|
792
604
|
case "\u4E8C\u7EF4\u7801\u72B6\u6001": {
|
|
793
|
-
BilibiliValidateData(data2, ["qrcode_key"]);
|
|
794
605
|
const result = await new Networks({
|
|
795
606
|
url: bilibiliApiUrls.\u4E8C\u7EF4\u7801\u72B6\u6001({ qrcode_key: data2.qrcode_key }),
|
|
796
607
|
headers: headers2,
|
|
@@ -807,7 +618,6 @@ var fetchBilibili = async (data2, cookie) => {
|
|
|
807
618
|
return result;
|
|
808
619
|
}
|
|
809
620
|
case "\u83B7\u53D6UP\u4E3B\u603B\u64AD\u653E\u91CF": {
|
|
810
|
-
BilibiliValidateData(data2, ["host_mid"]);
|
|
811
621
|
const result = await GlobalGetData({
|
|
812
622
|
url: bilibiliApiUrls.\u83B7\u53D6UP\u4E3B\u603B\u64AD\u653E\u91CF({ host_mid: data2.host_mid }),
|
|
813
623
|
headers: headers2,
|
|
@@ -816,7 +626,6 @@ var fetchBilibili = async (data2, cookie) => {
|
|
|
816
626
|
return result;
|
|
817
627
|
}
|
|
818
628
|
case "AV\u8F6CBV": {
|
|
819
|
-
BilibiliValidateData(data2, ["avid"]);
|
|
820
629
|
const result = av2bv(Number(data2.avid.toString().replace(/^av/i, "")));
|
|
821
630
|
return {
|
|
822
631
|
code: 0,
|
|
@@ -827,7 +636,6 @@ var fetchBilibili = async (data2, cookie) => {
|
|
|
827
636
|
};
|
|
828
637
|
}
|
|
829
638
|
case "BV\u8F6CAV": {
|
|
830
|
-
BilibiliValidateData(data2, ["bvid"]);
|
|
831
639
|
const result = "av" + bv2av(data2.bvid);
|
|
832
640
|
return {
|
|
833
641
|
code: 0,
|
|
@@ -953,9 +761,701 @@ var bilibiliErrorCodeMap = {
|
|
|
953
761
|
"-799": "\u8BF7\u6C42\u8FC7\u4E8E\u9891\u7E41\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5",
|
|
954
762
|
"-8888": "\u5BF9\u4E0D\u8D77\uFF0C\u670D\u52A1\u5668\u5F00\u5C0F\u5DEE\u4E86~ (\u0CA5\uFE4F\u0CA5)"
|
|
955
763
|
};
|
|
764
|
+
var mixinKeyEncTab = [
|
|
765
|
+
46,
|
|
766
|
+
47,
|
|
767
|
+
18,
|
|
768
|
+
2,
|
|
769
|
+
53,
|
|
770
|
+
8,
|
|
771
|
+
23,
|
|
772
|
+
32,
|
|
773
|
+
15,
|
|
774
|
+
50,
|
|
775
|
+
10,
|
|
776
|
+
31,
|
|
777
|
+
58,
|
|
778
|
+
3,
|
|
779
|
+
45,
|
|
780
|
+
35,
|
|
781
|
+
27,
|
|
782
|
+
43,
|
|
783
|
+
5,
|
|
784
|
+
49,
|
|
785
|
+
33,
|
|
786
|
+
9,
|
|
787
|
+
42,
|
|
788
|
+
19,
|
|
789
|
+
29,
|
|
790
|
+
28,
|
|
791
|
+
14,
|
|
792
|
+
39,
|
|
793
|
+
12,
|
|
794
|
+
38,
|
|
795
|
+
41,
|
|
796
|
+
13,
|
|
797
|
+
37,
|
|
798
|
+
48,
|
|
799
|
+
7,
|
|
800
|
+
16,
|
|
801
|
+
24,
|
|
802
|
+
55,
|
|
803
|
+
40,
|
|
804
|
+
61,
|
|
805
|
+
26,
|
|
806
|
+
17,
|
|
807
|
+
0,
|
|
808
|
+
1,
|
|
809
|
+
60,
|
|
810
|
+
51,
|
|
811
|
+
30,
|
|
812
|
+
4,
|
|
813
|
+
22,
|
|
814
|
+
25,
|
|
815
|
+
54,
|
|
816
|
+
21,
|
|
817
|
+
56,
|
|
818
|
+
59,
|
|
819
|
+
6,
|
|
820
|
+
63,
|
|
821
|
+
57,
|
|
822
|
+
62,
|
|
823
|
+
11,
|
|
824
|
+
36,
|
|
825
|
+
20,
|
|
826
|
+
34,
|
|
827
|
+
44,
|
|
828
|
+
52
|
|
829
|
+
];
|
|
830
|
+
var getMixinKey = (orig) => mixinKeyEncTab.map((n) => orig[n]).join("").slice(0, 32);
|
|
831
|
+
var encWbi = (params, img_key, sub_key) => {
|
|
832
|
+
const mixin_key = getMixinKey(img_key + sub_key);
|
|
833
|
+
const curr_time = Math.round(Date.now() / 1e3);
|
|
834
|
+
const chr_filter = /[!'()*]/g;
|
|
835
|
+
Object.assign(params, { wts: curr_time });
|
|
836
|
+
const query = Object.keys(params).sort().map((key) => {
|
|
837
|
+
const value = params[key].toString().replace(chr_filter, "");
|
|
838
|
+
return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
|
|
839
|
+
}).join("&");
|
|
840
|
+
const wbi_sign2 = crypto__default.default.createHash("md5").update(query + mixin_key).digest("hex");
|
|
841
|
+
return `&wts=${curr_time}&w_rid=${wbi_sign2}`;
|
|
842
|
+
};
|
|
843
|
+
var getWbiKeys = async (cookie) => {
|
|
844
|
+
const res = await axios__default.default("https://api.bilibili.com/x/web-interface/nav", {
|
|
845
|
+
headers: {
|
|
846
|
+
Cookie: cookie
|
|
847
|
+
}
|
|
848
|
+
});
|
|
849
|
+
const response = res.data;
|
|
850
|
+
const {
|
|
851
|
+
data: {
|
|
852
|
+
wbi_img: { img_url, sub_url }
|
|
853
|
+
}
|
|
854
|
+
} = response;
|
|
855
|
+
return {
|
|
856
|
+
img_key: img_url.slice(img_url.lastIndexOf("/") + 1, img_url.lastIndexOf(".")),
|
|
857
|
+
sub_key: sub_url.slice(sub_url.lastIndexOf("/") + 1, sub_url.lastIndexOf("."))
|
|
858
|
+
};
|
|
859
|
+
};
|
|
860
|
+
var wbi_sign = async (BASEURL, cookie) => {
|
|
861
|
+
const web_keys = await getWbiKeys(cookie);
|
|
862
|
+
const url = new URL(BASEURL);
|
|
863
|
+
const params = {};
|
|
864
|
+
for (const [key, value] of url.searchParams.entries()) {
|
|
865
|
+
params[key] = value;
|
|
866
|
+
}
|
|
867
|
+
const query = encWbi(params, web_keys.img_key, web_keys.sub_key);
|
|
868
|
+
return query;
|
|
869
|
+
};
|
|
870
|
+
function smartNumber(errorMessage, minValue = 1, isInteger = false) {
|
|
871
|
+
if (isInteger) {
|
|
872
|
+
return zod.z.coerce.number({ required_error: errorMessage }).int(`${errorMessage.replace("\u4E0D\u80FD\u4E3A\u7A7A", "")}\u5FC5\u987B\u662F\u6574\u6570\uFF0C\u4E0D\u80FD\u5305\u542B\u5C0F\u6570`).min(minValue, `${errorMessage.replace("\u4E0D\u80FD\u4E3A\u7A7A", "")}\u5FC5\u987B\u5927\u4E8E\u7B49\u4E8E${minValue}`);
|
|
873
|
+
} else {
|
|
874
|
+
return zod.z.coerce.number({ required_error: errorMessage }).min(minValue, `${errorMessage.replace("\u4E0D\u80FD\u4E3A\u7A7A", "")}\u5FC5\u987B\u5927\u4E8E\u7B49\u4E8E${minValue}`);
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
var smartPositiveInteger = (errorMessage) => {
|
|
878
|
+
return smartNumber(errorMessage, 1, true);
|
|
879
|
+
};
|
|
956
880
|
|
|
957
|
-
// src/
|
|
958
|
-
var
|
|
881
|
+
// src/validation/douyin.ts
|
|
882
|
+
var DouyinWorkParamsSchema = zod.z.object({
|
|
883
|
+
methodType: zod.z.enum(["\u89C6\u9891\u4F5C\u54C1\u6570\u636E", "\u56FE\u96C6\u4F5C\u54C1\u6570\u636E", "\u5408\u8F91\u4F5C\u54C1\u6570\u636E", "\u805A\u5408\u89E3\u6790"]),
|
|
884
|
+
aweme_id: zod.z.string({ required_error: "\u89C6\u9891ID\u4E0D\u80FD\u4E3A\u7A7A" }).min(1, "\u89C6\u9891ID\u4E0D\u80FD\u4E3A\u7A7A")
|
|
885
|
+
});
|
|
886
|
+
var DouyinCommentParamsSchema = zod.z.object({
|
|
887
|
+
methodType: zod.z.literal("\u8BC4\u8BBA\u6570\u636E"),
|
|
888
|
+
aweme_id: zod.z.string({ required_error: "\u89C6\u9891ID\u4E0D\u80FD\u4E3A\u7A7A" }).min(1, "\u89C6\u9891ID\u4E0D\u80FD\u4E3A\u7A7A"),
|
|
889
|
+
number: smartPositiveInteger("\u8BC4\u8BBA\u6570\u91CF\u5FC5\u987B\u662F\u6B63\u6574\u6570").optional().default(50),
|
|
890
|
+
cursor: zod.z.coerce.number().int().min(0).default(0).optional()
|
|
891
|
+
});
|
|
892
|
+
var DouyinSearchParamsSchema = zod.z.object({
|
|
893
|
+
methodType: zod.z.enum(["\u70ED\u70B9\u8BCD\u6570\u636E", "\u641C\u7D22\u6570\u636E"]),
|
|
894
|
+
query: zod.z.string({ required_error: "\u641C\u7D22\u8BCD\u4E0D\u80FD\u4E3A\u7A7A" }).min(1, "\u641C\u7D22\u8BCD\u4E0D\u80FD\u4E3A\u7A7A"),
|
|
895
|
+
number: smartPositiveInteger("\u641C\u7D22\u6570\u91CF\u5FC5\u987B\u662F\u6B63\u6574\u6570").optional().default(10),
|
|
896
|
+
search_id: zod.z.string().optional()
|
|
897
|
+
});
|
|
898
|
+
var DouyinCommentReplyParamsSchema = zod.z.object({
|
|
899
|
+
methodType: zod.z.literal("\u6307\u5B9A\u8BC4\u8BBA\u56DE\u590D\u6570\u636E"),
|
|
900
|
+
aweme_id: zod.z.string({ required_error: "\u89C6\u9891ID\u4E0D\u80FD\u4E3A\u7A7A" }).min(1, "\u89C6\u9891ID\u4E0D\u80FD\u4E3A\u7A7A"),
|
|
901
|
+
comment_id: zod.z.string({ required_error: "\u8BC4\u8BBAID\u4E0D\u80FD\u4E3A\u7A7A" }).min(1, "\u8BC4\u8BBAID\u4E0D\u80FD\u4E3A\u7A7A"),
|
|
902
|
+
number: smartPositiveInteger("\u8BC4\u8BBA\u6570\u91CF\u5FC5\u987B\u662F\u6B63\u6574\u6570").optional().default(5),
|
|
903
|
+
cursor: zod.z.coerce.number().int().min(0).default(0).optional()
|
|
904
|
+
});
|
|
905
|
+
var DouyinUserParamsSchema = zod.z.object({
|
|
906
|
+
methodType: zod.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"]),
|
|
907
|
+
sec_uid: zod.z.string({ required_error: "\u7528\u6237ID\u4E0D\u80FD\u4E3A\u7A7A" }).min(1, "\u7528\u6237ID\u4E0D\u80FD\u4E3A\u7A7A")
|
|
908
|
+
});
|
|
909
|
+
var DouyinMusicParamsSchema = zod.z.object({
|
|
910
|
+
methodType: zod.z.literal("\u97F3\u4E50\u6570\u636E"),
|
|
911
|
+
music_id: zod.z.string({ required_error: "\u97F3\u4E50ID\u4E0D\u80FD\u4E3A\u7A7A" }).min(1, "\u97F3\u4E50ID\u4E0D\u80FD\u4E3A\u7A7A")
|
|
912
|
+
});
|
|
913
|
+
var DouyinLiveRoomParamsSchema = zod.z.object({
|
|
914
|
+
methodType: zod.z.literal("\u76F4\u64AD\u95F4\u4FE1\u606F\u6570\u636E"),
|
|
915
|
+
room_id: zod.z.string({ required_error: "\u76F4\u64AD\u95F4ID\u4E0D\u80FD\u4E3A\u7A7A" }).min(1, "\u76F4\u64AD\u95F4ID\u4E0D\u80FD\u4E3A\u7A7A"),
|
|
916
|
+
web_rid: zod.z.string({ required_error: "\u76F4\u64AD\u95F4\u771F\u5B9E\u623F\u95F4\u53F7\u4E0D\u80FD\u4E3A\u7A7A" }).min(1, "\u76F4\u64AD\u95F4\u771F\u5B9E\u623F\u95F4\u53F7\u4E0D\u80FD\u4E3A\u7A7A")
|
|
917
|
+
});
|
|
918
|
+
var DouyinQrcodeParamsSchema = zod.z.object({
|
|
919
|
+
methodType: zod.z.literal("\u7533\u8BF7\u4E8C\u7EF4\u7801\u6570\u636E"),
|
|
920
|
+
verify_fp: zod.z.string({ required_error: "fp\u6307\u7EB9\u4E0D\u80FD\u4E3A\u7A7A" }).min(1, "fp\u6307\u7EB9\u4E0D\u80FD\u4E3A\u7A7A")
|
|
921
|
+
});
|
|
922
|
+
var DouyinEmojiListParamsSchema = zod.z.object({
|
|
923
|
+
methodType: zod.z.literal("Emoji\u6570\u636E")
|
|
924
|
+
});
|
|
925
|
+
var DouyinEmojiProParamsSchema = zod.z.object({
|
|
926
|
+
methodType: zod.z.literal("\u52A8\u6001\u8868\u60C5\u6570\u636E")
|
|
927
|
+
});
|
|
928
|
+
var DouyinValidationSchemas2 = {
|
|
929
|
+
"\u805A\u5408\u89E3\u6790": DouyinWorkParamsSchema,
|
|
930
|
+
"\u89C6\u9891\u4F5C\u54C1\u6570\u636E": DouyinWorkParamsSchema,
|
|
931
|
+
"\u56FE\u96C6\u4F5C\u54C1\u6570\u636E": DouyinWorkParamsSchema,
|
|
932
|
+
"\u5408\u8F91\u4F5C\u54C1\u6570\u636E": DouyinWorkParamsSchema,
|
|
933
|
+
"\u8BC4\u8BBA\u6570\u636E": DouyinCommentParamsSchema,
|
|
934
|
+
"\u7528\u6237\u4E3B\u9875\u6570\u636E": DouyinUserParamsSchema,
|
|
935
|
+
"\u7528\u6237\u4E3B\u9875\u89C6\u9891\u5217\u8868\u6570\u636E": DouyinUserParamsSchema,
|
|
936
|
+
"\u70ED\u70B9\u8BCD\u6570\u636E": DouyinSearchParamsSchema,
|
|
937
|
+
"\u641C\u7D22\u6570\u636E": DouyinSearchParamsSchema,
|
|
938
|
+
"\u97F3\u4E50\u6570\u636E": DouyinMusicParamsSchema,
|
|
939
|
+
"\u76F4\u64AD\u95F4\u4FE1\u606F\u6570\u636E": DouyinLiveRoomParamsSchema,
|
|
940
|
+
"\u7533\u8BF7\u4E8C\u7EF4\u7801\u6570\u636E": DouyinQrcodeParamsSchema,
|
|
941
|
+
"Emoji\u6570\u636E": DouyinEmojiListParamsSchema,
|
|
942
|
+
"\u52A8\u6001\u8868\u60C5\u6570\u636E": DouyinEmojiProParamsSchema,
|
|
943
|
+
"\u6307\u5B9A\u8BC4\u8BBA\u56DE\u590D\u6570\u636E": DouyinCommentReplyParamsSchema
|
|
944
|
+
};
|
|
945
|
+
var BilibiliVideoParamsSchema = zod.z.object({
|
|
946
|
+
methodType: zod.z.literal("\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E"),
|
|
947
|
+
bvid: zod.z.string({ required_error: "BVID\u4E0D\u80FD\u4E3A\u7A7A" }).min(1, "BVID\u4E0D\u80FD\u4E3A\u7A7A")
|
|
948
|
+
});
|
|
949
|
+
var BilibiliVideoDownloadParamsSchema = zod.z.object({
|
|
950
|
+
methodType: zod.z.literal("\u5355\u4E2A\u89C6\u9891\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E"),
|
|
951
|
+
avid: smartNumber("AVID\u4E0D\u80FD\u4E3A\u7A7A", 1, true),
|
|
952
|
+
cid: smartNumber("CID\u4E0D\u80FD\u4E3A\u7A7A", 1, true)
|
|
953
|
+
});
|
|
954
|
+
var BilibiliCommentParamsSchema = zod.z.object({
|
|
955
|
+
methodType: zod.z.literal("\u8BC4\u8BBA\u6570\u636E"),
|
|
956
|
+
oid: smartNumber("OID\u4E0D\u80FD\u4E3A\u7A7A", 1, true),
|
|
957
|
+
type: smartNumber("\u8BC4\u8BBA\u7C7B\u578B\u4E0D\u80FD\u4E3A\u7A7A", 1, true).refine(
|
|
958
|
+
(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),
|
|
959
|
+
{ message: "\u65E0\u6548\u7684\u8BC4\u8BBA\u533A\u7C7B\u578B" }
|
|
960
|
+
),
|
|
961
|
+
number: zod.z.coerce.number().int().positive().default(20).optional(),
|
|
962
|
+
pn: zod.z.coerce.number().int().positive().default(1).optional()
|
|
963
|
+
});
|
|
964
|
+
var BilibiliUserParamsSchema = zod.z.object({
|
|
965
|
+
methodType: zod.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"]),
|
|
966
|
+
host_mid: smartNumber("UP\u4E3BUID\u4E0D\u80FD\u4E3A\u7A7A", 1, true)
|
|
967
|
+
});
|
|
968
|
+
var BilibiliEmojiParamsSchema = zod.z.object({
|
|
969
|
+
methodType: zod.z.literal("Emoji\u6570\u636E")
|
|
970
|
+
});
|
|
971
|
+
var BilibiliBangumiInfoParamsSchema = zod.z.object({
|
|
972
|
+
methodType: zod.z.literal("\u756A\u5267\u57FA\u672C\u4FE1\u606F\u6570\u636E"),
|
|
973
|
+
ep_id: zod.z.string().min(1, "\u756A\u5267EP ID\u4E0D\u80FD\u4E3A\u7A7A").optional(),
|
|
974
|
+
season_id: zod.z.string().optional()
|
|
975
|
+
}).refine(
|
|
976
|
+
(data2) => data2.ep_id || data2.season_id,
|
|
977
|
+
{
|
|
978
|
+
message: "ep_id \u548C season_id \u81F3\u5C11\u9700\u8981\u63D0\u4F9B\u4E00\u4E2A",
|
|
979
|
+
path: ["ep_id"]
|
|
980
|
+
}
|
|
981
|
+
);
|
|
982
|
+
var BilibiliBangumiStreamParamsSchema = zod.z.object({
|
|
983
|
+
methodType: zod.z.literal("\u756A\u5267\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E"),
|
|
984
|
+
cid: smartNumber("CID\u4E0D\u80FD\u4E3A\u7A7A", 1, true),
|
|
985
|
+
ep_id: zod.z.string({ required_error: "\u756A\u5267EP ID\u4E0D\u80FD\u4E3A\u7A7A" }).min(1, "\u756A\u5267EP ID\u4E0D\u80FD\u4E3A\u7A7A")
|
|
986
|
+
});
|
|
987
|
+
var BilibiliDynamicParamsSchema = zod.z.object({
|
|
988
|
+
methodType: zod.z.enum(["\u52A8\u6001\u8BE6\u60C5\u6570\u636E", "\u52A8\u6001\u5361\u7247\u6570\u636E"]),
|
|
989
|
+
dynamic_id: zod.z.string({ required_error: "\u52A8\u6001ID\u4E0D\u80FD\u4E3A\u7A7A" }).min(1, "\u52A8\u6001ID\u4E0D\u80FD\u4E3A\u7A7A")
|
|
990
|
+
});
|
|
991
|
+
var BilibiliLiveParamsSchema = zod.z.object({
|
|
992
|
+
methodType: zod.z.enum(["\u76F4\u64AD\u95F4\u4FE1\u606F", "\u76F4\u64AD\u95F4\u521D\u59CB\u5316\u4FE1\u606F"]),
|
|
993
|
+
room_id: zod.z.string({ required_error: "\u76F4\u64AD\u95F4ID\u4E0D\u80FD\u4E3A\u7A7A" }).min(1, "\u76F4\u64AD\u95F4ID\u4E0D\u80FD\u4E3A\u7A7A")
|
|
994
|
+
});
|
|
995
|
+
var BilibiliLoginParamsSchema = zod.z.object({
|
|
996
|
+
methodType: zod.z.literal("\u767B\u5F55\u57FA\u672C\u4FE1\u606F")
|
|
997
|
+
});
|
|
998
|
+
var BilibiliQrcodeParamsSchema = zod.z.object({
|
|
999
|
+
methodType: zod.z.literal("\u7533\u8BF7\u4E8C\u7EF4\u7801")
|
|
1000
|
+
});
|
|
1001
|
+
var BilibiliQrcodeStatusParamsSchema = zod.z.object({
|
|
1002
|
+
methodType: zod.z.literal("\u4E8C\u7EF4\u7801\u72B6\u6001"),
|
|
1003
|
+
qrcode_key: zod.z.string({ required_error: "\u4E8C\u7EF4\u7801key\u4E0D\u80FD\u4E3A\u7A7A" }).min(1, "\u4E8C\u7EF4\u7801key\u4E0D\u80FD\u4E3A\u7A7A")
|
|
1004
|
+
});
|
|
1005
|
+
var BilibiliAv2BvParamsSchema = zod.z.object({
|
|
1006
|
+
methodType: zod.z.literal("AV\u8F6CBV"),
|
|
1007
|
+
avid: zod.z.coerce.number({ required_error: "AVID\u4E0D\u80FD\u4E3A\u7A7A" }).int().positive()
|
|
1008
|
+
});
|
|
1009
|
+
var BilibiliBv2AvParamsSchema = zod.z.object({
|
|
1010
|
+
methodType: zod.z.literal("BV\u8F6CAV"),
|
|
1011
|
+
bvid: zod.z.string({ required_error: "BVID\u4E0D\u80FD\u4E3A\u7A7A" }).min(1, "BVID\u4E0D\u80FD\u4E3A\u7A7A")
|
|
1012
|
+
});
|
|
1013
|
+
var BilibiliValidationSchemas2 = {
|
|
1014
|
+
"\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E": BilibiliVideoParamsSchema,
|
|
1015
|
+
"\u5355\u4E2A\u89C6\u9891\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E": BilibiliVideoDownloadParamsSchema,
|
|
1016
|
+
"\u8BC4\u8BBA\u6570\u636E": BilibiliCommentParamsSchema,
|
|
1017
|
+
"\u7528\u6237\u4E3B\u9875\u6570\u636E": BilibiliUserParamsSchema,
|
|
1018
|
+
"\u7528\u6237\u4E3B\u9875\u52A8\u6001\u5217\u8868\u6570\u636E": BilibiliUserParamsSchema,
|
|
1019
|
+
"Emoji\u6570\u636E": BilibiliEmojiParamsSchema,
|
|
1020
|
+
"\u756A\u5267\u57FA\u672C\u4FE1\u606F\u6570\u636E": BilibiliBangumiInfoParamsSchema,
|
|
1021
|
+
"\u756A\u5267\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E": BilibiliBangumiStreamParamsSchema,
|
|
1022
|
+
"\u52A8\u6001\u8BE6\u60C5\u6570\u636E": BilibiliDynamicParamsSchema,
|
|
1023
|
+
"\u52A8\u6001\u5361\u7247\u6570\u636E": BilibiliDynamicParamsSchema,
|
|
1024
|
+
"\u76F4\u64AD\u95F4\u4FE1\u606F": BilibiliLiveParamsSchema,
|
|
1025
|
+
"\u76F4\u64AD\u95F4\u521D\u59CB\u5316\u4FE1\u606F": BilibiliLiveParamsSchema,
|
|
1026
|
+
"\u767B\u5F55\u57FA\u672C\u4FE1\u606F": BilibiliLoginParamsSchema,
|
|
1027
|
+
"\u7533\u8BF7\u4E8C\u7EF4\u7801": BilibiliQrcodeParamsSchema,
|
|
1028
|
+
"\u4E8C\u7EF4\u7801\u72B6\u6001": BilibiliQrcodeStatusParamsSchema,
|
|
1029
|
+
"\u83B7\u53D6UP\u4E3B\u603B\u64AD\u653E\u91CF": BilibiliUserParamsSchema,
|
|
1030
|
+
"AV\u8F6CBV": BilibiliAv2BvParamsSchema,
|
|
1031
|
+
"BV\u8F6CAV": BilibiliBv2AvParamsSchema
|
|
1032
|
+
};
|
|
1033
|
+
var KuaishouVideoParamsSchema = zod.z.object({
|
|
1034
|
+
methodType: zod.z.literal("\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E"),
|
|
1035
|
+
photoId: zod.z.string({ required_error: "\u89C6\u9891ID\u4E0D\u80FD\u4E3A\u7A7A" }).min(1, "\u89C6\u9891ID\u4E0D\u80FD\u4E3A\u7A7A")
|
|
1036
|
+
});
|
|
1037
|
+
var KuaishouCommentParamsSchema = zod.z.object({
|
|
1038
|
+
methodType: zod.z.literal("\u8BC4\u8BBA\u6570\u636E"),
|
|
1039
|
+
photoId: zod.z.string({ required_error: "\u89C6\u9891ID\u4E0D\u80FD\u4E3A\u7A7A" }).min(1, "\u89C6\u9891ID\u4E0D\u80FD\u4E3A\u7A7A")
|
|
1040
|
+
});
|
|
1041
|
+
var KuaishouEmojiParamsSchema = zod.z.object({
|
|
1042
|
+
methodType: zod.z.literal("Emoji\u6570\u636E")
|
|
1043
|
+
});
|
|
1044
|
+
var KuaishouValidationSchemas2 = {
|
|
1045
|
+
"\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E": KuaishouVideoParamsSchema,
|
|
1046
|
+
"\u8BC4\u8BBA\u6570\u636E": KuaishouCommentParamsSchema,
|
|
1047
|
+
"Emoji\u6570\u636E": KuaishouEmojiParamsSchema
|
|
1048
|
+
};
|
|
1049
|
+
|
|
1050
|
+
// src/validation/index.ts
|
|
1051
|
+
var validateDouyinParams = (methodType, params) => {
|
|
1052
|
+
const schema = DouyinValidationSchemas2[methodType];
|
|
1053
|
+
const validated = schema.parse(
|
|
1054
|
+
typeof params === "object" && params !== null ? { methodType, ...params } : { methodType, params }
|
|
1055
|
+
);
|
|
1056
|
+
return validated;
|
|
1057
|
+
};
|
|
1058
|
+
var validateBilibiliParams = (methodType, params) => {
|
|
1059
|
+
const schema = BilibiliValidationSchemas2[methodType];
|
|
1060
|
+
const validated = schema.parse(
|
|
1061
|
+
typeof params === "object" && params !== null ? { methodType, ...params } : { methodType, params }
|
|
1062
|
+
);
|
|
1063
|
+
return validated;
|
|
1064
|
+
};
|
|
1065
|
+
var validateKuaishouParams = (methodType, params) => {
|
|
1066
|
+
const schema = KuaishouValidationSchemas2[methodType];
|
|
1067
|
+
const validated = schema.parse(
|
|
1068
|
+
typeof params === "object" && params !== null ? { methodType, ...params } : { methodType, params }
|
|
1069
|
+
);
|
|
1070
|
+
return validated;
|
|
1071
|
+
};
|
|
1072
|
+
var createApiResponse = (data2, message, code) => {
|
|
1073
|
+
const dynamicSchema = zod.z.object({
|
|
1074
|
+
code: zod.z.number().optional(),
|
|
1075
|
+
message: zod.z.string().optional(),
|
|
1076
|
+
data: zod.z.custom()
|
|
1077
|
+
});
|
|
1078
|
+
const validated = dynamicSchema.parse({
|
|
1079
|
+
code,
|
|
1080
|
+
message,
|
|
1081
|
+
data: data2
|
|
1082
|
+
});
|
|
1083
|
+
return {
|
|
1084
|
+
...validated,
|
|
1085
|
+
data: data2
|
|
1086
|
+
};
|
|
1087
|
+
};
|
|
1088
|
+
|
|
1089
|
+
// src/platform/bilibili/BilibiliApi.ts
|
|
1090
|
+
var bilibili = {
|
|
1091
|
+
/**
|
|
1092
|
+
* 获取单个视频作品数据
|
|
1093
|
+
* @param options 请求参数,包含 bvid 和可选的 typeMode
|
|
1094
|
+
* @param cookie 有效的用户 Cookie
|
|
1095
|
+
* @returns 统一格式的API响应
|
|
1096
|
+
*/
|
|
1097
|
+
getVideoInfo: async (options, cookie) => {
|
|
1098
|
+
try {
|
|
1099
|
+
const { typeMode, ...restOptions } = options;
|
|
1100
|
+
const data2 = await fetchBilibili({ ...restOptions, methodType: "\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E" }, cookie);
|
|
1101
|
+
return createApiResponse(data2, "\u83B7\u53D6\u89C6\u9891\u4FE1\u606F\u6210\u529F", 200);
|
|
1102
|
+
} catch (error) {
|
|
1103
|
+
return createApiResponse(null, `\u83B7\u53D6\u89C6\u9891\u4FE1\u606F\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
|
|
1104
|
+
}
|
|
1105
|
+
},
|
|
1106
|
+
/**
|
|
1107
|
+
* 获取单个视频下载信息数据
|
|
1108
|
+
* @param options 请求参数,包含 avid, cid 和可选的 typeMode
|
|
1109
|
+
* @param cookie 有效的用户 Cookie
|
|
1110
|
+
* @returns 统一格式的API响应
|
|
1111
|
+
*/
|
|
1112
|
+
getVideoStream: async (options, cookie) => {
|
|
1113
|
+
try {
|
|
1114
|
+
const { typeMode, ...restOptions } = options;
|
|
1115
|
+
const data2 = await fetchBilibili({ ...restOptions, methodType: "\u5355\u4E2A\u89C6\u9891\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E" }, cookie);
|
|
1116
|
+
return createApiResponse(data2, "\u83B7\u53D6\u89C6\u9891\u4E0B\u8F7D\u4FE1\u606F\u6210\u529F", 200);
|
|
1117
|
+
} catch (error) {
|
|
1118
|
+
return createApiResponse(null, `\u83B7\u53D6\u89C6\u9891\u4E0B\u8F7D\u4FE1\u606F\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
|
|
1119
|
+
}
|
|
1120
|
+
},
|
|
1121
|
+
/**
|
|
1122
|
+
* 获取评论数据
|
|
1123
|
+
* @param options 请求参数,包含 type, oid, 可选的 number, pn 和 typeMode
|
|
1124
|
+
* @param cookie 有效的用户 Cookie
|
|
1125
|
+
* @returns 统一格式的API响应
|
|
1126
|
+
*/
|
|
1127
|
+
getComments: async (options, cookie) => {
|
|
1128
|
+
try {
|
|
1129
|
+
const { typeMode, ...restOptions } = options;
|
|
1130
|
+
const data2 = await fetchBilibili({ ...restOptions, methodType: "\u8BC4\u8BBA\u6570\u636E" }, cookie);
|
|
1131
|
+
return createApiResponse(data2, "\u83B7\u53D6\u8BC4\u8BBA\u6570\u636E\u6210\u529F", 200);
|
|
1132
|
+
} catch (error) {
|
|
1133
|
+
return createApiResponse(null, `\u83B7\u53D6\u8BC4\u8BBA\u6570\u636E\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
|
|
1134
|
+
}
|
|
1135
|
+
},
|
|
1136
|
+
/**
|
|
1137
|
+
* 获取用户主页数据
|
|
1138
|
+
* @param options 请求参数,包含 host_mid 和可选的 typeMode
|
|
1139
|
+
* @param cookie 有效的用户 Cookie
|
|
1140
|
+
* @returns 统一格式的API响应
|
|
1141
|
+
*/
|
|
1142
|
+
getUserProfile: async (options, cookie) => {
|
|
1143
|
+
try {
|
|
1144
|
+
const { typeMode, ...restOptions } = options;
|
|
1145
|
+
const data2 = await fetchBilibili({ ...restOptions, methodType: "\u7528\u6237\u4E3B\u9875\u6570\u636E" }, cookie);
|
|
1146
|
+
return createApiResponse(data2, "\u83B7\u53D6\u7528\u6237\u4E3B\u9875\u6570\u636E\u6210\u529F", 200);
|
|
1147
|
+
} catch (error) {
|
|
1148
|
+
return createApiResponse(null, `\u83B7\u53D6\u7528\u6237\u4E3B\u9875\u6570\u636E\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
|
|
1149
|
+
}
|
|
1150
|
+
},
|
|
1151
|
+
/**
|
|
1152
|
+
* 获取用户主页动态列表数据
|
|
1153
|
+
* @param options 请求参数,包含 host_mid 和可选的 typeMode
|
|
1154
|
+
* @param cookie 有效的用户 Cookie
|
|
1155
|
+
* @returns 统一格式的API响应
|
|
1156
|
+
*/
|
|
1157
|
+
getUserDynamic: async (options, cookie) => {
|
|
1158
|
+
try {
|
|
1159
|
+
const { typeMode, ...restOptions } = options;
|
|
1160
|
+
const data2 = await fetchBilibili({ ...restOptions, methodType: "\u7528\u6237\u4E3B\u9875\u52A8\u6001\u5217\u8868\u6570\u636E" }, cookie);
|
|
1161
|
+
return createApiResponse(data2, "\u83B7\u53D6\u7528\u6237\u4E3B\u9875\u52A8\u6001\u5217\u8868\u6570\u636E\u6210\u529F", 200);
|
|
1162
|
+
} catch (error) {
|
|
1163
|
+
return createApiResponse(null, `\u83B7\u53D6\u7528\u6237\u4E3B\u9875\u52A8\u6001\u5217\u8868\u6570\u636E\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
|
|
1164
|
+
}
|
|
1165
|
+
},
|
|
1166
|
+
/**
|
|
1167
|
+
* 获取 Emoji 数据
|
|
1168
|
+
* @param options 可选的请求参数 (主要用于 typeMode)
|
|
1169
|
+
* @param cookie 有效的用户 Cookie
|
|
1170
|
+
* @returns 统一格式的API响应
|
|
1171
|
+
*/
|
|
1172
|
+
getEmojiList: async (options, cookie) => {
|
|
1173
|
+
try {
|
|
1174
|
+
const { typeMode, ...restOptions } = options;
|
|
1175
|
+
const data2 = await fetchBilibili({ ...restOptions, methodType: "Emoji\u6570\u636E" }, cookie);
|
|
1176
|
+
return createApiResponse(data2, "\u83B7\u53D6Emoji\u6570\u636E\u6210\u529F", 200);
|
|
1177
|
+
} catch (error) {
|
|
1178
|
+
return createApiResponse(null, `\u83B7\u53D6Emoji\u6570\u636E\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
|
|
1179
|
+
}
|
|
1180
|
+
},
|
|
1181
|
+
/**
|
|
1182
|
+
* 获取番剧基本信息数据
|
|
1183
|
+
* @param options 请求参数,包含可选的 season_id, ep_id 和 typeMode
|
|
1184
|
+
* @param cookie 有效的用户 Cookie
|
|
1185
|
+
* @returns 统一格式的API响应
|
|
1186
|
+
*/
|
|
1187
|
+
getBangumiInfo: async (options, cookie) => {
|
|
1188
|
+
try {
|
|
1189
|
+
const { typeMode, ...restOptions } = options;
|
|
1190
|
+
const data2 = await fetchBilibili({ ...restOptions, methodType: "\u756A\u5267\u57FA\u672C\u4FE1\u606F\u6570\u636E" }, cookie);
|
|
1191
|
+
return createApiResponse(data2, "\u83B7\u53D6\u756A\u5267\u57FA\u672C\u4FE1\u606F\u6570\u636E\u6210\u529F", 200);
|
|
1192
|
+
} catch (error) {
|
|
1193
|
+
return createApiResponse(null, `\u83B7\u53D6\u756A\u5267\u57FA\u672C\u4FE1\u606F\u6570\u636E\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
|
|
1194
|
+
}
|
|
1195
|
+
},
|
|
1196
|
+
/**
|
|
1197
|
+
* 获取番剧下载信息数据
|
|
1198
|
+
* @param options 请求参数,包含 cid, ep_id 和可选的 typeMode
|
|
1199
|
+
* @param cookie 有效的用户 Cookie
|
|
1200
|
+
* @returns 统一格式的API响应
|
|
1201
|
+
*/
|
|
1202
|
+
getBangumiStream: async (options, cookie) => {
|
|
1203
|
+
try {
|
|
1204
|
+
const { typeMode, ...restOptions } = options;
|
|
1205
|
+
const data2 = await fetchBilibili({ ...restOptions, methodType: "\u756A\u5267\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E" }, cookie);
|
|
1206
|
+
return createApiResponse(data2, "\u83B7\u53D6\u756A\u5267\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E\u6210\u529F", 200);
|
|
1207
|
+
} catch (error) {
|
|
1208
|
+
return createApiResponse(null, `\u83B7\u53D6\u756A\u5267\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
|
|
1209
|
+
}
|
|
1210
|
+
},
|
|
1211
|
+
/**
|
|
1212
|
+
* 获取动态详情数据
|
|
1213
|
+
* @param options 请求参数,包含 dynamic_id 和可选的 typeMode
|
|
1214
|
+
* @param cookie 有效的用户 Cookie
|
|
1215
|
+
* @returns 统一格式的API响应
|
|
1216
|
+
*/
|
|
1217
|
+
getDynamicInfo: async (options, cookie) => {
|
|
1218
|
+
try {
|
|
1219
|
+
const { typeMode, ...restOptions } = options;
|
|
1220
|
+
const data2 = await fetchBilibili({ ...restOptions, methodType: "\u52A8\u6001\u8BE6\u60C5\u6570\u636E" }, cookie);
|
|
1221
|
+
return createApiResponse(data2, "\u83B7\u53D6\u52A8\u6001\u8BE6\u60C5\u6570\u636E\u6210\u529F", 200);
|
|
1222
|
+
} catch (error) {
|
|
1223
|
+
return createApiResponse(null, `\u83B7\u53D6\u52A8\u6001\u8BE6\u60C5\u6570\u636E\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
|
|
1224
|
+
}
|
|
1225
|
+
},
|
|
1226
|
+
/**
|
|
1227
|
+
* 获取动态卡片数据
|
|
1228
|
+
* @param options 请求参数,包含 dynamic_id 和可选的 typeMode
|
|
1229
|
+
* @param cookie 有效的用户 Cookie
|
|
1230
|
+
* @returns 统一格式的API响应
|
|
1231
|
+
*/
|
|
1232
|
+
getDynamicCard: async (options, cookie) => {
|
|
1233
|
+
try {
|
|
1234
|
+
const { typeMode, ...restOptions } = options;
|
|
1235
|
+
const data2 = await fetchBilibili({ ...restOptions, methodType: "\u52A8\u6001\u5361\u7247\u6570\u636E" }, cookie);
|
|
1236
|
+
return createApiResponse(data2, "\u83B7\u53D6\u52A8\u6001\u5361\u7247\u6570\u636E\u6210\u529F", 200);
|
|
1237
|
+
} catch (error) {
|
|
1238
|
+
return createApiResponse(null, `\u83B7\u53D6\u52A8\u6001\u5361\u7247\u6570\u636E\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
|
|
1239
|
+
}
|
|
1240
|
+
},
|
|
1241
|
+
/**
|
|
1242
|
+
* 获取直播间信息
|
|
1243
|
+
* @param options 请求参数,包含 room_id 和可选的 typeMode
|
|
1244
|
+
* @param cookie 有效的用户 Cookie
|
|
1245
|
+
* @returns 统一格式的API响应
|
|
1246
|
+
*/
|
|
1247
|
+
getLiveRoomDetail: async (options, cookie) => {
|
|
1248
|
+
try {
|
|
1249
|
+
const { typeMode, ...restOptions } = options;
|
|
1250
|
+
const data2 = await fetchBilibili({ ...restOptions, methodType: "\u76F4\u64AD\u95F4\u4FE1\u606F" }, cookie);
|
|
1251
|
+
return createApiResponse(data2, "\u83B7\u53D6\u76F4\u64AD\u95F4\u4FE1\u606F\u6210\u529F", 200);
|
|
1252
|
+
} catch (error) {
|
|
1253
|
+
return createApiResponse(null, `\u83B7\u53D6\u76F4\u64AD\u95F4\u4FE1\u606F\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
|
|
1254
|
+
}
|
|
1255
|
+
},
|
|
1256
|
+
/**
|
|
1257
|
+
* 获取直播间初始化信息
|
|
1258
|
+
* @param options 请求参数,包含 room_id 和可选的 typeMode
|
|
1259
|
+
* @param cookie 有效的用户 Cookie
|
|
1260
|
+
* @returns 统一格式的API响应
|
|
1261
|
+
*/
|
|
1262
|
+
getLiveRoomInitInfo: async (options, cookie) => {
|
|
1263
|
+
try {
|
|
1264
|
+
const { typeMode, ...restOptions } = options;
|
|
1265
|
+
const data2 = await fetchBilibili({ ...restOptions, methodType: "\u76F4\u64AD\u95F4\u521D\u59CB\u5316\u4FE1\u606F" }, cookie);
|
|
1266
|
+
return createApiResponse(data2, "\u83B7\u53D6\u76F4\u64AD\u95F4\u521D\u59CB\u5316\u4FE1\u606F\u6210\u529F", 200);
|
|
1267
|
+
} catch (error) {
|
|
1268
|
+
return createApiResponse(null, `\u83B7\u53D6\u76F4\u64AD\u95F4\u521D\u59CB\u5316\u4FE1\u606F\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
|
|
1269
|
+
}
|
|
1270
|
+
},
|
|
1271
|
+
/**
|
|
1272
|
+
* 获取登录基本信息
|
|
1273
|
+
* @param options 可选的请求参数 (主要用于 typeMode)
|
|
1274
|
+
* @param cookie 有效的用户 Cookie
|
|
1275
|
+
* @returns 统一格式的API响应
|
|
1276
|
+
*/
|
|
1277
|
+
getLoginBasicInfo: async (options, cookie) => {
|
|
1278
|
+
try {
|
|
1279
|
+
const { typeMode, ...restOptions } = options;
|
|
1280
|
+
const data2 = await fetchBilibili({ ...restOptions, methodType: "\u767B\u5F55\u57FA\u672C\u4FE1\u606F" }, cookie);
|
|
1281
|
+
return createApiResponse(data2, "\u83B7\u53D6\u767B\u5F55\u57FA\u672C\u4FE1\u606F\u6210\u529F", 200);
|
|
1282
|
+
} catch (error) {
|
|
1283
|
+
return createApiResponse(null, `\u83B7\u53D6\u767B\u5F55\u57FA\u672C\u4FE1\u606F\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
|
|
1284
|
+
}
|
|
1285
|
+
},
|
|
1286
|
+
/**
|
|
1287
|
+
* 申请登录二维码
|
|
1288
|
+
* @param options 可选的请求参数 (主要用于 typeMode)
|
|
1289
|
+
* @param cookie 有效的用户 Cookie
|
|
1290
|
+
* @returns 统一格式的API响应
|
|
1291
|
+
*/
|
|
1292
|
+
getLoginQrcode: async (options, cookie) => {
|
|
1293
|
+
try {
|
|
1294
|
+
const { typeMode, ...restOptions } = options;
|
|
1295
|
+
const data2 = await fetchBilibili({ ...restOptions, methodType: "\u7533\u8BF7\u4E8C\u7EF4\u7801" }, cookie);
|
|
1296
|
+
return createApiResponse(data2, "\u7533\u8BF7\u767B\u5F55\u4E8C\u7EF4\u7801\u6210\u529F", 200);
|
|
1297
|
+
} catch (error) {
|
|
1298
|
+
return createApiResponse(null, `\u7533\u8BF7\u767B\u5F55\u4E8C\u7EF4\u7801\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
|
|
1299
|
+
}
|
|
1300
|
+
},
|
|
1301
|
+
/**
|
|
1302
|
+
* 检查二维码状态
|
|
1303
|
+
* @param options 请求参数,包含 qrcode_key 和可选的 typeMode
|
|
1304
|
+
* @param cookie 有效的用户 Cookie
|
|
1305
|
+
* @returns 统一格式的API响应
|
|
1306
|
+
*/
|
|
1307
|
+
checkQrcodeStatus: async (options, cookie) => {
|
|
1308
|
+
try {
|
|
1309
|
+
const { typeMode, ...restOptions } = options;
|
|
1310
|
+
const data2 = await fetchBilibili({ ...restOptions, methodType: "\u4E8C\u7EF4\u7801\u72B6\u6001" }, cookie);
|
|
1311
|
+
return createApiResponse(data2, "\u68C0\u67E5\u4E8C\u7EF4\u7801\u72B6\u6001\u6210\u529F", 200);
|
|
1312
|
+
} catch (error) {
|
|
1313
|
+
return createApiResponse(null, `\u68C0\u67E5\u4E8C\u7EF4\u7801\u72B6\u6001\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
|
|
1314
|
+
}
|
|
1315
|
+
},
|
|
1316
|
+
/**
|
|
1317
|
+
* 获取 UP 主总播放量
|
|
1318
|
+
* @param options 请求参数,包含 host_mid 和可选的 typeMode
|
|
1319
|
+
* @param cookie 有效的用户 Cookie
|
|
1320
|
+
* @returns 统一格式的API响应
|
|
1321
|
+
*/
|
|
1322
|
+
getUserTotalPlayCount: async (options, cookie) => {
|
|
1323
|
+
try {
|
|
1324
|
+
const { typeMode, ...restOptions } = options;
|
|
1325
|
+
const data2 = await fetchBilibili({ ...restOptions, methodType: "\u83B7\u53D6UP\u4E3B\u603B\u64AD\u653E\u91CF" }, cookie);
|
|
1326
|
+
return createApiResponse(data2, "\u83B7\u53D6UP\u4E3B\u603B\u64AD\u653E\u91CF\u6210\u529F", 200);
|
|
1327
|
+
} catch (error) {
|
|
1328
|
+
return createApiResponse(null, `\u83B7\u53D6UP\u4E3B\u603B\u64AD\u653E\u91CF\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
|
|
1329
|
+
}
|
|
1330
|
+
},
|
|
1331
|
+
/**
|
|
1332
|
+
* 将 AV 号转换为 BV 号
|
|
1333
|
+
* @param options 请求参数,包含 avid 和可选的 typeMode
|
|
1334
|
+
* @param cookie 有效的用户 Cookie (此接口通常不需要)
|
|
1335
|
+
* @returns 统一格式的API响应
|
|
1336
|
+
*/
|
|
1337
|
+
convertAvToBv: async (options, cookie) => {
|
|
1338
|
+
try {
|
|
1339
|
+
const { typeMode, ...restOptions } = options;
|
|
1340
|
+
const data2 = await fetchBilibili({ ...restOptions, methodType: "AV\u8F6CBV" }, cookie);
|
|
1341
|
+
return createApiResponse(data2, "AV\u53F7\u8F6C\u6362\u4E3ABV\u53F7\u6210\u529F", 200);
|
|
1342
|
+
} catch (error) {
|
|
1343
|
+
return createApiResponse(null, `AV\u53F7\u8F6C\u6362\u4E3ABV\u53F7\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
|
|
1344
|
+
}
|
|
1345
|
+
},
|
|
1346
|
+
/**
|
|
1347
|
+
* 将 BV 号转换为 AV 号
|
|
1348
|
+
* @param options 请求参数,包含 bvid 和可选的 typeMode
|
|
1349
|
+
* @param cookie 有效的用户 Cookie (此接口通常不需要)
|
|
1350
|
+
* @returns 统一格式的API响应
|
|
1351
|
+
*/
|
|
1352
|
+
convertBvToAv: async (options, cookie) => {
|
|
1353
|
+
try {
|
|
1354
|
+
const { typeMode, ...restOptions } = options;
|
|
1355
|
+
const data2 = await fetchBilibili({ ...restOptions, methodType: "BV\u8F6CAV" }, cookie);
|
|
1356
|
+
return createApiResponse(data2, "BV\u53F7\u8F6C\u6362\u4E3AAV\u53F7\u6210\u529F", 200);
|
|
1357
|
+
} catch (error) {
|
|
1358
|
+
return createApiResponse(null, `BV\u53F7\u8F6C\u6362\u4E3AAV\u53F7\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
|
|
1359
|
+
}
|
|
1360
|
+
}
|
|
1361
|
+
};
|
|
1362
|
+
var ApiError = class extends Error {
|
|
1363
|
+
code;
|
|
1364
|
+
platform;
|
|
1365
|
+
/**
|
|
1366
|
+
* 构造API错误
|
|
1367
|
+
* @param message - 错误消息
|
|
1368
|
+
* @param code - 错误代码
|
|
1369
|
+
* @param platform - 平台名称
|
|
1370
|
+
*/
|
|
1371
|
+
constructor(message, code = 500, platform = "unknown") {
|
|
1372
|
+
super(message);
|
|
1373
|
+
this.name = "ApiError";
|
|
1374
|
+
this.code = code;
|
|
1375
|
+
this.platform = platform;
|
|
1376
|
+
}
|
|
1377
|
+
};
|
|
1378
|
+
var ValidationError = class _ValidationError extends Error {
|
|
1379
|
+
errors;
|
|
1380
|
+
requestPath;
|
|
1381
|
+
/**
|
|
1382
|
+
* 构造参数验证错误
|
|
1383
|
+
* @param message - 错误消息
|
|
1384
|
+
* @param errors - 详细错误信息
|
|
1385
|
+
* @param requestPath - HTTP请求路径
|
|
1386
|
+
*/
|
|
1387
|
+
constructor(message, errors, requestPath) {
|
|
1388
|
+
super(message);
|
|
1389
|
+
this.name = "ValidationError";
|
|
1390
|
+
this.errors = errors;
|
|
1391
|
+
this.requestPath = requestPath;
|
|
1392
|
+
}
|
|
1393
|
+
/**
|
|
1394
|
+
* 从Zod错误创建验证错误
|
|
1395
|
+
* @param zodError - Zod验证错误
|
|
1396
|
+
* @param requestPath - HTTP请求路径
|
|
1397
|
+
* @returns 验证错误实例
|
|
1398
|
+
*/
|
|
1399
|
+
static fromZodError(zodError, requestPath) {
|
|
1400
|
+
const errors = zodError.errors.map((err) => ({
|
|
1401
|
+
field: err.path.join("."),
|
|
1402
|
+
message: err.message
|
|
1403
|
+
}));
|
|
1404
|
+
return new _ValidationError("\u53C2\u6570\u9A8C\u8BC1\u5931\u8D25", errors, requestPath);
|
|
1405
|
+
}
|
|
1406
|
+
};
|
|
1407
|
+
var handleError = (error, requestPath) => {
|
|
1408
|
+
if (error instanceof ValidationError) {
|
|
1409
|
+
return {
|
|
1410
|
+
code: 400,
|
|
1411
|
+
message: error.message,
|
|
1412
|
+
data: null,
|
|
1413
|
+
errors: error.errors,
|
|
1414
|
+
requestPath: error.requestPath || requestPath
|
|
1415
|
+
};
|
|
1416
|
+
}
|
|
1417
|
+
if (error instanceof ApiError) {
|
|
1418
|
+
return {
|
|
1419
|
+
code: error.code,
|
|
1420
|
+
message: error.message,
|
|
1421
|
+
data: null,
|
|
1422
|
+
platform: error.platform,
|
|
1423
|
+
requestPath
|
|
1424
|
+
};
|
|
1425
|
+
}
|
|
1426
|
+
if (error instanceof zod.z.ZodError) {
|
|
1427
|
+
const validationError = ValidationError.fromZodError(error, requestPath);
|
|
1428
|
+
return handleError(validationError, requestPath);
|
|
1429
|
+
}
|
|
1430
|
+
const errorMessage = error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF";
|
|
1431
|
+
return {
|
|
1432
|
+
code: 500,
|
|
1433
|
+
message: errorMessage,
|
|
1434
|
+
data: null,
|
|
1435
|
+
requestPath
|
|
1436
|
+
};
|
|
1437
|
+
};
|
|
1438
|
+
|
|
1439
|
+
// src/middleware/validation.ts
|
|
1440
|
+
var createValidationMiddleware = (validateFn, methodType) => {
|
|
1441
|
+
return (req, res, next) => {
|
|
1442
|
+
try {
|
|
1443
|
+
const params = { ...req.query, ...req.body };
|
|
1444
|
+
const validatedParams = validateFn(methodType, params);
|
|
1445
|
+
req.validatedParams = validatedParams;
|
|
1446
|
+
next();
|
|
1447
|
+
} catch (error) {
|
|
1448
|
+
const errorResponse = handleError(error, req.originalUrl);
|
|
1449
|
+
res.status(errorResponse.code || 500).json(errorResponse);
|
|
1450
|
+
}
|
|
1451
|
+
};
|
|
1452
|
+
};
|
|
1453
|
+
var createDouyinValidationMiddleware = (methodType) => createValidationMiddleware(validateDouyinParams, methodType);
|
|
1454
|
+
var createBilibiliValidationMiddleware = (methodType) => createValidationMiddleware(validateBilibiliParams, methodType);
|
|
1455
|
+
var createKuaishouValidationMiddleware = (methodType) => createValidationMiddleware(validateKuaishouParams, methodType);
|
|
1456
|
+
|
|
1457
|
+
// src/platform/douyin/sign/a_bogus.ts
|
|
1458
|
+
var SM3 = class {
|
|
959
1459
|
reg;
|
|
960
1460
|
chunk;
|
|
961
1461
|
size;
|
|
@@ -1418,274 +1918,6 @@ var DouyinAPI = class {
|
|
|
1418
1918
|
var douyinAPI = new DouyinAPI();
|
|
1419
1919
|
var douyinApiUrls = new DouyinAPI();
|
|
1420
1920
|
|
|
1421
|
-
// src/platform/douyin/DouyinApi.ts
|
|
1422
|
-
var douyin = {
|
|
1423
|
-
/**
|
|
1424
|
-
* 聚合解析 (视频/图集/合辑)
|
|
1425
|
-
* @param options 请求参数,包含 aweme_id 和可选的 typeMode
|
|
1426
|
-
* @param cookie 有效的用户 Cookie
|
|
1427
|
-
* @returns 接口返回的原始数据
|
|
1428
|
-
*/
|
|
1429
|
-
getWorkInfo: async (options, cookie) => {
|
|
1430
|
-
const { typeMode, ...restOptions } = options;
|
|
1431
|
-
const data2 = await DouyinData({ ...restOptions, methodType: "\u805A\u5408\u89E3\u6790" }, cookie);
|
|
1432
|
-
return data2;
|
|
1433
|
-
},
|
|
1434
|
-
/**
|
|
1435
|
-
* 获取视频作品数据
|
|
1436
|
-
* @param options 请求参数,包含 aweme_id 和可选的 typeMode
|
|
1437
|
-
* @param cookie 有效的用户 Cookie
|
|
1438
|
-
* @returns 接口返回的原始数据
|
|
1439
|
-
*/
|
|
1440
|
-
getVideoWorkInfo: async (options, cookie) => {
|
|
1441
|
-
const { typeMode, ...restOptions } = options;
|
|
1442
|
-
const data2 = await DouyinData({ ...restOptions, methodType: "\u89C6\u9891\u4F5C\u54C1\u6570\u636E" }, cookie);
|
|
1443
|
-
return data2;
|
|
1444
|
-
},
|
|
1445
|
-
/**
|
|
1446
|
-
* 获取图集作品数据
|
|
1447
|
-
* @param options 请求参数,包含 aweme_id 和可选的 typeMode
|
|
1448
|
-
* @param cookie 有效的用户 Cookie
|
|
1449
|
-
* @returns 接口返回的原始数据
|
|
1450
|
-
*/
|
|
1451
|
-
getImageAlbumWorkInfo: async (options, cookie) => {
|
|
1452
|
-
const { typeMode, ...restOptions } = options;
|
|
1453
|
-
const data2 = await DouyinData({ ...restOptions, methodType: "\u56FE\u96C6\u4F5C\u54C1\u6570\u636E" }, cookie);
|
|
1454
|
-
return data2;
|
|
1455
|
-
},
|
|
1456
|
-
/**
|
|
1457
|
-
* 获取合辑作品数据
|
|
1458
|
-
* @param options 请求参数,包含 aweme_id 和可选的 typeMode
|
|
1459
|
-
* @param cookie 有效的用户 Cookie
|
|
1460
|
-
* @returns 接口返回的原始数据
|
|
1461
|
-
*/
|
|
1462
|
-
getSlidesWorkInfo: async (options, cookie) => {
|
|
1463
|
-
const { typeMode, ...restOptions } = options;
|
|
1464
|
-
const data2 = await DouyinData({ ...restOptions, methodType: "\u5408\u8F91\u4F5C\u54C1\u6570\u636E" }, cookie);
|
|
1465
|
-
return data2;
|
|
1466
|
-
},
|
|
1467
|
-
/**
|
|
1468
|
-
* 获取评论数据
|
|
1469
|
-
* @param options 请求参数,包含 aweme_id, 可选的 number, cursor 和 typeMode
|
|
1470
|
-
* @param cookie 有效的用户 Cookie
|
|
1471
|
-
* @returns 接口返回的原始数据
|
|
1472
|
-
*/
|
|
1473
|
-
getComments: async (options, cookie) => {
|
|
1474
|
-
const { typeMode, ...restOptions } = options;
|
|
1475
|
-
const data2 = await DouyinData({ ...restOptions, methodType: "\u8BC4\u8BBA\u6570\u636E" }, cookie);
|
|
1476
|
-
return data2;
|
|
1477
|
-
},
|
|
1478
|
-
/**
|
|
1479
|
-
* 获取指定评论回复数据
|
|
1480
|
-
* @param options 请求参数,包含 aweme_id, comment_id, 可选的 number, cursor 和 typeMode
|
|
1481
|
-
* @param cookie 有效的用户 Cookie
|
|
1482
|
-
* @returns 接口返回的原始数据
|
|
1483
|
-
*/
|
|
1484
|
-
getCommentReplies: async (options, cookie) => {
|
|
1485
|
-
const { typeMode, ...restOptions } = options;
|
|
1486
|
-
const data2 = await DouyinData({ ...restOptions, methodType: "\u6307\u5B9A\u8BC4\u8BBA\u56DE\u590D\u6570\u636E" }, cookie);
|
|
1487
|
-
return data2;
|
|
1488
|
-
},
|
|
1489
|
-
/**
|
|
1490
|
-
* 获取用户主页数据
|
|
1491
|
-
* @param options 请求参数,包含 sec_uid 和可选的 typeMode
|
|
1492
|
-
* @param cookie 有效的用户 Cookie
|
|
1493
|
-
* @returns 接口返回的原始数据
|
|
1494
|
-
*/
|
|
1495
|
-
getUserProfile: async (options, cookie) => {
|
|
1496
|
-
const { typeMode, ...restOptions } = options;
|
|
1497
|
-
const data2 = await DouyinData({ ...restOptions, methodType: "\u7528\u6237\u4E3B\u9875\u6570\u636E" }, cookie);
|
|
1498
|
-
return data2;
|
|
1499
|
-
},
|
|
1500
|
-
/**
|
|
1501
|
-
* 获取 Emoji 数据
|
|
1502
|
-
* @param options 可选的请求参数 (主要用于 typeMode)
|
|
1503
|
-
* @param cookie 可选的用户 Cookie
|
|
1504
|
-
* @returns 接口返回的原始数据
|
|
1505
|
-
*/
|
|
1506
|
-
getEmojiList: async (options, cookie) => {
|
|
1507
|
-
const { typeMode, ...restOptions } = options;
|
|
1508
|
-
const data2 = await DouyinData({ ...restOptions, methodType: "Emoji\u6570\u636E" }, cookie);
|
|
1509
|
-
return data2;
|
|
1510
|
-
},
|
|
1511
|
-
/**
|
|
1512
|
-
* 获取动态表情数据
|
|
1513
|
-
* @param options 可选的请求参数 (主要用于 typeMode)
|
|
1514
|
-
* @param cookie 有效的用户 Cookie
|
|
1515
|
-
* @returns 接口返回的原始数据
|
|
1516
|
-
*/
|
|
1517
|
-
getEmojiProList: async (options, cookie) => {
|
|
1518
|
-
const { typeMode, ...restOptions } = options;
|
|
1519
|
-
const data2 = await DouyinData({ ...restOptions, methodType: "\u52A8\u6001\u8868\u60C5\u6570\u636E" }, cookie);
|
|
1520
|
-
return data2;
|
|
1521
|
-
},
|
|
1522
|
-
/**
|
|
1523
|
-
* 获取用户主页视频列表数据
|
|
1524
|
-
* @param options 请求参数,包含 sec_uid, 可选的 number, max_cursor 和 typeMode
|
|
1525
|
-
* @param cookie 有效的用户 Cookie
|
|
1526
|
-
* @returns 接口返回的原始数据
|
|
1527
|
-
*/
|
|
1528
|
-
getUserVideos: async (options, cookie) => {
|
|
1529
|
-
const { typeMode, ...restOptions } = options;
|
|
1530
|
-
const data2 = await DouyinData({ ...restOptions, methodType: "\u7528\u6237\u4E3B\u9875\u89C6\u9891\u5217\u8868\u6570\u636E" }, cookie);
|
|
1531
|
-
return data2;
|
|
1532
|
-
},
|
|
1533
|
-
/**
|
|
1534
|
-
* 获取音乐数据
|
|
1535
|
-
* @param options 请求参数,包含 music_id 和可选的 typeMode
|
|
1536
|
-
* @param cookie 有效的用户 Cookie
|
|
1537
|
-
* @returns 接口返回的原始数据
|
|
1538
|
-
*/
|
|
1539
|
-
getMusicInfo: async (options, cookie) => {
|
|
1540
|
-
const { typeMode, ...restOptions } = options;
|
|
1541
|
-
const data2 = await DouyinData({ ...restOptions, methodType: "\u97F3\u4E50\u6570\u636E" }, cookie);
|
|
1542
|
-
return data2;
|
|
1543
|
-
},
|
|
1544
|
-
/**
|
|
1545
|
-
* 获取热点词数据
|
|
1546
|
-
* @param options 请求参数,包含 query, 可选的 number 和 typeMode
|
|
1547
|
-
* @param cookie 有效的用户 Cookie
|
|
1548
|
-
* @returns 接口返回的原始数据
|
|
1549
|
-
*/
|
|
1550
|
-
getSuggestWords: async (options, cookie) => {
|
|
1551
|
-
const { typeMode, ...restOptions } = options;
|
|
1552
|
-
const data2 = await DouyinData({ ...restOptions, methodType: "\u70ED\u70B9\u8BCD\u6570\u636E" }, cookie);
|
|
1553
|
-
return data2;
|
|
1554
|
-
},
|
|
1555
|
-
/**
|
|
1556
|
-
* 获取搜索数据
|
|
1557
|
-
* @param options 请求参数,包含 query, 可选的 number, search_id, cursor 和 typeMode
|
|
1558
|
-
* @param cookie 有效的用户 Cookie
|
|
1559
|
-
* @returns 接口返回的原始数据
|
|
1560
|
-
*/
|
|
1561
|
-
search: async (options, cookie) => {
|
|
1562
|
-
const { typeMode, ...restOptions } = options;
|
|
1563
|
-
const data2 = await DouyinData({ ...restOptions, methodType: "\u641C\u7D22\u6570\u636E" }, cookie);
|
|
1564
|
-
return data2;
|
|
1565
|
-
},
|
|
1566
|
-
/**
|
|
1567
|
-
* 获取直播间信息
|
|
1568
|
-
* @param options 请求参数,包含 sec_uid 和可选的 typeMode
|
|
1569
|
-
* @param cookie 有效的用户 Cookie
|
|
1570
|
-
* @returns 接口返回的原始数据
|
|
1571
|
-
*/
|
|
1572
|
-
getLiveRoomInfo: async (options, cookie) => {
|
|
1573
|
-
const { typeMode, ...restOptions } = options;
|
|
1574
|
-
const data2 = await DouyinData({ ...restOptions, methodType: "\u76F4\u64AD\u95F4\u4FE1\u606F\u6570\u636E" }, cookie);
|
|
1575
|
-
return data2;
|
|
1576
|
-
},
|
|
1577
|
-
/**
|
|
1578
|
-
* 申请二维码数据
|
|
1579
|
-
* @param options 请求参数,包含 verify_fp 和可选的 typeMode
|
|
1580
|
-
* @param cookie 有效的用户 Cookie
|
|
1581
|
-
* @returns 接口返回的原始数据 (any)
|
|
1582
|
-
*/
|
|
1583
|
-
getLoginQrcode: async (options, cookie) => {
|
|
1584
|
-
const { typeMode, ...restOptions } = options;
|
|
1585
|
-
const data2 = await DouyinData({ ...restOptions, methodType: "\u7533\u8BF7\u4E8C\u7EF4\u7801\u6570\u636E" }, cookie);
|
|
1586
|
-
return data2;
|
|
1587
|
-
}
|
|
1588
|
-
};
|
|
1589
|
-
var registerDouyinRoutes = (cookie) => {
|
|
1590
|
-
const router = express__default.default.Router();
|
|
1591
|
-
router.get("/fetch_one_work", async (req, res) => {
|
|
1592
|
-
const data2 = await DouyinData({
|
|
1593
|
-
methodType: "\u805A\u5408\u89E3\u6790",
|
|
1594
|
-
aweme_id: req.query.aweme_id
|
|
1595
|
-
}, req.headers.cookie || cookie);
|
|
1596
|
-
res.json(data2);
|
|
1597
|
-
});
|
|
1598
|
-
router.get("/fetch_work_comments", async (req, res) => {
|
|
1599
|
-
const data2 = await DouyinData({
|
|
1600
|
-
methodType: "\u8BC4\u8BBA\u6570\u636E",
|
|
1601
|
-
aweme_id: req.query.aweme_id,
|
|
1602
|
-
number: parseInt(req.query.number ?? "50"),
|
|
1603
|
-
cursor: parseInt(req.query.cursor ?? "0")
|
|
1604
|
-
}, req.headers.cookie || cookie);
|
|
1605
|
-
res.json(data2);
|
|
1606
|
-
});
|
|
1607
|
-
router.get("/fetch_video_comment_replies", async (req, res) => {
|
|
1608
|
-
const data2 = await DouyinData({
|
|
1609
|
-
methodType: "\u6307\u5B9A\u8BC4\u8BBA\u56DE\u590D\u6570\u636E",
|
|
1610
|
-
aweme_id: req.query.aweme_id,
|
|
1611
|
-
comment_id: req.query.comment_id
|
|
1612
|
-
}, req.headers.cookie || cookie);
|
|
1613
|
-
res.json(data2);
|
|
1614
|
-
});
|
|
1615
|
-
router.get("/fetch_user_info", async (req, res) => {
|
|
1616
|
-
const data2 = await DouyinData({
|
|
1617
|
-
methodType: "\u7528\u6237\u4E3B\u9875\u6570\u636E",
|
|
1618
|
-
sec_uid: req.query.sec_uid
|
|
1619
|
-
}, req.headers.cookie || cookie);
|
|
1620
|
-
res.json(data2);
|
|
1621
|
-
});
|
|
1622
|
-
router.get("/fetch_user_post_videos", async (req, res) => {
|
|
1623
|
-
const data2 = await DouyinData({
|
|
1624
|
-
methodType: "\u7528\u6237\u4E3B\u9875\u89C6\u9891\u5217\u8868\u6570\u636E",
|
|
1625
|
-
sec_uid: req.query.sec_uid
|
|
1626
|
-
}, req.headers.cookie || cookie);
|
|
1627
|
-
res.json(data2);
|
|
1628
|
-
});
|
|
1629
|
-
router.get("/fetch_suggest_words", async (req, res) => {
|
|
1630
|
-
const data2 = await DouyinData({
|
|
1631
|
-
methodType: "\u70ED\u70B9\u8BCD\u6570\u636E",
|
|
1632
|
-
query: req.query.query
|
|
1633
|
-
}, req.headers.cookie || cookie);
|
|
1634
|
-
res.json(data2);
|
|
1635
|
-
});
|
|
1636
|
-
router.get("/fetch_search_info", async (req, res) => {
|
|
1637
|
-
const data2 = await DouyinData({
|
|
1638
|
-
methodType: "\u641C\u7D22\u6570\u636E",
|
|
1639
|
-
query: req.query.query,
|
|
1640
|
-
number: parseInt(req.query.number ?? "10"),
|
|
1641
|
-
search_id: req.query.search_id
|
|
1642
|
-
}, req.headers.cookie || cookie);
|
|
1643
|
-
res.json(data2);
|
|
1644
|
-
});
|
|
1645
|
-
router.get("/fetch_emoji_list", async (req, res) => {
|
|
1646
|
-
const data2 = await DouyinData({
|
|
1647
|
-
methodType: "Emoji\u6570\u636E"
|
|
1648
|
-
}, req.headers.cookie || cookie);
|
|
1649
|
-
res.json(data2);
|
|
1650
|
-
});
|
|
1651
|
-
router.get("/fetch_emoji_pro_list", async (req, res) => {
|
|
1652
|
-
const data2 = await DouyinData({
|
|
1653
|
-
methodType: "\u52A8\u6001\u8868\u60C5\u6570\u636E"
|
|
1654
|
-
}, req.headers.cookie || cookie);
|
|
1655
|
-
res.json(data2);
|
|
1656
|
-
});
|
|
1657
|
-
router.get("/fetch_music_work", async (req, res) => {
|
|
1658
|
-
const data2 = await DouyinData({
|
|
1659
|
-
methodType: "\u97F3\u4E50\u6570\u636E",
|
|
1660
|
-
music_id: req.query.music_id
|
|
1661
|
-
}, req.headers.cookie || cookie);
|
|
1662
|
-
res.json(data2);
|
|
1663
|
-
});
|
|
1664
|
-
router.get("/fetch_user_mix_videos", async (req, res) => {
|
|
1665
|
-
const data2 = await DouyinData({
|
|
1666
|
-
methodType: "\u5408\u8F91\u4F5C\u54C1\u6570\u636E",
|
|
1667
|
-
aweme_id: req.query.aweme_id
|
|
1668
|
-
}, req.headers.cookie || cookie);
|
|
1669
|
-
res.json(data2);
|
|
1670
|
-
});
|
|
1671
|
-
router.get("/fetch_user_live_videos", async (req, res) => {
|
|
1672
|
-
const data2 = await DouyinData({
|
|
1673
|
-
methodType: "\u76F4\u64AD\u95F4\u4FE1\u606F\u6570\u636E",
|
|
1674
|
-
sec_uid: req.query.sec_uid
|
|
1675
|
-
}, req.headers.cookie || cookie);
|
|
1676
|
-
res.json(data2);
|
|
1677
|
-
});
|
|
1678
|
-
return router;
|
|
1679
|
-
};
|
|
1680
|
-
|
|
1681
|
-
// src/platform/douyin/index.ts
|
|
1682
|
-
var douyinUtils = {
|
|
1683
|
-
sign: douyinSign,
|
|
1684
|
-
douyinApiUrls,
|
|
1685
|
-
getDouyinData,
|
|
1686
|
-
api: douyin
|
|
1687
|
-
};
|
|
1688
|
-
|
|
1689
1921
|
// src/platform/douyin/getdata.ts
|
|
1690
1922
|
var defheaders2 = {
|
|
1691
1923
|
accept: "*/*",
|
|
@@ -1708,7 +1940,6 @@ var DouyinData = async (data2, cookie) => {
|
|
|
1708
1940
|
case "\u89C6\u9891\u4F5C\u54C1\u6570\u636E":
|
|
1709
1941
|
case "\u56FE\u96C6\u4F5C\u54C1\u6570\u636E":
|
|
1710
1942
|
case "\u5408\u8F91\u4F5C\u54C1\u6570\u636E": {
|
|
1711
|
-
DouyinValidateData(data2, ["aweme_id"]);
|
|
1712
1943
|
const url = douyinApiUrls.\u89C6\u9891\u6216\u56FE\u96C6({ aweme_id: data2.aweme_id });
|
|
1713
1944
|
const VideoData = await GlobalGetData2({
|
|
1714
1945
|
url: `${url}&a_bogus=${douyinSign.AB(url)}`,
|
|
@@ -1718,13 +1949,11 @@ var DouyinData = async (data2, cookie) => {
|
|
|
1718
1949
|
return VideoData;
|
|
1719
1950
|
}
|
|
1720
1951
|
case "\u8BC4\u8BBA\u6570\u636E": {
|
|
1721
|
-
DouyinValidateData(data2, ["aweme_id"]);
|
|
1722
1952
|
const urlGenerator = (params) => douyinApiUrls.\u8BC4\u8BBA(params);
|
|
1723
1953
|
const response = await fetchPaginatedData(urlGenerator, data2, 50, headers2);
|
|
1724
1954
|
return response;
|
|
1725
1955
|
}
|
|
1726
1956
|
case "\u6307\u5B9A\u8BC4\u8BBA\u56DE\u590D\u6570\u636E": {
|
|
1727
|
-
DouyinValidateData(data2, ["aweme_id", "comment_id"]);
|
|
1728
1957
|
const urlGenerator = (params) => douyinApiUrls.\u4E8C\u7EA7\u8BC4\u8BBA(params);
|
|
1729
1958
|
const response = await fetchPaginatedData(
|
|
1730
1959
|
urlGenerator,
|
|
@@ -1738,7 +1967,6 @@ var DouyinData = async (data2, cookie) => {
|
|
|
1738
1967
|
return response;
|
|
1739
1968
|
}
|
|
1740
1969
|
case "\u7528\u6237\u4E3B\u9875\u6570\u636E": {
|
|
1741
|
-
DouyinValidateData(data2, ["sec_uid"]);
|
|
1742
1970
|
const url = douyinApiUrls.\u7528\u6237\u4E3B\u9875\u4FE1\u606F({ sec_uid: data2.sec_uid });
|
|
1743
1971
|
const UserInfoData = await GlobalGetData2({
|
|
1744
1972
|
url: `${url}&a_bogus=${douyinSign.AB(url)}`,
|
|
@@ -1760,7 +1988,6 @@ var DouyinData = async (data2, cookie) => {
|
|
|
1760
1988
|
return EmojiData;
|
|
1761
1989
|
}
|
|
1762
1990
|
case "\u7528\u6237\u4E3B\u9875\u89C6\u9891\u5217\u8868\u6570\u636E": {
|
|
1763
|
-
DouyinValidateData(data2, ["sec_uid"]);
|
|
1764
1991
|
const url = douyinApiUrls.\u7528\u6237\u4E3B\u9875\u89C6\u9891({ sec_uid: data2.sec_uid });
|
|
1765
1992
|
const UserVideoListData = await GlobalGetData2({
|
|
1766
1993
|
url: `${url}&a_bogus=${douyinSign.AB(url)}`,
|
|
@@ -1773,7 +2000,6 @@ var DouyinData = async (data2, cookie) => {
|
|
|
1773
2000
|
return UserVideoListData;
|
|
1774
2001
|
}
|
|
1775
2002
|
case "\u70ED\u70B9\u8BCD\u6570\u636E": {
|
|
1776
|
-
DouyinValidateData(data2, ["query"]);
|
|
1777
2003
|
const url = douyinApiUrls.\u70ED\u70B9\u8BCD({ query: data2.query, number: data2.number ?? 10 });
|
|
1778
2004
|
const SuggestWordsData = await GlobalGetData2({
|
|
1779
2005
|
url: `${url}&a_bogus=${douyinSign.AB(url)}`,
|
|
@@ -1786,7 +2012,6 @@ var DouyinData = async (data2, cookie) => {
|
|
|
1786
2012
|
return SuggestWordsData;
|
|
1787
2013
|
}
|
|
1788
2014
|
case "\u641C\u7D22\u6570\u636E": {
|
|
1789
|
-
DouyinValidateData(data2, ["query"]);
|
|
1790
2015
|
let search_id = "";
|
|
1791
2016
|
const maxPageSize = 15;
|
|
1792
2017
|
let fetchedSearchList = [];
|
|
@@ -1833,7 +2058,6 @@ var DouyinData = async (data2, cookie) => {
|
|
|
1833
2058
|
return ExpressionPlusData;
|
|
1834
2059
|
}
|
|
1835
2060
|
case "\u97F3\u4E50\u6570\u636E": {
|
|
1836
|
-
DouyinValidateData(data2, ["music_id"]);
|
|
1837
2061
|
const url = douyinApiUrls.\u80CC\u666F\u97F3\u4E50({ music_id: data2.music_id });
|
|
1838
2062
|
const MusicData = await GlobalGetData2({
|
|
1839
2063
|
url: `${url}&a_bogus=${douyinSign.AB(url)}`,
|
|
@@ -1843,7 +2067,6 @@ var DouyinData = async (data2, cookie) => {
|
|
|
1843
2067
|
return MusicData;
|
|
1844
2068
|
}
|
|
1845
2069
|
case "\u76F4\u64AD\u95F4\u4FE1\u606F\u6570\u636E": {
|
|
1846
|
-
DouyinValidateData(data2, ["sec_uid"]);
|
|
1847
2070
|
let url = douyinApiUrls.\u7528\u6237\u4E3B\u9875\u4FE1\u606F({ sec_uid: data2.sec_uid });
|
|
1848
2071
|
const fetchUrl = `${url}&a_bogus=${douyinSign.AB(url)}`;
|
|
1849
2072
|
const UserInfoData = await GlobalGetData2({
|
|
@@ -1889,7 +2112,6 @@ var DouyinData = async (data2, cookie) => {
|
|
|
1889
2112
|
return LiveRoomData;
|
|
1890
2113
|
}
|
|
1891
2114
|
case "\u7533\u8BF7\u4E8C\u7EF4\u7801\u6570\u636E": {
|
|
1892
|
-
DouyinValidateData(data2, ["verify_fp"]);
|
|
1893
2115
|
const url = douyinApiUrls.\u7533\u8BF7\u4E8C\u7EF4\u7801({ verify_fp: data2.verify_fp });
|
|
1894
2116
|
const LoginQrcodeStatusData = await GlobalGetData2({
|
|
1895
2117
|
url: `${url}&a_bogus=${douyinSign.AB(url)}`,
|
|
@@ -1933,7 +2155,7 @@ var fetchPaginatedData = async (apiUrlGenerator, params, maxPageSize, headers2)
|
|
|
1933
2155
|
};
|
|
1934
2156
|
return finalResponse;
|
|
1935
2157
|
};
|
|
1936
|
-
async
|
|
2158
|
+
var GlobalGetData2 = async (options) => {
|
|
1937
2159
|
let warningMessage = "";
|
|
1938
2160
|
try {
|
|
1939
2161
|
const result = await new Networks(options).getData();
|
|
@@ -1991,7 +2213,7 @@ async function GlobalGetData2(options) {
|
|
|
1991
2213
|
amagiMessage: warningMessage
|
|
1992
2214
|
};
|
|
1993
2215
|
}
|
|
1994
|
-
}
|
|
2216
|
+
};
|
|
1995
2217
|
|
|
1996
2218
|
// src/platform/kuaishou/API.ts
|
|
1997
2219
|
var API = class {
|
|
@@ -2043,71 +2265,6 @@ var API = class {
|
|
|
2043
2265
|
var KuaishouAPI = new API();
|
|
2044
2266
|
var kuaishouAPI = new API();
|
|
2045
2267
|
var kuaishouApiUrls = new API();
|
|
2046
|
-
var registerKuaishouRoutes = (cookie) => {
|
|
2047
|
-
const router = express__default.default.Router();
|
|
2048
|
-
router.get("/fetch_one_work", async (req, res) => {
|
|
2049
|
-
const data2 = await KuaishouData({
|
|
2050
|
-
methodType: "\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E",
|
|
2051
|
-
photoId: req.query.photoId
|
|
2052
|
-
}, req.headers.cookie || cookie);
|
|
2053
|
-
res.json(data2);
|
|
2054
|
-
});
|
|
2055
|
-
router.get("/fetch_work_comments", async (req, res) => {
|
|
2056
|
-
const data2 = await KuaishouData({
|
|
2057
|
-
methodType: "\u8BC4\u8BBA\u6570\u636E",
|
|
2058
|
-
photoId: req.query.photoId
|
|
2059
|
-
}, req.headers.cookie || cookie);
|
|
2060
|
-
res.json(data2);
|
|
2061
|
-
});
|
|
2062
|
-
router.get("/fetch_emoji_list", async (req, res) => {
|
|
2063
|
-
const data2 = await KuaishouData({
|
|
2064
|
-
methodType: "Emoji\u6570\u636E"
|
|
2065
|
-
}, req.headers.cookie || cookie);
|
|
2066
|
-
res.json(data2);
|
|
2067
|
-
});
|
|
2068
|
-
return router;
|
|
2069
|
-
};
|
|
2070
|
-
|
|
2071
|
-
// src/platform/kuaishou/KuaishouApi.ts
|
|
2072
|
-
var kuaishou = {
|
|
2073
|
-
/**
|
|
2074
|
-
* 获取单个视频作品数据
|
|
2075
|
-
* @param options 请求参数,包含 photoId 和可选的 typeMode
|
|
2076
|
-
* @param cookie 可选的用户 Cookie
|
|
2077
|
-
* @returns 接口返回的原始数据
|
|
2078
|
-
*/
|
|
2079
|
-
getWorkInfo: async (options, cookie) => {
|
|
2080
|
-
const data2 = await KuaishouData({ ...options, methodType: "\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E" }, cookie);
|
|
2081
|
-
return data2;
|
|
2082
|
-
},
|
|
2083
|
-
/**
|
|
2084
|
-
* 获取评论数据
|
|
2085
|
-
* @param options 请求参数,包含 photoId 和可选的 typeMode
|
|
2086
|
-
* @param cookie 可选的用户 Cookie
|
|
2087
|
-
* @returns 接口返回的原始数据
|
|
2088
|
-
*/
|
|
2089
|
-
getComments: async (options, cookie) => {
|
|
2090
|
-
const data2 = await KuaishouData({ ...options, methodType: "\u8BC4\u8BBA\u6570\u636E" }, cookie);
|
|
2091
|
-
return data2;
|
|
2092
|
-
},
|
|
2093
|
-
/**
|
|
2094
|
-
* 获取 Emoji 数据
|
|
2095
|
-
* @param options 可选的请求参数 (主要用于 typeMode)
|
|
2096
|
-
* @param cookie 可选的用户 Cookie
|
|
2097
|
-
* @returns 接口返回的原始数据
|
|
2098
|
-
*/
|
|
2099
|
-
getEmojiList: async (options, cookie) => {
|
|
2100
|
-
const data2 = await KuaishouData({ ...options, methodType: "Emoji\u6570\u636E" }, cookie);
|
|
2101
|
-
return data2;
|
|
2102
|
-
}
|
|
2103
|
-
};
|
|
2104
|
-
|
|
2105
|
-
// src/platform/kuaishou/index.ts
|
|
2106
|
-
var kuaishouUtils = {
|
|
2107
|
-
kuaishouApiUrls,
|
|
2108
|
-
getKuaishouData,
|
|
2109
|
-
api: kuaishou
|
|
2110
|
-
};
|
|
2111
2268
|
|
|
2112
2269
|
// src/platform/kuaishou/getdata.ts
|
|
2113
2270
|
var defheaders3 = {
|
|
@@ -2125,7 +2282,6 @@ var KuaishouData = async (data2, cookie) => {
|
|
|
2125
2282
|
};
|
|
2126
2283
|
switch (data2.methodType) {
|
|
2127
2284
|
case "\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E": {
|
|
2128
|
-
KusiahouValidateData(data2, ["photoId"]);
|
|
2129
2285
|
const body = kuaishouApiUrls.\u5355\u4E2A\u4F5C\u54C1\u4FE1\u606F({ photoId: data2.photoId });
|
|
2130
2286
|
const VideoData = await GlobalGetData3({
|
|
2131
2287
|
url: body.url,
|
|
@@ -2137,7 +2293,6 @@ var KuaishouData = async (data2, cookie) => {
|
|
|
2137
2293
|
return VideoData;
|
|
2138
2294
|
}
|
|
2139
2295
|
case "\u8BC4\u8BBA\u6570\u636E": {
|
|
2140
|
-
KusiahouValidateData(data2, ["photoId"]);
|
|
2141
2296
|
const body = kuaishouApiUrls.\u4F5C\u54C1\u8BC4\u8BBA\u4FE1\u606F({ photoId: data2.photoId });
|
|
2142
2297
|
const VideoData = await GlobalGetData3({
|
|
2143
2298
|
url: body.url,
|
|
@@ -2164,7 +2319,7 @@ var KuaishouData = async (data2, cookie) => {
|
|
|
2164
2319
|
return null;
|
|
2165
2320
|
}
|
|
2166
2321
|
};
|
|
2167
|
-
async
|
|
2322
|
+
var GlobalGetData3 = async (options) => {
|
|
2168
2323
|
let warningMessage = "";
|
|
2169
2324
|
try {
|
|
2170
2325
|
const result = await new Networks(options).getData();
|
|
@@ -2205,348 +2360,615 @@ async function GlobalGetData3(options) {
|
|
|
2205
2360
|
amagiMessage: warningMessage
|
|
2206
2361
|
};
|
|
2207
2362
|
}
|
|
2208
|
-
}
|
|
2363
|
+
};
|
|
2209
2364
|
|
|
2210
2365
|
// src/model/DataFetchers.ts
|
|
2211
|
-
async function getDouyinData(
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2366
|
+
async function getDouyinData(methodType, optionsOrCookie, cookieOrOptions) {
|
|
2367
|
+
try {
|
|
2368
|
+
let options;
|
|
2369
|
+
let cookie;
|
|
2370
|
+
if (typeof optionsOrCookie === "string") {
|
|
2371
|
+
cookie = optionsOrCookie;
|
|
2372
|
+
options = cookieOrOptions;
|
|
2373
|
+
} else {
|
|
2374
|
+
options = optionsOrCookie;
|
|
2375
|
+
cookie = cookieOrOptions;
|
|
2376
|
+
}
|
|
2377
|
+
const { typeMode: _, ...validationOptions } = options || {};
|
|
2378
|
+
const validatedParams = validateDouyinParams(methodType, validationOptions);
|
|
2379
|
+
const apiParams = {
|
|
2380
|
+
...validatedParams
|
|
2381
|
+
};
|
|
2382
|
+
const rawData = await DouyinData(apiParams, cookie);
|
|
2383
|
+
return createApiResponse(rawData, "\u83B7\u53D6\u6210\u529F", 200);
|
|
2384
|
+
} catch (error) {
|
|
2385
|
+
const errorMessage = error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF";
|
|
2386
|
+
throw new Error(`\u6296\u97F3\u6570\u636E\u83B7\u53D6\u5931\u8D25: ${errorMessage}`);
|
|
2220
2387
|
}
|
|
2221
|
-
const data2 = await DouyinData({ ...options, methodType: type }, cookie);
|
|
2222
|
-
return data2;
|
|
2223
2388
|
}
|
|
2224
|
-
async function getBilibiliData(methodType,
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2389
|
+
async function getBilibiliData(methodType, optionsOrCookie, cookieOrOptions) {
|
|
2390
|
+
try {
|
|
2391
|
+
let options;
|
|
2392
|
+
let cookie;
|
|
2393
|
+
if (typeof optionsOrCookie === "string") {
|
|
2394
|
+
cookie = optionsOrCookie;
|
|
2395
|
+
options = cookieOrOptions;
|
|
2396
|
+
} else {
|
|
2397
|
+
options = optionsOrCookie;
|
|
2398
|
+
cookie = cookieOrOptions;
|
|
2399
|
+
}
|
|
2400
|
+
const { typeMode: _, ...validationOptions } = options || {};
|
|
2401
|
+
const validatedParams = validateBilibiliParams(methodType, validationOptions);
|
|
2402
|
+
const apiParams = {
|
|
2403
|
+
...validatedParams
|
|
2404
|
+
};
|
|
2405
|
+
const rawData = await fetchBilibili(apiParams, cookie);
|
|
2406
|
+
return createApiResponse(rawData, "\u83B7\u53D6\u6210\u529F", 200);
|
|
2407
|
+
} catch (error) {
|
|
2408
|
+
const errorMessage = error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF";
|
|
2409
|
+
throw new Error(`B\u7AD9\u6570\u636E\u83B7\u53D6\u5931\u8D25: ${errorMessage}`);
|
|
2233
2410
|
}
|
|
2234
|
-
const data2 = await fetchBilibili({ ...options, methodType }, cookie);
|
|
2235
|
-
return data2;
|
|
2236
2411
|
}
|
|
2237
|
-
async function getKuaishouData(methodType,
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2412
|
+
async function getKuaishouData(methodType, optionsOrCookie, cookieOrOptions) {
|
|
2413
|
+
try {
|
|
2414
|
+
let options;
|
|
2415
|
+
let cookie;
|
|
2416
|
+
if (typeof optionsOrCookie === "string") {
|
|
2417
|
+
cookie = optionsOrCookie;
|
|
2418
|
+
options = cookieOrOptions;
|
|
2419
|
+
} else {
|
|
2420
|
+
options = optionsOrCookie;
|
|
2421
|
+
cookie = cookieOrOptions;
|
|
2422
|
+
}
|
|
2423
|
+
const { typeMode: _, ...validationOptions } = options || {};
|
|
2424
|
+
const validatedParams = validateKuaishouParams(methodType, validationOptions);
|
|
2425
|
+
const apiParams = {
|
|
2426
|
+
...validatedParams
|
|
2427
|
+
};
|
|
2428
|
+
const rawData = await KuaishouData(apiParams, cookie);
|
|
2429
|
+
return createApiResponse(rawData, "\u83B7\u53D6\u6210\u529F", 200);
|
|
2430
|
+
} catch (error) {
|
|
2431
|
+
const errorMessage = error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF";
|
|
2432
|
+
throw new Error(`\u5FEB\u624B\u6570\u636E\u83B7\u53D6\u5931\u8D25: ${errorMessage}`);
|
|
2246
2433
|
}
|
|
2247
|
-
const data2 = await KuaishouData({ ...options, methodType }, cookie);
|
|
2248
|
-
return data2;
|
|
2249
2434
|
}
|
|
2250
|
-
var
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2435
|
+
var createBilibiliRouteHandler = (dataFetcher, methodType, cookie) => {
|
|
2436
|
+
return async (req, res) => {
|
|
2437
|
+
try {
|
|
2438
|
+
const result = await dataFetcher(methodType, req.validatedParams, cookie);
|
|
2439
|
+
res.json({
|
|
2440
|
+
...result,
|
|
2441
|
+
requestPath: req.originalUrl
|
|
2442
|
+
});
|
|
2443
|
+
} catch (error) {
|
|
2444
|
+
const errorResponse = handleError(error);
|
|
2445
|
+
res.status(errorResponse.code || 500).json({
|
|
2446
|
+
...errorResponse,
|
|
2447
|
+
requestPath: req.originalUrl
|
|
2448
|
+
});
|
|
2261
2449
|
}
|
|
2262
|
-
|
|
2263
|
-
}
|
|
2264
|
-
return path__default.default.join(packageRoot, "logs");
|
|
2450
|
+
};
|
|
2265
2451
|
};
|
|
2266
|
-
var
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2452
|
+
var createBilibiliRoutes = (cookie) => {
|
|
2453
|
+
const router = express.Router();
|
|
2454
|
+
router.get(
|
|
2455
|
+
"/fetch_one_video",
|
|
2456
|
+
createBilibiliValidationMiddleware("\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E"),
|
|
2457
|
+
createBilibiliRouteHandler(getBilibiliData, "\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E", cookie)
|
|
2458
|
+
);
|
|
2459
|
+
router.get(
|
|
2460
|
+
"/fetch_video_playurl",
|
|
2461
|
+
createBilibiliValidationMiddleware("\u5355\u4E2A\u89C6\u9891\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E"),
|
|
2462
|
+
createBilibiliRouteHandler(getBilibiliData, "\u5355\u4E2A\u89C6\u9891\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E", cookie)
|
|
2463
|
+
);
|
|
2464
|
+
router.get(
|
|
2465
|
+
"/fetch_work_comments",
|
|
2466
|
+
createBilibiliValidationMiddleware("\u8BC4\u8BBA\u6570\u636E"),
|
|
2467
|
+
createBilibiliRouteHandler(getBilibiliData, "\u8BC4\u8BBA\u6570\u636E", cookie)
|
|
2468
|
+
);
|
|
2469
|
+
router.get(
|
|
2470
|
+
"/fetch_user_profile",
|
|
2471
|
+
createBilibiliValidationMiddleware("\u7528\u6237\u4E3B\u9875\u6570\u636E"),
|
|
2472
|
+
createBilibiliRouteHandler(getBilibiliData, "\u7528\u6237\u4E3B\u9875\u6570\u636E", cookie)
|
|
2473
|
+
);
|
|
2474
|
+
router.get(
|
|
2475
|
+
"/fetch_user_dynamic",
|
|
2476
|
+
createBilibiliValidationMiddleware("\u7528\u6237\u4E3B\u9875\u52A8\u6001\u5217\u8868\u6570\u636E"),
|
|
2477
|
+
createBilibiliRouteHandler(getBilibiliData, "\u7528\u6237\u4E3B\u9875\u52A8\u6001\u5217\u8868\u6570\u636E", cookie)
|
|
2478
|
+
);
|
|
2479
|
+
router.get(
|
|
2480
|
+
"/fetch_emoji_list",
|
|
2481
|
+
createBilibiliValidationMiddleware("Emoji\u6570\u636E"),
|
|
2482
|
+
createBilibiliRouteHandler(getBilibiliData, "Emoji\u6570\u636E", cookie)
|
|
2483
|
+
);
|
|
2484
|
+
router.get(
|
|
2485
|
+
"/fetch_bangumi_video_info",
|
|
2486
|
+
createBilibiliValidationMiddleware("\u756A\u5267\u57FA\u672C\u4FE1\u606F\u6570\u636E"),
|
|
2487
|
+
createBilibiliRouteHandler(getBilibiliData, "\u756A\u5267\u57FA\u672C\u4FE1\u606F\u6570\u636E", cookie)
|
|
2488
|
+
);
|
|
2489
|
+
router.get(
|
|
2490
|
+
"/fetch_bangumi_video_playurl",
|
|
2491
|
+
createBilibiliValidationMiddleware("\u756A\u5267\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E"),
|
|
2492
|
+
createBilibiliRouteHandler(getBilibiliData, "\u756A\u5267\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E", cookie)
|
|
2493
|
+
);
|
|
2494
|
+
router.get(
|
|
2495
|
+
"/fetch_dynamic_info",
|
|
2496
|
+
createBilibiliValidationMiddleware("\u52A8\u6001\u8BE6\u60C5\u6570\u636E"),
|
|
2497
|
+
createBilibiliRouteHandler(getBilibiliData, "\u52A8\u6001\u8BE6\u60C5\u6570\u636E", cookie)
|
|
2498
|
+
);
|
|
2499
|
+
router.get(
|
|
2500
|
+
"/fetch_dynamic_card",
|
|
2501
|
+
createBilibiliValidationMiddleware("\u52A8\u6001\u5361\u7247\u6570\u636E"),
|
|
2502
|
+
createBilibiliRouteHandler(getBilibiliData, "\u52A8\u6001\u5361\u7247\u6570\u636E", cookie)
|
|
2503
|
+
);
|
|
2504
|
+
router.get(
|
|
2505
|
+
"/fetch_live_room_detail",
|
|
2506
|
+
createBilibiliValidationMiddleware("\u76F4\u64AD\u95F4\u4FE1\u606F"),
|
|
2507
|
+
createBilibiliRouteHandler(getBilibiliData, "\u76F4\u64AD\u95F4\u4FE1\u606F", cookie)
|
|
2508
|
+
);
|
|
2509
|
+
router.get(
|
|
2510
|
+
"/fetch_liveroom_def",
|
|
2511
|
+
createBilibiliValidationMiddleware("\u76F4\u64AD\u95F4\u521D\u59CB\u5316\u4FE1\u606F"),
|
|
2512
|
+
createBilibiliRouteHandler(getBilibiliData, "\u76F4\u64AD\u95F4\u521D\u59CB\u5316\u4FE1\u606F", cookie)
|
|
2513
|
+
);
|
|
2514
|
+
router.get(
|
|
2515
|
+
"/login_basic_info",
|
|
2516
|
+
createBilibiliValidationMiddleware("\u767B\u5F55\u57FA\u672C\u4FE1\u606F"),
|
|
2517
|
+
createBilibiliRouteHandler(getBilibiliData, "\u767B\u5F55\u57FA\u672C\u4FE1\u606F", cookie)
|
|
2518
|
+
);
|
|
2519
|
+
router.get(
|
|
2520
|
+
"/new_login_qrcode",
|
|
2521
|
+
createBilibiliValidationMiddleware("\u7533\u8BF7\u4E8C\u7EF4\u7801"),
|
|
2522
|
+
createBilibiliRouteHandler(getBilibiliData, "\u7533\u8BF7\u4E8C\u7EF4\u7801", cookie)
|
|
2523
|
+
);
|
|
2524
|
+
router.get(
|
|
2525
|
+
"/check_qrcode",
|
|
2526
|
+
createBilibiliValidationMiddleware("\u4E8C\u7EF4\u7801\u72B6\u6001"),
|
|
2527
|
+
createBilibiliRouteHandler(getBilibiliData, "\u4E8C\u7EF4\u7801\u72B6\u6001", cookie)
|
|
2528
|
+
);
|
|
2529
|
+
router.get(
|
|
2530
|
+
"/fetch_user_full_view",
|
|
2531
|
+
createBilibiliValidationMiddleware("\u83B7\u53D6UP\u4E3B\u603B\u64AD\u653E\u91CF"),
|
|
2532
|
+
createBilibiliRouteHandler(getBilibiliData, "\u83B7\u53D6UP\u4E3B\u603B\u64AD\u653E\u91CF", cookie)
|
|
2533
|
+
);
|
|
2534
|
+
router.get(
|
|
2535
|
+
"/av_to_bv",
|
|
2536
|
+
createBilibiliValidationMiddleware("AV\u8F6CBV"),
|
|
2537
|
+
createBilibiliRouteHandler(getBilibiliData, "AV\u8F6CBV", cookie)
|
|
2538
|
+
);
|
|
2539
|
+
router.get(
|
|
2540
|
+
"/bv_to_av",
|
|
2541
|
+
createBilibiliValidationMiddleware("BV\u8F6CAV"),
|
|
2542
|
+
createBilibiliRouteHandler(getBilibiliData, "BV\u8F6CAV", cookie)
|
|
2543
|
+
);
|
|
2544
|
+
return router;
|
|
2545
|
+
};
|
|
2546
|
+
|
|
2547
|
+
// src/platform/bilibili/index.ts
|
|
2548
|
+
var bilibiliUtils = {
|
|
2549
|
+
sign: {
|
|
2550
|
+
wbi_sign,
|
|
2551
|
+
av2bv,
|
|
2552
|
+
bv2av
|
|
2553
|
+
},
|
|
2554
|
+
bilibiliApiUrls,
|
|
2555
|
+
api: bilibili
|
|
2556
|
+
};
|
|
2557
|
+
|
|
2558
|
+
// src/platform/douyin/DouyinApi.ts
|
|
2559
|
+
var douyin = {
|
|
2560
|
+
/**
|
|
2561
|
+
* 聚合解析 (视频/图集/合辑)
|
|
2562
|
+
* @param options 请求参数,包含 aweme_id 和可选的 typeMode
|
|
2563
|
+
* @param cookie 有效的用户 Cookie
|
|
2564
|
+
* @returns 统一格式的API响应
|
|
2565
|
+
*/
|
|
2566
|
+
getWorkInfo: async (options, cookie) => {
|
|
2567
|
+
try {
|
|
2568
|
+
const { typeMode, ...restOptions } = options;
|
|
2569
|
+
const data2 = await DouyinData({ ...restOptions, methodType: "\u805A\u5408\u89E3\u6790" }, cookie);
|
|
2570
|
+
return createApiResponse(data2, "\u83B7\u53D6\u805A\u5408\u89E3\u6790\u6570\u636E\u6210\u529F", 200);
|
|
2571
|
+
} catch (error) {
|
|
2572
|
+
return createApiResponse(null, `\u83B7\u53D6\u805A\u5408\u89E3\u6790\u6570\u636E\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
|
|
2304
2573
|
}
|
|
2305
2574
|
},
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2575
|
+
/**
|
|
2576
|
+
* 获取视频作品数据
|
|
2577
|
+
* @param options 请求参数,包含 aweme_id 和可选的 typeMode
|
|
2578
|
+
* @param cookie 有效的用户 Cookie
|
|
2579
|
+
* @returns 统一格式的API响应
|
|
2580
|
+
*/
|
|
2581
|
+
getVideoWorkInfo: async (options, cookie) => {
|
|
2582
|
+
try {
|
|
2583
|
+
const { typeMode, ...restOptions } = options;
|
|
2584
|
+
const data2 = await DouyinData({ ...restOptions, methodType: "\u89C6\u9891\u4F5C\u54C1\u6570\u636E" }, cookie);
|
|
2585
|
+
return createApiResponse(data2, "\u83B7\u53D6\u89C6\u9891\u4F5C\u54C1\u6570\u636E\u6210\u529F", 200);
|
|
2586
|
+
} catch (error) {
|
|
2587
|
+
return createApiResponse(null, `\u83B7\u53D6\u89C6\u9891\u4F5C\u54C1\u6570\u636E\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
|
|
2588
|
+
}
|
|
2309
2589
|
},
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
}
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
const
|
|
2364
|
-
const
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2590
|
+
/**
|
|
2591
|
+
* 获取图集作品数据
|
|
2592
|
+
* @param options 请求参数,包含 aweme_id 和可选的 typeMode
|
|
2593
|
+
* @param cookie 有效的用户 Cookie
|
|
2594
|
+
* @returns 统一格式的API响应
|
|
2595
|
+
*/
|
|
2596
|
+
getImageAlbumWorkInfo: async (options, cookie) => {
|
|
2597
|
+
try {
|
|
2598
|
+
const { typeMode, ...restOptions } = options;
|
|
2599
|
+
const data2 = await DouyinData({ ...restOptions, methodType: "\u56FE\u96C6\u4F5C\u54C1\u6570\u636E" }, cookie);
|
|
2600
|
+
return createApiResponse(data2, "\u83B7\u53D6\u56FE\u96C6\u4F5C\u54C1\u6570\u636E\u6210\u529F", 200);
|
|
2601
|
+
} catch (error) {
|
|
2602
|
+
return createApiResponse(null, `\u83B7\u53D6\u56FE\u96C6\u4F5C\u54C1\u6570\u636E\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
|
|
2603
|
+
}
|
|
2604
|
+
},
|
|
2605
|
+
/**
|
|
2606
|
+
* 获取合辑作品数据
|
|
2607
|
+
* @param options 请求参数,包含 aweme_id 和可选的 typeMode
|
|
2608
|
+
* @param cookie 有效的用户 Cookie
|
|
2609
|
+
* @returns 统一格式的API响应
|
|
2610
|
+
*/
|
|
2611
|
+
getSlidesWorkInfo: async (options, cookie) => {
|
|
2612
|
+
try {
|
|
2613
|
+
const { typeMode, ...restOptions } = options;
|
|
2614
|
+
const data2 = await DouyinData({ ...restOptions, methodType: "\u5408\u8F91\u4F5C\u54C1\u6570\u636E" }, cookie);
|
|
2615
|
+
return createApiResponse(data2, "\u83B7\u53D6\u5408\u8F91\u4F5C\u54C1\u6570\u636E\u6210\u529F", 200);
|
|
2616
|
+
} catch (error) {
|
|
2617
|
+
return createApiResponse(null, `\u83B7\u53D6\u5408\u8F91\u4F5C\u54C1\u6570\u636E\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
|
|
2618
|
+
}
|
|
2619
|
+
},
|
|
2620
|
+
/**
|
|
2621
|
+
* 获取评论数据
|
|
2622
|
+
* @param options 请求参数,包含 aweme_id, 可选的 number, cursor 和 typeMode
|
|
2623
|
+
* @param cookie 有效的用户 Cookie
|
|
2624
|
+
* @returns 统一格式的API响应
|
|
2625
|
+
*/
|
|
2626
|
+
getComments: async (options, cookie) => {
|
|
2627
|
+
try {
|
|
2628
|
+
const { typeMode, ...restOptions } = options;
|
|
2629
|
+
const data2 = await DouyinData({ ...restOptions, methodType: "\u8BC4\u8BBA\u6570\u636E" }, cookie);
|
|
2630
|
+
return createApiResponse(data2, "\u83B7\u53D6\u8BC4\u8BBA\u6570\u636E\u6210\u529F", 200);
|
|
2631
|
+
} catch (error) {
|
|
2632
|
+
return createApiResponse(null, `\u83B7\u53D6\u8BC4\u8BBA\u6570\u636E\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
|
|
2633
|
+
}
|
|
2634
|
+
},
|
|
2635
|
+
/**
|
|
2636
|
+
* 获取指定评论回复数据
|
|
2637
|
+
* @param options 请求参数,包含 aweme_id, comment_id, 可选的 number, cursor 和 typeMode
|
|
2638
|
+
* @param cookie 有效的用户 Cookie
|
|
2639
|
+
* @returns 统一格式的API响应
|
|
2640
|
+
*/
|
|
2641
|
+
getCommentReplies: async (options, cookie) => {
|
|
2642
|
+
try {
|
|
2643
|
+
const { typeMode, ...restOptions } = options;
|
|
2644
|
+
const data2 = await DouyinData({ ...restOptions, methodType: "\u6307\u5B9A\u8BC4\u8BBA\u56DE\u590D\u6570\u636E" }, cookie);
|
|
2645
|
+
return createApiResponse(data2, "\u83B7\u53D6\u6307\u5B9A\u8BC4\u8BBA\u56DE\u590D\u6570\u636E\u6210\u529F", 200);
|
|
2646
|
+
} catch (error) {
|
|
2647
|
+
return createApiResponse(null, `\u83B7\u53D6\u6307\u5B9A\u8BC4\u8BBA\u56DE\u590D\u6570\u636E\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
|
|
2648
|
+
}
|
|
2649
|
+
},
|
|
2650
|
+
/**
|
|
2651
|
+
* 获取用户主页数据
|
|
2652
|
+
* @param options 请求参数,包含 sec_uid 和可选的 typeMode
|
|
2653
|
+
* @param cookie 有效的用户 Cookie
|
|
2654
|
+
* @returns 统一格式的API响应
|
|
2655
|
+
*/
|
|
2656
|
+
getUserProfile: async (options, cookie) => {
|
|
2657
|
+
try {
|
|
2658
|
+
const { typeMode, ...restOptions } = options;
|
|
2659
|
+
const data2 = await DouyinData({ ...restOptions, methodType: "\u7528\u6237\u4E3B\u9875\u6570\u636E" }, cookie);
|
|
2660
|
+
return createApiResponse(data2, "\u83B7\u53D6\u7528\u6237\u4E3B\u9875\u6570\u636E\u6210\u529F", 200);
|
|
2661
|
+
} catch (error) {
|
|
2662
|
+
return createApiResponse(null, `\u83B7\u53D6\u7528\u6237\u4E3B\u9875\u6570\u636E\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
|
|
2663
|
+
}
|
|
2664
|
+
},
|
|
2665
|
+
/**
|
|
2666
|
+
* 获取 Emoji 数据
|
|
2667
|
+
* @param options 可选的请求参数 (主要用于 typeMode)
|
|
2668
|
+
* @param cookie 可选的用户 Cookie
|
|
2669
|
+
* @returns 统一格式的API响应
|
|
2670
|
+
*/
|
|
2671
|
+
getEmojiList: async (options, cookie) => {
|
|
2672
|
+
try {
|
|
2673
|
+
const { typeMode, ...restOptions } = options;
|
|
2674
|
+
const data2 = await DouyinData({ ...restOptions, methodType: "Emoji\u6570\u636E" }, cookie);
|
|
2675
|
+
return createApiResponse(data2, "\u83B7\u53D6Emoji\u6570\u636E\u6210\u529F", 200);
|
|
2676
|
+
} catch (error) {
|
|
2677
|
+
return createApiResponse(null, `\u83B7\u53D6Emoji\u6570\u636E\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
|
|
2678
|
+
}
|
|
2679
|
+
},
|
|
2680
|
+
/**
|
|
2681
|
+
* 获取动态表情数据
|
|
2682
|
+
* @param options 可选的请求参数 (主要用于 typeMode)
|
|
2683
|
+
* @param cookie 有效的用户 Cookie
|
|
2684
|
+
* @returns 统一格式的API响应
|
|
2685
|
+
*/
|
|
2686
|
+
getEmojiProList: async (options, cookie) => {
|
|
2687
|
+
try {
|
|
2688
|
+
const { typeMode, ...restOptions } = options;
|
|
2689
|
+
const data2 = await DouyinData({ ...restOptions, methodType: "\u52A8\u6001\u8868\u60C5\u6570\u636E" }, cookie);
|
|
2690
|
+
return createApiResponse(data2, "\u83B7\u53D6\u52A8\u6001\u8868\u60C5\u6570\u636E\u6210\u529F", 200);
|
|
2691
|
+
} catch (error) {
|
|
2692
|
+
return createApiResponse(null, `\u83B7\u53D6\u52A8\u6001\u8868\u60C5\u6570\u636E\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
|
|
2693
|
+
}
|
|
2694
|
+
},
|
|
2695
|
+
/**
|
|
2696
|
+
* 获取用户主页视频列表数据
|
|
2697
|
+
* @param options 请求参数,包含 sec_uid, 可选的 number, max_cursor 和 typeMode
|
|
2698
|
+
* @param cookie 有效的用户 Cookie
|
|
2699
|
+
* @returns 统一格式的API响应
|
|
2700
|
+
*/
|
|
2701
|
+
getUserVideos: async (options, cookie) => {
|
|
2702
|
+
try {
|
|
2703
|
+
const { typeMode, ...restOptions } = options;
|
|
2704
|
+
const data2 = await DouyinData({ ...restOptions, methodType: "\u7528\u6237\u4E3B\u9875\u89C6\u9891\u5217\u8868\u6570\u636E" }, cookie);
|
|
2705
|
+
return createApiResponse(data2, "\u83B7\u53D6\u7528\u6237\u4E3B\u9875\u89C6\u9891\u5217\u8868\u6570\u636E\u6210\u529F", 200);
|
|
2706
|
+
} catch (error) {
|
|
2707
|
+
return createApiResponse(null, `\u83B7\u53D6\u7528\u6237\u4E3B\u9875\u89C6\u9891\u5217\u8868\u6570\u636E\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
|
|
2386
2708
|
}
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
constructor(data2) {
|
|
2402
|
-
this.headers = data2.headers ?? {};
|
|
2403
|
-
this.url = data2.url ?? "";
|
|
2404
|
-
this.type = data2.responseType ?? "json";
|
|
2405
|
-
this.method = data2.method ?? "GET";
|
|
2406
|
-
this.body = data2.body ?? null;
|
|
2407
|
-
this.data = {};
|
|
2408
|
-
this.timeout = data2.timeout ?? 15e3;
|
|
2409
|
-
this.isGetResult = false;
|
|
2410
|
-
this.timer = void 0;
|
|
2411
|
-
this.axiosInstance = axios__default.default.create({
|
|
2412
|
-
timeout: this.timeout,
|
|
2413
|
-
headers: this.headers,
|
|
2414
|
-
maxRedirects: 5,
|
|
2415
|
-
validateStatus: (status) => {
|
|
2416
|
-
return status >= 200 && status < 600;
|
|
2417
|
-
}
|
|
2418
|
-
});
|
|
2419
|
-
}
|
|
2420
|
-
get config() {
|
|
2421
|
-
let config = {
|
|
2422
|
-
url: this.url,
|
|
2423
|
-
method: this.method,
|
|
2424
|
-
headers: this.headers
|
|
2425
|
-
};
|
|
2426
|
-
if (this.method === "POST" && this.body) {
|
|
2427
|
-
config.data = this.body;
|
|
2709
|
+
},
|
|
2710
|
+
/**
|
|
2711
|
+
* 获取音乐数据
|
|
2712
|
+
* @param options 请求参数,包含 music_id 和可选的 typeMode
|
|
2713
|
+
* @param cookie 有效的用户 Cookie
|
|
2714
|
+
* @returns 统一格式的API响应
|
|
2715
|
+
*/
|
|
2716
|
+
getMusicInfo: async (options, cookie) => {
|
|
2717
|
+
try {
|
|
2718
|
+
const { typeMode, ...restOptions } = options;
|
|
2719
|
+
const data2 = await DouyinData({ ...restOptions, methodType: "\u97F3\u4E50\u6570\u636E" }, cookie);
|
|
2720
|
+
return createApiResponse(data2, "\u83B7\u53D6\u97F3\u4E50\u6570\u636E\u6210\u529F", 200);
|
|
2721
|
+
} catch (error) {
|
|
2722
|
+
return createApiResponse(null, `\u83B7\u53D6\u97F3\u4E50\u6570\u636E\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
|
|
2428
2723
|
}
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2724
|
+
},
|
|
2725
|
+
/**
|
|
2726
|
+
* 获取热点词数据
|
|
2727
|
+
* @param options 请求参数,包含 query, 可选的 number 和 typeMode
|
|
2728
|
+
* @param cookie 有效的用户 Cookie
|
|
2729
|
+
* @returns 统一格式的API响应
|
|
2730
|
+
*/
|
|
2731
|
+
getSuggestWords: async (options, cookie) => {
|
|
2432
2732
|
try {
|
|
2433
|
-
const
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
}
|
|
2437
|
-
this.isGetResult = true;
|
|
2438
|
-
return result;
|
|
2733
|
+
const { typeMode, ...restOptions } = options;
|
|
2734
|
+
const data2 = await DouyinData({ ...restOptions, methodType: "\u70ED\u70B9\u8BCD\u6570\u636E" }, cookie);
|
|
2735
|
+
return createApiResponse(data2, "\u83B7\u53D6\u70ED\u70B9\u8BCD\u6570\u636E\u6210\u529F", 200);
|
|
2439
2736
|
} catch (error) {
|
|
2440
|
-
|
|
2441
|
-
return false;
|
|
2737
|
+
return createApiResponse(null, `\u83B7\u53D6\u70ED\u70B9\u8BCD\u6570\u636E\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
|
|
2442
2738
|
}
|
|
2443
|
-
}
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2739
|
+
},
|
|
2740
|
+
/**
|
|
2741
|
+
* 获取搜索数据
|
|
2742
|
+
* @param options 请求参数,包含 query, 可选的 number, search_id, cursor 和 typeMode
|
|
2743
|
+
* @param cookie 有效的用户 Cookie
|
|
2744
|
+
* @returns 统一格式的API响应
|
|
2745
|
+
*/
|
|
2746
|
+
search: async (options, cookie) => {
|
|
2449
2747
|
try {
|
|
2450
|
-
const
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
});
|
|
2454
|
-
return response.request.res.responseUrl;
|
|
2748
|
+
const { typeMode, ...restOptions } = options;
|
|
2749
|
+
const data2 = await DouyinData({ ...restOptions, methodType: "\u641C\u7D22\u6570\u636E" }, cookie);
|
|
2750
|
+
return createApiResponse(data2, "\u83B7\u53D6\u641C\u7D22\u6570\u636E\u6210\u529F", 200);
|
|
2455
2751
|
} catch (error) {
|
|
2456
|
-
|
|
2457
|
-
throw new Error(error.stack);
|
|
2458
|
-
}
|
|
2459
|
-
return "";
|
|
2752
|
+
return createApiResponse(null, `\u83B7\u53D6\u641C\u7D22\u6570\u636E\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
|
|
2460
2753
|
}
|
|
2461
|
-
}
|
|
2462
|
-
/**
|
|
2463
|
-
|
|
2754
|
+
},
|
|
2755
|
+
/**
|
|
2756
|
+
* 获取直播间信息
|
|
2757
|
+
* @param options 请求参数,包含 sec_uid 和可选的 typeMode
|
|
2758
|
+
* @param cookie 有效的用户 Cookie
|
|
2759
|
+
* @returns 统一格式的API响应
|
|
2760
|
+
*/
|
|
2761
|
+
getLiveRoomInfo: async (options, cookie) => {
|
|
2464
2762
|
try {
|
|
2465
|
-
const
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
maxRedirects: 0,
|
|
2469
|
-
// 禁止跟随重定向
|
|
2470
|
-
validateStatus: (status) => status >= 300 && status < 400
|
|
2471
|
-
// 仅处理3xx响应
|
|
2472
|
-
});
|
|
2473
|
-
return response.headers["location"];
|
|
2763
|
+
const { typeMode, ...restOptions } = options;
|
|
2764
|
+
const data2 = await DouyinData({ ...restOptions, methodType: "\u76F4\u64AD\u95F4\u4FE1\u606F\u6570\u636E" }, cookie);
|
|
2765
|
+
return createApiResponse(data2, "\u83B7\u53D6\u76F4\u64AD\u95F4\u4FE1\u606F\u6570\u636E\u6210\u529F", 200);
|
|
2474
2766
|
} catch (error) {
|
|
2475
|
-
|
|
2476
|
-
throw new Error(error.stack);
|
|
2477
|
-
}
|
|
2478
|
-
return "";
|
|
2767
|
+
return createApiResponse(null, `\u83B7\u53D6\u76F4\u64AD\u95F4\u4FE1\u606F\u6570\u636E\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
|
|
2479
2768
|
}
|
|
2480
|
-
}
|
|
2481
|
-
/**
|
|
2482
|
-
|
|
2769
|
+
},
|
|
2770
|
+
/**
|
|
2771
|
+
* 申请二维码数据
|
|
2772
|
+
* @param options 请求参数,包含 verify_fp 和可选的 typeMode
|
|
2773
|
+
* @param cookie 有效的用户 Cookie
|
|
2774
|
+
* @returns 统一格式的API响应
|
|
2775
|
+
*/
|
|
2776
|
+
getLoginQrcode: async (options, cookie) => {
|
|
2483
2777
|
try {
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
return result;
|
|
2488
|
-
}
|
|
2489
|
-
if (result.status === 429) {
|
|
2490
|
-
logger.error("HTTP \u54CD\u5E94\u72B6\u6001\u7801: 429");
|
|
2491
|
-
throw new Error("ratelimit triggered, \u89E6\u53D1 https://www.douyin.com/ \u7684\u901F\u7387\u9650\u5236\uFF01\uFF01\uFF01");
|
|
2492
|
-
}
|
|
2493
|
-
this.axiosInstance = result;
|
|
2494
|
-
this.isGetResult = true;
|
|
2495
|
-
} else {
|
|
2496
|
-
this.axiosInstance = new_fetch;
|
|
2497
|
-
}
|
|
2498
|
-
return this.axiosInstance.data;
|
|
2778
|
+
const { typeMode, ...restOptions } = options;
|
|
2779
|
+
const data2 = await DouyinData({ ...restOptions, methodType: "\u7533\u8BF7\u4E8C\u7EF4\u7801\u6570\u636E" }, cookie);
|
|
2780
|
+
return createApiResponse(data2, "\u7533\u8BF7\u4E8C\u7EF4\u7801\u6570\u636E\u6210\u529F", 200);
|
|
2499
2781
|
} catch (error) {
|
|
2500
|
-
|
|
2501
|
-
throw new Error(error.stack);
|
|
2502
|
-
}
|
|
2503
|
-
return false;
|
|
2782
|
+
return createApiResponse(null, `\u7533\u8BF7\u4E8C\u7EF4\u7801\u6570\u636E\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
|
|
2504
2783
|
}
|
|
2505
2784
|
}
|
|
2506
|
-
|
|
2785
|
+
};
|
|
2786
|
+
var createDouyinRouteHandler = (dataFetcher, methodType, cookie) => {
|
|
2787
|
+
return async (req, res) => {
|
|
2507
2788
|
try {
|
|
2508
|
-
const result = await
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
}
|
|
2514
|
-
return { headers: headers2, data: result.data };
|
|
2789
|
+
const result = await dataFetcher(methodType, req.validatedParams, cookie);
|
|
2790
|
+
res.json({
|
|
2791
|
+
...result,
|
|
2792
|
+
requestPath: req.originalUrl
|
|
2793
|
+
});
|
|
2515
2794
|
} catch (error) {
|
|
2516
|
-
|
|
2517
|
-
|
|
2795
|
+
const errorResponse = handleError(error);
|
|
2796
|
+
res.status(errorResponse.code || 500).json({
|
|
2797
|
+
...errorResponse,
|
|
2798
|
+
requestPath: req.originalUrl
|
|
2799
|
+
});
|
|
2518
2800
|
}
|
|
2519
|
-
}
|
|
2801
|
+
};
|
|
2802
|
+
};
|
|
2803
|
+
var createDouyinRoutes = (cookie) => {
|
|
2804
|
+
const router = express.Router();
|
|
2805
|
+
router.get(
|
|
2806
|
+
"/fetch_one_work",
|
|
2807
|
+
createDouyinValidationMiddleware("\u805A\u5408\u89E3\u6790"),
|
|
2808
|
+
createDouyinRouteHandler(getDouyinData, "\u805A\u5408\u89E3\u6790", cookie)
|
|
2809
|
+
);
|
|
2810
|
+
router.get(
|
|
2811
|
+
"/fetch_one_work",
|
|
2812
|
+
createDouyinValidationMiddleware("\u89C6\u9891\u4F5C\u54C1\u6570\u636E"),
|
|
2813
|
+
createDouyinRouteHandler(getDouyinData, "\u89C6\u9891\u4F5C\u54C1\u6570\u636E", cookie)
|
|
2814
|
+
);
|
|
2815
|
+
router.get(
|
|
2816
|
+
"/fetch_one_work",
|
|
2817
|
+
createDouyinValidationMiddleware("\u56FE\u96C6\u4F5C\u54C1\u6570\u636E"),
|
|
2818
|
+
createDouyinRouteHandler(getDouyinData, "\u56FE\u96C6\u4F5C\u54C1\u6570\u636E", cookie)
|
|
2819
|
+
);
|
|
2820
|
+
router.get(
|
|
2821
|
+
"/fetch_one_work",
|
|
2822
|
+
createDouyinValidationMiddleware("\u5408\u8F91\u4F5C\u54C1\u6570\u636E"),
|
|
2823
|
+
createDouyinRouteHandler(getDouyinData, "\u5408\u8F91\u4F5C\u54C1\u6570\u636E", cookie)
|
|
2824
|
+
);
|
|
2825
|
+
router.get(
|
|
2826
|
+
"/fetch_work_comments",
|
|
2827
|
+
createDouyinValidationMiddleware("\u8BC4\u8BBA\u6570\u636E"),
|
|
2828
|
+
createDouyinRouteHandler(getDouyinData, "\u8BC4\u8BBA\u6570\u636E", cookie)
|
|
2829
|
+
);
|
|
2830
|
+
router.get(
|
|
2831
|
+
"/fetch_user_info",
|
|
2832
|
+
createDouyinValidationMiddleware("\u7528\u6237\u4E3B\u9875\u6570\u636E"),
|
|
2833
|
+
createDouyinRouteHandler(getDouyinData, "\u7528\u6237\u4E3B\u9875\u6570\u636E", cookie)
|
|
2834
|
+
);
|
|
2835
|
+
router.get(
|
|
2836
|
+
"/fetch_user_post_videos",
|
|
2837
|
+
createDouyinValidationMiddleware("\u7528\u6237\u4E3B\u9875\u89C6\u9891\u5217\u8868\u6570\u636E"),
|
|
2838
|
+
createDouyinRouteHandler(getDouyinData, "\u7528\u6237\u4E3B\u9875\u89C6\u9891\u5217\u8868\u6570\u636E", cookie)
|
|
2839
|
+
);
|
|
2840
|
+
router.get(
|
|
2841
|
+
"/fetch_search_info",
|
|
2842
|
+
createDouyinValidationMiddleware("\u641C\u7D22\u6570\u636E"),
|
|
2843
|
+
createDouyinRouteHandler(getDouyinData, "\u641C\u7D22\u6570\u636E", cookie)
|
|
2844
|
+
);
|
|
2845
|
+
router.get(
|
|
2846
|
+
"/fetch_suggest_words",
|
|
2847
|
+
createDouyinValidationMiddleware("\u70ED\u70B9\u8BCD\u6570\u636E"),
|
|
2848
|
+
createDouyinRouteHandler(getDouyinData, "\u70ED\u70B9\u8BCD\u6570\u636E", cookie)
|
|
2849
|
+
);
|
|
2850
|
+
router.get(
|
|
2851
|
+
"/fetch_music_work",
|
|
2852
|
+
createDouyinValidationMiddleware("\u97F3\u4E50\u6570\u636E"),
|
|
2853
|
+
createDouyinRouteHandler(getDouyinData, "\u97F3\u4E50\u6570\u636E", cookie)
|
|
2854
|
+
);
|
|
2855
|
+
router.get(
|
|
2856
|
+
"/fetch_emoji_list",
|
|
2857
|
+
createDouyinValidationMiddleware("Emoji\u6570\u636E"),
|
|
2858
|
+
createDouyinRouteHandler(getDouyinData, "Emoji\u6570\u636E", cookie)
|
|
2859
|
+
);
|
|
2860
|
+
router.get(
|
|
2861
|
+
"/fetch_emoji_pro_list",
|
|
2862
|
+
createDouyinValidationMiddleware("\u52A8\u6001\u8868\u60C5\u6570\u636E"),
|
|
2863
|
+
createDouyinRouteHandler(getDouyinData, "\u52A8\u6001\u8868\u60C5\u6570\u636E", cookie)
|
|
2864
|
+
);
|
|
2865
|
+
router.get(
|
|
2866
|
+
"/fetch_user_live_videos",
|
|
2867
|
+
createDouyinValidationMiddleware("\u76F4\u64AD\u95F4\u4FE1\u606F\u6570\u636E"),
|
|
2868
|
+
createDouyinRouteHandler(getDouyinData, "\u76F4\u64AD\u95F4\u4FE1\u606F\u6570\u636E", cookie)
|
|
2869
|
+
);
|
|
2870
|
+
router.get(
|
|
2871
|
+
"/fetch_video_comment_replies",
|
|
2872
|
+
createDouyinValidationMiddleware("\u6307\u5B9A\u8BC4\u8BBA\u56DE\u590D\u6570\u636E"),
|
|
2873
|
+
createDouyinRouteHandler(getDouyinData, "\u6307\u5B9A\u8BC4\u8BBA\u56DE\u590D\u6570\u636E", cookie)
|
|
2874
|
+
);
|
|
2875
|
+
return router;
|
|
2520
2876
|
};
|
|
2521
2877
|
|
|
2522
|
-
// src/
|
|
2523
|
-
var
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
const missingFields = atLeastOne ? fields : fields.filter((f) => !checkField(f));
|
|
2528
|
-
const missingStr = missingFields.map((f) => `'${logger.green(f.toString())}'`).join(", ");
|
|
2529
|
-
throw new Error(`\u83B7\u53D6\u300C${data2.methodType}\u300D${logger.red("\u7F3A\u5C11\u53C2\u6570")}: ${missingStr}`);
|
|
2530
|
-
}
|
|
2878
|
+
// src/platform/douyin/index.ts
|
|
2879
|
+
var douyinUtils = {
|
|
2880
|
+
sign: douyinSign,
|
|
2881
|
+
douyinApiUrls,
|
|
2882
|
+
api: douyin
|
|
2531
2883
|
};
|
|
2532
|
-
var
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2884
|
+
var createKuaishouRouteHandler = (dataFetcher, methodType, cookie) => {
|
|
2885
|
+
return async (req, res) => {
|
|
2886
|
+
try {
|
|
2887
|
+
const result = await dataFetcher(methodType, req.validatedParams, cookie);
|
|
2888
|
+
res.json({
|
|
2889
|
+
...result,
|
|
2890
|
+
requestPath: req.originalUrl
|
|
2891
|
+
});
|
|
2892
|
+
} catch (error) {
|
|
2893
|
+
const errorResponse = handleError(error);
|
|
2894
|
+
res.status(errorResponse.code || 500).json({
|
|
2895
|
+
...errorResponse,
|
|
2896
|
+
requestPath: req.originalUrl
|
|
2897
|
+
});
|
|
2898
|
+
}
|
|
2899
|
+
};
|
|
2900
|
+
};
|
|
2901
|
+
var createKuaishouRoutes = (cookie) => {
|
|
2902
|
+
const router = express.Router();
|
|
2903
|
+
router.get(
|
|
2904
|
+
"/fetch_one_work",
|
|
2905
|
+
createKuaishouValidationMiddleware("\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E"),
|
|
2906
|
+
createKuaishouRouteHandler(getKuaishouData, "\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E", cookie)
|
|
2907
|
+
);
|
|
2908
|
+
router.get(
|
|
2909
|
+
"/fetch_work_comments",
|
|
2910
|
+
createKuaishouValidationMiddleware("\u8BC4\u8BBA\u6570\u636E"),
|
|
2911
|
+
createKuaishouRouteHandler(getKuaishouData, "\u8BC4\u8BBA\u6570\u636E", cookie)
|
|
2912
|
+
);
|
|
2913
|
+
router.get(
|
|
2914
|
+
"/fetch_emoji_list",
|
|
2915
|
+
createKuaishouValidationMiddleware("Emoji\u6570\u636E"),
|
|
2916
|
+
createKuaishouRouteHandler(getKuaishouData, "Emoji\u6570\u636E", cookie)
|
|
2917
|
+
);
|
|
2918
|
+
return router;
|
|
2540
2919
|
};
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2920
|
+
|
|
2921
|
+
// src/platform/kuaishou/KuaishouApi.ts
|
|
2922
|
+
var kuaishou = {
|
|
2923
|
+
/**
|
|
2924
|
+
* 获取单个视频作品数据
|
|
2925
|
+
* @param options 请求参数,包含 photoId 和可选的 typeMode
|
|
2926
|
+
* @param cookie 可选的用户 Cookie
|
|
2927
|
+
* @returns 统一格式的API响应
|
|
2928
|
+
*/
|
|
2929
|
+
getWorkInfo: async (options, cookie) => {
|
|
2930
|
+
try {
|
|
2931
|
+
const data2 = await KuaishouData({ ...options, methodType: "\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E" }, cookie);
|
|
2932
|
+
return createApiResponse(data2, "\u83B7\u53D6\u89C6\u9891\u4F5C\u54C1\u6570\u636E\u6210\u529F", 200);
|
|
2933
|
+
} catch (error) {
|
|
2934
|
+
return createApiResponse(null, `\u83B7\u53D6\u89C6\u9891\u4F5C\u54C1\u6570\u636E\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
|
|
2935
|
+
}
|
|
2936
|
+
},
|
|
2937
|
+
/**
|
|
2938
|
+
* 获取评论数据
|
|
2939
|
+
* @param options 请求参数,包含 photoId 和可选的 typeMode
|
|
2940
|
+
* @param cookie 可选的用户 Cookie
|
|
2941
|
+
* @returns 统一格式的API响应
|
|
2942
|
+
*/
|
|
2943
|
+
getComments: async (options, cookie) => {
|
|
2944
|
+
try {
|
|
2945
|
+
const data2 = await KuaishouData({ ...options, methodType: "\u8BC4\u8BBA\u6570\u636E" }, cookie);
|
|
2946
|
+
return createApiResponse(data2, "\u83B7\u53D6\u8BC4\u8BBA\u6570\u636E\u6210\u529F", 200);
|
|
2947
|
+
} catch (error) {
|
|
2948
|
+
return createApiResponse(null, `\u83B7\u53D6\u8BC4\u8BBA\u6570\u636E\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
|
|
2949
|
+
}
|
|
2950
|
+
},
|
|
2951
|
+
/**
|
|
2952
|
+
* 获取 Emoji 数据
|
|
2953
|
+
* @param options 可选的请求参数 (主要用于 typeMode)
|
|
2954
|
+
* @param cookie 可选的用户 Cookie
|
|
2955
|
+
* @returns 统一格式的API响应
|
|
2956
|
+
*/
|
|
2957
|
+
getEmojiList: async (options, cookie) => {
|
|
2958
|
+
try {
|
|
2959
|
+
const data2 = await KuaishouData({ ...options, methodType: "Emoji\u6570\u636E" }, cookie);
|
|
2960
|
+
return createApiResponse(data2, "\u83B7\u53D6Emoji\u6570\u636E\u6210\u529F", 200);
|
|
2961
|
+
} catch (error) {
|
|
2962
|
+
return createApiResponse(null, `\u83B7\u53D6Emoji\u6570\u636E\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
|
|
2963
|
+
}
|
|
2548
2964
|
}
|
|
2549
2965
|
};
|
|
2966
|
+
|
|
2967
|
+
// src/platform/kuaishou/index.ts
|
|
2968
|
+
var kuaishouUtils = {
|
|
2969
|
+
kuaishouApiUrls,
|
|
2970
|
+
api: kuaishou
|
|
2971
|
+
};
|
|
2550
2972
|
var amagiClient = class {
|
|
2551
2973
|
#douyin;
|
|
2552
2974
|
#bilibili;
|
|
@@ -2575,9 +2997,9 @@ var amagiClient = class {
|
|
|
2575
2997
|
res.redirect(301, "https://amagi.apifox.cn");
|
|
2576
2998
|
});
|
|
2577
2999
|
app.use(logMiddleware(["/api/douyin", "/api/bilibili", "/api/kuaishou"]));
|
|
2578
|
-
app.use("/api/douyin",
|
|
2579
|
-
app.use("/api/bilibili",
|
|
2580
|
-
app.use("/api/kuaishou",
|
|
3000
|
+
app.use("/api/douyin", createDouyinRoutes(this.#douyin));
|
|
3001
|
+
app.use("/api/bilibili", createBilibiliRoutes(this.#bilibili));
|
|
3002
|
+
app.use("/api/kuaishou", createKuaishouRoutes(this.#kuaishou));
|
|
2581
3003
|
app.listen(port, "::", () => {
|
|
2582
3004
|
logger.mark(`Amagi server listening on ${logger.green(`http://localhost:${port}`)} ${logger.yellow("API docs: https://amagi.apifox.cn ")}`);
|
|
2583
3005
|
});
|
|
@@ -2624,6 +3046,50 @@ var amagiClient = class {
|
|
|
2624
3046
|
};
|
|
2625
3047
|
};
|
|
2626
3048
|
|
|
3049
|
+
// src/v4/DataFetchers.ts
|
|
3050
|
+
async function getDouyinData2(type, arg2, arg3) {
|
|
3051
|
+
let cookie;
|
|
3052
|
+
let options;
|
|
3053
|
+
if (typeof arg2 === "string") {
|
|
3054
|
+
cookie = arg2;
|
|
3055
|
+
options = arg3;
|
|
3056
|
+
} else {
|
|
3057
|
+
options = arg2;
|
|
3058
|
+
cookie = arg3;
|
|
3059
|
+
}
|
|
3060
|
+
const data2 = await DouyinData({ ...options, methodType: type }, cookie);
|
|
3061
|
+
return data2;
|
|
3062
|
+
}
|
|
3063
|
+
async function getBilibiliData2(methodType, arg2, arg3) {
|
|
3064
|
+
let cookie;
|
|
3065
|
+
let options;
|
|
3066
|
+
if (typeof arg2 === "string") {
|
|
3067
|
+
cookie = arg2;
|
|
3068
|
+
options = arg3;
|
|
3069
|
+
} else {
|
|
3070
|
+
options = arg2;
|
|
3071
|
+
cookie = arg3;
|
|
3072
|
+
}
|
|
3073
|
+
const data2 = await fetchBilibili({ ...options, methodType }, cookie);
|
|
3074
|
+
return data2;
|
|
3075
|
+
}
|
|
3076
|
+
async function getKuaishouData2(methodType, arg2, arg3) {
|
|
3077
|
+
let cookie;
|
|
3078
|
+
let options;
|
|
3079
|
+
if (typeof arg2 === "string") {
|
|
3080
|
+
cookie = arg2;
|
|
3081
|
+
options = arg3;
|
|
3082
|
+
} else {
|
|
3083
|
+
options = arg2;
|
|
3084
|
+
cookie = arg3;
|
|
3085
|
+
}
|
|
3086
|
+
const data2 = await KuaishouData({ ...options, methodType }, cookie);
|
|
3087
|
+
return data2;
|
|
3088
|
+
}
|
|
3089
|
+
var fetchDouyinData = getDouyinData2;
|
|
3090
|
+
var fetchBilibiliData = getBilibiliData2;
|
|
3091
|
+
var fetchKuaishouData = getKuaishouData2;
|
|
3092
|
+
|
|
2627
3093
|
// src/index.ts
|
|
2628
3094
|
function createAmagiClient(options = {}) {
|
|
2629
3095
|
if (!(this instanceof createAmagiClient)) {
|
|
@@ -2634,18 +3100,20 @@ function createAmagiClient(options = {}) {
|
|
|
2634
3100
|
createAmagiClient.douyin = douyinUtils;
|
|
2635
3101
|
createAmagiClient.bilibili = bilibiliUtils;
|
|
2636
3102
|
createAmagiClient.kuaishou = kuaishouUtils;
|
|
2637
|
-
createAmagiClient.getDouyinData =
|
|
2638
|
-
createAmagiClient.getBilibiliData =
|
|
2639
|
-
createAmagiClient.getKuaishouData =
|
|
3103
|
+
createAmagiClient.getDouyinData = getDouyinData2;
|
|
3104
|
+
createAmagiClient.getBilibiliData = getBilibiliData2;
|
|
3105
|
+
createAmagiClient.getKuaishouData = getKuaishouData2;
|
|
2640
3106
|
var CreateApp = createAmagiClient;
|
|
2641
3107
|
var Client = CreateApp;
|
|
2642
3108
|
var amagi = Client;
|
|
3109
|
+
/*!
|
|
3110
|
+
* @ikenxuan/amagi v4 (default)
|
|
3111
|
+
* Copyright(c) 2023 ikenxuan
|
|
3112
|
+
* GPL-3.0 Licensed
|
|
3113
|
+
*/
|
|
2643
3114
|
|
|
2644
|
-
exports.BilibiliValidateData = BilibiliValidateData;
|
|
2645
3115
|
exports.CreateApp = CreateApp;
|
|
2646
|
-
exports.DouyinValidateData = DouyinValidateData;
|
|
2647
3116
|
exports.KuaishouAPI = KuaishouAPI;
|
|
2648
|
-
exports.KusiahouValidateData = KusiahouValidateData;
|
|
2649
3117
|
exports.Networks = Networks;
|
|
2650
3118
|
exports.amagi = amagi;
|
|
2651
3119
|
exports.amagiClient = amagiClient;
|
|
@@ -2656,6 +3124,9 @@ exports.bilibiliApiUrls = bilibiliApiUrls;
|
|
|
2656
3124
|
exports.bilibiliErrorCodeMap = bilibiliErrorCodeMap;
|
|
2657
3125
|
exports.bilibiliUtils = bilibiliUtils;
|
|
2658
3126
|
exports.bv2av = bv2av;
|
|
3127
|
+
exports.createBilibiliRoutes = createBilibiliRoutes;
|
|
3128
|
+
exports.createDouyinRoutes = createDouyinRoutes;
|
|
3129
|
+
exports.createKuaishouRoutes = createKuaishouRoutes;
|
|
2659
3130
|
exports.default = Client;
|
|
2660
3131
|
exports.douyin = douyin;
|
|
2661
3132
|
exports.douyinAPI = douyinAPI;
|
|
@@ -2665,9 +3136,9 @@ exports.douyinUtils = douyinUtils;
|
|
|
2665
3136
|
exports.fetchBilibiliData = fetchBilibiliData;
|
|
2666
3137
|
exports.fetchDouyinData = fetchDouyinData;
|
|
2667
3138
|
exports.fetchKuaishouData = fetchKuaishouData;
|
|
2668
|
-
exports.getBilibiliData =
|
|
2669
|
-
exports.getDouyinData =
|
|
2670
|
-
exports.getKuaishouData =
|
|
3139
|
+
exports.getBilibiliData = getBilibiliData2;
|
|
3140
|
+
exports.getDouyinData = getDouyinData2;
|
|
3141
|
+
exports.getKuaishouData = getKuaishouData2;
|
|
2671
3142
|
exports.httpLogger = httpLogger;
|
|
2672
3143
|
exports.kuaishou = kuaishou;
|
|
2673
3144
|
exports.kuaishouAPI = kuaishouAPI;
|
|
@@ -2676,7 +3147,7 @@ exports.kuaishouUtils = kuaishouUtils;
|
|
|
2676
3147
|
exports.logMiddleware = logMiddleware;
|
|
2677
3148
|
exports.logger = logger;
|
|
2678
3149
|
exports.qtparam = qtparam;
|
|
2679
|
-
exports.registerBilibiliRoutes =
|
|
2680
|
-
exports.registerDouyinRoutes =
|
|
2681
|
-
exports.registerKuaishouRoutes =
|
|
3150
|
+
exports.registerBilibiliRoutes = createDouyinRoutes;
|
|
3151
|
+
exports.registerDouyinRoutes = createBilibiliRoutes;
|
|
3152
|
+
exports.registerKuaishouRoutes = createKuaishouRoutes;
|
|
2682
3153
|
exports.wbi_sign = wbi_sign;
|