@ikenxuan/amagi 5.0.1 → 5.0.2
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 +21 -10
- package/dist/default/esm/index.mjs +20 -9
- package/dist/default/index.d.ts +0 -3
- package/package.json +1 -1
|
@@ -27,7 +27,7 @@ var express__default = /*#__PURE__*/_interopDefault(express);
|
|
|
27
27
|
* GPL-3.0 Licensed
|
|
28
28
|
*/
|
|
29
29
|
|
|
30
|
-
// node_modules/.pnpm/tsup@8.5.0_@swc+core@1.13.3_tsx@4.20.3_typescript@5.
|
|
30
|
+
// node_modules/.pnpm/tsup@8.5.0_@swc+core@1.13.3_tsx@4.20.3_typescript@5.9.2/node_modules/tsup/assets/cjs_shims.js
|
|
31
31
|
var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
|
|
32
32
|
var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
33
33
|
var getPackageLogsPath = () => {
|
|
@@ -167,9 +167,16 @@ var logMiddleware = (pathsToLog) => {
|
|
|
167
167
|
next();
|
|
168
168
|
};
|
|
169
169
|
};
|
|
170
|
+
var cleanUserAgent = (userAgent) => {
|
|
171
|
+
return userAgent.replace(/\s+Edg\/[\d\.]+/g, "");
|
|
172
|
+
};
|
|
170
173
|
var fetchData = async (config) => {
|
|
171
174
|
try {
|
|
172
|
-
const
|
|
175
|
+
const cleanedConfig = { ...config };
|
|
176
|
+
if (cleanedConfig.headers && cleanedConfig.headers["User-Agent"]) {
|
|
177
|
+
cleanedConfig.headers["User-Agent"] = cleanUserAgent(cleanedConfig.headers["User-Agent"]);
|
|
178
|
+
}
|
|
179
|
+
const response = await axios__default.default(cleanedConfig);
|
|
173
180
|
if (response.status === 429) {
|
|
174
181
|
logger.error("HTTP \u54CD\u5E94\u72B6\u6001\u7801: 429");
|
|
175
182
|
throw new Error("ratelimit triggered, \u89E6\u53D1\u901F\u7387\u9650\u5236\uFF01");
|
|
@@ -185,7 +192,11 @@ var fetchData = async (config) => {
|
|
|
185
192
|
};
|
|
186
193
|
var fetchResponse = async (config) => {
|
|
187
194
|
try {
|
|
188
|
-
|
|
195
|
+
const cleanedConfig = { ...config };
|
|
196
|
+
if (cleanedConfig.headers && cleanedConfig.headers["User-Agent"]) {
|
|
197
|
+
cleanedConfig.headers["User-Agent"] = cleanUserAgent(cleanedConfig.headers["User-Agent"]);
|
|
198
|
+
}
|
|
199
|
+
return await axios__default.default(cleanedConfig);
|
|
189
200
|
} catch (error) {
|
|
190
201
|
if (error instanceof axios.AxiosError) {
|
|
191
202
|
throw error;
|
|
@@ -444,7 +455,8 @@ var generateSecChUa = (userAgent) => {
|
|
|
444
455
|
};
|
|
445
456
|
var getDouyinDefaultConfig = (cookie, requestConfig) => {
|
|
446
457
|
var _a;
|
|
447
|
-
|
|
458
|
+
let finalUserAgent = ((_a = void 0 ) == null ? void 0 : _a["User-Agent"]) || "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36";
|
|
459
|
+
finalUserAgent = finalUserAgent.replace(/\s+Edg\/[\d\.]+/g, "");
|
|
448
460
|
const defHeaders = {
|
|
449
461
|
Accept: "application/json, text/plain, */*",
|
|
450
462
|
"Accept-Encoding": "gzip, deflate, br, zstd",
|
|
@@ -1229,8 +1241,12 @@ function generate_random_str() {
|
|
|
1229
1241
|
random_str_list = random_str_list.concat(gener_random(Math.random() * 1e4, [1, 5]));
|
|
1230
1242
|
return String.fromCharCode.apply(null, random_str_list);
|
|
1231
1243
|
}
|
|
1244
|
+
var cleanUserAgentForSigning = (userAgent) => {
|
|
1245
|
+
return userAgent.replace(/\s+Edg\/[\d\.]+/g, "");
|
|
1246
|
+
};
|
|
1232
1247
|
var a_bogus_default = (url, user_agent) => {
|
|
1233
|
-
|
|
1248
|
+
const cleanedUserAgent = cleanUserAgentForSigning(user_agent);
|
|
1249
|
+
let result_str = generate_random_str() + generate_rc4_bb_str(new URLSearchParams(new URL(url).search).toString(), cleanedUserAgent, "1536|747|1536|834|0|30|0|0|1536|834|1536|864|1525|747|24|24|Win32");
|
|
1234
1250
|
return result_encrypt(result_str, "s4") + "=";
|
|
1235
1251
|
};
|
|
1236
1252
|
|
|
@@ -3345,9 +3361,6 @@ var createAmagiClient = (options) => {
|
|
|
3345
3361
|
});
|
|
3346
3362
|
return app;
|
|
3347
3363
|
};
|
|
3348
|
-
const startClient = (port = 4567) => {
|
|
3349
|
-
return startServer(port);
|
|
3350
|
-
};
|
|
3351
3364
|
const getDouyinDataWithCookie = async (methodType, options2) => {
|
|
3352
3365
|
return await getDouyinData(methodType, options2, douyinCookie, requestConfig);
|
|
3353
3366
|
};
|
|
@@ -3360,8 +3373,6 @@ var createAmagiClient = (options) => {
|
|
|
3360
3373
|
return {
|
|
3361
3374
|
/** 启动本地HTTP服务 */
|
|
3362
3375
|
startServer,
|
|
3363
|
-
/** @deprecated 此方法已废弃,请使用 startServer 方法代替 */
|
|
3364
|
-
startClient,
|
|
3365
3376
|
getDouyinData: getDouyinDataWithCookie,
|
|
3366
3377
|
getBilibiliData: getBilibiliDataWithCookie,
|
|
3367
3378
|
getKuaishouData: getKuaishouDataWithCookie,
|
|
@@ -151,9 +151,16 @@ var logMiddleware = (pathsToLog) => {
|
|
|
151
151
|
next();
|
|
152
152
|
};
|
|
153
153
|
};
|
|
154
|
+
var cleanUserAgent = (userAgent) => {
|
|
155
|
+
return userAgent.replace(/\s+Edg\/[\d\.]+/g, "");
|
|
156
|
+
};
|
|
154
157
|
var fetchData = async (config) => {
|
|
155
158
|
try {
|
|
156
|
-
const
|
|
159
|
+
const cleanedConfig = { ...config };
|
|
160
|
+
if (cleanedConfig.headers && cleanedConfig.headers["User-Agent"]) {
|
|
161
|
+
cleanedConfig.headers["User-Agent"] = cleanUserAgent(cleanedConfig.headers["User-Agent"]);
|
|
162
|
+
}
|
|
163
|
+
const response = await axios(cleanedConfig);
|
|
157
164
|
if (response.status === 429) {
|
|
158
165
|
logger.error("HTTP \u54CD\u5E94\u72B6\u6001\u7801: 429");
|
|
159
166
|
throw new Error("ratelimit triggered, \u89E6\u53D1\u901F\u7387\u9650\u5236\uFF01");
|
|
@@ -169,7 +176,11 @@ var fetchData = async (config) => {
|
|
|
169
176
|
};
|
|
170
177
|
var fetchResponse = async (config) => {
|
|
171
178
|
try {
|
|
172
|
-
|
|
179
|
+
const cleanedConfig = { ...config };
|
|
180
|
+
if (cleanedConfig.headers && cleanedConfig.headers["User-Agent"]) {
|
|
181
|
+
cleanedConfig.headers["User-Agent"] = cleanUserAgent(cleanedConfig.headers["User-Agent"]);
|
|
182
|
+
}
|
|
183
|
+
return await axios(cleanedConfig);
|
|
173
184
|
} catch (error) {
|
|
174
185
|
if (error instanceof AxiosError) {
|
|
175
186
|
throw error;
|
|
@@ -428,7 +439,8 @@ var generateSecChUa = (userAgent) => {
|
|
|
428
439
|
};
|
|
429
440
|
var getDouyinDefaultConfig = (cookie, requestConfig) => {
|
|
430
441
|
var _a;
|
|
431
|
-
|
|
442
|
+
let finalUserAgent = ((_a = void 0 ) == null ? void 0 : _a["User-Agent"]) || "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36";
|
|
443
|
+
finalUserAgent = finalUserAgent.replace(/\s+Edg\/[\d\.]+/g, "");
|
|
432
444
|
const defHeaders = {
|
|
433
445
|
Accept: "application/json, text/plain, */*",
|
|
434
446
|
"Accept-Encoding": "gzip, deflate, br, zstd",
|
|
@@ -1213,8 +1225,12 @@ function generate_random_str() {
|
|
|
1213
1225
|
random_str_list = random_str_list.concat(gener_random(Math.random() * 1e4, [1, 5]));
|
|
1214
1226
|
return String.fromCharCode.apply(null, random_str_list);
|
|
1215
1227
|
}
|
|
1228
|
+
var cleanUserAgentForSigning = (userAgent) => {
|
|
1229
|
+
return userAgent.replace(/\s+Edg\/[\d\.]+/g, "");
|
|
1230
|
+
};
|
|
1216
1231
|
var a_bogus_default = (url, user_agent) => {
|
|
1217
|
-
|
|
1232
|
+
const cleanedUserAgent = cleanUserAgentForSigning(user_agent);
|
|
1233
|
+
let result_str = generate_random_str() + generate_rc4_bb_str(new URLSearchParams(new URL(url).search).toString(), cleanedUserAgent, "1536|747|1536|834|0|30|0|0|1536|834|1536|864|1525|747|24|24|Win32");
|
|
1218
1234
|
return result_encrypt(result_str, "s4") + "=";
|
|
1219
1235
|
};
|
|
1220
1236
|
|
|
@@ -3329,9 +3345,6 @@ var createAmagiClient = (options) => {
|
|
|
3329
3345
|
});
|
|
3330
3346
|
return app;
|
|
3331
3347
|
};
|
|
3332
|
-
const startClient = (port = 4567) => {
|
|
3333
|
-
return startServer(port);
|
|
3334
|
-
};
|
|
3335
3348
|
const getDouyinDataWithCookie = async (methodType, options2) => {
|
|
3336
3349
|
return await getDouyinData(methodType, options2, douyinCookie, requestConfig);
|
|
3337
3350
|
};
|
|
@@ -3344,8 +3357,6 @@ var createAmagiClient = (options) => {
|
|
|
3344
3357
|
return {
|
|
3345
3358
|
/** 启动本地HTTP服务 */
|
|
3346
3359
|
startServer,
|
|
3347
|
-
/** @deprecated 此方法已废弃,请使用 startServer 方法代替 */
|
|
3348
|
-
startClient,
|
|
3349
3360
|
getDouyinData: getDouyinDataWithCookie,
|
|
3350
3361
|
getBilibiliData: getBilibiliDataWithCookie,
|
|
3351
3362
|
getKuaishouData: getKuaishouDataWithCookie,
|
package/dist/default/index.d.ts
CHANGED
|
@@ -14291,8 +14291,6 @@ type Options = {
|
|
|
14291
14291
|
declare const createAmagiClient: (options?: Options) => {
|
|
14292
14292
|
/** 启动本地HTTP服务 */
|
|
14293
14293
|
startServer: (port?: number) => express__default.Application;
|
|
14294
|
-
/** @deprecated 此方法已废弃,请使用 startServer 方法代替 */
|
|
14295
|
-
startClient: (port?: number) => express__default.Application;
|
|
14296
14294
|
getDouyinData: <T extends DouyinMethodType, M extends TypeMode>(methodType: T, options?: ExtendedDouyinOptions<T> & {
|
|
14297
14295
|
typeMode?: M;
|
|
14298
14296
|
}) => Promise<ApiResponse<ConditionalReturnType<DouyinDataOptionsMap[T]["data"], M>>>;
|
|
@@ -16248,7 +16246,6 @@ declare const handleError: (error: unknown, requestPath?: string) => {
|
|
|
16248
16246
|
*/
|
|
16249
16247
|
declare const amagiClient: (options?: Options) => {
|
|
16250
16248
|
startServer: (port?: number) => express.Application;
|
|
16251
|
-
startClient: (port?: number) => express.Application;
|
|
16252
16249
|
getDouyinData: <T extends DouyinMethodType, M extends TypeMode>(methodType: T, options?: ExtendedDouyinOptions<T> & {
|
|
16253
16250
|
typeMode?: M;
|
|
16254
16251
|
}) => Promise<ApiResponse<ConditionalReturnType<DouyinDataOptionsMap[T]["data"], M>>>;
|