@iflyrpa/actions 2.0.0-beta.4 → 2.0.0-beta.6
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/bundle.js +246 -172
- package/dist/bundle.js.map +1 -1
- package/dist/index.js +246 -172
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +246 -172
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/bundle.js
CHANGED
|
@@ -8238,7 +8238,7 @@ var __webpack_exports__ = {};
|
|
|
8238
8238
|
origin: ()=>utils_origin
|
|
8239
8239
|
});
|
|
8240
8240
|
var package_namespaceObject = JSON.parse('{"i8":"0.0.18-beta.0"}');
|
|
8241
|
-
var package_namespaceObject_0 = JSON.parse('{"i8":"2.0.0-beta.
|
|
8241
|
+
var package_namespaceObject_0 = JSON.parse('{"i8":"2.0.0-beta.5"}');
|
|
8242
8242
|
const external_node_fs_namespaceObject = require("node:fs");
|
|
8243
8243
|
var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
|
|
8244
8244
|
const external_node_https_namespaceObject = require("node:https");
|
|
@@ -30137,7 +30137,7 @@ var __webpack_exports__ = {};
|
|
|
30137
30137
|
const musicParams = {
|
|
30138
30138
|
keyword: keyword || "11",
|
|
30139
30139
|
search_source: "normal_search",
|
|
30140
|
-
|
|
30140
|
+
count: params.count?.toString() || "20",
|
|
30141
30141
|
aid: "1128",
|
|
30142
30142
|
cursor: "0",
|
|
30143
30143
|
cookie_enabled: "true",
|
|
@@ -31023,11 +31023,12 @@ var __webpack_exports__ = {};
|
|
|
31023
31023
|
music_id: params.musicId,
|
|
31024
31024
|
music_end_time: 1000 * (params.musicDuration || 0),
|
|
31025
31025
|
hot_sentence: params.hotSentence || "",
|
|
31026
|
-
visibility_type: params.visibleRange || 0,
|
|
31026
|
+
visibility_type: Number(params.visibleRange) || 0,
|
|
31027
31027
|
download: params.allowSave ? 1 : 0,
|
|
31028
31028
|
timing: params.isImmediatelyPublish ? -1 : params.scheduledPublish,
|
|
31029
|
-
media_type: params.publishType || 2,
|
|
31030
|
-
images: []
|
|
31029
|
+
media_type: Number(params.publishType) || 2,
|
|
31030
|
+
images: [],
|
|
31031
|
+
creation_id: ""
|
|
31031
31032
|
},
|
|
31032
31033
|
cover: {
|
|
31033
31034
|
poster: ""
|
|
@@ -36163,14 +36164,25 @@ var __webpack_exports__ = {};
|
|
|
36163
36164
|
}
|
|
36164
36165
|
});
|
|
36165
36166
|
if (createrLogin.ok()) {
|
|
36166
|
-
|
|
36167
|
-
|
|
36168
|
-
|
|
36169
|
-
|
|
36170
|
-
|
|
36171
|
-
|
|
36172
|
-
|
|
36173
|
-
|
|
36167
|
+
let num = 30;
|
|
36168
|
+
async function getUserInfo() {
|
|
36169
|
+
userInfo = await page.evaluate(()=>{
|
|
36170
|
+
const raw = window.__INITIAL_STATE__?.user?.userInfo?._rawValue;
|
|
36171
|
+
return {
|
|
36172
|
+
name: raw?.nickname ?? raw?.nickname ?? "",
|
|
36173
|
+
avatar: raw?.images ?? raw?.images ?? "",
|
|
36174
|
+
uniqueId: raw?.userId ?? raw?.userId ?? ""
|
|
36175
|
+
};
|
|
36176
|
+
});
|
|
36177
|
+
await reporter(0, `第${30 - num + 1}次抓取用户信息!`, {
|
|
36178
|
+
userInfo
|
|
36179
|
+
});
|
|
36180
|
+
if (userInfo.uniqueId || num <= 0) return;
|
|
36181
|
+
num--;
|
|
36182
|
+
await new Promise((resolve)=>setTimeout(resolve, 1000));
|
|
36183
|
+
await getUserInfo();
|
|
36184
|
+
}
|
|
36185
|
+
await getUserInfo();
|
|
36174
36186
|
await reporter(0, "扫码成功!", {
|
|
36175
36187
|
stage: "scanQrcode",
|
|
36176
36188
|
connectAddress
|
|
@@ -36245,6 +36257,7 @@ var __webpack_exports__ = {};
|
|
|
36245
36257
|
const xiaohongshuLogin_rpa_server_waitQrcodeResultMaxTime = 2000 * xiaohongshuLogin_rpa_server_scanRetryMaxCount;
|
|
36246
36258
|
const xiaohongshuLogin_rpa_server_rpaServer = async (task, params)=>{
|
|
36247
36259
|
const updateTaskState = task.taskStageStore?.update?.bind(task.taskStageStore, task.taskId || "");
|
|
36260
|
+
const reporter = task.reportService?.reportLoginStatus ?? (()=>Promise.resolve());
|
|
36248
36261
|
let executionState;
|
|
36249
36262
|
let proxyUrl;
|
|
36250
36263
|
if (params.localIP) {
|
|
@@ -36263,22 +36276,14 @@ var __webpack_exports__ = {};
|
|
|
36263
36276
|
const page = await task.createPage({
|
|
36264
36277
|
url: "https://www.xiaohongshu.com/login",
|
|
36265
36278
|
proxyUrl,
|
|
36266
|
-
userAgent: params.userAgent
|
|
36267
|
-
...params.viewport ? {
|
|
36268
|
-
viewport: params.viewport
|
|
36269
|
-
} : {}
|
|
36279
|
+
userAgent: params.userAgent
|
|
36270
36280
|
});
|
|
36271
|
-
task.steelBrowser?.on("disconnected",
|
|
36272
|
-
const browserContext = task.steelBrowserContext;
|
|
36273
|
-
const browser = task.steelBrowser;
|
|
36281
|
+
task.steelBrowser?.on("disconnected", ()=>{
|
|
36274
36282
|
executionState = types_ExecutionState.BROWSER_CLOSED;
|
|
36275
|
-
await page.close();
|
|
36276
|
-
if (browserContext) await browserContext.close();
|
|
36277
|
-
if (browser) await browser.close();
|
|
36278
36283
|
});
|
|
36279
36284
|
await updateTaskState?.({
|
|
36280
36285
|
state: types_TaskState.WAIT_SCAN,
|
|
36281
|
-
connectAddress:
|
|
36286
|
+
connectAddress: task.steelConnector?.getProxyUrl(task.sessionId || "", "v1/sessions/debug"),
|
|
36282
36287
|
sessionId: task.sessionId
|
|
36283
36288
|
});
|
|
36284
36289
|
let userInfo = {
|
|
@@ -36286,125 +36291,136 @@ var __webpack_exports__ = {};
|
|
|
36286
36291
|
avatar: "",
|
|
36287
36292
|
name: ""
|
|
36288
36293
|
};
|
|
36289
|
-
|
|
36290
|
-
|
|
36291
|
-
|
|
36292
|
-
|
|
36293
|
-
|
|
36294
|
-
|
|
36295
|
-
|
|
36296
|
-
|
|
36297
|
-
|
|
36298
|
-
|
|
36299
|
-
|
|
36300
|
-
|
|
36301
|
-
|
|
36302
|
-
|
|
36303
|
-
|
|
36304
|
-
|
|
36305
|
-
|
|
36306
|
-
|
|
36307
|
-
|
|
36308
|
-
|
|
36309
|
-
|
|
36310
|
-
|
|
36311
|
-
|
|
36312
|
-
|
|
36313
|
-
|
|
36314
|
-
|
|
36315
|
-
|
|
36316
|
-
|
|
36317
|
-
|
|
36318
|
-
if (url.includes("/explore") && "GET" === resp.request().method() && 200 === resp.status()) {
|
|
36319
|
-
cleanup();
|
|
36320
|
-
await updateTaskState?.({
|
|
36321
|
-
state: types_TaskState.CONFIRMED
|
|
36322
|
-
});
|
|
36323
|
-
await page.waitForFunction(()=>"function" == typeof window.mnsv2, {
|
|
36324
|
-
timeout: 10000
|
|
36325
|
-
});
|
|
36326
|
-
const ticket_mnsv2 = await page.evaluate(({ c, d })=>{
|
|
36327
|
-
if ("function" == typeof window.mnsv2) return window.mnsv2(c, d);
|
|
36328
|
-
return "mnsv2 未定义";
|
|
36329
|
-
}, {
|
|
36330
|
-
c: '/api/cas/customer/web/service-ticket{"service":"https://creator.xiaohongshu.com","source":"official","type":"tgt"}',
|
|
36331
|
-
d: "71bcd9dc89f6c256ead6cbe2b0a9793c"
|
|
36332
|
-
});
|
|
36333
|
-
const XS = rpa_server_encode_mnsv2(ticket_mnsv2, "Windows", "object");
|
|
36334
|
-
const createrLogin = await page.request.post("https://customer.xiaohongshu.com/api/cas/customer/web/service-ticket", {
|
|
36335
|
-
headers: {
|
|
36336
|
-
"x-s": XS,
|
|
36337
|
-
"x-t": Date.now().toString(),
|
|
36338
|
-
referer: "https://creator.xiaohongshu.com/",
|
|
36339
|
-
origin: "https://creator.xiaohongshu.com",
|
|
36340
|
-
cookie: (await task.steelBrowserContext?.cookies())?.map((c)=>`${c.name}=${c.value}`).join(";") || ""
|
|
36341
|
-
},
|
|
36342
|
-
data: {
|
|
36343
|
-
service: "https://creator.xiaohongshu.com",
|
|
36344
|
-
source: "official",
|
|
36345
|
-
type: "tgt"
|
|
36346
|
-
}
|
|
36347
|
-
});
|
|
36348
|
-
if (createrLogin.ok()) userInfo = await page.evaluate(()=>{
|
|
36349
|
-
const raw = window.__INITIAL_STATE__?.user?.userInfo?._rawValue;
|
|
36350
|
-
return {
|
|
36351
|
-
name: raw?.nickname ?? raw?.nickname ?? "",
|
|
36352
|
-
avatar: raw?.images ?? raw?.images ?? "",
|
|
36353
|
-
uniqueId: raw?.userId ?? raw?.userId ?? ""
|
|
36354
|
-
};
|
|
36355
|
-
});
|
|
36356
|
-
executionState = types_ExecutionState.SUCCESS;
|
|
36357
|
-
resolve();
|
|
36358
|
-
}
|
|
36359
|
-
} catch (err) {
|
|
36294
|
+
await new Promise((resolve, reject)=>{
|
|
36295
|
+
let finished = false;
|
|
36296
|
+
const timer = setTimeout(async ()=>{
|
|
36297
|
+
if (finished) return;
|
|
36298
|
+
cleanup();
|
|
36299
|
+
executionState = types_ExecutionState.TIMEOUT;
|
|
36300
|
+
await updateTaskState?.({
|
|
36301
|
+
state: types_TaskState.TIMEOUT,
|
|
36302
|
+
error: "等待扫码登录超时"
|
|
36303
|
+
});
|
|
36304
|
+
resolve();
|
|
36305
|
+
}, xiaohongshuLogin_rpa_server_waitQrcodeResultMaxTime);
|
|
36306
|
+
const cleanup = ()=>{
|
|
36307
|
+
if (finished) return;
|
|
36308
|
+
finished = true;
|
|
36309
|
+
clearTimeout(timer);
|
|
36310
|
+
page.off("response", handleWebCommon);
|
|
36311
|
+
page.off("response", handleCheckQR);
|
|
36312
|
+
task.steelBrowser?.off("disconnected", handleBrowserClosed);
|
|
36313
|
+
};
|
|
36314
|
+
const handleBrowserClosed = ()=>{
|
|
36315
|
+
cleanup();
|
|
36316
|
+
executionState = types_ExecutionState.BROWSER_CLOSED;
|
|
36317
|
+
resolve();
|
|
36318
|
+
};
|
|
36319
|
+
const handleWebCommon = async (resp)=>{
|
|
36320
|
+
try {
|
|
36321
|
+
const url = resp.url();
|
|
36322
|
+
if (url.includes("/explore") && "GET" === resp.request().method() && 200 === resp.status()) {
|
|
36360
36323
|
cleanup();
|
|
36361
|
-
|
|
36362
|
-
|
|
36363
|
-
|
|
36364
|
-
|
|
36365
|
-
|
|
36366
|
-
|
|
36367
|
-
|
|
36368
|
-
|
|
36369
|
-
|
|
36370
|
-
|
|
36371
|
-
|
|
36372
|
-
|
|
36373
|
-
|
|
36324
|
+
await updateTaskState?.({
|
|
36325
|
+
state: types_TaskState.CONFIRMED
|
|
36326
|
+
});
|
|
36327
|
+
await page.waitForFunction(()=>"function" == typeof window.mnsv2, {
|
|
36328
|
+
timeout: 10000
|
|
36329
|
+
});
|
|
36330
|
+
const ticket_mnsv2 = await page.evaluate(({ c, d })=>{
|
|
36331
|
+
if ("function" == typeof window.mnsv2) return window.mnsv2(c, d);
|
|
36332
|
+
return "mnsv2 未定义";
|
|
36333
|
+
}, {
|
|
36334
|
+
c: '/api/cas/customer/web/service-ticket{"service":"https://creator.xiaohongshu.com","source":"official","type":"tgt"}',
|
|
36335
|
+
d: "71bcd9dc89f6c256ead6cbe2b0a9793c"
|
|
36336
|
+
});
|
|
36337
|
+
const XS = rpa_server_encode_mnsv2(ticket_mnsv2, "Windows", "object");
|
|
36338
|
+
const createrLogin = await page.request.post("https://customer.xiaohongshu.com/api/cas/customer/web/service-ticket", {
|
|
36339
|
+
headers: {
|
|
36340
|
+
"x-s": XS,
|
|
36341
|
+
"x-t": Date.now().toString(),
|
|
36342
|
+
referer: "https://creator.xiaohongshu.com/",
|
|
36343
|
+
origin: "https://creator.xiaohongshu.com",
|
|
36344
|
+
cookie: (await task._steelBrowserContext?.cookies())?.map((c)=>`${c.name}=${c.value}`).join(";") || ""
|
|
36345
|
+
},
|
|
36346
|
+
data: {
|
|
36347
|
+
service: "https://creator.xiaohongshu.com",
|
|
36348
|
+
source: "official",
|
|
36349
|
+
type: "tgt"
|
|
36350
|
+
}
|
|
36351
|
+
});
|
|
36352
|
+
task.logger.info(`createrLogin------- ${createrLogin.ok()}`);
|
|
36353
|
+
if (createrLogin.ok()) {
|
|
36354
|
+
let num = 30;
|
|
36355
|
+
async function getUserInfo() {
|
|
36356
|
+
userInfo = await page.evaluate(()=>{
|
|
36357
|
+
const raw = window.__INITIAL_STATE__?.user?.userInfo?._rawValue;
|
|
36358
|
+
return {
|
|
36359
|
+
name: raw?.nickname ?? raw?.nickname ?? "",
|
|
36360
|
+
avatar: raw?.images ?? raw?.images ?? "",
|
|
36361
|
+
uniqueId: raw?.userId ?? raw?.userId ?? ""
|
|
36362
|
+
};
|
|
36374
36363
|
});
|
|
36375
|
-
|
|
36364
|
+
await reporter(0, `第${30 - num + 1}次抓取用户信息!`, {
|
|
36365
|
+
userInfo
|
|
36366
|
+
});
|
|
36367
|
+
if (userInfo.uniqueId || num <= 0) return;
|
|
36368
|
+
num--;
|
|
36369
|
+
await new Promise((resolve)=>setTimeout(resolve, 1000));
|
|
36370
|
+
await getUserInfo();
|
|
36376
36371
|
}
|
|
36377
|
-
|
|
36378
|
-
|
|
36379
|
-
task.logger.warn("Failed to parse json:", {
|
|
36380
|
-
url,
|
|
36381
|
-
erroe: e
|
|
36382
|
-
});
|
|
36383
|
-
return;
|
|
36372
|
+
await getUserInfo();
|
|
36373
|
+
task.logger.info(`userInfo------- ${JSON.stringify(userInfo)}`);
|
|
36384
36374
|
}
|
|
36385
|
-
|
|
36386
|
-
|
|
36387
|
-
|
|
36388
|
-
|
|
36389
|
-
|
|
36390
|
-
|
|
36391
|
-
|
|
36392
|
-
|
|
36375
|
+
executionState = types_ExecutionState.SUCCESS;
|
|
36376
|
+
resolve();
|
|
36377
|
+
}
|
|
36378
|
+
} catch (err) {
|
|
36379
|
+
cleanup();
|
|
36380
|
+
reject(err);
|
|
36381
|
+
}
|
|
36382
|
+
};
|
|
36383
|
+
const handleCheckQR = async (response)=>{
|
|
36384
|
+
try {
|
|
36385
|
+
const url = response.url();
|
|
36386
|
+
if (!url.includes("/login/qrcode/status") || "GET" !== response.request().method()) return;
|
|
36387
|
+
let jsonResponse;
|
|
36388
|
+
try {
|
|
36389
|
+
const text = await response.text();
|
|
36390
|
+
if (!text) {
|
|
36391
|
+
task.logger.warn("Empty response body:", {
|
|
36392
|
+
url
|
|
36393
36393
|
});
|
|
36394
|
-
|
|
36395
|
-
page.on("response", handleWebCommon);
|
|
36394
|
+
return;
|
|
36396
36395
|
}
|
|
36397
|
-
|
|
36398
|
-
|
|
36399
|
-
|
|
36396
|
+
jsonResponse = JSON.parse(text);
|
|
36397
|
+
} catch (e) {
|
|
36398
|
+
task.logger.warn("Failed to parse json:", {
|
|
36399
|
+
url,
|
|
36400
|
+
erroe: e
|
|
36401
|
+
});
|
|
36402
|
+
return;
|
|
36400
36403
|
}
|
|
36401
|
-
|
|
36402
|
-
|
|
36403
|
-
|
|
36404
|
-
|
|
36405
|
-
|
|
36406
|
-
|
|
36407
|
-
|
|
36404
|
+
const codeStatus = jsonResponse.data?.code_status;
|
|
36405
|
+
if (0 === jsonResponse.code && (1 === codeStatus || 2 === codeStatus)) {
|
|
36406
|
+
if (2 === codeStatus) userInfo.uniqueId = jsonResponse.data.login_info.user_id;
|
|
36407
|
+
await updateTaskState?.({
|
|
36408
|
+
state: types_TaskState.SCANNED,
|
|
36409
|
+
result: {
|
|
36410
|
+
userInfo
|
|
36411
|
+
}
|
|
36412
|
+
});
|
|
36413
|
+
page.off("response", handleCheckQR);
|
|
36414
|
+
page.on("response", handleWebCommon);
|
|
36415
|
+
}
|
|
36416
|
+
} catch (err) {
|
|
36417
|
+
cleanup();
|
|
36418
|
+
reject(err);
|
|
36419
|
+
}
|
|
36420
|
+
};
|
|
36421
|
+
task.steelBrowser?.on("disconnected", handleBrowserClosed);
|
|
36422
|
+
page.on("response", handleCheckQR);
|
|
36423
|
+
});
|
|
36408
36424
|
if (void 0 === executionState) return {
|
|
36409
36425
|
code: 500,
|
|
36410
36426
|
message: "未知错误",
|
|
@@ -36581,25 +36597,54 @@ var __webpack_exports__ = {};
|
|
|
36581
36597
|
source: "web"
|
|
36582
36598
|
};
|
|
36583
36599
|
const fetchCoverXsHeader = mock_xsEncrypt.signHeadersGet(fetchCoverUrl, recordCookie, "ugc", fetchCoverParams);
|
|
36584
|
-
const coverIdInfo = await proxyHttp.api({
|
|
36585
|
-
method: "get",
|
|
36586
|
-
baseURL: "https://creator.xiaohongshu.com",
|
|
36587
|
-
url: fetchCoverUrl,
|
|
36588
|
-
defaultErrorMsg: "获取小红书用户信息失败,请稍后重试发布。",
|
|
36589
|
-
headers: fetchCoverXsHeader,
|
|
36590
|
-
params: fetchCoverParams
|
|
36591
|
-
}, {
|
|
36592
|
-
retries: 3,
|
|
36593
|
-
retryDelay: 20,
|
|
36594
|
-
timeout: 3000
|
|
36595
|
-
});
|
|
36596
36600
|
const uploadInfos = [];
|
|
36597
|
-
|
|
36598
|
-
|
|
36599
|
-
|
|
36600
|
-
|
|
36601
|
-
|
|
36602
|
-
|
|
36601
|
+
if (params.banners.length > 18) {
|
|
36602
|
+
let num = Math.ceil(params.banners.length / 14);
|
|
36603
|
+
for(let i = 0; i < num; i++){
|
|
36604
|
+
const start = 14 * i;
|
|
36605
|
+
params.banners.length;
|
|
36606
|
+
({
|
|
36607
|
+
...fetchCoverParams
|
|
36608
|
+
});
|
|
36609
|
+
const batchCoverIdInfo = await proxyHttp.api({
|
|
36610
|
+
method: "get",
|
|
36611
|
+
baseURL: "https://creator.xiaohongshu.com",
|
|
36612
|
+
url: fetchCoverUrl,
|
|
36613
|
+
defaultErrorMsg: "获取小红书用户信息失败,请稍后重试发布。",
|
|
36614
|
+
headers: fetchCoverXsHeader,
|
|
36615
|
+
params: fetchCoverParams
|
|
36616
|
+
}, {
|
|
36617
|
+
retries: 3,
|
|
36618
|
+
retryDelay: 20,
|
|
36619
|
+
timeout: 3000
|
|
36620
|
+
});
|
|
36621
|
+
for (const item of batchCoverIdInfo.data.uploadTempPermits)for (const fileId of item.fileIds)uploadInfos.push({
|
|
36622
|
+
bucket: item.bucket || "",
|
|
36623
|
+
uploadAddr: item.uploadAddr || "",
|
|
36624
|
+
fileIds: fileId,
|
|
36625
|
+
token: item.token || ""
|
|
36626
|
+
});
|
|
36627
|
+
}
|
|
36628
|
+
} else {
|
|
36629
|
+
const coverIdInfo = await proxyHttp.api({
|
|
36630
|
+
method: "get",
|
|
36631
|
+
baseURL: "https://creator.xiaohongshu.com",
|
|
36632
|
+
url: fetchCoverUrl,
|
|
36633
|
+
defaultErrorMsg: "获取小红书用户信息失败,请稍后重试发布。",
|
|
36634
|
+
headers: fetchCoverXsHeader,
|
|
36635
|
+
params: fetchCoverParams
|
|
36636
|
+
}, {
|
|
36637
|
+
retries: 3,
|
|
36638
|
+
retryDelay: 20,
|
|
36639
|
+
timeout: 3000
|
|
36640
|
+
});
|
|
36641
|
+
for (const item of coverIdInfo.data.uploadTempPermits)for (const fileId of item.fileIds)uploadInfos.push({
|
|
36642
|
+
bucket: item.bucket || "",
|
|
36643
|
+
uploadAddr: item.uploadAddr || "",
|
|
36644
|
+
fileIds: fileId,
|
|
36645
|
+
token: item.token || ""
|
|
36646
|
+
});
|
|
36647
|
+
}
|
|
36603
36648
|
if (uploadInfos.length < params.banners.length) return {
|
|
36604
36649
|
code: 414,
|
|
36605
36650
|
message: "可用 OSS bucket 数量不足,无法上传所有图片!",
|
|
@@ -37547,25 +37592,54 @@ var __webpack_exports__ = {};
|
|
|
37547
37592
|
source: "web"
|
|
37548
37593
|
};
|
|
37549
37594
|
const fetchCoverXsHeader = rpa_server_mock_xsEncrypt.signHeadersGet(fetchCoverUrl, recordCookie, "ugc", fetchCoverParams);
|
|
37550
|
-
const coverIdInfo = await proxyHttp.api({
|
|
37551
|
-
method: "get",
|
|
37552
|
-
baseURL: "https://creator.xiaohongshu.com",
|
|
37553
|
-
url: fetchCoverUrl,
|
|
37554
|
-
defaultErrorMsg: "获取小红书用户信息失败,请稍后重试发布。",
|
|
37555
|
-
headers: fetchCoverXsHeader,
|
|
37556
|
-
params: fetchCoverParams
|
|
37557
|
-
}, {
|
|
37558
|
-
retries: 3,
|
|
37559
|
-
retryDelay: 20,
|
|
37560
|
-
timeout: 3000
|
|
37561
|
-
});
|
|
37562
37595
|
const uploadInfos = [];
|
|
37563
|
-
|
|
37564
|
-
|
|
37565
|
-
|
|
37566
|
-
|
|
37567
|
-
|
|
37568
|
-
|
|
37596
|
+
if (params.banners.length > 18) {
|
|
37597
|
+
let num = Math.ceil(params.banners.length / 14);
|
|
37598
|
+
for(let i = 0; i < num; i++){
|
|
37599
|
+
const start = 14 * i;
|
|
37600
|
+
params.banners.length;
|
|
37601
|
+
({
|
|
37602
|
+
...fetchCoverParams
|
|
37603
|
+
});
|
|
37604
|
+
const batchCoverIdInfo = await proxyHttp.api({
|
|
37605
|
+
method: "get",
|
|
37606
|
+
baseURL: "https://creator.xiaohongshu.com",
|
|
37607
|
+
url: fetchCoverUrl,
|
|
37608
|
+
defaultErrorMsg: "获取小红书用户信息失败,请稍后重试发布。",
|
|
37609
|
+
headers: fetchCoverXsHeader,
|
|
37610
|
+
params: fetchCoverParams
|
|
37611
|
+
}, {
|
|
37612
|
+
retries: 3,
|
|
37613
|
+
retryDelay: 20,
|
|
37614
|
+
timeout: 3000
|
|
37615
|
+
});
|
|
37616
|
+
for (const item of batchCoverIdInfo.data.uploadTempPermits)for (const fileId of item.fileIds)uploadInfos.push({
|
|
37617
|
+
bucket: item.bucket || "",
|
|
37618
|
+
uploadAddr: item.uploadAddr || "",
|
|
37619
|
+
fileIds: fileId,
|
|
37620
|
+
token: item.token || ""
|
|
37621
|
+
});
|
|
37622
|
+
}
|
|
37623
|
+
} else {
|
|
37624
|
+
const coverIdInfo = await proxyHttp.api({
|
|
37625
|
+
method: "get",
|
|
37626
|
+
baseURL: "https://creator.xiaohongshu.com",
|
|
37627
|
+
url: fetchCoverUrl,
|
|
37628
|
+
defaultErrorMsg: "获取小红书用户信息失败,请稍后重试发布。",
|
|
37629
|
+
headers: fetchCoverXsHeader,
|
|
37630
|
+
params: fetchCoverParams
|
|
37631
|
+
}, {
|
|
37632
|
+
retries: 3,
|
|
37633
|
+
retryDelay: 20,
|
|
37634
|
+
timeout: 3000
|
|
37635
|
+
});
|
|
37636
|
+
for (const item of coverIdInfo.data.uploadTempPermits)for (const fileId of item.fileIds)uploadInfos.push({
|
|
37637
|
+
bucket: item.bucket || "",
|
|
37638
|
+
uploadAddr: item.uploadAddr || "",
|
|
37639
|
+
fileIds: fileId,
|
|
37640
|
+
token: item.token || ""
|
|
37641
|
+
});
|
|
37642
|
+
}
|
|
37569
37643
|
if (uploadInfos.length < params.banners.length) return {
|
|
37570
37644
|
code: 414,
|
|
37571
37645
|
message: "可用 OSS bucket 数量不足,无法上传所有图片!",
|