@ikenxuan/amagi 5.9.1 → 5.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/default/index.cjs +249 -71
- package/dist/default/index.d.cts +9208 -8285
- package/dist/default/index.d.ts +9208 -8285
- package/dist/default/index.js +249 -72
- package/package.json +1 -1
package/dist/default/index.js
CHANGED
|
@@ -284,19 +284,18 @@ const getDouyinDefaultConfig = (cookie, requestConfig) => {
|
|
|
284
284
|
*/
|
|
285
285
|
const getBilibiliDefaultConfig = (cookie, requestConfig) => {
|
|
286
286
|
const defHeaders = {
|
|
287
|
-
Accept: "
|
|
287
|
+
Accept: "application/json, text/plain, */*",
|
|
288
288
|
"Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
|
|
289
|
-
"
|
|
290
|
-
|
|
291
|
-
|
|
289
|
+
"Accept-Encoding": "gzip, deflate, br",
|
|
290
|
+
Origin: "https://www.bilibili.com",
|
|
291
|
+
Referer: "https://www.bilibili.com/",
|
|
292
|
+
Priority: "u=1, i",
|
|
293
|
+
"Sec-Ch-Ua": "\"Microsoft Edge\";v=\"141\", \"Chromium\";v=\"141\", \"Not_A Brand\";v=\"24\"",
|
|
292
294
|
"Sec-Ch-Ua-Mobile": "?0",
|
|
293
295
|
"Sec-Ch-Ua-Platform": "\"Windows\"",
|
|
294
|
-
"Sec-Fetch-Dest": "
|
|
295
|
-
"Sec-Fetch-Mode": "
|
|
296
|
-
"Sec-Fetch-Site": "
|
|
297
|
-
"Sec-Fetch-User": "?1",
|
|
298
|
-
"Upgrade-Insecure-Requests": "1",
|
|
299
|
-
Referer: "https://www.bilibili.com/",
|
|
296
|
+
"Sec-Fetch-Dest": "empty",
|
|
297
|
+
"Sec-Fetch-Mode": "cors",
|
|
298
|
+
"Sec-Fetch-Site": "same-site",
|
|
300
299
|
Cookie: cookie ? cookie.replace(/\s+/g, "") : ""
|
|
301
300
|
};
|
|
302
301
|
return {
|
|
@@ -558,7 +557,7 @@ var BiLiBiLiAPI = class {
|
|
|
558
557
|
return `https://api.bilibili.com/pgc/player/web/playurl?cid=${data$1.cid}&ep_id=${data$1.ep_id}`;
|
|
559
558
|
}
|
|
560
559
|
用户空间动态(data$1) {
|
|
561
|
-
return `https://api.bilibili.com/x/polymer/web-dynamic/v1/feed/space?host_mid=${data$1.host_mid}&features=itemOpusStyle,listOnlyfans,opusBigCover,onlyfansVote,forwardListHidden,decorationCard,commentsNewVersion,onlyfansAssetsV2,ugcDelete,onlyfansQaCard`;
|
|
560
|
+
return `https://api.bilibili.com/x/polymer/web-dynamic/v1/feed/space?host_mid=${data$1.host_mid}&dm_img_switch=0&&features=itemOpusStyle,listOnlyfans,opusBigCover,onlyfansVote,forwardListHidden,decorationCard,commentsNewVersion,onlyfansAssetsV2,ugcDelete,onlyfansQaCard`;
|
|
562
561
|
}
|
|
563
562
|
动态详情(data$1) {
|
|
564
563
|
return `https://api.bilibili.com/x/polymer/web-dynamic/v1/detail?id=${data$1.dynamic_id}&features=itemOpusStyle,opusBigCover,onlyfansVote,endFooterHidden,decorationCard,onlyfansAssetsV2,ugcDelete,onlyfansQaCard,editable,opusPrivateVisible,avatarAutoTheme`;
|
|
@@ -1180,9 +1179,18 @@ const DouyinCommentParamsSchema = zod.object({
|
|
|
1180
1179
|
number: smartPositiveInteger("评论数量必须是正整数").optional().default(50),
|
|
1181
1180
|
cursor: zod.coerce.number({ error: "游标必须是数字" }).int({ error: "游标必须是整数" }).min(0, { error: "游标不能小于0" }).default(0).optional()
|
|
1182
1181
|
});
|
|
1182
|
+
const DouyinHotWordsParamsSchema = zod.object({
|
|
1183
|
+
methodType: zod.literal("热点词数据", { error: "方法类型必须是\"热点词数据\"" }),
|
|
1184
|
+
query: zod.string({ error: "搜索词必须是字符串" }).min(1, { error: "搜索词不能为空" })
|
|
1185
|
+
});
|
|
1183
1186
|
const DouyinSearchParamsSchema = zod.object({
|
|
1184
|
-
methodType: zod.
|
|
1187
|
+
methodType: zod.literal("搜索数据", { error: "方法类型必须是\"搜索数据\"" }),
|
|
1185
1188
|
query: zod.string({ error: "搜索词必须是字符串" }).min(1, { error: "搜索词不能为空" }),
|
|
1189
|
+
type: zod.enum([
|
|
1190
|
+
"综合",
|
|
1191
|
+
"用户",
|
|
1192
|
+
"视频"
|
|
1193
|
+
], { error: "搜索类型必须是\"综合\"、\"用户\"或\"视频\"" }).optional().default("综合"),
|
|
1186
1194
|
number: smartPositiveInteger("搜索数量必须是正整数").optional().default(10),
|
|
1187
1195
|
search_id: zod.string({ error: "搜索ID必须是字符串" }).optional()
|
|
1188
1196
|
});
|
|
@@ -1240,7 +1248,7 @@ const DouyinValidationSchemas = {
|
|
|
1240
1248
|
评论数据: DouyinCommentParamsSchema,
|
|
1241
1249
|
用户主页数据: DouyinUserParamsSchema,
|
|
1242
1250
|
用户主页视频列表数据: DouyinUserParamsSchema,
|
|
1243
|
-
热点词数据:
|
|
1251
|
+
热点词数据: DouyinHotWordsParamsSchema,
|
|
1244
1252
|
搜索数据: DouyinSearchParamsSchema,
|
|
1245
1253
|
音乐数据: DouyinMusicParamsSchema,
|
|
1246
1254
|
直播间信息数据: DouyinLiveRoomParamsSchema,
|
|
@@ -1887,7 +1895,7 @@ const fetchBilibili = async (data$1, cookie, requestConfig) => {
|
|
|
1887
1895
|
timeout: 1e4,
|
|
1888
1896
|
...requestConfig,
|
|
1889
1897
|
headers: {
|
|
1890
|
-
|
|
1898
|
+
Referer: "https://www.bilibili.com/",
|
|
1891
1899
|
...defHeaders,
|
|
1892
1900
|
...requestConfig?.headers ?? {}
|
|
1893
1901
|
}
|
|
@@ -2004,14 +2012,15 @@ const fetchBilibili = async (data$1, cookie, requestConfig) => {
|
|
|
2004
2012
|
});
|
|
2005
2013
|
}
|
|
2006
2014
|
case "用户主页动态列表数据": {
|
|
2015
|
+
const { host_mid } = data$1;
|
|
2007
2016
|
const customConfig = {
|
|
2008
2017
|
...baseRequestConfig,
|
|
2009
2018
|
headers: {
|
|
2010
2019
|
...baseRequestConfig.headers,
|
|
2011
|
-
...
|
|
2020
|
+
...requestConfig?.headers && ("referer" in requestConfig.headers || "Referer" in requestConfig.headers) ? {} : { Referer: `https://space.bilibili.com/${host_mid}` },
|
|
2021
|
+
Origin: "https://space.bilibili.com"
|
|
2012
2022
|
}
|
|
2013
2023
|
};
|
|
2014
|
-
const { host_mid } = data$1;
|
|
2015
2024
|
const wbiSignQuery = await wbi_sign(bilibiliApiUrls.用户空间动态({ host_mid }), baseRequestConfig.headers?.cookie);
|
|
2016
2025
|
return await GlobalGetData$3(data$1.methodType, {
|
|
2017
2026
|
...customConfig,
|
|
@@ -2145,31 +2154,11 @@ const fetchBilibili = async (data$1, cookie, requestConfig) => {
|
|
|
2145
2154
|
* @param options - 网络请求配置
|
|
2146
2155
|
* @returns
|
|
2147
2156
|
*/
|
|
2148
|
-
const GlobalGetData$3 = async (type, options) => {
|
|
2157
|
+
const GlobalGetData$3 = async (type, options, retryCount = 0) => {
|
|
2158
|
+
const MAX_RETRIES = 3;
|
|
2149
2159
|
let warningMessage = "";
|
|
2150
2160
|
try {
|
|
2151
2161
|
const result = await fetchData(options);
|
|
2152
|
-
if (typeof result === "string" && result.includes("<!DOCTYPE html>")) {
|
|
2153
|
-
const Err = {
|
|
2154
|
-
errorDescription: "触发B站风控策略,请求被拦截!可能原因:请求频率过高、Cookie失效、缺少必要请求头",
|
|
2155
|
-
requestType: type ?? "未知请求类型",
|
|
2156
|
-
requestUrl: options.url
|
|
2157
|
-
};
|
|
2158
|
-
warningMessage = `
|
|
2159
|
-
${logger.red("触发B站风控策略,请求被拦截")}
|
|
2160
|
-
请求类型:「${type}」
|
|
2161
|
-
请求URL:${options.url}
|
|
2162
|
-
建议:降低请求频率、检查Cookie
|
|
2163
|
-
`;
|
|
2164
|
-
logger.warn(warningMessage);
|
|
2165
|
-
const riskError = new Error(Err.errorDescription);
|
|
2166
|
-
Object.assign(riskError, {
|
|
2167
|
-
code: bilibiliAPIErrorCode.IP_BLOCKED,
|
|
2168
|
-
data: result,
|
|
2169
|
-
amagiError: Err
|
|
2170
|
-
});
|
|
2171
|
-
throw riskError;
|
|
2172
|
-
}
|
|
2173
2162
|
if (!result || result === "") {
|
|
2174
2163
|
const Err = {
|
|
2175
2164
|
errorDescription: "获取响应数据失败!接口返回内容为空,你的B站ck可能已经失效!",
|
|
@@ -2191,11 +2180,13 @@ const GlobalGetData$3 = async (type, options) => {
|
|
|
2191
2180
|
throw riskError;
|
|
2192
2181
|
}
|
|
2193
2182
|
if (result.code !== 0 || !result.data || typeof result.data === "object" && Object.keys(result.data).length === 0) {
|
|
2183
|
+
if (result.code === -412 && retryCount < MAX_RETRIES) return await GlobalGetData$3(type, options, retryCount + 1);
|
|
2194
2184
|
const errorMessage = bilibiliErrorCodeMap[result.code] || typeof result.data === "object" && Object.keys(result.data).length === 0 && "请求成功但无返回内容" || (result.message ?? "未知错误");
|
|
2195
2185
|
const Err = {
|
|
2196
2186
|
errorDescription: `获取响应数据失败!原因:${errorMessage}!`,
|
|
2197
2187
|
requestType: type ?? "未知请求类型",
|
|
2198
|
-
requestUrl: options.url
|
|
2188
|
+
requestUrl: options.url,
|
|
2189
|
+
responseCode: result.code
|
|
2199
2190
|
};
|
|
2200
2191
|
warningMessage = `
|
|
2201
2192
|
获取响应数据失败!原因:${logger.yellow(errorMessage)}
|
|
@@ -3147,12 +3138,68 @@ var DouyinAPI = class {
|
|
|
3147
3138
|
}
|
|
3148
3139
|
/**
|
|
3149
3140
|
* 获取搜索数据的接口地址
|
|
3150
|
-
* @param data - 请求参数,包含query、number、search_id等
|
|
3141
|
+
* @param data - 请求参数,包含query、type、number、search_id等
|
|
3151
3142
|
* @returns 完整的接口URL
|
|
3152
3143
|
*/
|
|
3153
3144
|
搜索(data$1) {
|
|
3154
|
-
|
|
3155
|
-
|
|
3145
|
+
const searchType = data$1.type ?? "综合";
|
|
3146
|
+
const { verifyFp, fp: fp$1, ...baseParamsWithoutFp } = this.getBaseParams();
|
|
3147
|
+
if (searchType === "用户") return `https://www.douyin.com/aweme/v1/web/discover/search/?${buildQueryString({
|
|
3148
|
+
...baseParamsWithoutFp,
|
|
3149
|
+
count: data$1.number ?? 10,
|
|
3150
|
+
disable_rs: "0",
|
|
3151
|
+
from_group_id: "",
|
|
3152
|
+
is_filter_search: "0",
|
|
3153
|
+
keyword: data$1.query,
|
|
3154
|
+
list_type: "single",
|
|
3155
|
+
need_filter_settings: "1",
|
|
3156
|
+
offset: "0",
|
|
3157
|
+
pc_libra_divert: "Windows",
|
|
3158
|
+
pc_search_top_1_params: "{\"enable_ai_search_top_1\":1}",
|
|
3159
|
+
query_correct_type: "1",
|
|
3160
|
+
round_trip_time: "250",
|
|
3161
|
+
screen_height: "1310",
|
|
3162
|
+
screen_width: "2328",
|
|
3163
|
+
search_channel: "aweme_user_web",
|
|
3164
|
+
search_source: "switch_tab",
|
|
3165
|
+
support_dash: "1",
|
|
3166
|
+
support_h265: "1",
|
|
3167
|
+
version_code: "170400",
|
|
3168
|
+
version_name: "17.4.0",
|
|
3169
|
+
webid: "7521399115230610959",
|
|
3170
|
+
...data$1.search_id && { search_id: data$1.search_id }
|
|
3171
|
+
})}`;
|
|
3172
|
+
else if (searchType === "视频") {
|
|
3173
|
+
const baseUrl = "https://www.douyin.com/aweme/v1/web/search/item/";
|
|
3174
|
+
const { verifyFp: verifyFp$1, fp: fp$2, ...baseParamsWithoutFp$1 } = this.getBaseParams();
|
|
3175
|
+
return `${baseUrl}?${buildQueryString({
|
|
3176
|
+
...baseParamsWithoutFp$1,
|
|
3177
|
+
count: data$1.number ?? 10,
|
|
3178
|
+
disable_rs: "0",
|
|
3179
|
+
enable_history: "1",
|
|
3180
|
+
from_group_id: "",
|
|
3181
|
+
is_filter_search: "0",
|
|
3182
|
+
keyword: data$1.query,
|
|
3183
|
+
list_type: "single",
|
|
3184
|
+
need_filter_settings: "1",
|
|
3185
|
+
offset: "0",
|
|
3186
|
+
pc_libra_divert: "Windows",
|
|
3187
|
+
pc_search_top_1_params: "{\"enable_ai_search_top_1\":1}",
|
|
3188
|
+
query_correct_type: "1",
|
|
3189
|
+
round_trip_time: "50",
|
|
3190
|
+
screen_height: "1310",
|
|
3191
|
+
screen_width: "2328",
|
|
3192
|
+
search_channel: "aweme_video_web",
|
|
3193
|
+
search_source: "switch_tab",
|
|
3194
|
+
support_dash: "1",
|
|
3195
|
+
support_h265: "1",
|
|
3196
|
+
version_code: "170400",
|
|
3197
|
+
version_name: "17.4.0",
|
|
3198
|
+
webid: "7521399115230610959",
|
|
3199
|
+
...data$1.search_id && { search_id: data$1.search_id }
|
|
3200
|
+
})}`;
|
|
3201
|
+
} else return `https://www.douyin.com/aweme/v1/web/general/search/stream/?${buildQueryString({
|
|
3202
|
+
...baseParamsWithoutFp,
|
|
3156
3203
|
count: data$1.number ?? 10,
|
|
3157
3204
|
disable_rs: "0",
|
|
3158
3205
|
enable_history: "1",
|
|
@@ -3470,10 +3517,7 @@ const DouyinData = async (data$1, cookie, requestConfig) => {
|
|
|
3470
3517
|
});
|
|
3471
3518
|
}
|
|
3472
3519
|
case "热点词数据": {
|
|
3473
|
-
const url$1 = douyinApiUrls$1.热点词({
|
|
3474
|
-
query: data$1.query,
|
|
3475
|
-
number: data$1.number ?? 10
|
|
3476
|
-
});
|
|
3520
|
+
const url$1 = douyinApiUrls$1.热点词({ query: data$1.query });
|
|
3477
3521
|
const customConfig = {
|
|
3478
3522
|
...baseRequestConfig,
|
|
3479
3523
|
headers: {
|
|
@@ -3491,49 +3535,182 @@ const DouyinData = async (data$1, cookie, requestConfig) => {
|
|
|
3491
3535
|
const maxPageSize = 15;
|
|
3492
3536
|
let fetchedSearchList = [];
|
|
3493
3537
|
let tmpresp = null;
|
|
3538
|
+
const searchType = data$1.type ?? "综合";
|
|
3539
|
+
const refererUrl = searchType === "用户" ? `https://www.douyin.com/search/${encodeURIComponent(String(data$1.query))}?type=user` : searchType === "视频" ? `https://www.douyin.com/search/${encodeURIComponent(String(data$1.query))}?type=video` : `https://www.douyin.com/root/search/${encodeURIComponent(String(data$1.query))}`;
|
|
3494
3540
|
const customConfig = {
|
|
3495
3541
|
...baseRequestConfig,
|
|
3496
3542
|
headers: {
|
|
3497
3543
|
...baseRequestConfig.headers,
|
|
3498
|
-
...(!requestConfig?.headers || !("Referer" in requestConfig.headers)) && {
|
|
3544
|
+
...(!requestConfig?.headers || !("Referer" in requestConfig.headers)) && { referer: refererUrl }
|
|
3499
3545
|
}
|
|
3500
3546
|
};
|
|
3547
|
+
const isUserSearch = searchType === "用户";
|
|
3548
|
+
const isVideoSearch = searchType === "视频";
|
|
3549
|
+
let isFirstRequest = true;
|
|
3501
3550
|
while (fetchedSearchList.length < Number(data$1.number ?? 10)) {
|
|
3502
3551
|
const requestCount = Math.min(Number(data$1.number ?? 50) - fetchedSearchList.length, maxPageSize);
|
|
3503
3552
|
const url$1 = douyinApiUrls$1.搜索({
|
|
3504
3553
|
query: data$1.query,
|
|
3554
|
+
type: data$1.type,
|
|
3505
3555
|
number: requestCount,
|
|
3506
3556
|
search_id: search_id === "" ? void 0 : search_id
|
|
3507
3557
|
});
|
|
3508
3558
|
const raw = await GlobalGetData$2(data$1.methodType, {
|
|
3509
3559
|
...customConfig,
|
|
3510
|
-
url:
|
|
3560
|
+
url: url$1
|
|
3511
3561
|
});
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3562
|
+
if (isUserSearch) {
|
|
3563
|
+
if (!raw || typeof raw !== "object") {
|
|
3564
|
+
const Err = {
|
|
3565
|
+
errorDescription: "抖音用户搜索返回无有效数据,疑似触发反爬机制,你的抖音Cookie可能已经失效!",
|
|
3566
|
+
requestType: data$1.methodType ?? "未知请求类型",
|
|
3567
|
+
requestUrl: url$1
|
|
3568
|
+
};
|
|
3569
|
+
const warningMessage = `
|
|
3570
|
+
获取响应数据失败!原因:${logger.yellow("用户搜索返回无有效数据,疑似触发反爬机制")}
|
|
3571
|
+
请求类型:「${data$1.methodType}」
|
|
3572
|
+
搜索关键词:「${data$1.query}」
|
|
3573
|
+
请求URL:${url$1}
|
|
3574
|
+
`;
|
|
3575
|
+
!isFirstRequest && logger.warn(warningMessage);
|
|
3576
|
+
return {
|
|
3577
|
+
code: douoyinAPIErrorCode.COOKIE,
|
|
3578
|
+
data: raw,
|
|
3579
|
+
amagiError: Err,
|
|
3580
|
+
amagiMessage: warningMessage
|
|
3581
|
+
};
|
|
3582
|
+
}
|
|
3583
|
+
const userList = raw.user_list;
|
|
3584
|
+
if (isFirstRequest && (!userList || userList.length === 0)) {
|
|
3585
|
+
const Err = {
|
|
3586
|
+
errorDescription: "抖音用户搜索接口第一次请求就返回空数组,可能该关键词无搜索结果或触发风控限制,你的抖音Cookie可能已经失效!",
|
|
3587
|
+
requestType: data$1.methodType ?? "未知请求类型",
|
|
3588
|
+
requestUrl: url$1
|
|
3589
|
+
};
|
|
3590
|
+
const warningMessage = `
|
|
3591
|
+
获取响应数据失败!原因:${logger.yellow("用户搜索接口第一次请求就返回空数组,你的抖音Cookie可能已经失效!")}
|
|
3592
|
+
请求类型:「${data$1.methodType}」
|
|
3593
|
+
搜索关键词:「${data$1.query}」
|
|
3594
|
+
请求URL:${url$1}
|
|
3595
|
+
`;
|
|
3596
|
+
logger.warn(warningMessage);
|
|
3597
|
+
return {
|
|
3598
|
+
data: raw,
|
|
3599
|
+
amagiError: Err,
|
|
3600
|
+
amagiMessage: warningMessage
|
|
3601
|
+
};
|
|
3602
|
+
}
|
|
3603
|
+
if (Array.isArray(userList) && userList.length > 0) fetchedSearchList.push(...userList);
|
|
3604
|
+
tmpresp = raw;
|
|
3605
|
+
search_id = raw.rid ?? search_id;
|
|
3606
|
+
if (typeof raw.has_more === "number" && raw.has_more === 0) break;
|
|
3607
|
+
if (!userList || userList.length === 0) break;
|
|
3608
|
+
} else if (isVideoSearch) {
|
|
3609
|
+
if (!raw || typeof raw !== "object") {
|
|
3610
|
+
const Err = {
|
|
3611
|
+
errorDescription: "抖音视频搜索接口返回无有效数据,疑似触发反爬机制,你的抖音Cookie可能已经失效,你的抖音Cookie可能已经失效!",
|
|
3612
|
+
requestType: data$1.methodType ?? "未知请求类型",
|
|
3613
|
+
requestUrl: url$1
|
|
3614
|
+
};
|
|
3615
|
+
const warningMessage = `
|
|
3616
|
+
获取响应数据失败!原因:${logger.yellow("视频搜索接口返回无有效数据,疑似触发反爬机制,你的抖音Cookie可能已经失效!")}
|
|
3617
|
+
请求类型:「${data$1.methodType}」
|
|
3618
|
+
搜索关键词:「${data$1.query}」
|
|
3619
|
+
请求URL:${url$1}
|
|
3620
|
+
`;
|
|
3621
|
+
!isFirstRequest && logger.warn(warningMessage);
|
|
3622
|
+
return {
|
|
3623
|
+
code: douoyinAPIErrorCode.COOKIE,
|
|
3624
|
+
data: raw,
|
|
3625
|
+
amagiError: Err,
|
|
3626
|
+
amagiMessage: warningMessage
|
|
3627
|
+
};
|
|
3628
|
+
}
|
|
3629
|
+
const videoList = raw.data;
|
|
3630
|
+
if (isFirstRequest && (!videoList || videoList.length === 0)) {
|
|
3631
|
+
const Err = {
|
|
3632
|
+
errorDescription: "抖音视频搜索接口第一次请求就返回空数组,可能该关键词无搜索结果或触发风控限制,你的抖音Cookie可能已经失效!",
|
|
3633
|
+
requestType: data$1.methodType ?? "未知请求类型",
|
|
3634
|
+
requestUrl: url$1
|
|
3635
|
+
};
|
|
3636
|
+
const warningMessage = `
|
|
3637
|
+
获取响应数据失败!原因:${logger.yellow("视频搜索接口第一次请求就返回空数组,你的抖音Cookie可能已经失效!")}
|
|
3638
|
+
请求类型:「${data$1.methodType}」
|
|
3639
|
+
搜索关键词:「${data$1.query}」
|
|
3640
|
+
请求URL:${url$1}
|
|
3641
|
+
`;
|
|
3642
|
+
logger.warn(warningMessage);
|
|
3643
|
+
return {
|
|
3644
|
+
data: raw,
|
|
3645
|
+
amagiError: Err,
|
|
3646
|
+
amagiMessage: warningMessage
|
|
3647
|
+
};
|
|
3648
|
+
}
|
|
3649
|
+
if (Array.isArray(videoList) && videoList.length > 0) fetchedSearchList.push(...videoList);
|
|
3650
|
+
tmpresp = raw;
|
|
3651
|
+
search_id = raw.log_pb?.impr_id ?? search_id;
|
|
3652
|
+
if (typeof raw.has_more === "number" && raw.has_more === 0) break;
|
|
3653
|
+
if (!videoList || videoList.length === 0) break;
|
|
3654
|
+
} else {
|
|
3655
|
+
const responses = filterSearchResponses(typeof raw === "string" ? parseDouyinMultiJson(raw) : [raw]);
|
|
3656
|
+
if (responses.length === 0) {
|
|
3657
|
+
const Err = {
|
|
3658
|
+
errorDescription: "抖音综合搜索接口返回无有效数据,疑似触发反爬机制,你的抖音Cookie可能已经失效!",
|
|
3659
|
+
requestType: data$1.methodType ?? "未知请求类型",
|
|
3660
|
+
requestUrl: url$1
|
|
3661
|
+
};
|
|
3662
|
+
const warningMessage = `
|
|
3663
|
+
获取响应数据失败!原因:${logger.yellow("综合搜索接口返回无有效数据,疑似触发反爬机制,你的抖音Cookie可能已经失效!")}
|
|
3664
|
+
请求类型:「${data$1.methodType}」
|
|
3665
|
+
搜索关键词:「${data$1.query}」
|
|
3666
|
+
请求URL:${url$1}
|
|
3667
|
+
`;
|
|
3668
|
+
!isFirstRequest && logger.warn(warningMessage);
|
|
3669
|
+
return {
|
|
3670
|
+
code: douoyinAPIErrorCode.COOKIE,
|
|
3671
|
+
data: raw,
|
|
3672
|
+
amagiError: Err,
|
|
3673
|
+
amagiMessage: warningMessage
|
|
3674
|
+
};
|
|
3675
|
+
}
|
|
3676
|
+
for (const resp of responses) {
|
|
3677
|
+
if (Array.isArray(resp.data) && resp.data.length > 0) fetchedSearchList.push(...resp.data);
|
|
3678
|
+
tmpresp = resp;
|
|
3679
|
+
search_id = resp.log_pb?.impr_id ?? search_id;
|
|
3680
|
+
}
|
|
3681
|
+
if (isFirstRequest && fetchedSearchList.length === 0) {
|
|
3682
|
+
const Err = {
|
|
3683
|
+
errorDescription: "抖音综合搜索接口第一次请求就返回空数组,可能该关键词无搜索结果或触发风控限制,你的抖音Cookie可能已经失效!",
|
|
3684
|
+
requestType: data$1.methodType ?? "未知请求类型",
|
|
3685
|
+
requestUrl: url$1
|
|
3686
|
+
};
|
|
3687
|
+
const warningMessage = `
|
|
3688
|
+
获取响应数据失败!原因:${logger.yellow("综合搜索索接第一次请求就返回空数组,你的抖音Cookie可能已经失效!")}
|
|
3689
|
+
请求类型:「${data$1.methodType}」
|
|
3690
|
+
搜索关键词:「${data$1.query}」
|
|
3691
|
+
请求URL:${url$1}
|
|
3692
|
+
`;
|
|
3693
|
+
logger.warn(warningMessage);
|
|
3694
|
+
return {
|
|
3695
|
+
data: raw,
|
|
3696
|
+
amagiError: Err,
|
|
3697
|
+
amagiMessage: warningMessage
|
|
3698
|
+
};
|
|
3699
|
+
}
|
|
3700
|
+
if (tmpresp && typeof tmpresp.has_more === "number" && tmpresp.has_more === 0) break;
|
|
3531
3701
|
}
|
|
3532
|
-
|
|
3702
|
+
isFirstRequest = false;
|
|
3533
3703
|
}
|
|
3534
|
-
|
|
3704
|
+
const slicedList = Number(data$1.number ?? 10) === 0 ? [] : fetchedSearchList.slice(0, Number(data$1.number ?? 10));
|
|
3705
|
+
return isUserSearch ? {
|
|
3706
|
+
...tmpresp ?? {},
|
|
3707
|
+
user_list: slicedList
|
|
3708
|
+
} : isVideoSearch ? {
|
|
3709
|
+
...tmpresp ?? {},
|
|
3710
|
+
data: slicedList
|
|
3711
|
+
} : {
|
|
3535
3712
|
...tmpresp ?? {},
|
|
3536
|
-
data:
|
|
3713
|
+
data: slicedList
|
|
3537
3714
|
};
|
|
3538
3715
|
}
|
|
3539
3716
|
case "动态表情数据": {
|
|
@@ -4783,7 +4960,7 @@ let DynamicType = /* @__PURE__ */ function(DynamicType$1) {
|
|
|
4783
4960
|
|
|
4784
4961
|
//#endregion
|
|
4785
4962
|
//#region src/index.ts
|
|
4786
|
-
const VERSION = "5.
|
|
4963
|
+
const VERSION = "5.10.0";
|
|
4787
4964
|
/**
|
|
4788
4965
|
* @deprecated 请使用 createAmagiClient 替代
|
|
4789
4966
|
*/
|
|
@@ -4819,4 +4996,4 @@ const Client = CreateApp;
|
|
|
4819
4996
|
const amagi = Client;
|
|
4820
4997
|
|
|
4821
4998
|
//#endregion
|
|
4822
|
-
export { AdditionalType, ApiError, BilibiliArticleCardParamsSchema, BilibiliArticleInfoParamsSchema, BilibiliArticleParamsSchema, BilibiliAv2BvParamsSchema, BilibiliBangumiInfoParamsSchema, BilibiliBangumiStreamParamsSchema, BilibiliBv2AvParamsSchema, BilibiliColumnInfoParamsSchema, BilibiliCommentParamsSchema, BilibiliCommentReplyParamsSchema, BilibiliDynamicParamsSchema, BilibiliEmojiParamsSchema, BilibiliLiveParamsSchema, BilibiliLoginParamsSchema, BilibiliMethodRoutes, BilibiliQrcodeParamsSchema, BilibiliQrcodeStatusParamsSchema, BilibiliUserParamsSchema, BilibiliValidationSchemas, BilibiliVideoDownloadParamsSchema, BilibiliVideoParamsSchema, CommentType, CreateApp, DouyinCommentParamsSchema, DouyinCommentReplyParamsSchema, DouyinDanmakuParamsSchema, DouyinEmojiListParamsSchema, DouyinEmojiProParamsSchema, DouyinLiveRoomParamsSchema, DouyinMethodRoutes, DouyinMusicParamsSchema, DouyinQrcodeParamsSchema, DouyinSearchParamsSchema, DouyinUserParamsSchema, DouyinValidationSchemas, DouyinWorkParamsSchema, DynamicType, KuaishouCommentParamsSchema, KuaishouEmojiParamsSchema, KuaishouMethodRoutes, KuaishouValidationSchemas, KuaishouVideoParamsSchema, MajorType, ValidationError, XiaohongshuMethodRoutes, XiaohongshuValidationSchemas, amagi, amagiClient, av2bv, bilibili, bilibiliApiUrls, bilibiliErrorCodeMap, bilibiliUtils, bv2av, createAmagiClient, createBilibiliRoutes, createBilibiliRoutes as registerBilibiliRoutes, createBoundBilibiliApi, createBoundDouyinApi, createBoundKuaishouApi, createBoundXiaohongshuApi, createDouyinRoutes, createDouyinRoutes as registerDouyinRoutes, createErrorResponse, createKuaishouRoutes, createKuaishouRoutes as registerKuaishouRoutes, createSuccessResponse, createXiaohongshuRoutes, createXiaohongshuRoutes as registerXiaohongshuRoutes, Client as default, douyin, douyinApiUrls, douyinSign, douyinUtils, fetchData, fetchResponse, getBilibiliData, getDouyinData, getHeadersAndData, getKuaishouData, handleError, httpLogger, kuaishou, kuaishouApiUrls, kuaishouUtils, logMiddleware, logger, qtparam, validateBilibiliParams, validateDouyinParams, validateKuaishouParams, validateXiaohongshuParams, wbi_sign, xiaohongshu, xiaohongshuApiUrls, xiaohongshuSign, xiaohongshuUtils };
|
|
4999
|
+
export { AdditionalType, ApiError, BilibiliArticleCardParamsSchema, BilibiliArticleInfoParamsSchema, BilibiliArticleParamsSchema, BilibiliAv2BvParamsSchema, BilibiliBangumiInfoParamsSchema, BilibiliBangumiStreamParamsSchema, BilibiliBv2AvParamsSchema, BilibiliColumnInfoParamsSchema, BilibiliCommentParamsSchema, BilibiliCommentReplyParamsSchema, BilibiliDynamicParamsSchema, BilibiliEmojiParamsSchema, BilibiliLiveParamsSchema, BilibiliLoginParamsSchema, BilibiliMethodRoutes, BilibiliQrcodeParamsSchema, BilibiliQrcodeStatusParamsSchema, BilibiliUserParamsSchema, BilibiliValidationSchemas, BilibiliVideoDownloadParamsSchema, BilibiliVideoParamsSchema, CommentType, CreateApp, DouyinCommentParamsSchema, DouyinCommentReplyParamsSchema, DouyinDanmakuParamsSchema, DouyinEmojiListParamsSchema, DouyinEmojiProParamsSchema, DouyinHotWordsParamsSchema, DouyinLiveRoomParamsSchema, DouyinMethodRoutes, DouyinMusicParamsSchema, DouyinQrcodeParamsSchema, DouyinSearchParamsSchema, DouyinUserParamsSchema, DouyinValidationSchemas, DouyinWorkParamsSchema, DynamicType, KuaishouCommentParamsSchema, KuaishouEmojiParamsSchema, KuaishouMethodRoutes, KuaishouValidationSchemas, KuaishouVideoParamsSchema, MajorType, ValidationError, XiaohongshuMethodRoutes, XiaohongshuValidationSchemas, amagi, amagiClient, av2bv, bilibili, bilibiliApiUrls, bilibiliErrorCodeMap, bilibiliUtils, bv2av, createAmagiClient, createBilibiliRoutes, createBilibiliRoutes as registerBilibiliRoutes, createBoundBilibiliApi, createBoundDouyinApi, createBoundKuaishouApi, createBoundXiaohongshuApi, createDouyinRoutes, createDouyinRoutes as registerDouyinRoutes, createErrorResponse, createKuaishouRoutes, createKuaishouRoutes as registerKuaishouRoutes, createSuccessResponse, createXiaohongshuRoutes, createXiaohongshuRoutes as registerXiaohongshuRoutes, Client as default, douyin, douyinApiUrls, douyinSign, douyinUtils, fetchData, fetchResponse, getBilibiliData, getDouyinData, getHeadersAndData, getKuaishouData, handleError, httpLogger, kuaishou, kuaishouApiUrls, kuaishouUtils, logMiddleware, logger, qtparam, validateBilibiliParams, validateDouyinParams, validateKuaishouParams, validateXiaohongshuParams, wbi_sign, xiaohongshu, xiaohongshuApiUrls, xiaohongshuSign, xiaohongshuUtils };
|