@iflyrpa/actions 4.0.5 → 4.0.6-beta.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/actions/searchAccountInfo/getDouyinInfo.d.ts +16 -0
- package/dist/actions/searchAccountInfo/getShipinhaoInfo.d.ts +14 -0
- package/dist/actions/searchAccountInfo/index.d.ts +4 -2
- package/dist/actions/searchAccountInfo/types.d.ts +21 -1
- package/dist/actions/searchPublishInfo/handleDouyinData.d.ts +17 -0
- package/dist/actions/searchPublishInfo/handleShipinhaoData.d.ts +17 -0
- package/dist/actions/searchPublishInfo/index.d.ts +7 -0
- package/dist/actions/searchPublishInfo/types.d.ts +97 -0
- package/dist/actions/shipinhaoPublish/uploader.d.ts +4 -0
- package/dist/actions/weixinPublish/index.d.ts +2 -2
- package/dist/actions/xiaohongshuPublish/index.d.ts +1 -1
- package/dist/bundle.js +1002 -395
- package/dist/bundle.js.map +1 -1
- package/dist/index.d.ts +79 -1
- package/dist/index.js +1007 -400
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1006 -401
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -4350,9 +4350,7 @@ function __webpack_require__(moduleId) {
|
|
|
4350
4350
|
return module;
|
|
4351
4351
|
};
|
|
4352
4352
|
})();
|
|
4353
|
-
var package_namespaceObject = {
|
|
4354
|
-
i8: "4.0.5"
|
|
4355
|
-
};
|
|
4353
|
+
var package_namespaceObject = JSON.parse('{"i8":"4.0.6-beta.0"}');
|
|
4356
4354
|
const PROXY_CREDENTIALS = [
|
|
4357
4355
|
{
|
|
4358
4356
|
ip: "47.110.131.129",
|
|
@@ -4585,11 +4583,12 @@ class Http {
|
|
|
4585
4583
|
this.logger?.debug(`未处理的网络错误代码: ${error.code} ${error.message}`, {
|
|
4586
4584
|
errorString: stringifyError(error)
|
|
4587
4585
|
});
|
|
4588
|
-
_message =
|
|
4586
|
+
_message = `网络错误: ${error.message}`;
|
|
4589
4587
|
break;
|
|
4590
4588
|
}
|
|
4591
4589
|
}
|
|
4592
|
-
|
|
4590
|
+
if (error.code && !error.response?.data) errorResponse.message = _message || errorResponse.message;
|
|
4591
|
+
else errorResponse.message = errorResponse.message ? errorResponse.message : _message;
|
|
4593
4592
|
if ("canceled" === errorResponse.message) {
|
|
4594
4593
|
const message = errorResponse.extra?.isProxyRequest ? "代理连接建立超时,请更换区域或稍后重试!" : "网络请求超时,请稍后重试!";
|
|
4595
4594
|
errorResponse.message = message;
|
|
@@ -13367,400 +13366,421 @@ function generateRandomString(length) {
|
|
|
13367
13366
|
}
|
|
13368
13367
|
return randomString;
|
|
13369
13368
|
}
|
|
13369
|
+
function safeSerialize(obj) {
|
|
13370
|
+
if (!obj || "object" != typeof obj) return obj;
|
|
13371
|
+
try {
|
|
13372
|
+
return JSON.parse(JSON.stringify(obj));
|
|
13373
|
+
} catch (error) {
|
|
13374
|
+
return {};
|
|
13375
|
+
}
|
|
13376
|
+
}
|
|
13370
13377
|
const mock_mockAction = async (task, params)=>{
|
|
13371
13378
|
const updateTaskState = task.taskStageStore?.update?.bind(task.taskStageStore, task.taskId || "");
|
|
13372
|
-
if (!params.extraParam || !params.extraParam["security-sdk/
|
|
13373
|
-
|
|
13374
|
-
|
|
13375
|
-
|
|
13376
|
-
|
|
13377
|
-
|
|
13378
|
-
|
|
13379
|
-
|
|
13380
|
-
|
|
13381
|
-
|
|
13382
|
-
|
|
13383
|
-
|
|
13384
|
-
|
|
13385
|
-
|
|
13386
|
-
|
|
13387
|
-
|
|
13388
|
-
|
|
13389
|
-
|
|
13390
|
-
|
|
13391
|
-
|
|
13392
|
-
|
|
13393
|
-
|
|
13394
|
-
|
|
13395
|
-
|
|
13396
|
-
|
|
13397
|
-
|
|
13398
|
-
|
|
13399
|
-
|
|
13400
|
-
|
|
13401
|
-
|
|
13402
|
-
|
|
13403
|
-
|
|
13404
|
-
|
|
13405
|
-
|
|
13406
|
-
|
|
13407
|
-
|
|
13408
|
-
|
|
13409
|
-
|
|
13410
|
-
|
|
13411
|
-
|
|
13412
|
-
|
|
13413
|
-
|
|
13414
|
-
|
|
13415
|
-
|
|
13416
|
-
|
|
13417
|
-
|
|
13418
|
-
|
|
13419
|
-
|
|
13420
|
-
|
|
13421
|
-
|
|
13422
|
-
|
|
13423
|
-
|
|
13424
|
-
|
|
13425
|
-
|
|
13426
|
-
|
|
13427
|
-
|
|
13428
|
-
|
|
13429
|
-
|
|
13430
|
-
|
|
13431
|
-
|
|
13432
|
-
|
|
13433
|
-
|
|
13434
|
-
|
|
13435
|
-
|
|
13436
|
-
|
|
13437
|
-
|
|
13379
|
+
if (!params.extraParam || !params.extraParam["security-sdk/s_sdk_sign_data_key/web_protect"] || !params.extraParam["security-sdk/s_sdk_server_cert_key"] || !params.extraParam["security-sdk/s_sdk_crypt_sdk"]) return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "extraParam 参数缺失或不完整", "");
|
|
13380
|
+
let currentStep = "初始化";
|
|
13381
|
+
try {
|
|
13382
|
+
currentStep = "验证账号信息";
|
|
13383
|
+
const userAgent = params.userAgent || "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.38";
|
|
13384
|
+
const sessionidCookie = params.cookies.find((it)=>"msToken" === it.name)?.value;
|
|
13385
|
+
if (!sessionidCookie) return {
|
|
13386
|
+
code: 414,
|
|
13387
|
+
message: "账号数据异常,请重新绑定账号后重试。",
|
|
13388
|
+
data: ""
|
|
13389
|
+
};
|
|
13390
|
+
currentStep = "准备请求参数";
|
|
13391
|
+
const headers = {
|
|
13392
|
+
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
13393
|
+
origin: "https://creator.douyin.com",
|
|
13394
|
+
referer: "https://creator.douyin.com/creator-micro/content/post/image?default-tab=3&enter_from=publish_page&media_type=image&type=new",
|
|
13395
|
+
Accept: "application/json, text/plain, */*",
|
|
13396
|
+
"Accept-Encoding": "gzip, deflate, br, zstd",
|
|
13397
|
+
"Content-Type": "application/json",
|
|
13398
|
+
pragma: "no-cache",
|
|
13399
|
+
"cache-control": "no-cache",
|
|
13400
|
+
"sec-ch-ua-platform": params.extraParam?.browserInfo?.["sec-ch-ua-platform"] || "",
|
|
13401
|
+
"sec-ch-ua": params.extraParam?.browserInfo?.["sec-ch-ua"] || "",
|
|
13402
|
+
"bd-ticket-guard-web-version": "2",
|
|
13403
|
+
"sec-ch-ua-mobile": "?0",
|
|
13404
|
+
"user-agent": userAgent,
|
|
13405
|
+
"sec-fetch-site": "same-origin",
|
|
13406
|
+
"sec-fetch-mode": "cors",
|
|
13407
|
+
"sec-fetch-dest": "empty",
|
|
13408
|
+
"accept-language": "zh-CN,zh;q=0.9",
|
|
13409
|
+
priority: "u=1, i"
|
|
13410
|
+
};
|
|
13411
|
+
const publishParams = {
|
|
13412
|
+
read_aid: "2906",
|
|
13413
|
+
aid: "1128",
|
|
13414
|
+
cookie_enabled: "true",
|
|
13415
|
+
screen_width: params.extraParam?.browserInfo.screen_width || "1920",
|
|
13416
|
+
screen_height: params.extraParam?.browserInfo.screen_height || "1080",
|
|
13417
|
+
browser_language: params.extraParam?.browserInfo.browser_language || "zh-CN",
|
|
13418
|
+
browser_platform: params.extraParam?.browserInfo.browser_platform || "Win32",
|
|
13419
|
+
browser_name: params.extraParam?.browserInfo.browser_name || "Mozilla",
|
|
13420
|
+
browser_version: userAgent,
|
|
13421
|
+
browser_online: "true",
|
|
13422
|
+
timezone_name: "Asia/Shanghai",
|
|
13423
|
+
support_h265: "1",
|
|
13424
|
+
msToken: params.cookies.find((e)=>"msToken" === e.name)?.value || "",
|
|
13425
|
+
a_bogus: ""
|
|
13426
|
+
};
|
|
13427
|
+
task.logger.info(`[douyinPublish] publishParams ${JSON.stringify(publishParams)}`);
|
|
13428
|
+
const publishData = {
|
|
13429
|
+
item: {
|
|
13430
|
+
common: {
|
|
13431
|
+
text: params.content,
|
|
13432
|
+
text_extra: params.textExtra,
|
|
13433
|
+
activity: "[]",
|
|
13434
|
+
challenges: params.challengeIds || "[]",
|
|
13435
|
+
hashtag_source: "",
|
|
13436
|
+
mentions: "[]",
|
|
13437
|
+
music_id: params.musicId || "",
|
|
13438
|
+
music_end_time: 1000 * (params.musicDuration || 0),
|
|
13439
|
+
hot_sentence: params.hotSentence || "",
|
|
13440
|
+
visibility_type: Number(params.visibleRange) || 0,
|
|
13441
|
+
download: params.allowSave ? 1 : 0,
|
|
13442
|
+
timing: params.isImmediatelyPublish ? -1 : params.scheduledPublish,
|
|
13443
|
+
media_type: Number(params.publishType) || 2,
|
|
13444
|
+
images: [],
|
|
13445
|
+
creation_id: ""
|
|
13446
|
+
},
|
|
13447
|
+
cover: {
|
|
13448
|
+
poster: ""
|
|
13449
|
+
},
|
|
13450
|
+
mix: params.mix ? {
|
|
13451
|
+
mix_id: params.mix.mix_id,
|
|
13452
|
+
mix_order: params.mix.mix_order || 0
|
|
13453
|
+
} : {},
|
|
13454
|
+
anchor: {},
|
|
13455
|
+
declare: {
|
|
13456
|
+
user_declare_info: "{}"
|
|
13457
|
+
}
|
|
13458
|
+
}
|
|
13459
|
+
};
|
|
13460
|
+
const args = [
|
|
13461
|
+
{
|
|
13462
|
+
headers
|
|
13438
13463
|
},
|
|
13439
|
-
|
|
13440
|
-
|
|
13441
|
-
|
|
13442
|
-
|
|
13443
|
-
|
|
13444
|
-
|
|
13445
|
-
|
|
13464
|
+
task.logger,
|
|
13465
|
+
"",
|
|
13466
|
+
"",
|
|
13467
|
+
params.accountId,
|
|
13468
|
+
"douyin"
|
|
13469
|
+
];
|
|
13470
|
+
const http = new Http({
|
|
13471
|
+
headers
|
|
13472
|
+
});
|
|
13473
|
+
const proxyHttp = new Http(...args);
|
|
13474
|
+
const uploadedImgList = params.uploadedImgList ? JSON.parse(params.uploadedImgList) : [];
|
|
13475
|
+
if (uploadedImgList.length > 0) publishData.item.common.images = uploadedImgList;
|
|
13476
|
+
else {
|
|
13477
|
+
const tmpCachePath = task.getTmpPath();
|
|
13478
|
+
const uploader = new DouyinImageUploader(proxyHttp, headers, publishParams, tmpCachePath);
|
|
13479
|
+
if (params.coverImage) {
|
|
13480
|
+
const cover = await uploader.uploadCover(params.coverImage);
|
|
13481
|
+
if (cover) {
|
|
13482
|
+
publishData.item.common.images.push({
|
|
13483
|
+
uri: cover.uri,
|
|
13484
|
+
width: cover.width,
|
|
13485
|
+
height: cover.height
|
|
13486
|
+
});
|
|
13487
|
+
publishData.item.cover = {
|
|
13488
|
+
poster: cover.uri
|
|
13489
|
+
};
|
|
13490
|
+
}
|
|
13491
|
+
}
|
|
13492
|
+
if (params.banners && params.banners.length > 0) {
|
|
13493
|
+
const banners = params.banners.filter((i)=>i !== params.coverImage);
|
|
13494
|
+
const uploadResults = await uploader.uploadImages(banners);
|
|
13495
|
+
publishData.item.common.images = publishData.item.common.images.concat(uploadResults.map((result)=>({
|
|
13496
|
+
uri: result.uri,
|
|
13497
|
+
width: result.width,
|
|
13498
|
+
height: result.height
|
|
13499
|
+
})));
|
|
13446
13500
|
}
|
|
13447
13501
|
}
|
|
13448
|
-
|
|
13449
|
-
|
|
13450
|
-
{
|
|
13451
|
-
headers
|
|
13452
|
-
|
|
13453
|
-
|
|
13454
|
-
|
|
13455
|
-
|
|
13456
|
-
|
|
13457
|
-
|
|
13458
|
-
|
|
13459
|
-
|
|
13460
|
-
|
|
13461
|
-
|
|
13462
|
-
|
|
13463
|
-
|
|
13464
|
-
|
|
13465
|
-
|
|
13466
|
-
|
|
13467
|
-
const uploader = new DouyinImageUploader(proxyHttp, headers, publishParams, tmpCachePath);
|
|
13468
|
-
if (params.coverImage) {
|
|
13469
|
-
const cover = await uploader.uploadCover(params.coverImage);
|
|
13470
|
-
if (cover) {
|
|
13471
|
-
publishData.item.common.images.push({
|
|
13472
|
-
uri: cover.uri,
|
|
13473
|
-
width: cover.width,
|
|
13474
|
-
height: cover.height
|
|
13475
|
-
});
|
|
13476
|
-
publishData.item.cover = {
|
|
13477
|
-
poster: cover.uri
|
|
13502
|
+
publishData.item.common.creation_id = generateRandomString(8) + Date.now();
|
|
13503
|
+
let decision = null;
|
|
13504
|
+
proxyHttp.addResponseInterceptor((response)=>{
|
|
13505
|
+
task.logger.info(`[douyinPublish] 拦截器收到响应response.headers: ${JSON.stringify(response.headers)} `);
|
|
13506
|
+
task.logger.info(`[douyinPublish] 拦截器收到响应response.data: ${JSON.stringify(response.data)} `);
|
|
13507
|
+
decision = parseVerifyPassportDecision(response.headers["x-tt-verify-passport-decision"]);
|
|
13508
|
+
if (needsVerification(decision)) {
|
|
13509
|
+
task.logger.info(`[douyinPublish] 检测到需要验证: ${JSON.stringify(decision)}`);
|
|
13510
|
+
return;
|
|
13511
|
+
}
|
|
13512
|
+
if (!response || !response.data) return;
|
|
13513
|
+
const responseData = response.data;
|
|
13514
|
+
if (response && responseData?.status_code && 0 !== responseData.status_code) {
|
|
13515
|
+
const errorCode = 4 === responseData.status_code ? 500 : responseData.status_code;
|
|
13516
|
+
if (4 === responseData.status_code) task.logger.warn(`[douyinPublish] 抖音服务器错误 status_code: 4,映射为 500 触发重试。原始响应: ${JSON.stringify(responseData)}`);
|
|
13517
|
+
return {
|
|
13518
|
+
code: errorCode,
|
|
13519
|
+
message: responseData.status_msg || "文章发布异常,请稍后重试。",
|
|
13520
|
+
data: responseData
|
|
13478
13521
|
};
|
|
13479
13522
|
}
|
|
13523
|
+
});
|
|
13524
|
+
task._timerRecord.PrePublish = Date.now();
|
|
13525
|
+
if (MockPublish) {
|
|
13526
|
+
const data = "123456789";
|
|
13527
|
+
const message = `图文模拟发布成功 ${http.proxyInfo}`;
|
|
13528
|
+
await updateTaskState?.({
|
|
13529
|
+
state: __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.TaskState.SUCCESS,
|
|
13530
|
+
result: {
|
|
13531
|
+
response: data
|
|
13532
|
+
}
|
|
13533
|
+
});
|
|
13534
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(0, message, data);
|
|
13480
13535
|
}
|
|
13481
|
-
|
|
13482
|
-
|
|
13483
|
-
|
|
13484
|
-
|
|
13485
|
-
|
|
13486
|
-
|
|
13487
|
-
height: result.height
|
|
13488
|
-
})));
|
|
13489
|
-
}
|
|
13490
|
-
}
|
|
13491
|
-
publishData.item.common.creation_id = generateRandomString(8) + Date.now();
|
|
13492
|
-
let decision = null;
|
|
13493
|
-
proxyHttp.addResponseInterceptor((response)=>{
|
|
13494
|
-
task.logger.info(`[douyinPublish] 拦截器收到响应response.headers: ${JSON.stringify(response.headers)} `);
|
|
13495
|
-
task.logger.info(`[douyinPublish] 拦截器收到响应response.data: ${JSON.stringify(response.data)} `);
|
|
13496
|
-
decision = parseVerifyPassportDecision(response.headers["x-tt-verify-passport-decision"]);
|
|
13497
|
-
if (needsVerification(decision)) {
|
|
13498
|
-
task.logger.info(`[douyinPublish] 检测到需要验证: ${JSON.stringify(decision)}`);
|
|
13499
|
-
return;
|
|
13500
|
-
}
|
|
13501
|
-
if (!response || !response.data) return;
|
|
13502
|
-
const responseData = response.data;
|
|
13503
|
-
if (response && responseData?.status_code && 0 !== responseData.status_code) {
|
|
13504
|
-
const errorCode = 4 === responseData.status_code ? 500 : responseData.status_code;
|
|
13505
|
-
if (4 === responseData.status_code) task.logger.warn(`[douyinPublish] 抖音服务器错误 status_code: 4,映射为 500 触发重试。原始响应: ${JSON.stringify(responseData)}`);
|
|
13506
|
-
return {
|
|
13507
|
-
code: errorCode,
|
|
13508
|
-
message: responseData.status_msg || "文章发布异常,请稍后重试。",
|
|
13509
|
-
data: responseData
|
|
13510
|
-
};
|
|
13511
|
-
}
|
|
13512
|
-
});
|
|
13513
|
-
task._timerRecord.PrePublish = Date.now();
|
|
13514
|
-
if (MockPublish) {
|
|
13515
|
-
const data = "123456789";
|
|
13516
|
-
const message = `图文模拟发布成功 ${http.proxyInfo}`;
|
|
13517
|
-
await updateTaskState?.({
|
|
13518
|
-
state: __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.TaskState.SUCCESS,
|
|
13519
|
-
result: {
|
|
13520
|
-
response: data
|
|
13536
|
+
let webProtectData;
|
|
13537
|
+
try {
|
|
13538
|
+
webProtectData = JSON.parse(JSON.parse(params.extraParam["security-sdk/s_sdk_sign_data_key/web_protect"] || "{}").data || "{}");
|
|
13539
|
+
if (!webProtectData.ticket || !webProtectData.ts_sign || !webProtectData.client_cert) {
|
|
13540
|
+
task.logger.error(`webProtectData 关键字段缺失: ${JSON.stringify(webProtectData)}`);
|
|
13541
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "安全参数 webProtectData 不完整,请重新获取后重试", "");
|
|
13521
13542
|
}
|
|
13522
|
-
})
|
|
13523
|
-
|
|
13524
|
-
|
|
13525
|
-
|
|
13526
|
-
|
|
13527
|
-
|
|
13528
|
-
|
|
13529
|
-
|
|
13530
|
-
|
|
13543
|
+
} catch (error) {
|
|
13544
|
+
task.logger.error(`解析 webProtectData 失败: ${error}`);
|
|
13545
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "安全参数 webProtectData 解析失败,请重新获取后重试", "");
|
|
13546
|
+
}
|
|
13547
|
+
let ticket = webProtectData.ticket;
|
|
13548
|
+
let ts_sign = webProtectData.ts_sign;
|
|
13549
|
+
const serverDataCookie = params.cookies.find((it)=>"bd_ticket_guard_server_data" === it.name)?.value;
|
|
13550
|
+
if (serverDataCookie) try {
|
|
13551
|
+
const decoded = JSON.parse(Buffer.from(decodeURIComponent(serverDataCookie), "base64").toString("utf8"));
|
|
13552
|
+
if (decoded.ticket && decoded.ts_sign) {
|
|
13553
|
+
if (decoded.ticket !== ticket) task.logger.info("[douyinPublish] 使用 cookie 中的最新 ticket(web_protect 已过期)");
|
|
13554
|
+
ticket = decoded.ticket;
|
|
13555
|
+
ts_sign = decoded.ts_sign;
|
|
13556
|
+
}
|
|
13557
|
+
} catch (error) {
|
|
13558
|
+
task.logger.info(`[douyinPublish] 解析 bd_ticket_guard_server_data 失败,回退到 web_protect: ${error}`);
|
|
13531
13559
|
}
|
|
13532
|
-
|
|
13533
|
-
|
|
13534
|
-
|
|
13535
|
-
|
|
13536
|
-
|
|
13537
|
-
|
|
13538
|
-
|
|
13539
|
-
|
|
13540
|
-
|
|
13541
|
-
|
|
13542
|
-
if (decoded.ticket !== ticket) task.logger.info("[douyinPublish] 使用 cookie 中的最新 ticket(web_protect 已过期)");
|
|
13543
|
-
ticket = decoded.ticket;
|
|
13544
|
-
ts_sign = decoded.ts_sign;
|
|
13560
|
+
let ec_privateKey;
|
|
13561
|
+
try {
|
|
13562
|
+
ec_privateKey = JSON.parse(JSON.parse(params.extraParam["security-sdk/s_sdk_crypt_sdk"] || "{}").data || "{}").ec_privateKey;
|
|
13563
|
+
if (!ec_privateKey) {
|
|
13564
|
+
task.logger.error("[douyinPublish] ec_privateKey 为空");
|
|
13565
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "安全参数 ec_privateKey 缺失,请重新获取后重试", "");
|
|
13566
|
+
}
|
|
13567
|
+
} catch (error) {
|
|
13568
|
+
task.logger.error(`[douyinPublish] 解析 ec_privateKey 失败: ${error}`);
|
|
13569
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "安全参数 ec_privateKey 解析失败,请重新获取后重试", "");
|
|
13545
13570
|
}
|
|
13546
|
-
|
|
13547
|
-
|
|
13548
|
-
|
|
13549
|
-
|
|
13550
|
-
|
|
13551
|
-
|
|
13552
|
-
|
|
13553
|
-
|
|
13554
|
-
|
|
13571
|
+
let certificate;
|
|
13572
|
+
try {
|
|
13573
|
+
certificate = JSON.parse(params.extraParam["security-sdk/s_sdk_server_cert_key"] || "{}").cert;
|
|
13574
|
+
if (!certificate) {
|
|
13575
|
+
task.logger.error("[douyinPublish] certificate 为空");
|
|
13576
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "安全参数 certificate 缺失,请重新获取后重试", "");
|
|
13577
|
+
}
|
|
13578
|
+
} catch (error) {
|
|
13579
|
+
task.logger.error(`[douyinPublish] 解析 certificate 失败: ${error}`);
|
|
13580
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "安全参数 certificate 解析失败,请重新获取后重试", "");
|
|
13555
13581
|
}
|
|
13556
|
-
|
|
13557
|
-
|
|
13558
|
-
|
|
13559
|
-
|
|
13560
|
-
|
|
13561
|
-
|
|
13562
|
-
|
|
13563
|
-
|
|
13564
|
-
|
|
13565
|
-
|
|
13582
|
+
const ree_public_key = webProtectData.client_cert.replace("pub.", "");
|
|
13583
|
+
let bdTicketGuardClientData;
|
|
13584
|
+
try {
|
|
13585
|
+
bdTicketGuardClientData = getBdV2({
|
|
13586
|
+
ticket,
|
|
13587
|
+
ts_sign: ts_sign,
|
|
13588
|
+
ec_privateKey: ec_privateKey,
|
|
13589
|
+
certificate: certificate,
|
|
13590
|
+
bd_ticket_guard_ree_public_key: ree_public_key
|
|
13591
|
+
});
|
|
13592
|
+
if (!bdTicketGuardClientData || !bdTicketGuardClientData["headers_bd_ticket_guard_client_data"]) {
|
|
13593
|
+
task.logger.error(`[douyinPublish] bdTicketGuardClientData 生成失败或不完整: ${JSON.stringify(bdTicketGuardClientData)}`);
|
|
13594
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "安全参数 bdTicketGuardClientData 生成失败,请重新获取后重试", "");
|
|
13595
|
+
}
|
|
13596
|
+
} catch (error) {
|
|
13597
|
+
task.logger.error(`[douyinPublish] 生成 bdTicketGuardClientData 失败: ${error}`);
|
|
13598
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "安全参数 bdTicketGuardClientData 生成异常,请重新获取后重试", "");
|
|
13566
13599
|
}
|
|
13567
|
-
|
|
13568
|
-
|
|
13569
|
-
|
|
13570
|
-
|
|
13571
|
-
|
|
13572
|
-
|
|
13573
|
-
|
|
13574
|
-
|
|
13575
|
-
|
|
13576
|
-
|
|
13577
|
-
|
|
13578
|
-
|
|
13579
|
-
|
|
13580
|
-
})
|
|
13581
|
-
|
|
13582
|
-
|
|
13583
|
-
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "安全参数 bdTicketGuardClientData 生成失败,请重新获取后重试", "");
|
|
13600
|
+
task.logger.info("[douyinPublish] bdTicketGuardClientData 生成成功");
|
|
13601
|
+
const publishQuery = {
|
|
13602
|
+
...publishParams,
|
|
13603
|
+
a_bogus: ""
|
|
13604
|
+
};
|
|
13605
|
+
const queryString = new URLSearchParams(publishQuery).toString();
|
|
13606
|
+
let aBogus;
|
|
13607
|
+
try {
|
|
13608
|
+
aBogus = mock_getABogus(`https://creator.douyin.com/web/api/media/aweme/create_v2/?${queryString}`, publishData, userAgent);
|
|
13609
|
+
if (!aBogus || aBogus.length < 10) {
|
|
13610
|
+
task.logger.error(`[douyinPublish] a_bogus 生成异常,长度过短: ${aBogus}`);
|
|
13611
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "安全参数 a_bogus 生成失败,请重试", "");
|
|
13612
|
+
}
|
|
13613
|
+
} catch (error) {
|
|
13614
|
+
task.logger.error(`[douyinPublish] 生成 a_bogus 失败: ${error}`);
|
|
13615
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "安全参数 a_bogus 生成异常,请重试", "");
|
|
13584
13616
|
}
|
|
13585
|
-
|
|
13586
|
-
|
|
13587
|
-
|
|
13588
|
-
|
|
13589
|
-
|
|
13590
|
-
|
|
13591
|
-
|
|
13592
|
-
|
|
13593
|
-
|
|
13594
|
-
|
|
13595
|
-
|
|
13596
|
-
|
|
13597
|
-
|
|
13598
|
-
|
|
13599
|
-
task.logger.
|
|
13600
|
-
|
|
13617
|
+
publishQuery.a_bogus = aBogus;
|
|
13618
|
+
const publishQueryParams = new URLSearchParams(publishQuery).toString();
|
|
13619
|
+
let csrfToken;
|
|
13620
|
+
try {
|
|
13621
|
+
csrfToken = mock_generateCsrfTokenAdvanced({
|
|
13622
|
+
cookies: params.cookies,
|
|
13623
|
+
url: "https://creator.douyin.com/web/api/media/aweme/create_v2/",
|
|
13624
|
+
method: "POST",
|
|
13625
|
+
userAgent
|
|
13626
|
+
});
|
|
13627
|
+
if (!csrfToken || csrfToken.length < 10) {
|
|
13628
|
+
task.logger.error(`[douyinPublish] csrfToken 生成异常,长度过短: ${csrfToken}`);
|
|
13629
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "安全参数 csrfToken 生成失败,请重试", "");
|
|
13630
|
+
}
|
|
13631
|
+
task.logger.info(`[douyinPublish] csrfToken 生成成功: ${csrfToken.substring(0, 20)}...`);
|
|
13632
|
+
} catch (error) {
|
|
13633
|
+
task.logger.error(`[douyinPublish] 生成 csrfToken 失败: ${error}`);
|
|
13634
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "安全参数 csrfToken 生成异常,请重试", "");
|
|
13601
13635
|
}
|
|
13602
|
-
|
|
13603
|
-
|
|
13604
|
-
|
|
13605
|
-
|
|
13606
|
-
|
|
13607
|
-
|
|
13608
|
-
|
|
13609
|
-
try {
|
|
13610
|
-
csrfToken = mock_generateCsrfTokenAdvanced({
|
|
13611
|
-
cookies: params.cookies,
|
|
13612
|
-
url: "https://creator.douyin.com/web/api/media/aweme/create_v2/",
|
|
13613
|
-
method: "POST",
|
|
13614
|
-
userAgent
|
|
13615
|
-
});
|
|
13616
|
-
if (!csrfToken || csrfToken.length < 10) {
|
|
13617
|
-
task.logger.error(`[douyinPublish] csrfToken 生成异常,长度过短: ${csrfToken}`);
|
|
13618
|
-
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "安全参数 csrfToken 生成失败,请重试", "");
|
|
13636
|
+
let sessionDtrait;
|
|
13637
|
+
try {
|
|
13638
|
+
sessionDtrait = mock_generateDtrait("/web/api/media/aweme/create_v2/");
|
|
13639
|
+
task.logger.info(`[douyinPublish] sessionDtrait 生成成功: ${sessionDtrait || "(空)"}`);
|
|
13640
|
+
} catch (error) {
|
|
13641
|
+
task.logger.error(`[douyinPublish] 生成 sessionDtrait 失败: ${error}`);
|
|
13642
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "安全参数 sessionDtrait 生成异常,请重试", "");
|
|
13619
13643
|
}
|
|
13620
|
-
task.logger.info(`[douyinPublish]
|
|
13621
|
-
|
|
13622
|
-
|
|
13623
|
-
|
|
13624
|
-
|
|
13625
|
-
|
|
13626
|
-
|
|
13627
|
-
|
|
13628
|
-
|
|
13629
|
-
|
|
13630
|
-
|
|
13631
|
-
|
|
13632
|
-
|
|
13633
|
-
|
|
13634
|
-
|
|
13635
|
-
|
|
13636
|
-
|
|
13637
|
-
|
|
13638
|
-
|
|
13639
|
-
|
|
13640
|
-
|
|
13641
|
-
|
|
13642
|
-
|
|
13643
|
-
|
|
13644
|
-
|
|
13645
|
-
|
|
13646
|
-
|
|
13647
|
-
|
|
13648
|
-
|
|
13649
|
-
|
|
13650
|
-
|
|
13651
|
-
|
|
13652
|
-
|
|
13653
|
-
|
|
13654
|
-
|
|
13655
|
-
|
|
13656
|
-
|
|
13657
|
-
|
|
13658
|
-
|
|
13659
|
-
|
|
13660
|
-
|
|
13661
|
-
|
|
13662
|
-
|
|
13663
|
-
|
|
13664
|
-
|
|
13665
|
-
|
|
13644
|
+
task.logger.info(`[douyinPublish] headers: ${JSON.stringify({
|
|
13645
|
+
...headers,
|
|
13646
|
+
Referer: "https://creator.douyin.com/creator-micro/content/post/image?default-tab=3&enter_from=publish_page&media_type=image&type=new",
|
|
13647
|
+
"Content-Type": "application/json",
|
|
13648
|
+
Accept: "application/json, text/plain, */*",
|
|
13649
|
+
"bd-ticket-guard-client-data": bdTicketGuardClientData["headers_bd_ticket_guard_client_data"],
|
|
13650
|
+
"bd-ticket-guard-ree-public-key": bdTicketGuardClientData["headers_bd_ticket_guard_ree_public_key"],
|
|
13651
|
+
"bd-ticket-guard-version": "2",
|
|
13652
|
+
"bd-ticket-guard-web-sign-type": "1",
|
|
13653
|
+
"bd-ticket-guard-web-version": "2",
|
|
13654
|
+
"x-secsdk-csrf-token": csrfToken,
|
|
13655
|
+
"x-tt-session-dtrait": sessionDtrait || ""
|
|
13656
|
+
})}`);
|
|
13657
|
+
task.logger.info(`[douyinPublish] url: https://creator.douyin.com/web/api/media/aweme/create_v2/?${publishQueryParams}`);
|
|
13658
|
+
let publishResult;
|
|
13659
|
+
try {
|
|
13660
|
+
publishResult = await proxyHttp.api({
|
|
13661
|
+
method: "post",
|
|
13662
|
+
url: `https://creator.douyin.com/web/api/media/aweme/create_v2/?${publishQueryParams}`,
|
|
13663
|
+
data: publishData,
|
|
13664
|
+
defaultErrorMsg: "发布异常,请稍后重试。",
|
|
13665
|
+
headers: {
|
|
13666
|
+
...headers,
|
|
13667
|
+
Referer: "https://creator.douyin.com/creator-micro/content/post/image?default-tab=3&enter_from=publish_page&media_type=image&type=new",
|
|
13668
|
+
"Content-Type": "application/json",
|
|
13669
|
+
Accept: "application/json, text/plain, */*",
|
|
13670
|
+
"bd-ticket-guard-client-data": bdTicketGuardClientData["headers_bd_ticket_guard_client_data"],
|
|
13671
|
+
"bd-ticket-guard-ree-public-key": bdTicketGuardClientData["headers_bd_ticket_guard_ree_public_key"],
|
|
13672
|
+
"bd-ticket-guard-version": "2",
|
|
13673
|
+
"bd-ticket-guard-web-sign-type": "1",
|
|
13674
|
+
"bd-ticket-guard-web-version": "2",
|
|
13675
|
+
"x-secsdk-csrf-token": csrfToken,
|
|
13676
|
+
"x-tt-session-dtrait": sessionDtrait || ""
|
|
13677
|
+
}
|
|
13678
|
+
}, {
|
|
13679
|
+
timeout: 60000,
|
|
13680
|
+
retries: 3,
|
|
13681
|
+
retryDelay: 2000
|
|
13682
|
+
});
|
|
13683
|
+
} catch (error) {
|
|
13684
|
+
const handledError = Http.handleApiError(error);
|
|
13685
|
+
const isProxyOrNetworkError = [
|
|
13686
|
+
599,
|
|
13687
|
+
500,
|
|
13688
|
+
502,
|
|
13689
|
+
503,
|
|
13690
|
+
504
|
|
13691
|
+
].includes(handledError.code);
|
|
13692
|
+
if (isProxyOrNetworkError) {
|
|
13693
|
+
const isProxyRequest = handledError.extra?.isProxyRequest === true;
|
|
13694
|
+
const errorType = 599 === handledError.code || isProxyRequest ? "代理错误" : "网络错误";
|
|
13695
|
+
const message = `图文发布失败,${errorType}:${handledError.message}${task.debug ? ` ${http.proxyInfo}` : ""}`;
|
|
13696
|
+
task.logger.error(`[douyinPublish] ${errorType},直接返回: ${message}`, stringifyError(handledError));
|
|
13697
|
+
await updateTaskState?.({
|
|
13698
|
+
state: __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.TaskState.FAILED,
|
|
13699
|
+
error: message
|
|
13700
|
+
});
|
|
13701
|
+
return {
|
|
13702
|
+
code: 414,
|
|
13703
|
+
data: "",
|
|
13704
|
+
message
|
|
13705
|
+
};
|
|
13666
13706
|
}
|
|
13667
|
-
|
|
13668
|
-
|
|
13669
|
-
|
|
13670
|
-
|
|
13671
|
-
|
|
13672
|
-
|
|
13673
|
-
|
|
13674
|
-
|
|
13675
|
-
|
|
13676
|
-
|
|
13677
|
-
|
|
13678
|
-
|
|
13679
|
-
504
|
|
13680
|
-
].includes(handledError.code);
|
|
13681
|
-
if (isProxyOrNetworkError) {
|
|
13682
|
-
const isProxyRequest = handledError.extra?.isProxyRequest === true;
|
|
13683
|
-
const errorType = 599 === handledError.code || isProxyRequest ? "代理错误" : "网络错误";
|
|
13684
|
-
const message = `图文发布失败,${errorType}:${handledError.message}${task.debug ? ` ${http.proxyInfo}` : ""}`;
|
|
13685
|
-
task.logger.error(`[douyinPublish] ${errorType},直接返回: ${message}`, stringifyError(handledError));
|
|
13686
|
-
await updateTaskState?.({
|
|
13707
|
+
throw error;
|
|
13708
|
+
}
|
|
13709
|
+
task.logger.info(`[douyinPublish] decision值: ${JSON.stringify(decision)}, needsVerification(decision): ${needsVerification(decision)}`);
|
|
13710
|
+
if (needsVerification(decision)) {
|
|
13711
|
+
const details = [
|
|
13712
|
+
publishResult.status_msg,
|
|
13713
|
+
decision?.verify_title,
|
|
13714
|
+
decision?.verify_desc
|
|
13715
|
+
].filter(Boolean).join(" ");
|
|
13716
|
+
const message = `图文发布失败,原因:${details}${task.debug ? ` ${http.proxyInfo}` : ""}`;
|
|
13717
|
+
const safeDecision = safeSerialize(decision) ?? {};
|
|
13718
|
+
const mockData = {
|
|
13687
13719
|
state: __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.TaskState.FAILED,
|
|
13688
|
-
error: message
|
|
13689
|
-
|
|
13720
|
+
error: message,
|
|
13721
|
+
result: {
|
|
13722
|
+
...safeDecision,
|
|
13723
|
+
data: decision,
|
|
13724
|
+
uploadedImgList: JSON.stringify(publishData.item.common.images)
|
|
13725
|
+
}
|
|
13726
|
+
};
|
|
13727
|
+
await updateTaskState?.(mockData);
|
|
13690
13728
|
return {
|
|
13691
|
-
code:
|
|
13692
|
-
data:
|
|
13693
|
-
message
|
|
13729
|
+
code: 0,
|
|
13730
|
+
data: mockData,
|
|
13731
|
+
message: "操作成功"
|
|
13732
|
+
};
|
|
13733
|
+
}
|
|
13734
|
+
reportLogger({
|
|
13735
|
+
token: params.huiwenToken || "",
|
|
13736
|
+
enverionment: task.enverionment || "development",
|
|
13737
|
+
postId: params.articleId,
|
|
13738
|
+
eip: proxyHttp.proxyInfo,
|
|
13739
|
+
proxyIp: params.localIP,
|
|
13740
|
+
accountId: params.accountId,
|
|
13741
|
+
uid: params.uid,
|
|
13742
|
+
platform: "douyin",
|
|
13743
|
+
publishParams: publishData
|
|
13744
|
+
});
|
|
13745
|
+
task.logger.info(`[douyinPublish] 发布结果 ${JSON.stringify(publishResult)}`);
|
|
13746
|
+
const isSuccess = 0 === publishResult.status_code;
|
|
13747
|
+
const message = `图文发布${isSuccess ? "成功" : `失败,原因:${publishResult.status_msg} ${decision?.verify_title} ${decision?.verify_desc}`}${task.debug ? ` ${http.proxyInfo}` : ""}`;
|
|
13748
|
+
const data = isSuccess ? publishResult.item_id || "" : "";
|
|
13749
|
+
if (!isSuccess) {
|
|
13750
|
+
const safeDecision = safeSerialize(decision) ?? {};
|
|
13751
|
+
await updateTaskState?.({
|
|
13752
|
+
state: __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.TaskState.FAILED,
|
|
13753
|
+
error: message,
|
|
13754
|
+
result: {
|
|
13755
|
+
...safeDecision,
|
|
13756
|
+
data: safeDecision,
|
|
13757
|
+
uploadedImgList: JSON.stringify(publishData.item.common.images)
|
|
13758
|
+
}
|
|
13759
|
+
});
|
|
13760
|
+
return {
|
|
13761
|
+
code: 414,
|
|
13762
|
+
data: safeDecision,
|
|
13763
|
+
message
|
|
13694
13764
|
};
|
|
13695
13765
|
}
|
|
13696
|
-
throw error;
|
|
13697
|
-
}
|
|
13698
|
-
task.logger.info(`[douyinPublish] decision值: ${JSON.stringify(decision)}, needsVerification(decision): ${needsVerification(decision)}`);
|
|
13699
|
-
if (needsVerification(decision)) {
|
|
13700
|
-
const details = [
|
|
13701
|
-
publishResult.status_msg,
|
|
13702
|
-
decision?.verify_title,
|
|
13703
|
-
decision?.verify_desc
|
|
13704
|
-
].filter(Boolean).join(" ");
|
|
13705
|
-
const message = `图文发布失败,原因:${details}${task.debug ? ` ${http.proxyInfo}` : ""}`;
|
|
13706
|
-
let decisionObj = {};
|
|
13707
|
-
if (decision) decisionObj = decision;
|
|
13708
|
-
const mockData = {
|
|
13709
|
-
state: __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.TaskState.FAILED,
|
|
13710
|
-
error: message,
|
|
13711
|
-
result: {
|
|
13712
|
-
...decisionObj,
|
|
13713
|
-
data: decision,
|
|
13714
|
-
uploadedImgList: JSON.stringify(publishData.item.common.images)
|
|
13715
|
-
}
|
|
13716
|
-
};
|
|
13717
|
-
await updateTaskState?.(mockData);
|
|
13718
|
-
return {
|
|
13719
|
-
code: 0,
|
|
13720
|
-
data: mockData,
|
|
13721
|
-
message: "操作成功"
|
|
13722
|
-
};
|
|
13723
|
-
}
|
|
13724
|
-
reportLogger({
|
|
13725
|
-
token: params.huiwenToken || "",
|
|
13726
|
-
enverionment: task.enverionment || "development",
|
|
13727
|
-
postId: params.articleId,
|
|
13728
|
-
eip: proxyHttp.proxyInfo,
|
|
13729
|
-
proxyIp: params.localIP,
|
|
13730
|
-
accountId: params.accountId,
|
|
13731
|
-
uid: params.uid,
|
|
13732
|
-
platform: "douyin",
|
|
13733
|
-
publishParams: publishData
|
|
13734
|
-
});
|
|
13735
|
-
task.logger.info(`[douyinPublish] 发布结果 ${JSON.stringify(publishResult)}`);
|
|
13736
|
-
const isSuccess = 0 === publishResult.status_code;
|
|
13737
|
-
const message = `图文发布${isSuccess ? "成功" : `失败,原因:${publishResult.status_msg} ${decision?.verify_title} ${decision?.verify_desc}`}${task.debug ? ` ${http.proxyInfo}` : ""}`;
|
|
13738
|
-
const data = isSuccess ? publishResult.item_id || "" : "";
|
|
13739
|
-
if (!isSuccess) {
|
|
13740
|
-
let decisionObj = {};
|
|
13741
|
-
if (decision) decisionObj = decision;
|
|
13742
13766
|
await updateTaskState?.({
|
|
13743
|
-
state: __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.TaskState.
|
|
13744
|
-
error: message,
|
|
13767
|
+
state: __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.TaskState.SUCCESS,
|
|
13745
13768
|
result: {
|
|
13746
|
-
|
|
13747
|
-
data: decision,
|
|
13748
|
-
uploadedImgList: JSON.stringify(publishData.item.common.images)
|
|
13769
|
+
response: data
|
|
13749
13770
|
}
|
|
13750
13771
|
});
|
|
13751
|
-
return
|
|
13752
|
-
|
|
13753
|
-
|
|
13754
|
-
|
|
13755
|
-
|
|
13772
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(isSuccess ? 0 : 414, message, data);
|
|
13773
|
+
} catch (error) {
|
|
13774
|
+
const handledError = Http.handleApiError(error);
|
|
13775
|
+
const errorMsg = handledError.message || "发布失败";
|
|
13776
|
+
const errorCode = handledError.code || 500;
|
|
13777
|
+
task.logger.error(`[douyinPublish] 发布流程异常 (步骤: ${currentStep}): ${errorMsg}`, stringifyError(error), handledError.extra);
|
|
13778
|
+
await updateTaskState?.({
|
|
13779
|
+
state: __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.TaskState.FAILED,
|
|
13780
|
+
error: `${currentStep}失败: ${errorMsg}`
|
|
13781
|
+
});
|
|
13782
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(errorCode, errorMsg, "");
|
|
13756
13783
|
}
|
|
13757
|
-
await updateTaskState?.({
|
|
13758
|
-
state: __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.TaskState.SUCCESS,
|
|
13759
|
-
result: {
|
|
13760
|
-
response: data
|
|
13761
|
-
}
|
|
13762
|
-
});
|
|
13763
|
-
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(isSuccess ? 0 : 414, message, data);
|
|
13764
13784
|
};
|
|
13765
13785
|
const douyinPublish_rpa_rpaAction = async (task, params)=>{
|
|
13766
13786
|
const commonCookies = {
|
|
@@ -15286,6 +15306,241 @@ async function getBaijiahaoData(_task, params) {
|
|
|
15286
15306
|
};
|
|
15287
15307
|
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(bjhData, "百家号平台数据获取成功!");
|
|
15288
15308
|
}
|
|
15309
|
+
async function getDouyinData(_task, params) {
|
|
15310
|
+
try {
|
|
15311
|
+
const sessionidCookie = params.cookies.find((it)=>"sessionid" === it.name)?.value;
|
|
15312
|
+
if (!sessionidCookie) return types_errorResponse("抖音账号数据异常,请重新绑定账号后重试。", 414);
|
|
15313
|
+
const csrfToken = params.cookies.find((it)=>"passport_csrf_token" === it.name)?.value || "";
|
|
15314
|
+
const headers = {
|
|
15315
|
+
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
15316
|
+
referer: "https://creator.douyin.com/creator-micro/home",
|
|
15317
|
+
origin: "https://creator.douyin.com",
|
|
15318
|
+
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36",
|
|
15319
|
+
...csrfToken ? {
|
|
15320
|
+
"x-secsdk-csrf-token": csrfToken
|
|
15321
|
+
} : {}
|
|
15322
|
+
};
|
|
15323
|
+
const args = [
|
|
15324
|
+
{
|
|
15325
|
+
headers
|
|
15326
|
+
},
|
|
15327
|
+
_task.logger,
|
|
15328
|
+
params.proxyLoc,
|
|
15329
|
+
params.localIP,
|
|
15330
|
+
params.accountId
|
|
15331
|
+
];
|
|
15332
|
+
const http = new Http(...args);
|
|
15333
|
+
const toNum = (val)=>{
|
|
15334
|
+
if (null == val) return 0;
|
|
15335
|
+
const n = Number.parseInt(String(val).replace(/[+,]/g, ""), 10);
|
|
15336
|
+
return Number.isNaN(n) ? 0 : n;
|
|
15337
|
+
};
|
|
15338
|
+
const userProfileP = http.api({
|
|
15339
|
+
method: "get",
|
|
15340
|
+
url: "https://www.douyin.com/aweme/v1/web/user/profile/self/",
|
|
15341
|
+
params: {
|
|
15342
|
+
device_platform: "webapp",
|
|
15343
|
+
aid: "6383",
|
|
15344
|
+
channel: "channel_pc_web",
|
|
15345
|
+
pc_client_type: "1",
|
|
15346
|
+
version_code: "170400",
|
|
15347
|
+
version_name: "17.4.0",
|
|
15348
|
+
cookie_enabled: "true",
|
|
15349
|
+
platform: "PC"
|
|
15350
|
+
}
|
|
15351
|
+
}, {
|
|
15352
|
+
retries: 3,
|
|
15353
|
+
retryDelay: 100,
|
|
15354
|
+
timeout: 10000
|
|
15355
|
+
}).catch((e)=>{
|
|
15356
|
+
_task.logger.warn(`抖音用户信息获取失败: ${e instanceof Error ? e.message : String(e)}`);
|
|
15357
|
+
return null;
|
|
15358
|
+
});
|
|
15359
|
+
const overviewP = http.api({
|
|
15360
|
+
method: "get",
|
|
15361
|
+
url: "https://creator.douyin.com/aweme/janus/creator/data/overview/all/",
|
|
15362
|
+
params: {
|
|
15363
|
+
last_days_type: 1,
|
|
15364
|
+
aid: 2906,
|
|
15365
|
+
app_name: "aweme_creator_platform",
|
|
15366
|
+
device_platform: "web"
|
|
15367
|
+
}
|
|
15368
|
+
}, {
|
|
15369
|
+
retries: 3,
|
|
15370
|
+
retryDelay: 100,
|
|
15371
|
+
timeout: 5000
|
|
15372
|
+
}).catch((e)=>{
|
|
15373
|
+
_task.logger.warn(`抖音近7日数据获取失败(可能未开通数据中心或被风控): ${e instanceof Error ? e.message : String(e)}`);
|
|
15374
|
+
return null;
|
|
15375
|
+
});
|
|
15376
|
+
const [userProfile, overview] = await Promise.all([
|
|
15377
|
+
userProfileP,
|
|
15378
|
+
overviewP
|
|
15379
|
+
]);
|
|
15380
|
+
let fansNum = 0;
|
|
15381
|
+
let favedNum = 0;
|
|
15382
|
+
let followingNum = 0;
|
|
15383
|
+
if (userProfile?.status_code === 0 && userProfile.user) {
|
|
15384
|
+
const user = userProfile.user;
|
|
15385
|
+
fansNum = toNum(user.follower_count);
|
|
15386
|
+
followingNum = toNum(user.following_count);
|
|
15387
|
+
favedNum = toNum(user.total_favorited);
|
|
15388
|
+
} else _task.logger.warn(`用户信息接口返回异常: status_code=${userProfile?.status_code}, msg=${userProfile?.status_msg}`);
|
|
15389
|
+
const ov = overview?.data;
|
|
15390
|
+
const douyinData = {
|
|
15391
|
+
fansNum,
|
|
15392
|
+
favedNum,
|
|
15393
|
+
fansNumLastWeek: toNum(ov?.new_fans?.last_period_incr),
|
|
15394
|
+
watchNumLastWeek: toNum(ov?.play?.last_period_incr),
|
|
15395
|
+
likeNumLastWeek: toNum(ov?.digg?.last_period_incr),
|
|
15396
|
+
commentNumLastWeek: toNum(ov?.comment?.last_period_incr),
|
|
15397
|
+
shareNumLastWeek: toNum(ov?.share?.last_period_incr),
|
|
15398
|
+
visitNumLastWeek: toNum(ov?.profile?.last_period_incr)
|
|
15399
|
+
};
|
|
15400
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(douyinData, "抖音平台数据获取成功!");
|
|
15401
|
+
} catch (error) {
|
|
15402
|
+
if (error && "object" == typeof error && "code" in error && "message" in error) {
|
|
15403
|
+
const err = error;
|
|
15404
|
+
_task.logger.error(`抖音账号数据获取失败: ${err.message} (${err.code})`);
|
|
15405
|
+
return types_errorResponse(err.message, err.code);
|
|
15406
|
+
}
|
|
15407
|
+
const errMsg = error instanceof Error ? error.message : String(error);
|
|
15408
|
+
_task.logger.error(`抖音账号数据获取失败: ${errMsg}`);
|
|
15409
|
+
return types_errorResponse(errMsg || "抖音账号数据获取失败");
|
|
15410
|
+
}
|
|
15411
|
+
}
|
|
15412
|
+
async function getShipinhaoData(_task, params) {
|
|
15413
|
+
try {
|
|
15414
|
+
const sessionidCookie = params.cookies.find((it)=>"sessionid" === it.name)?.value;
|
|
15415
|
+
if (!sessionidCookie) return types_errorResponse("视频号账号数据异常,请重新绑定账号后重试。", 414);
|
|
15416
|
+
const uinCookie = params.cookies.find((it)=>"uin" === it.name || "wxuin" === it.name)?.value || "0000000000";
|
|
15417
|
+
const deviceIdCookie = params.cookies.find((it)=>"device_id" === it.name || "finger_print_device_id" === it.name)?.value;
|
|
15418
|
+
const aid = params.cookies.find((it)=>"_aid" === it.name)?.value || "9d3e0e9f-b842-498d-a273-4285d58df264";
|
|
15419
|
+
const finderId = params.cookies.find((it)=>"_log_finder_id" === it.name || "finder_id" === it.name)?.value || "";
|
|
15420
|
+
const headers = {
|
|
15421
|
+
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
15422
|
+
referer: "https://channels.weixin.qq.com/platform",
|
|
15423
|
+
origin: "https://channels.weixin.qq.com",
|
|
15424
|
+
"content-type": "application/json",
|
|
15425
|
+
"X-WECHAT-UIN": uinCookie,
|
|
15426
|
+
...deviceIdCookie ? {
|
|
15427
|
+
"finger-print-device-id": deviceIdCookie
|
|
15428
|
+
} : {}
|
|
15429
|
+
};
|
|
15430
|
+
const args = [
|
|
15431
|
+
{
|
|
15432
|
+
headers
|
|
15433
|
+
},
|
|
15434
|
+
_task.logger,
|
|
15435
|
+
params.proxyLoc,
|
|
15436
|
+
params.localIP,
|
|
15437
|
+
params.accountId
|
|
15438
|
+
];
|
|
15439
|
+
const http = new Http(...args);
|
|
15440
|
+
const authData = await http.api({
|
|
15441
|
+
method: "post",
|
|
15442
|
+
url: "https://channels.weixin.qq.com/cgi-bin/mmfinderassistant-bin/auth/auth_data",
|
|
15443
|
+
params: {
|
|
15444
|
+
_aid: aid,
|
|
15445
|
+
_rid: `${Date.now().toString(16)}-${Math.random().toString(36).substring(2, 9)}`,
|
|
15446
|
+
_pageUrl: encodeURIComponent("https://channels.weixin.qq.com/platform")
|
|
15447
|
+
},
|
|
15448
|
+
data: {
|
|
15449
|
+
timestamp: Date.now().toString(),
|
|
15450
|
+
_log_finder_uin: "",
|
|
15451
|
+
_log_finder_id: finderId,
|
|
15452
|
+
rawKeyBuff: "",
|
|
15453
|
+
pluginSessionId: null,
|
|
15454
|
+
scene: 7,
|
|
15455
|
+
reqScene: 7
|
|
15456
|
+
}
|
|
15457
|
+
}, {
|
|
15458
|
+
retries: 3,
|
|
15459
|
+
retryDelay: 100,
|
|
15460
|
+
timeout: 5000
|
|
15461
|
+
});
|
|
15462
|
+
const AUTH_ERROR_CODES = [
|
|
15463
|
+
300333,
|
|
15464
|
+
300334,
|
|
15465
|
+
300330,
|
|
15466
|
+
300331,
|
|
15467
|
+
300332
|
|
15468
|
+
];
|
|
15469
|
+
if (authData.errCode && AUTH_ERROR_CODES.includes(authData.errCode)) {
|
|
15470
|
+
_task.logger.warn(`视频号登录已失效:${authData.errMsg} (${authData.errCode})`);
|
|
15471
|
+
return types_errorResponse("视频号账号信息获取失败,请检查账号状态", 414);
|
|
15472
|
+
}
|
|
15473
|
+
if (authData.errCode) {
|
|
15474
|
+
_task.logger.warn(`视频号账号API错误:${authData.errMsg} (${authData.errCode})`);
|
|
15475
|
+
return types_errorResponse(`视频号账号信息获取失败:${authData.errMsg || "未知错误"}`, 414);
|
|
15476
|
+
}
|
|
15477
|
+
const finderUser = authData.data?.finderUser;
|
|
15478
|
+
const now = new Date();
|
|
15479
|
+
const yesterday = new Date(now.getFullYear(), now.getMonth(), now.getDate() - 2);
|
|
15480
|
+
const startTs = Math.floor(yesterday.getTime() / 1000);
|
|
15481
|
+
const endTs = startTs + 86400;
|
|
15482
|
+
_task.logger.info(`视频号昨日数据范围 start: ${startTs} ~ end: ${endTs}`);
|
|
15483
|
+
let fansNumYesterday = 0;
|
|
15484
|
+
let playNumYesterday = 0;
|
|
15485
|
+
let likeNumYesterday = 0;
|
|
15486
|
+
let commentNumYesterday = 0;
|
|
15487
|
+
try {
|
|
15488
|
+
const statsData = await http.api({
|
|
15489
|
+
method: "post",
|
|
15490
|
+
url: "https://channels.weixin.qq.com/cgi-bin/mmfinderassistant-bin/statistic/new_post_total_data",
|
|
15491
|
+
params: {
|
|
15492
|
+
_aid: aid,
|
|
15493
|
+
_rid: `${Date.now().toString(16)}-${Math.random().toString(36).substring(2, 9)}`,
|
|
15494
|
+
_pageUrl: encodeURIComponent("https://channels.weixin.qq.com/platform")
|
|
15495
|
+
},
|
|
15496
|
+
data: {
|
|
15497
|
+
startTs: startTs.toString(),
|
|
15498
|
+
endTs: endTs.toString(),
|
|
15499
|
+
interval: 3,
|
|
15500
|
+
timestamp: Date.now().toString(),
|
|
15501
|
+
_log_finder_uin: "",
|
|
15502
|
+
_log_finder_id: finderId,
|
|
15503
|
+
rawKeyBuff: "",
|
|
15504
|
+
pluginSessionId: null,
|
|
15505
|
+
scene: 7,
|
|
15506
|
+
reqScene: 7
|
|
15507
|
+
}
|
|
15508
|
+
}, {
|
|
15509
|
+
retries: 3,
|
|
15510
|
+
retryDelay: 100,
|
|
15511
|
+
timeout: 5000
|
|
15512
|
+
});
|
|
15513
|
+
if (!statsData.errCode && statsData.data?.totalData) {
|
|
15514
|
+
const data = statsData.data.totalData;
|
|
15515
|
+
fansNumYesterday = Number.parseInt(data.follow?.[1] || "0", 10) || 0;
|
|
15516
|
+
playNumYesterday = Number.parseInt(data.browse?.[1] || "0", 10) || 0;
|
|
15517
|
+
likeNumYesterday = Number.parseInt(data.like?.[1] || "0", 10) || 0;
|
|
15518
|
+
commentNumYesterday = Number.parseInt(data.comment?.[1] || "0", 10) || 0;
|
|
15519
|
+
}
|
|
15520
|
+
} catch (error) {
|
|
15521
|
+
const errMsg = error instanceof Error ? error.message : String(error);
|
|
15522
|
+
_task.logger.warn(`视频号昨日数据获取失败(降级为null): ${errMsg}`);
|
|
15523
|
+
}
|
|
15524
|
+
const shipinhaoData = {
|
|
15525
|
+
fansNum: finderUser?.fansCount || 0,
|
|
15526
|
+
feedsCount: finderUser?.feedsCount || 0,
|
|
15527
|
+
fansNumYesterday,
|
|
15528
|
+
playNumYesterday,
|
|
15529
|
+
likeNumYesterday,
|
|
15530
|
+
commentNumYesterday
|
|
15531
|
+
};
|
|
15532
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(shipinhaoData, "视频号平台数据获取成功!");
|
|
15533
|
+
} catch (error) {
|
|
15534
|
+
if (error && "object" == typeof error && "code" in error && "message" in error) {
|
|
15535
|
+
const err = error;
|
|
15536
|
+
_task.logger.error(`视频号账号数据获取失败: ${err.message} (${err.code})`);
|
|
15537
|
+
return types_errorResponse(err.message, err.code);
|
|
15538
|
+
}
|
|
15539
|
+
const errMsg = error instanceof Error ? error.message : String(error);
|
|
15540
|
+
_task.logger.error(`视频号账号数据获取失败: ${errMsg}`);
|
|
15541
|
+
return types_errorResponse(errMsg || "视频号账号数据获取失败");
|
|
15542
|
+
}
|
|
15543
|
+
}
|
|
15289
15544
|
async function getToutiaoData(_task, params) {
|
|
15290
15545
|
const http = new Http({
|
|
15291
15546
|
headers: {
|
|
@@ -15382,7 +15637,7 @@ async function getWeixinData(_task, params) {
|
|
|
15382
15637
|
userInfoHtmlPromise,
|
|
15383
15638
|
userSummaryHtmlPromise
|
|
15384
15639
|
]);
|
|
15385
|
-
if (userInfoHtml.includes("请重新<a id='jumpUrl' href='/'>登录</a>")) return types_errorResponse("
|
|
15640
|
+
if (userInfoHtml.includes("请重新<a id='jumpUrl' href='/'>登录</a>")) return types_errorResponse("微信公众号数据获取失败,请检查账号状态", 414);
|
|
15386
15641
|
const userInfoJson = exportWxCgiData(userInfoHtml);
|
|
15387
15642
|
const userSummaryJson = exportWxCgiData(userSummaryHtml);
|
|
15388
15643
|
const wxData = {
|
|
@@ -15459,7 +15714,9 @@ const SearchAccountInfoParamsSchema = ActionCommonParamsSchema.extend({
|
|
|
15459
15714
|
"toutiao",
|
|
15460
15715
|
"xiaohongshu",
|
|
15461
15716
|
"weixin",
|
|
15462
|
-
"baijiahao"
|
|
15717
|
+
"baijiahao",
|
|
15718
|
+
"douyin",
|
|
15719
|
+
"shipinhao"
|
|
15463
15720
|
])
|
|
15464
15721
|
});
|
|
15465
15722
|
const SearchAccountInfo = async (_task, params)=>{
|
|
@@ -15473,6 +15730,10 @@ const SearchAccountInfo = async (_task, params)=>{
|
|
|
15473
15730
|
return getWeixinData(_task, params);
|
|
15474
15731
|
case "baijiahao":
|
|
15475
15732
|
return getBaijiahaoData(_task, params);
|
|
15733
|
+
case "douyin":
|
|
15734
|
+
return getDouyinData(_task, params);
|
|
15735
|
+
case "shipinhao":
|
|
15736
|
+
return getShipinhaoData(_task, params);
|
|
15476
15737
|
default:
|
|
15477
15738
|
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(null, "暂不支持该平台");
|
|
15478
15739
|
}
|
|
@@ -15567,18 +15828,45 @@ const XiaohongshuArticleSchema = BaseArticleSchema.extend({
|
|
|
15567
15828
|
collectNum: schemas_number(),
|
|
15568
15829
|
shareNum: schemas_number()
|
|
15569
15830
|
});
|
|
15831
|
+
const DouyinArticleSchema = BaseArticleSchema.extend({
|
|
15832
|
+
playNum: schemas_number(),
|
|
15833
|
+
likeNum: schemas_number(),
|
|
15834
|
+
commentNum: schemas_number(),
|
|
15835
|
+
shareNum: schemas_number(),
|
|
15836
|
+
collectNum: schemas_number(),
|
|
15837
|
+
awemeId: schemas_string(),
|
|
15838
|
+
awemeType: schemas_number(),
|
|
15839
|
+
duration: schemas_number().optional(),
|
|
15840
|
+
status: schemas_string(),
|
|
15841
|
+
publicUrl: schemas_string()
|
|
15842
|
+
});
|
|
15843
|
+
const ShipinhaoArticleSchema = BaseArticleSchema.extend({
|
|
15844
|
+
readNum: schemas_number(),
|
|
15845
|
+
likeNum: schemas_number(),
|
|
15846
|
+
commentNum: schemas_number(),
|
|
15847
|
+
forwardNum: schemas_number(),
|
|
15848
|
+
favNum: schemas_number(),
|
|
15849
|
+
objectId: schemas_string(),
|
|
15850
|
+
postType: schemas_string(),
|
|
15851
|
+
postStatus: schemas_number(),
|
|
15852
|
+
effectiveTime: schemas_number().optional()
|
|
15853
|
+
});
|
|
15570
15854
|
const FetchArticlesDataSchema = schemas_object({
|
|
15571
15855
|
articleCell: schemas_array(union([
|
|
15572
15856
|
ToutiaoArticleSchema,
|
|
15573
15857
|
WeixinArticleSchema,
|
|
15574
15858
|
BaijiahaoArticleSchema,
|
|
15575
|
-
XiaohongshuArticleSchema
|
|
15859
|
+
XiaohongshuArticleSchema,
|
|
15860
|
+
DouyinArticleSchema,
|
|
15861
|
+
ShipinhaoArticleSchema
|
|
15576
15862
|
])).optional(),
|
|
15577
15863
|
timerPublish: schemas_array(union([
|
|
15578
15864
|
ToutiaoArticleSchema,
|
|
15579
15865
|
WeixinArticleSchema,
|
|
15580
15866
|
BaijiahaoArticleSchema,
|
|
15581
|
-
XiaohongshuArticleSchema
|
|
15867
|
+
XiaohongshuArticleSchema,
|
|
15868
|
+
DouyinArticleSchema,
|
|
15869
|
+
ShipinhaoArticleSchema
|
|
15582
15870
|
])).optional(),
|
|
15583
15871
|
pagination: schemas_object({
|
|
15584
15872
|
total: schemas_number().optional(),
|
|
@@ -15693,6 +15981,269 @@ async function handleBaijiahaoData(_task, params) {
|
|
|
15693
15981
|
return searchPublishInfo_types_errorResponse(error instanceof Error ? error.message : "百家号文章数据获取失败");
|
|
15694
15982
|
}
|
|
15695
15983
|
}
|
|
15984
|
+
async function handleDouyinData(_task, params) {
|
|
15985
|
+
try {
|
|
15986
|
+
const { cookies, pageSize = 12, status = 0, showOriginalData = false, onlySuccess = false } = params;
|
|
15987
|
+
const pageNum = params.pageNum || 1;
|
|
15988
|
+
const headers = {
|
|
15989
|
+
cookie: cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
15990
|
+
referer: "https://creator.douyin.com"
|
|
15991
|
+
};
|
|
15992
|
+
const args = [
|
|
15993
|
+
{
|
|
15994
|
+
headers
|
|
15995
|
+
},
|
|
15996
|
+
_task.logger,
|
|
15997
|
+
params.proxyLoc,
|
|
15998
|
+
params.localIP,
|
|
15999
|
+
params.accountId
|
|
16000
|
+
];
|
|
16001
|
+
const http = new Http(...args);
|
|
16002
|
+
async function fetchWorks(cursor) {
|
|
16003
|
+
return await http.api({
|
|
16004
|
+
method: "get",
|
|
16005
|
+
url: "https://creator.douyin.com/janus/douyin/creator/pc/work_list",
|
|
16006
|
+
params: {
|
|
16007
|
+
scene: "star_atlas",
|
|
16008
|
+
device_platform: "android",
|
|
16009
|
+
aid: 1128,
|
|
16010
|
+
status,
|
|
16011
|
+
count: pageSize,
|
|
16012
|
+
max_cursor: cursor
|
|
16013
|
+
}
|
|
16014
|
+
}, {
|
|
16015
|
+
retries: 3,
|
|
16016
|
+
retryDelay: 100,
|
|
16017
|
+
timeout: 5000
|
|
16018
|
+
});
|
|
16019
|
+
}
|
|
16020
|
+
const isHasMore = (v)=>true === v || 1 === v;
|
|
16021
|
+
const skipCount = (pageNum - 1) * pageSize;
|
|
16022
|
+
const needCount = skipCount + pageSize;
|
|
16023
|
+
const workListResponse = await fetchWorks(0);
|
|
16024
|
+
if (!workListResponse || !Array.isArray(workListResponse.aweme_list)) return searchPublishInfo_types_errorResponse("抖音数据获取失败,请检查账号状态", 414);
|
|
16025
|
+
const allWorks = [
|
|
16026
|
+
...workListResponse.aweme_list
|
|
16027
|
+
];
|
|
16028
|
+
let hasMore = isHasMore(workListResponse.has_more);
|
|
16029
|
+
let currentCursor = workListResponse.cursor ?? workListResponse.max_cursor ?? 0;
|
|
16030
|
+
let guard = 0;
|
|
16031
|
+
while(allWorks.length < needCount && hasMore && guard < 20){
|
|
16032
|
+
const nextPageResponse = await fetchWorks(currentCursor);
|
|
16033
|
+
if (!Array.isArray(nextPageResponse.aweme_list) || 0 === nextPageResponse.aweme_list.length) break;
|
|
16034
|
+
allWorks.push(...nextPageResponse.aweme_list);
|
|
16035
|
+
hasMore = isHasMore(nextPageResponse.has_more);
|
|
16036
|
+
currentCursor = nextPageResponse.cursor ?? nextPageResponse.max_cursor ?? currentCursor;
|
|
16037
|
+
guard++;
|
|
16038
|
+
}
|
|
16039
|
+
const finalWorks = allWorks.slice(skipCount, needCount);
|
|
16040
|
+
const articleCell = finalWorks.map((item)=>{
|
|
16041
|
+
const workDetailUrl = `https://creator.douyin.com/creator-micro/work-management/work-detail/${item.aweme_id}`;
|
|
16042
|
+
const workPublicUrl = item.share_url || `https://www.douyin.com/video/${item.aweme_id}`;
|
|
16043
|
+
let statusText;
|
|
16044
|
+
statusText = item.status?.is_delete ? "deleted" : item.status?.is_private ? "private" : item.status?.in_reviewing ? "reviewing" : "public";
|
|
16045
|
+
return {
|
|
16046
|
+
title: item.desc || "无作品描述",
|
|
16047
|
+
imageUrl: item.Cover?.url_list?.[0] || "",
|
|
16048
|
+
createTime: item.create_time,
|
|
16049
|
+
redirectUrl: workDetailUrl,
|
|
16050
|
+
playNum: item.statistics?.play_count || 0,
|
|
16051
|
+
likeNum: item.statistics?.digg_count || 0,
|
|
16052
|
+
commentNum: item.statistics?.comment_count || 0,
|
|
16053
|
+
shareNum: item.statistics?.share_count || 0,
|
|
16054
|
+
collectNum: item.statistics?.collect_count || 0,
|
|
16055
|
+
awemeId: item.aweme_id,
|
|
16056
|
+
awemeType: item.aweme_type ?? 0,
|
|
16057
|
+
duration: item.duration,
|
|
16058
|
+
status: statusText,
|
|
16059
|
+
publicUrl: workPublicUrl,
|
|
16060
|
+
...showOriginalData ? {
|
|
16061
|
+
originalData: item
|
|
16062
|
+
} : {}
|
|
16063
|
+
};
|
|
16064
|
+
});
|
|
16065
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)({
|
|
16066
|
+
articleCell,
|
|
16067
|
+
...onlySuccess ? {
|
|
16068
|
+
pagination: {
|
|
16069
|
+
total: workListResponse.total || allWorks.length,
|
|
16070
|
+
nextPage: hasMore,
|
|
16071
|
+
pageNum,
|
|
16072
|
+
pageSize
|
|
16073
|
+
}
|
|
16074
|
+
} : null
|
|
16075
|
+
}, "抖音数据获取成功");
|
|
16076
|
+
} catch (error) {
|
|
16077
|
+
return searchPublishInfo_types_errorResponse(error instanceof Error ? error.message : "抖音数据获取失败");
|
|
16078
|
+
}
|
|
16079
|
+
}
|
|
16080
|
+
async function handleShipinhaoData(_task, params) {
|
|
16081
|
+
try {
|
|
16082
|
+
const { cookies, postType = "all", pageSize = 10, showOriginalData = false } = params;
|
|
16083
|
+
const pageNum = params.pageNum || 1;
|
|
16084
|
+
const aidCookie = cookies.find((it)=>"_aid" === it.name)?.value;
|
|
16085
|
+
const aid = aidCookie || "9d3e0e9f-b842-498d-a273-4285d58df264";
|
|
16086
|
+
const uinCookie = cookies.find((it)=>"uin" === it.name || "wxuin" === it.name)?.value || "0000000000";
|
|
16087
|
+
const deviceIdCookie = cookies.find((it)=>"device_id" === it.name || "finger_print_device_id" === it.name)?.value;
|
|
16088
|
+
const headers = {
|
|
16089
|
+
cookie: cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
16090
|
+
referer: "https://channels.weixin.qq.com",
|
|
16091
|
+
origin: "https://channels.weixin.qq.com",
|
|
16092
|
+
"content-type": "application/json",
|
|
16093
|
+
"X-WECHAT-UIN": uinCookie,
|
|
16094
|
+
...deviceIdCookie ? {
|
|
16095
|
+
"finger-print-device-id": deviceIdCookie
|
|
16096
|
+
} : {}
|
|
16097
|
+
};
|
|
16098
|
+
const args = [
|
|
16099
|
+
{
|
|
16100
|
+
headers
|
|
16101
|
+
},
|
|
16102
|
+
_task.logger,
|
|
16103
|
+
params.proxyLoc,
|
|
16104
|
+
params.localIP,
|
|
16105
|
+
params.accountId
|
|
16106
|
+
];
|
|
16107
|
+
const http = new Http(...args);
|
|
16108
|
+
const finderIdCookie = cookies.find((it)=>"_log_finder_id" === it.name || "finder_id" === it.name)?.value || "";
|
|
16109
|
+
async function fetchPosts(currentPage, userpageType, pageUrl, rawKeyBuff = "") {
|
|
16110
|
+
return await http.api({
|
|
16111
|
+
method: "post",
|
|
16112
|
+
url: "https://channels.weixin.qq.com/micro/content/cgi-bin/mmfinderassistant-bin/post/post_list",
|
|
16113
|
+
params: {
|
|
16114
|
+
_aid: aid,
|
|
16115
|
+
_rid: `${Date.now().toString(16)}-${Math.random().toString(36).substring(2, 9)}`,
|
|
16116
|
+
_pageUrl: encodeURIComponent(pageUrl)
|
|
16117
|
+
},
|
|
16118
|
+
data: {
|
|
16119
|
+
pageSize,
|
|
16120
|
+
currentPage,
|
|
16121
|
+
userpageType,
|
|
16122
|
+
stickyOrder: true,
|
|
16123
|
+
timestamp: Date.now().toString(),
|
|
16124
|
+
_log_finder_uin: "",
|
|
16125
|
+
_log_finder_id: finderIdCookie,
|
|
16126
|
+
rawKeyBuff,
|
|
16127
|
+
pluginSessionId: null,
|
|
16128
|
+
scene: 7,
|
|
16129
|
+
reqScene: 7
|
|
16130
|
+
}
|
|
16131
|
+
}, {
|
|
16132
|
+
retries: 3,
|
|
16133
|
+
retryDelay: 100,
|
|
16134
|
+
timeout: 5000
|
|
16135
|
+
});
|
|
16136
|
+
}
|
|
16137
|
+
async function fetchAllPosts(userpageType, pageUrl) {
|
|
16138
|
+
const allPosts = [];
|
|
16139
|
+
let currentPage = 1;
|
|
16140
|
+
let rawKeyBuff = "";
|
|
16141
|
+
let continueFlag = true;
|
|
16142
|
+
let totalCount = 0;
|
|
16143
|
+
while(continueFlag){
|
|
16144
|
+
const response = await fetchPosts(currentPage, userpageType, pageUrl, rawKeyBuff);
|
|
16145
|
+
if (response.errCode && AUTH_ERROR_CODES.includes(response.errCode)) throw new Error(`AUTH_ERROR:${response.errMsg || "登录已失效"}`);
|
|
16146
|
+
if (response.errCode) {
|
|
16147
|
+
_task.logger.warn(`视频号API错误:${response.errMsg} (${response.errCode})`);
|
|
16148
|
+
throw new Error(`视频号API错误:${response.errMsg} (${response.errCode})`);
|
|
16149
|
+
}
|
|
16150
|
+
if (1 === currentPage) totalCount = response.data?.totalCount ?? 0;
|
|
16151
|
+
const posts = response.data?.list || response.posts || response.post_list || [];
|
|
16152
|
+
allPosts.push(...posts);
|
|
16153
|
+
continueFlag = response.data?.continueFlag ?? false;
|
|
16154
|
+
rawKeyBuff = response.data?.lastBuff || "";
|
|
16155
|
+
currentPage++;
|
|
16156
|
+
if (currentPage > 100) {
|
|
16157
|
+
_task.logger.warn("分页超过100页,停止请求");
|
|
16158
|
+
break;
|
|
16159
|
+
}
|
|
16160
|
+
}
|
|
16161
|
+
if (totalCount > 0 && allPosts.length !== totalCount) _task.logger.warn(`视频号分页可能不完整:期望${totalCount}条,实际${allPosts.length}条`);
|
|
16162
|
+
return {
|
|
16163
|
+
posts: allPosts,
|
|
16164
|
+
totalCount
|
|
16165
|
+
};
|
|
16166
|
+
}
|
|
16167
|
+
const mapPost = (item, forcePostType)=>{
|
|
16168
|
+
let imageUrl = "";
|
|
16169
|
+
if (item.desc?.media?.[0]?.thumbUrl) imageUrl = item.desc.media[0].thumbUrl;
|
|
16170
|
+
else if (item.desc?.media?.[0]?.coverUrl) imageUrl = item.desc.media[0].coverUrl;
|
|
16171
|
+
else if (item.cover?.url) imageUrl = item.cover.url;
|
|
16172
|
+
else if (item.media_url) imageUrl = item.media_url;
|
|
16173
|
+
const title = item.desc?.description || item.object_desc || "无标题";
|
|
16174
|
+
return {
|
|
16175
|
+
title,
|
|
16176
|
+
imageUrl,
|
|
16177
|
+
createTime: item.createTime || item.create_time,
|
|
16178
|
+
redirectUrl: "https://channels.weixin.qq.com/platform",
|
|
16179
|
+
readNum: item.readCount || item.read_count || 0,
|
|
16180
|
+
likeNum: item.likeCount || item.like_count || 0,
|
|
16181
|
+
commentNum: item.commentCount || item.comment_count || 0,
|
|
16182
|
+
forwardNum: item.forwardCount || item.forward_count || 0,
|
|
16183
|
+
favNum: item.favCount || item.fav_count || 0,
|
|
16184
|
+
objectId: item.exportId || item.objectId || "",
|
|
16185
|
+
postType: forcePostType,
|
|
16186
|
+
postStatus: item.status || item.post_status || 0,
|
|
16187
|
+
...item.effectiveTime ? {
|
|
16188
|
+
effectiveTime: item.effectiveTime
|
|
16189
|
+
} : {},
|
|
16190
|
+
...showOriginalData ? {
|
|
16191
|
+
originalData: item
|
|
16192
|
+
} : {}
|
|
16193
|
+
};
|
|
16194
|
+
};
|
|
16195
|
+
const allArticles = [];
|
|
16196
|
+
const needVideo = "all" === postType || "video" === postType;
|
|
16197
|
+
const needArticle = "all" === postType || "article" === postType;
|
|
16198
|
+
const AUTH_ERROR_CODES = [
|
|
16199
|
+
300333,
|
|
16200
|
+
300334,
|
|
16201
|
+
300330,
|
|
16202
|
+
300331,
|
|
16203
|
+
300332
|
|
16204
|
+
];
|
|
16205
|
+
let combinedTotal = 0;
|
|
16206
|
+
if (needVideo) try {
|
|
16207
|
+
const videoPageUrl = "https://channels.weixin.qq.com/micro/content/post/list";
|
|
16208
|
+
const { posts, totalCount } = await fetchAllPosts(11, videoPageUrl);
|
|
16209
|
+
const videoArticles = posts.filter((item)=>item.createTime || item.create_time).map((item)=>mapPost(item, "video"));
|
|
16210
|
+
allArticles.push(...videoArticles);
|
|
16211
|
+
combinedTotal += totalCount || videoArticles.length;
|
|
16212
|
+
} catch (error) {
|
|
16213
|
+
const errMsg = error instanceof Error ? error.message : String(error);
|
|
16214
|
+
if (errMsg.startsWith("AUTH_ERROR:")) throw error;
|
|
16215
|
+
_task.logger.warn(`获取视频号视频失败:${errMsg}`);
|
|
16216
|
+
}
|
|
16217
|
+
if (needArticle) try {
|
|
16218
|
+
const articlePageUrl = "https://channels.weixin.qq.com/micro/content/post/finderNewLifePostList";
|
|
16219
|
+
const { posts, totalCount } = await fetchAllPosts(10, articlePageUrl);
|
|
16220
|
+
const articleArticles = posts.filter((item)=>item.createTime || item.create_time).map((item)=>mapPost(item, "article"));
|
|
16221
|
+
allArticles.push(...articleArticles);
|
|
16222
|
+
combinedTotal += totalCount || articleArticles.length;
|
|
16223
|
+
} catch (error) {
|
|
16224
|
+
const errMsg = error instanceof Error ? error.message : String(error);
|
|
16225
|
+
if (errMsg.startsWith("AUTH_ERROR:")) throw error;
|
|
16226
|
+
_task.logger.warn(`获取视频号图文失败:${errMsg}`);
|
|
16227
|
+
}
|
|
16228
|
+
allArticles.sort((a, b)=>b.createTime - a.createTime);
|
|
16229
|
+
const total = allArticles.length;
|
|
16230
|
+
const start = (pageNum - 1) * pageSize;
|
|
16231
|
+
const pageItems = allArticles.slice(start, start + pageSize);
|
|
16232
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)({
|
|
16233
|
+
articleCell: pageItems,
|
|
16234
|
+
pagination: {
|
|
16235
|
+
total,
|
|
16236
|
+
nextPage: start + pageSize < total,
|
|
16237
|
+
pageNum,
|
|
16238
|
+
pageSize
|
|
16239
|
+
}
|
|
16240
|
+
}, "视频号数据获取成功");
|
|
16241
|
+
} catch (error) {
|
|
16242
|
+
const errMsg = error instanceof Error ? error.message : String(error);
|
|
16243
|
+
if (errMsg.startsWith("AUTH_ERROR:")) return searchPublishInfo_types_errorResponse("视频号数据获取失败,请检查账号状态", 414);
|
|
16244
|
+
return searchPublishInfo_types_errorResponse(errMsg || "视频号数据获取失败");
|
|
16245
|
+
}
|
|
16246
|
+
}
|
|
15696
16247
|
async function handleToutiaoData(_task, params) {
|
|
15697
16248
|
try {
|
|
15698
16249
|
const { cookies, pageNum = 1, pageSize = 10, showOriginalData = false, onlySuccess = false, containsArticle = false } = params;
|
|
@@ -15725,7 +16276,7 @@ async function handleToutiaoData(_task, params) {
|
|
|
15725
16276
|
app_id: 1231
|
|
15726
16277
|
}
|
|
15727
16278
|
});
|
|
15728
|
-
if (0 !== visitedUid.code) return searchPublishInfo_types_errorResponse("
|
|
16279
|
+
if (0 !== visitedUid.code) return searchPublishInfo_types_errorResponse("头条号数据获取失败,请检查账号状态", 414);
|
|
15729
16280
|
const articleInfo = await http.api({
|
|
15730
16281
|
method: "get",
|
|
15731
16282
|
url: "https://mp.toutiao.com/api/feed/mp_provider/v1/",
|
|
@@ -15832,7 +16383,7 @@ async function handleWeixinData(_task, params) {
|
|
|
15832
16383
|
const size = onlySuccess ? 10 : pageSize > 20 ? 20 : pageSize;
|
|
15833
16384
|
let begin = (lastPage ?? pageNum) - 1;
|
|
15834
16385
|
const rawArticlesInfo = await fetchArticles(begin * size, size, token);
|
|
15835
|
-
if (rawArticlesInfo.includes("请重新<a id='jumpUrl' href='/'>登录</a>")) return searchPublishInfo_types_errorResponse("
|
|
16386
|
+
if (rawArticlesInfo.includes("请重新<a id='jumpUrl' href='/'>登录</a>")) return searchPublishInfo_types_errorResponse("微信公众号数据获取失败,请检查账号状态", 414);
|
|
15836
16387
|
const articlesInfo = ParsePublishPage(rawArticlesInfo);
|
|
15837
16388
|
let articleCell = [];
|
|
15838
16389
|
if (!onlySuccess && pageSize > 20) {
|
|
@@ -15994,7 +16545,7 @@ async function handleXiaohongshuData(_task, params) {
|
|
|
15994
16545
|
const a1Cookie = cookies.find((it)=>"a1" === it.name)?.value;
|
|
15995
16546
|
if (!a1Cookie) return {
|
|
15996
16547
|
code: 414,
|
|
15997
|
-
message: "
|
|
16548
|
+
message: "小红书数据获取失败,请检查账号状态",
|
|
15998
16549
|
data: {}
|
|
15999
16550
|
};
|
|
16000
16551
|
if (onlySuccess && 10 !== pageSize) return {
|
|
@@ -16113,7 +16664,7 @@ async function handleXiaohongshuData(_task, params) {
|
|
|
16113
16664
|
}, "小红书文章数据获取成功");
|
|
16114
16665
|
}
|
|
16115
16666
|
const FetchArticlesParamsSchema = ActionCommonParamsSchema.extend({
|
|
16116
|
-
platform: schemas_string().describe("社交平台:weixin, toutiao, baijiahao, xiaohongshu"),
|
|
16667
|
+
platform: schemas_string().describe("社交平台:weixin, toutiao, baijiahao, xiaohongshu, douyin, shipinhao"),
|
|
16117
16668
|
token: union([
|
|
16118
16669
|
schemas_string(),
|
|
16119
16670
|
schemas_number()
|
|
@@ -16125,7 +16676,14 @@ const FetchArticlesParamsSchema = ActionCommonParamsSchema.extend({
|
|
|
16125
16676
|
showOriginalData: schemas_boolean().optional().describe("是否展示原始数据,默认false"),
|
|
16126
16677
|
cursor: schemas_number().optional().describe("仅用于微信分页游标,默认为空"),
|
|
16127
16678
|
lastPage: schemas_number().optional(),
|
|
16128
|
-
containsArticle: schemas_boolean().optional().describe("是否包含文章内容,默认false")
|
|
16679
|
+
containsArticle: schemas_boolean().optional().describe("是否包含文章内容,默认false"),
|
|
16680
|
+
status: schemas_number().optional().describe("抖音作品状态:0=全部"),
|
|
16681
|
+
includeAccount: schemas_boolean().optional().describe("是否包含账号数据,默认true"),
|
|
16682
|
+
postType: schemas_enum([
|
|
16683
|
+
"video",
|
|
16684
|
+
"article",
|
|
16685
|
+
"all"
|
|
16686
|
+
]).optional().describe("视频号作品类型:video=视频, article=图文, all=全部")
|
|
16129
16687
|
});
|
|
16130
16688
|
const FetchArticles = async (_task, params)=>{
|
|
16131
16689
|
const { platform } = params;
|
|
@@ -16138,6 +16696,10 @@ const FetchArticles = async (_task, params)=>{
|
|
|
16138
16696
|
return handleBaijiahaoData(_task, params);
|
|
16139
16697
|
case "xiaohongshu":
|
|
16140
16698
|
return handleXiaohongshuData(_task, params);
|
|
16699
|
+
case "douyin":
|
|
16700
|
+
return handleDouyinData(_task, params);
|
|
16701
|
+
case "shipinhao":
|
|
16702
|
+
return handleShipinhaoData(_task, params);
|
|
16141
16703
|
default:
|
|
16142
16704
|
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)({}, "暂不支持该平台");
|
|
16143
16705
|
}
|
|
@@ -17541,6 +18103,11 @@ class VideoChannelUploader {
|
|
|
17541
18103
|
this.concurrentLimit = config.concurrentLimit || 4;
|
|
17542
18104
|
this.singleFileSize = config.singleFileSize || 10485760;
|
|
17543
18105
|
this.http = config.http || new Http();
|
|
18106
|
+
this.reqOptions = {
|
|
18107
|
+
timeout: config.timeout ?? 60000,
|
|
18108
|
+
retries: config.retries ?? 3,
|
|
18109
|
+
retryDelay: config.retryDelay ?? 2000
|
|
18110
|
+
};
|
|
17544
18111
|
}
|
|
17545
18112
|
calculateMd5(buffer) {
|
|
17546
18113
|
const MAX_SIZE = 5242880;
|
|
@@ -17597,7 +18164,7 @@ class VideoChannelUploader {
|
|
|
17597
18164
|
url: filePath,
|
|
17598
18165
|
method: "get",
|
|
17599
18166
|
responseType: "arraybuffer"
|
|
17600
|
-
});
|
|
18167
|
+
}, this.reqOptions);
|
|
17601
18168
|
return Buffer.from(resp);
|
|
17602
18169
|
}
|
|
17603
18170
|
return __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].promises.readFile(filePath);
|
|
@@ -17627,7 +18194,7 @@ class VideoChannelUploader {
|
|
|
17627
18194
|
headers,
|
|
17628
18195
|
data: requestBody,
|
|
17629
18196
|
defaultErrorMsg: "获取UploadID失败"
|
|
17630
|
-
});
|
|
18197
|
+
}, this.reqOptions);
|
|
17631
18198
|
if (!resp?.UploadID) throw new Error(`获取 UploadID 失败: ${resp?.errMsg || "未知错误"}`);
|
|
17632
18199
|
return resp.UploadID;
|
|
17633
18200
|
}
|
|
@@ -17648,7 +18215,7 @@ class VideoChannelUploader {
|
|
|
17648
18215
|
headers,
|
|
17649
18216
|
data: chunk,
|
|
17650
18217
|
defaultErrorMsg: `分片 ${partNumber} 上传失败`
|
|
17651
|
-
});
|
|
18218
|
+
}, this.reqOptions);
|
|
17652
18219
|
if (resp?.errCode !== void 0 && 0 !== resp.errCode) throw new Error(`分片 ${partNumber} 上传失败: ${resp.errMsg}`);
|
|
17653
18220
|
if (onProgress) onProgress(chunk.length);
|
|
17654
18221
|
return resp.ETag || "";
|
|
@@ -17672,7 +18239,7 @@ class VideoChannelUploader {
|
|
|
17672
18239
|
headers,
|
|
17673
18240
|
data: requestBody,
|
|
17674
18241
|
defaultErrorMsg: "确认分片上传失败"
|
|
17675
|
-
});
|
|
18242
|
+
}, this.reqOptions);
|
|
17676
18243
|
if (resp?.ListPartsResult?.Part) return resp.ListPartsResult.Part.map((p)=>({
|
|
17677
18244
|
PartNumber: parseInt(p.PartNumber),
|
|
17678
18245
|
ETag: p.ETag
|
|
@@ -17698,7 +18265,7 @@ class VideoChannelUploader {
|
|
|
17698
18265
|
headers,
|
|
17699
18266
|
data: requestBody,
|
|
17700
18267
|
defaultErrorMsg: "完成上传失败"
|
|
17701
|
-
});
|
|
18268
|
+
}, this.reqOptions);
|
|
17702
18269
|
if (!resp?.DownloadURL) throw new Error(`完成上传失败: ${resp?.errMsg || "未知错误"}`);
|
|
17703
18270
|
return resp.DownloadURL;
|
|
17704
18271
|
}
|
|
@@ -18049,7 +18616,9 @@ const shipinhaoPublish_mock_mockAction = async (task, params)=>{
|
|
|
18049
18616
|
task.logger.info("[shipinhaoPublish] 开始执行视频号发布 - Mock API 方式");
|
|
18050
18617
|
const updateTaskState = task.taskStageStore?.update?.bind(task.taskStageStore, task.taskId || "");
|
|
18051
18618
|
if (!params.extraParam.fingerPrintDeviceId || !params.extraParam.aId) return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(400, "fingerPrintDeviceId和aId 不能为空", "");
|
|
18619
|
+
let currentStep = "初始化";
|
|
18052
18620
|
try {
|
|
18621
|
+
currentStep = "解析认证信息";
|
|
18053
18622
|
const cookieString = params.cookies.map((c)=>`${c.name}=${c.value}`).join("; ");
|
|
18054
18623
|
const fingerPrintDeviceId = params.extraParam.fingerPrintDeviceId;
|
|
18055
18624
|
const aId = params.extraParam.aId;
|
|
@@ -18070,8 +18639,10 @@ const shipinhaoPublish_mock_mockAction = async (task, params)=>{
|
|
|
18070
18639
|
headers
|
|
18071
18640
|
});
|
|
18072
18641
|
const proxyHttp = new Http(...args);
|
|
18642
|
+
currentStep = "验证发布参数";
|
|
18073
18643
|
if (!params.banners || 0 === params.banners.length) return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(400, "至少需要一张图片", "");
|
|
18074
18644
|
const images = params.banners.slice(0, 18).filter((img)=>"string" == typeof img);
|
|
18645
|
+
currentStep = "获取用户信息";
|
|
18075
18646
|
task.logger.info("[shipinhaoPublish] 获取用户信息...");
|
|
18076
18647
|
console.log("cookieString", cookieString);
|
|
18077
18648
|
const userInfo = await mock_getUserInfo(cookieString, http);
|
|
@@ -18082,6 +18653,7 @@ const shipinhaoPublish_mock_mockAction = async (task, params)=>{
|
|
|
18082
18653
|
}
|
|
18083
18654
|
const finderUsername = userInfo.data.finderUser.finderUsername;
|
|
18084
18655
|
console.log(finderUsername);
|
|
18656
|
+
currentStep = "获取上传认证密钥";
|
|
18085
18657
|
task.logger.info("[shipinhaoPublish] 获取上传认证密钥...");
|
|
18086
18658
|
const authKeyResponse = await getUploadAuthKey(cookieString, finderUsername, http);
|
|
18087
18659
|
if (0 !== authKeyResponse.errCode || !authKeyResponse.data?.authKey) return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(authKeyResponse.errCode || 500, `获取上传认证参数失败: ${authKeyResponse.errMsg}`, "");
|
|
@@ -18089,10 +18661,12 @@ const shipinhaoPublish_mock_mockAction = async (task, params)=>{
|
|
|
18089
18661
|
const uin = authKeyResponse.data.uin;
|
|
18090
18662
|
if (!uin) return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(500, "获取用户 uin 失败", "");
|
|
18091
18663
|
const taskId = String(generateUUID());
|
|
18664
|
+
currentStep = "上传图片";
|
|
18092
18665
|
task.logger.info(`[shipinhaoPublish] 开始上传 ${images.length} 张图片...`);
|
|
18093
18666
|
const uploadedImages = [];
|
|
18094
18667
|
for(let i = 0; i < images.length; i++){
|
|
18095
|
-
|
|
18668
|
+
currentStep = `上传图片 ${i + 1}/${images.length}`;
|
|
18669
|
+
task.logger.info(`[shipinhaoPublish] ${currentStep}...`);
|
|
18096
18670
|
const uploadResult = await uploadImageComplete(images[i], taskId, finderUsername, uin, authKey, http);
|
|
18097
18671
|
console.log(JSON.stringify(uploadResult));
|
|
18098
18672
|
if (!uploadResult.DownloadURL) return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(500, `图片上传失败: ${uploadResult.errMsg}`, "");
|
|
@@ -18109,6 +18683,7 @@ const shipinhaoPublish_mock_mockAction = async (task, params)=>{
|
|
|
18109
18683
|
urlCdnTaskId: ""
|
|
18110
18684
|
});
|
|
18111
18685
|
}
|
|
18686
|
+
currentStep = "发布图文内容";
|
|
18112
18687
|
task.logger.info("[shipinhaoPublish] 正在发布...");
|
|
18113
18688
|
const topicNames = params.topic || void 0;
|
|
18114
18689
|
const addressInfo = params.address ? {
|
|
@@ -18195,9 +18770,15 @@ const shipinhaoPublish_mock_mockAction = async (task, params)=>{
|
|
|
18195
18770
|
});
|
|
18196
18771
|
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(resultCode || 500, errorMessage, "");
|
|
18197
18772
|
} catch (error) {
|
|
18198
|
-
const
|
|
18199
|
-
|
|
18200
|
-
|
|
18773
|
+
const handledError = Http.handleApiError(error);
|
|
18774
|
+
const errorMsg = handledError.message || "发布失败,请稍后重试";
|
|
18775
|
+
const errorCode = handledError.code || 500;
|
|
18776
|
+
task.logger.error(`[shipinhaoPublish] 发布流程异常: ${errorMsg}`, stringifyError(error), handledError.extra);
|
|
18777
|
+
await updateTaskState?.({
|
|
18778
|
+
state: __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.TaskState.FAILED,
|
|
18779
|
+
error: errorMsg
|
|
18780
|
+
});
|
|
18781
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(errorCode, errorMsg, "");
|
|
18201
18782
|
}
|
|
18202
18783
|
};
|
|
18203
18784
|
const shipinhaoPublish_rpa_rpaAction = async (task, params)=>{
|
|
@@ -22712,8 +23293,8 @@ const xiaohongshuPublish_mock_mockAction = async (task, params)=>{
|
|
|
22712
23293
|
params: fetchCoverParams
|
|
22713
23294
|
}, {
|
|
22714
23295
|
retries: 3,
|
|
22715
|
-
retryDelay:
|
|
22716
|
-
timeout:
|
|
23296
|
+
retryDelay: 500,
|
|
23297
|
+
timeout: 30000
|
|
22717
23298
|
});
|
|
22718
23299
|
for (const item of batchCoverIdInfo?.data?.uploadTempPermits ?? [])for (const fileId of item.fileIds)uploadInfos.push({
|
|
22719
23300
|
bucket: item.bucket || "",
|
|
@@ -22732,8 +23313,8 @@ const xiaohongshuPublish_mock_mockAction = async (task, params)=>{
|
|
|
22732
23313
|
params: fetchCoverParams
|
|
22733
23314
|
}, {
|
|
22734
23315
|
retries: 3,
|
|
22735
|
-
retryDelay:
|
|
22736
|
-
timeout:
|
|
23316
|
+
retryDelay: 500,
|
|
23317
|
+
timeout: 30000
|
|
22737
23318
|
});
|
|
22738
23319
|
for (const item of coverIdInfo?.data?.uploadTempPermits ?? [])for (const fileId of item.fileIds)uploadInfos.push({
|
|
22739
23320
|
bucket: item.bucket || "",
|
|
@@ -22794,7 +23375,9 @@ const xiaohongshuPublish_mock_mockAction = async (task, params)=>{
|
|
|
22794
23375
|
headers: {
|
|
22795
23376
|
"x-cos-security-token": ossToken
|
|
22796
23377
|
},
|
|
22797
|
-
defaultErrorMsg: "
|
|
23378
|
+
defaultErrorMsg: "图片上传异常,请稍后重试。"
|
|
23379
|
+
}, {
|
|
23380
|
+
timeout: 60000
|
|
22798
23381
|
});
|
|
22799
23382
|
return {
|
|
22800
23383
|
ossFileId,
|
|
@@ -22804,6 +23387,8 @@ const xiaohongshuPublish_mock_mockAction = async (task, params)=>{
|
|
|
22804
23387
|
originSize
|
|
22805
23388
|
};
|
|
22806
23389
|
} catch (error) {
|
|
23390
|
+
const e = Http.handleApiError(error);
|
|
23391
|
+
task.logger.warn(`[xhs upload] 第${attempt + 1}次失败 index=${index} bucket=${ossBucketIndex} domain=${ossDomain} fileId=${ossFileId} code=${e.code} msg=${e.message} data=${stringifyError(e.data)}`);
|
|
22807
23392
|
attempt++;
|
|
22808
23393
|
}
|
|
22809
23394
|
}
|
|
@@ -23783,8 +24368,8 @@ const rpaAction_Server_Mock = async (task, params)=>{
|
|
|
23783
24368
|
params: fetchCoverParams
|
|
23784
24369
|
}, {
|
|
23785
24370
|
retries: 3,
|
|
23786
|
-
retryDelay:
|
|
23787
|
-
timeout:
|
|
24371
|
+
retryDelay: 500,
|
|
24372
|
+
timeout: 8000
|
|
23788
24373
|
});
|
|
23789
24374
|
for (const item of batchCoverIdInfo?.data?.uploadTempPermits ?? [])for (const fileId of item?.fileIds ?? [])uploadInfos.push({
|
|
23790
24375
|
bucket: item.bucket || "",
|
|
@@ -23803,8 +24388,8 @@ const rpaAction_Server_Mock = async (task, params)=>{
|
|
|
23803
24388
|
params: fetchCoverParams
|
|
23804
24389
|
}, {
|
|
23805
24390
|
retries: 3,
|
|
23806
|
-
retryDelay:
|
|
23807
|
-
timeout:
|
|
24391
|
+
retryDelay: 500,
|
|
24392
|
+
timeout: 8000
|
|
23808
24393
|
});
|
|
23809
24394
|
for (const item of coverIdInfo?.data?.uploadTempPermits ?? [])for (const fileId of item?.fileIds ?? [])uploadInfos.push({
|
|
23810
24395
|
bucket: item.bucket || "",
|
|
@@ -23849,6 +24434,8 @@ const rpaAction_Server_Mock = async (task, params)=>{
|
|
|
23849
24434
|
"x-cos-security-token": ossToken
|
|
23850
24435
|
},
|
|
23851
24436
|
defaultErrorMsg: "图片上传异常,请稍后重试发布。"
|
|
24437
|
+
}, {
|
|
24438
|
+
timeout: 60000
|
|
23852
24439
|
});
|
|
23853
24440
|
return {
|
|
23854
24441
|
ossFileId,
|
|
@@ -24703,6 +25290,24 @@ const bjhConfigDataSchema = schemas_object({
|
|
|
24703
25290
|
likeNumYesterday: schemas_number().nullable(),
|
|
24704
25291
|
commentNumYesterday: schemas_number().nullable()
|
|
24705
25292
|
});
|
|
25293
|
+
const douyinConfigDataSchema = schemas_object({
|
|
25294
|
+
fansNum: schemas_number(),
|
|
25295
|
+
favedNum: schemas_number(),
|
|
25296
|
+
fansNumLastWeek: schemas_number(),
|
|
25297
|
+
watchNumLastWeek: schemas_number(),
|
|
25298
|
+
likeNumLastWeek: schemas_number(),
|
|
25299
|
+
commentNumLastWeek: schemas_number(),
|
|
25300
|
+
shareNumLastWeek: schemas_number(),
|
|
25301
|
+
visitNumLastWeek: schemas_number()
|
|
25302
|
+
});
|
|
25303
|
+
const shipinhaoConfigDataSchema = schemas_object({
|
|
25304
|
+
fansNum: schemas_number(),
|
|
25305
|
+
feedsCount: schemas_number(),
|
|
25306
|
+
fansNumYesterday: schemas_number().nullable(),
|
|
25307
|
+
playNumYesterday: schemas_number().nullable(),
|
|
25308
|
+
likeNumYesterday: schemas_number().nullable(),
|
|
25309
|
+
commentNumYesterday: schemas_number().nullable()
|
|
25310
|
+
});
|
|
24706
25311
|
const BetaFlag = "HuiwenCanary";
|
|
24707
25312
|
class Action {
|
|
24708
25313
|
constructor(task){
|
|
@@ -24985,6 +25590,6 @@ class Action {
|
|
|
24985
25590
|
}
|
|
24986
25591
|
}
|
|
24987
25592
|
var __webpack_exports__version = package_namespaceObject.i8;
|
|
24988
|
-
export { Action, ActionCommonParamsSchema, BaijiahaoPublishParamsSchema, BetaFlag, CollectionDetailSchema, ConfigDataSchema, DouyinCheckVerifyQrCodeParamsSchema, DouyinCreateCommentReplyParamsSchema, DouyinGetCollectionParamsSchema, DouyinGetCommentListParamsSchema, DouyinGetCommentReplyListParamsSchema, DouyinGetHotParamsSchema, DouyinGetLocationParamsSchema, DouyinGetMusicByCategoryParamsSchema, DouyinGetMusicCategoryParamsSchema, DouyinGetMusicParamsSchema, DouyinGetTopicsParamsSchema, DouyinGetVerifyQrCodeParamsSchema, DouyinGetWorkListParamsSchema, DouyinPublishParamsSchema, FetchArticlesDataSchema, FetchArticlesParamsSchema, Http, ProxyAgent, SearchAccountInfoParamsSchema, SessionCheckResultSchema, ShipinhaoCheckLinkValidateParamsSchema, ShipinhaoGetLocationParamsSchema, ShipinhaoGetMsgParamsSchema, ShipinhaoPublishParamsSchema, ShipinhaoSendMsgParamsSchema, ToutiaoPublishParamsSchema, UnreadCountSchema, WeixinPublishParamsSchema, WxBjhSessionParamsSchema, XhsWebSearchParamsSchema, XiaohongshuPublishParamsSchema, bjhConfigDataSchema, getFileState, reportLogger, rpaAction_Server_Mock, ttConfigDataSchema, wxConfigDataSchema, xhsConfigDataSchema, __webpack_exports__version as version };
|
|
25593
|
+
export { Action, ActionCommonParamsSchema, BaijiahaoPublishParamsSchema, BetaFlag, CollectionDetailSchema, ConfigDataSchema, DouyinCheckVerifyQrCodeParamsSchema, DouyinCreateCommentReplyParamsSchema, DouyinGetCollectionParamsSchema, DouyinGetCommentListParamsSchema, DouyinGetCommentReplyListParamsSchema, DouyinGetHotParamsSchema, DouyinGetLocationParamsSchema, DouyinGetMusicByCategoryParamsSchema, DouyinGetMusicCategoryParamsSchema, DouyinGetMusicParamsSchema, DouyinGetTopicsParamsSchema, DouyinGetVerifyQrCodeParamsSchema, DouyinGetWorkListParamsSchema, DouyinPublishParamsSchema, FetchArticlesDataSchema, FetchArticlesParamsSchema, Http, ProxyAgent, SearchAccountInfoParamsSchema, SessionCheckResultSchema, ShipinhaoCheckLinkValidateParamsSchema, ShipinhaoGetLocationParamsSchema, ShipinhaoGetMsgParamsSchema, ShipinhaoPublishParamsSchema, ShipinhaoSendMsgParamsSchema, ToutiaoPublishParamsSchema, UnreadCountSchema, WeixinPublishParamsSchema, WxBjhSessionParamsSchema, XhsWebSearchParamsSchema, XiaohongshuPublishParamsSchema, bjhConfigDataSchema, douyinConfigDataSchema, getFileState, reportLogger, rpaAction_Server_Mock, shipinhaoConfigDataSchema, ttConfigDataSchema, wxConfigDataSchema, xhsConfigDataSchema, __webpack_exports__version as version };
|
|
24989
25594
|
|
|
24990
25595
|
//# sourceMappingURL=index.mjs.map
|