@iflyrpa/actions 4.0.4-beta.1 → 4.0.4-beta.3
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/shipinhaoPublish/uploader.d.ts +4 -0
- package/dist/bundle.js +423 -377
- package/dist/bundle.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +422 -376
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +421 -377
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="8b4e45ee-5a8e-53e3-b9eb-aaddbf5aef36")}catch(e){}}();
|
|
1
3
|
import * as __WEBPACK_EXTERNAL_MODULE_crypto__ from "crypto";
|
|
2
4
|
import * as __WEBPACK_EXTERNAL_MODULE_fs__ from "fs";
|
|
3
5
|
import * as __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_package_json_58ae5f06__ from "@iflyrpa/share/package.json";
|
|
@@ -4350,7 +4352,7 @@ function __webpack_require__(moduleId) {
|
|
|
4350
4352
|
return module;
|
|
4351
4353
|
};
|
|
4352
4354
|
})();
|
|
4353
|
-
var package_namespaceObject = JSON.parse('{"i8":"4.0.4-beta.
|
|
4355
|
+
var package_namespaceObject = JSON.parse('{"i8":"4.0.4-beta.3"}');
|
|
4354
4356
|
const PROXY_CREDENTIALS = [
|
|
4355
4357
|
{
|
|
4356
4358
|
ip: "47.110.131.129",
|
|
@@ -4583,11 +4585,12 @@ class Http {
|
|
|
4583
4585
|
this.logger?.debug(`未处理的网络错误代码: ${error.code} ${error.message}`, {
|
|
4584
4586
|
errorString: stringifyError(error)
|
|
4585
4587
|
});
|
|
4586
|
-
_message =
|
|
4588
|
+
_message = `网络错误: ${error.message}`;
|
|
4587
4589
|
break;
|
|
4588
4590
|
}
|
|
4589
4591
|
}
|
|
4590
|
-
|
|
4592
|
+
if (error.code && !error.response?.data) errorResponse.message = _message || errorResponse.message;
|
|
4593
|
+
else errorResponse.message = errorResponse.message ? errorResponse.message : _message;
|
|
4591
4594
|
if ("canceled" === errorResponse.message) {
|
|
4592
4595
|
const message = errorResponse.extra?.isProxyRequest ? "代理连接建立超时,请更换区域或稍后重试!" : "网络请求超时,请稍后重试!";
|
|
4593
4596
|
errorResponse.message = message;
|
|
@@ -13365,400 +13368,421 @@ function generateRandomString(length) {
|
|
|
13365
13368
|
}
|
|
13366
13369
|
return randomString;
|
|
13367
13370
|
}
|
|
13371
|
+
function safeSerialize(obj) {
|
|
13372
|
+
if (!obj || "object" != typeof obj) return obj;
|
|
13373
|
+
try {
|
|
13374
|
+
return JSON.parse(JSON.stringify(obj));
|
|
13375
|
+
} catch (error) {
|
|
13376
|
+
return {};
|
|
13377
|
+
}
|
|
13378
|
+
}
|
|
13368
13379
|
const mock_mockAction = async (task, params)=>{
|
|
13369
13380
|
const updateTaskState = task.taskStageStore?.update?.bind(task.taskStageStore, task.taskId || "");
|
|
13370
13381
|
if (!params.extraParam || !params.extraParam["security-sdk/s_sdk_pri_key"] || !params.extraParam["security-sdk/s_sdk_pub_key"] || !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 参数缺失或不完整", "");
|
|
13371
|
-
|
|
13372
|
-
|
|
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
|
-
|
|
13382
|
+
let currentStep = "初始化";
|
|
13383
|
+
try {
|
|
13384
|
+
currentStep = "验证账号信息";
|
|
13385
|
+
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";
|
|
13386
|
+
const sessionidCookie = params.cookies.find((it)=>"msToken" === it.name)?.value;
|
|
13387
|
+
if (!sessionidCookie) return {
|
|
13388
|
+
code: 414,
|
|
13389
|
+
message: "账号数据异常,请重新绑定账号后重试。",
|
|
13390
|
+
data: ""
|
|
13391
|
+
};
|
|
13392
|
+
currentStep = "准备请求参数";
|
|
13393
|
+
const headers = {
|
|
13394
|
+
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
13395
|
+
origin: "https://creator.douyin.com",
|
|
13396
|
+
referer: "https://creator.douyin.com/creator-micro/content/post/image?default-tab=3&enter_from=publish_page&media_type=image&type=new",
|
|
13397
|
+
Accept: "application/json, text/plain, */*",
|
|
13398
|
+
"Accept-Encoding": "gzip, deflate, br, zstd",
|
|
13399
|
+
"Content-Type": "application/json",
|
|
13400
|
+
pragma: "no-cache",
|
|
13401
|
+
"cache-control": "no-cache",
|
|
13402
|
+
"sec-ch-ua-platform": params.extraParam?.browserInfo?.["sec-ch-ua-platform"] || "",
|
|
13403
|
+
"sec-ch-ua": params.extraParam?.browserInfo?.["sec-ch-ua"] || "",
|
|
13404
|
+
"bd-ticket-guard-web-version": "2",
|
|
13405
|
+
"sec-ch-ua-mobile": "?0",
|
|
13406
|
+
"user-agent": userAgent,
|
|
13407
|
+
"sec-fetch-site": "same-origin",
|
|
13408
|
+
"sec-fetch-mode": "cors",
|
|
13409
|
+
"sec-fetch-dest": "empty",
|
|
13410
|
+
"accept-language": "zh-CN,zh;q=0.9",
|
|
13411
|
+
priority: "u=1, i"
|
|
13412
|
+
};
|
|
13413
|
+
const publishParams = {
|
|
13414
|
+
read_aid: "2906",
|
|
13415
|
+
aid: "1128",
|
|
13416
|
+
cookie_enabled: "true",
|
|
13417
|
+
screen_width: params.extraParam?.browserInfo.screen_width || "1920",
|
|
13418
|
+
screen_height: params.extraParam?.browserInfo.screen_height || "1080",
|
|
13419
|
+
browser_language: params.extraParam?.browserInfo.browser_language || "zh-CN",
|
|
13420
|
+
browser_platform: params.extraParam?.browserInfo.browser_platform || "Win32",
|
|
13421
|
+
browser_name: params.extraParam?.browserInfo.browser_name || "Mozilla",
|
|
13422
|
+
browser_version: userAgent,
|
|
13423
|
+
browser_online: "true",
|
|
13424
|
+
timezone_name: "Asia/Shanghai",
|
|
13425
|
+
support_h265: "1",
|
|
13426
|
+
msToken: params.cookies.find((e)=>"msToken" === e.name)?.value || "",
|
|
13427
|
+
a_bogus: ""
|
|
13428
|
+
};
|
|
13429
|
+
task.logger.info(`[douyinPublish] publishParams ${JSON.stringify(publishParams)}`);
|
|
13430
|
+
const publishData = {
|
|
13431
|
+
item: {
|
|
13432
|
+
common: {
|
|
13433
|
+
text: params.content,
|
|
13434
|
+
text_extra: params.textExtra,
|
|
13435
|
+
activity: "[]",
|
|
13436
|
+
challenges: params.challengeIds || "[]",
|
|
13437
|
+
hashtag_source: "",
|
|
13438
|
+
mentions: "[]",
|
|
13439
|
+
music_id: params.musicId || "",
|
|
13440
|
+
music_end_time: 1000 * (params.musicDuration || 0),
|
|
13441
|
+
hot_sentence: params.hotSentence || "",
|
|
13442
|
+
visibility_type: Number(params.visibleRange) || 0,
|
|
13443
|
+
download: params.allowSave ? 1 : 0,
|
|
13444
|
+
timing: params.isImmediatelyPublish ? -1 : params.scheduledPublish,
|
|
13445
|
+
media_type: Number(params.publishType) || 2,
|
|
13446
|
+
images: [],
|
|
13447
|
+
creation_id: ""
|
|
13448
|
+
},
|
|
13449
|
+
cover: {
|
|
13450
|
+
poster: ""
|
|
13451
|
+
},
|
|
13452
|
+
mix: params.mix ? {
|
|
13453
|
+
mix_id: params.mix.mix_id,
|
|
13454
|
+
mix_order: params.mix.mix_order || 0
|
|
13455
|
+
} : {},
|
|
13456
|
+
anchor: {},
|
|
13457
|
+
declare: {
|
|
13458
|
+
user_declare_info: "{}"
|
|
13459
|
+
}
|
|
13460
|
+
}
|
|
13461
|
+
};
|
|
13462
|
+
const args = [
|
|
13463
|
+
{
|
|
13464
|
+
headers
|
|
13436
13465
|
},
|
|
13437
|
-
|
|
13438
|
-
|
|
13439
|
-
|
|
13440
|
-
|
|
13441
|
-
|
|
13442
|
-
|
|
13443
|
-
|
|
13466
|
+
task.logger,
|
|
13467
|
+
"",
|
|
13468
|
+
"",
|
|
13469
|
+
params.accountId,
|
|
13470
|
+
"douyin"
|
|
13471
|
+
];
|
|
13472
|
+
const http = new Http({
|
|
13473
|
+
headers
|
|
13474
|
+
});
|
|
13475
|
+
const proxyHttp = new Http(...args);
|
|
13476
|
+
const uploadedImgList = params.uploadedImgList ? JSON.parse(params.uploadedImgList) : [];
|
|
13477
|
+
if (uploadedImgList.length > 0) publishData.item.common.images = uploadedImgList;
|
|
13478
|
+
else {
|
|
13479
|
+
const tmpCachePath = task.getTmpPath();
|
|
13480
|
+
const uploader = new DouyinImageUploader(proxyHttp, headers, publishParams, tmpCachePath);
|
|
13481
|
+
if (params.coverImage) {
|
|
13482
|
+
const cover = await uploader.uploadCover(params.coverImage);
|
|
13483
|
+
if (cover) {
|
|
13484
|
+
publishData.item.common.images.push({
|
|
13485
|
+
uri: cover.uri,
|
|
13486
|
+
width: cover.width,
|
|
13487
|
+
height: cover.height
|
|
13488
|
+
});
|
|
13489
|
+
publishData.item.cover = {
|
|
13490
|
+
poster: cover.uri
|
|
13491
|
+
};
|
|
13492
|
+
}
|
|
13493
|
+
}
|
|
13494
|
+
if (params.banners && params.banners.length > 0) {
|
|
13495
|
+
const banners = params.banners.filter((i)=>i !== params.coverImage);
|
|
13496
|
+
const uploadResults = await uploader.uploadImages(banners);
|
|
13497
|
+
publishData.item.common.images = publishData.item.common.images.concat(uploadResults.map((result)=>({
|
|
13498
|
+
uri: result.uri,
|
|
13499
|
+
width: result.width,
|
|
13500
|
+
height: result.height
|
|
13501
|
+
})));
|
|
13444
13502
|
}
|
|
13445
13503
|
}
|
|
13446
|
-
|
|
13447
|
-
|
|
13448
|
-
{
|
|
13449
|
-
headers
|
|
13450
|
-
|
|
13451
|
-
|
|
13452
|
-
|
|
13453
|
-
|
|
13454
|
-
|
|
13455
|
-
|
|
13456
|
-
|
|
13457
|
-
|
|
13458
|
-
|
|
13459
|
-
|
|
13460
|
-
|
|
13461
|
-
|
|
13462
|
-
|
|
13463
|
-
|
|
13464
|
-
|
|
13465
|
-
const uploader = new DouyinImageUploader(proxyHttp, headers, publishParams, tmpCachePath);
|
|
13466
|
-
if (params.coverImage) {
|
|
13467
|
-
const cover = await uploader.uploadCover(params.coverImage);
|
|
13468
|
-
if (cover) {
|
|
13469
|
-
publishData.item.common.images.push({
|
|
13470
|
-
uri: cover.uri,
|
|
13471
|
-
width: cover.width,
|
|
13472
|
-
height: cover.height
|
|
13473
|
-
});
|
|
13474
|
-
publishData.item.cover = {
|
|
13475
|
-
poster: cover.uri
|
|
13504
|
+
publishData.item.common.creation_id = generateRandomString(8) + Date.now();
|
|
13505
|
+
let decision = null;
|
|
13506
|
+
proxyHttp.addResponseInterceptor((response)=>{
|
|
13507
|
+
task.logger.info(`[douyinPublish] 拦截器收到响应response.headers: ${JSON.stringify(response.headers)} `);
|
|
13508
|
+
task.logger.info(`[douyinPublish] 拦截器收到响应response.data: ${JSON.stringify(response.data)} `);
|
|
13509
|
+
decision = parseVerifyPassportDecision(response.headers["x-tt-verify-passport-decision"]);
|
|
13510
|
+
if (needsVerification(decision)) {
|
|
13511
|
+
task.logger.info(`[douyinPublish] 检测到需要验证: ${JSON.stringify(decision)}`);
|
|
13512
|
+
return;
|
|
13513
|
+
}
|
|
13514
|
+
if (!response || !response.data) return;
|
|
13515
|
+
const responseData = response.data;
|
|
13516
|
+
if (response && responseData?.status_code && 0 !== responseData.status_code) {
|
|
13517
|
+
const errorCode = 4 === responseData.status_code ? 500 : responseData.status_code;
|
|
13518
|
+
if (4 === responseData.status_code) task.logger.warn(`[douyinPublish] 抖音服务器错误 status_code: 4,映射为 500 触发重试。原始响应: ${JSON.stringify(responseData)}`);
|
|
13519
|
+
return {
|
|
13520
|
+
code: errorCode,
|
|
13521
|
+
message: responseData.status_msg || "文章发布异常,请稍后重试。",
|
|
13522
|
+
data: responseData
|
|
13476
13523
|
};
|
|
13477
13524
|
}
|
|
13525
|
+
});
|
|
13526
|
+
task._timerRecord.PrePublish = Date.now();
|
|
13527
|
+
if (MockPublish) {
|
|
13528
|
+
const data = "123456789";
|
|
13529
|
+
const message = `图文模拟发布成功 ${http.proxyInfo}`;
|
|
13530
|
+
await updateTaskState?.({
|
|
13531
|
+
state: __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.TaskState.SUCCESS,
|
|
13532
|
+
result: {
|
|
13533
|
+
response: data
|
|
13534
|
+
}
|
|
13535
|
+
});
|
|
13536
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(0, message, data);
|
|
13478
13537
|
}
|
|
13479
|
-
|
|
13480
|
-
|
|
13481
|
-
|
|
13482
|
-
|
|
13483
|
-
|
|
13484
|
-
|
|
13485
|
-
|
|
13486
|
-
|
|
13487
|
-
|
|
13488
|
-
|
|
13489
|
-
|
|
13490
|
-
|
|
13491
|
-
|
|
13492
|
-
|
|
13493
|
-
|
|
13494
|
-
|
|
13495
|
-
|
|
13496
|
-
|
|
13497
|
-
|
|
13538
|
+
let webProtectData;
|
|
13539
|
+
try {
|
|
13540
|
+
webProtectData = JSON.parse(JSON.parse(params.extraParam["security-sdk/s_sdk_sign_data_key/web_protect"] || "{}").data || "{}");
|
|
13541
|
+
if (!webProtectData.ticket || !webProtectData.ts_sign || !webProtectData.client_cert) {
|
|
13542
|
+
task.logger.error(`webProtectData 关键字段缺失: ${JSON.stringify(webProtectData)}`);
|
|
13543
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "安全参数 webProtectData 不完整,请重新获取后重试", "");
|
|
13544
|
+
}
|
|
13545
|
+
} catch (error) {
|
|
13546
|
+
task.logger.error(`解析 webProtectData 失败: ${error}`);
|
|
13547
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "安全参数 webProtectData 解析失败,请重新获取后重试", "");
|
|
13548
|
+
}
|
|
13549
|
+
let ticket = webProtectData.ticket;
|
|
13550
|
+
let ts_sign = webProtectData.ts_sign;
|
|
13551
|
+
const serverDataCookie = params.cookies.find((it)=>"bd_ticket_guard_server_data" === it.name)?.value;
|
|
13552
|
+
if (serverDataCookie) try {
|
|
13553
|
+
const decoded = JSON.parse(Buffer.from(decodeURIComponent(serverDataCookie), "base64").toString("utf8"));
|
|
13554
|
+
if (decoded.ticket && decoded.ts_sign) {
|
|
13555
|
+
if (decoded.ticket !== ticket) task.logger.info("[douyinPublish] 使用 cookie 中的最新 ticket(web_protect 已过期)");
|
|
13556
|
+
ticket = decoded.ticket;
|
|
13557
|
+
ts_sign = decoded.ts_sign;
|
|
13558
|
+
}
|
|
13559
|
+
} catch (error) {
|
|
13560
|
+
task.logger.info(`[douyinPublish] 解析 bd_ticket_guard_server_data 失败,回退到 web_protect: ${error}`);
|
|
13498
13561
|
}
|
|
13499
|
-
|
|
13500
|
-
|
|
13501
|
-
|
|
13502
|
-
|
|
13503
|
-
|
|
13504
|
-
|
|
13505
|
-
|
|
13506
|
-
|
|
13507
|
-
|
|
13508
|
-
|
|
13562
|
+
let ec_privateKey;
|
|
13563
|
+
try {
|
|
13564
|
+
ec_privateKey = JSON.parse(JSON.parse(params.extraParam["security-sdk/s_sdk_crypt_sdk"] || "{}").data || "{}").ec_privateKey;
|
|
13565
|
+
if (!ec_privateKey) {
|
|
13566
|
+
task.logger.error("[douyinPublish] ec_privateKey 为空");
|
|
13567
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "安全参数 ec_privateKey 缺失,请重新获取后重试", "");
|
|
13568
|
+
}
|
|
13569
|
+
} catch (error) {
|
|
13570
|
+
task.logger.error(`[douyinPublish] 解析 ec_privateKey 失败: ${error}`);
|
|
13571
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "安全参数 ec_privateKey 解析失败,请重新获取后重试", "");
|
|
13509
13572
|
}
|
|
13510
|
-
|
|
13511
|
-
|
|
13512
|
-
|
|
13513
|
-
|
|
13514
|
-
|
|
13515
|
-
|
|
13516
|
-
state: __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.TaskState.SUCCESS,
|
|
13517
|
-
result: {
|
|
13518
|
-
response: data
|
|
13573
|
+
let certificate;
|
|
13574
|
+
try {
|
|
13575
|
+
certificate = JSON.parse(params.extraParam["security-sdk/s_sdk_server_cert_key"] || "{}").cert;
|
|
13576
|
+
if (!certificate) {
|
|
13577
|
+
task.logger.error("[douyinPublish] certificate 为空");
|
|
13578
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "安全参数 certificate 缺失,请重新获取后重试", "");
|
|
13519
13579
|
}
|
|
13520
|
-
})
|
|
13521
|
-
|
|
13522
|
-
|
|
13523
|
-
let webProtectData;
|
|
13524
|
-
try {
|
|
13525
|
-
webProtectData = JSON.parse(JSON.parse(params.extraParam["security-sdk/s_sdk_sign_data_key/web_protect"] || "{}").data || "{}");
|
|
13526
|
-
if (!webProtectData.ticket || !webProtectData.ts_sign || !webProtectData.client_cert) {
|
|
13527
|
-
task.logger.error(`webProtectData 关键字段缺失: ${JSON.stringify(webProtectData)}`);
|
|
13528
|
-
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "安全参数 webProtectData 不完整,请重新获取后重试", "");
|
|
13580
|
+
} catch (error) {
|
|
13581
|
+
task.logger.error(`[douyinPublish] 解析 certificate 失败: ${error}`);
|
|
13582
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "安全参数 certificate 解析失败,请重新获取后重试", "");
|
|
13529
13583
|
}
|
|
13530
|
-
|
|
13531
|
-
|
|
13532
|
-
|
|
13533
|
-
|
|
13534
|
-
|
|
13535
|
-
|
|
13536
|
-
|
|
13537
|
-
|
|
13538
|
-
|
|
13539
|
-
|
|
13540
|
-
if (
|
|
13541
|
-
|
|
13542
|
-
|
|
13584
|
+
const ree_public_key = webProtectData.client_cert.replace("pub.", "");
|
|
13585
|
+
let bdTicketGuardClientData;
|
|
13586
|
+
try {
|
|
13587
|
+
bdTicketGuardClientData = getBdV2({
|
|
13588
|
+
ticket,
|
|
13589
|
+
ts_sign: ts_sign,
|
|
13590
|
+
ec_privateKey: ec_privateKey,
|
|
13591
|
+
certificate: certificate,
|
|
13592
|
+
bd_ticket_guard_ree_public_key: ree_public_key
|
|
13593
|
+
});
|
|
13594
|
+
if (!bdTicketGuardClientData || !bdTicketGuardClientData["headers_bd_ticket_guard_client_data"]) {
|
|
13595
|
+
task.logger.error(`[douyinPublish] bdTicketGuardClientData 生成失败或不完整: ${JSON.stringify(bdTicketGuardClientData)}`);
|
|
13596
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "安全参数 bdTicketGuardClientData 生成失败,请重新获取后重试", "");
|
|
13597
|
+
}
|
|
13598
|
+
} catch (error) {
|
|
13599
|
+
task.logger.error(`[douyinPublish] 生成 bdTicketGuardClientData 失败: ${error}`);
|
|
13600
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "安全参数 bdTicketGuardClientData 生成异常,请重新获取后重试", "");
|
|
13543
13601
|
}
|
|
13544
|
-
|
|
13545
|
-
|
|
13546
|
-
|
|
13547
|
-
|
|
13548
|
-
|
|
13549
|
-
|
|
13550
|
-
|
|
13551
|
-
|
|
13552
|
-
|
|
13602
|
+
task.logger.info("[douyinPublish] bdTicketGuardClientData 生成成功");
|
|
13603
|
+
const publishQuery = {
|
|
13604
|
+
...publishParams,
|
|
13605
|
+
a_bogus: ""
|
|
13606
|
+
};
|
|
13607
|
+
const queryString = new URLSearchParams(publishQuery).toString();
|
|
13608
|
+
let aBogus;
|
|
13609
|
+
try {
|
|
13610
|
+
aBogus = mock_getABogus(`https://creator.douyin.com/web/api/media/aweme/create_v2/?${queryString}`, publishData, userAgent);
|
|
13611
|
+
if (!aBogus || aBogus.length < 10) {
|
|
13612
|
+
task.logger.error(`[douyinPublish] a_bogus 生成异常,长度过短: ${aBogus}`);
|
|
13613
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "安全参数 a_bogus 生成失败,请重试", "");
|
|
13614
|
+
}
|
|
13615
|
+
} catch (error) {
|
|
13616
|
+
task.logger.error(`[douyinPublish] 生成 a_bogus 失败: ${error}`);
|
|
13617
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "安全参数 a_bogus 生成异常,请重试", "");
|
|
13553
13618
|
}
|
|
13554
|
-
|
|
13555
|
-
|
|
13556
|
-
|
|
13557
|
-
|
|
13558
|
-
|
|
13559
|
-
|
|
13560
|
-
|
|
13561
|
-
|
|
13562
|
-
|
|
13563
|
-
|
|
13619
|
+
publishQuery.a_bogus = aBogus;
|
|
13620
|
+
const publishQueryParams = new URLSearchParams(publishQuery).toString();
|
|
13621
|
+
let csrfToken;
|
|
13622
|
+
try {
|
|
13623
|
+
csrfToken = mock_generateCsrfTokenAdvanced({
|
|
13624
|
+
cookies: params.cookies,
|
|
13625
|
+
url: "https://creator.douyin.com/web/api/media/aweme/create_v2/",
|
|
13626
|
+
method: "POST",
|
|
13627
|
+
userAgent
|
|
13628
|
+
});
|
|
13629
|
+
if (!csrfToken || csrfToken.length < 10) {
|
|
13630
|
+
task.logger.error(`[douyinPublish] csrfToken 生成异常,长度过短: ${csrfToken}`);
|
|
13631
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "安全参数 csrfToken 生成失败,请重试", "");
|
|
13632
|
+
}
|
|
13633
|
+
task.logger.info(`[douyinPublish] csrfToken 生成成功: ${csrfToken.substring(0, 20)}...`);
|
|
13634
|
+
} catch (error) {
|
|
13635
|
+
task.logger.error(`[douyinPublish] 生成 csrfToken 失败: ${error}`);
|
|
13636
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "安全参数 csrfToken 生成异常,请重试", "");
|
|
13564
13637
|
}
|
|
13565
|
-
|
|
13566
|
-
|
|
13567
|
-
|
|
13568
|
-
|
|
13569
|
-
|
|
13570
|
-
|
|
13571
|
-
|
|
13572
|
-
bdTicketGuardClientData = getBdV2({
|
|
13573
|
-
ticket,
|
|
13574
|
-
ts_sign: ts_sign,
|
|
13575
|
-
ec_privateKey: ec_privateKey,
|
|
13576
|
-
certificate: certificate,
|
|
13577
|
-
bd_ticket_guard_ree_public_key: ree_public_key
|
|
13578
|
-
});
|
|
13579
|
-
if (!bdTicketGuardClientData || !bdTicketGuardClientData["headers_bd_ticket_guard_client_data"]) {
|
|
13580
|
-
task.logger.error(`[douyinPublish] bdTicketGuardClientData 生成失败或不完整: ${JSON.stringify(bdTicketGuardClientData)}`);
|
|
13581
|
-
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "安全参数 bdTicketGuardClientData 生成失败,请重新获取后重试", "");
|
|
13638
|
+
let sessionDtrait;
|
|
13639
|
+
try {
|
|
13640
|
+
sessionDtrait = mock_generateDtrait("/web/api/media/aweme/create_v2/");
|
|
13641
|
+
task.logger.info(`[douyinPublish] sessionDtrait 生成成功: ${sessionDtrait || "(空)"}`);
|
|
13642
|
+
} catch (error) {
|
|
13643
|
+
task.logger.error(`[douyinPublish] 生成 sessionDtrait 失败: ${error}`);
|
|
13644
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "安全参数 sessionDtrait 生成异常,请重试", "");
|
|
13582
13645
|
}
|
|
13583
|
-
|
|
13584
|
-
|
|
13585
|
-
|
|
13586
|
-
|
|
13587
|
-
|
|
13588
|
-
|
|
13589
|
-
|
|
13590
|
-
|
|
13591
|
-
|
|
13592
|
-
|
|
13593
|
-
|
|
13594
|
-
|
|
13595
|
-
|
|
13596
|
-
|
|
13597
|
-
|
|
13598
|
-
|
|
13646
|
+
task.logger.info(`[douyinPublish] headers: ${JSON.stringify({
|
|
13647
|
+
...headers,
|
|
13648
|
+
Referer: "https://creator.douyin.com/creator-micro/content/post/image?default-tab=3&enter_from=publish_page&media_type=image&type=new",
|
|
13649
|
+
"Content-Type": "application/json",
|
|
13650
|
+
Accept: "application/json, text/plain, */*",
|
|
13651
|
+
"bd-ticket-guard-client-data": bdTicketGuardClientData["headers_bd_ticket_guard_client_data"],
|
|
13652
|
+
"bd-ticket-guard-ree-public-key": bdTicketGuardClientData["headers_bd_ticket_guard_ree_public_key"],
|
|
13653
|
+
"bd-ticket-guard-version": "2",
|
|
13654
|
+
"bd-ticket-guard-web-sign-type": "1",
|
|
13655
|
+
"bd-ticket-guard-web-version": "2",
|
|
13656
|
+
"x-secsdk-csrf-token": csrfToken,
|
|
13657
|
+
"x-tt-session-dtrait": sessionDtrait || ""
|
|
13658
|
+
})}`);
|
|
13659
|
+
task.logger.info(`[douyinPublish] url: https://creator.douyin.com/web/api/media/aweme/create_v2/?${publishQueryParams}`);
|
|
13660
|
+
let publishResult;
|
|
13661
|
+
try {
|
|
13662
|
+
publishResult = await proxyHttp.api({
|
|
13663
|
+
method: "post",
|
|
13664
|
+
url: `https://creator.douyin.com/web/api/media/aweme/create_v2/?${publishQueryParams}`,
|
|
13665
|
+
data: publishData,
|
|
13666
|
+
defaultErrorMsg: "发布异常,请稍后重试。",
|
|
13667
|
+
headers: {
|
|
13668
|
+
...headers,
|
|
13669
|
+
Referer: "https://creator.douyin.com/creator-micro/content/post/image?default-tab=3&enter_from=publish_page&media_type=image&type=new",
|
|
13670
|
+
"Content-Type": "application/json",
|
|
13671
|
+
Accept: "application/json, text/plain, */*",
|
|
13672
|
+
"bd-ticket-guard-client-data": bdTicketGuardClientData["headers_bd_ticket_guard_client_data"],
|
|
13673
|
+
"bd-ticket-guard-ree-public-key": bdTicketGuardClientData["headers_bd_ticket_guard_ree_public_key"],
|
|
13674
|
+
"bd-ticket-guard-version": "2",
|
|
13675
|
+
"bd-ticket-guard-web-sign-type": "1",
|
|
13676
|
+
"bd-ticket-guard-web-version": "2",
|
|
13677
|
+
"x-secsdk-csrf-token": csrfToken,
|
|
13678
|
+
"x-tt-session-dtrait": sessionDtrait || ""
|
|
13679
|
+
}
|
|
13680
|
+
}, {
|
|
13681
|
+
timeout: 60000,
|
|
13682
|
+
retries: 3,
|
|
13683
|
+
retryDelay: 2000
|
|
13684
|
+
});
|
|
13685
|
+
} catch (error) {
|
|
13686
|
+
const handledError = Http.handleApiError(error);
|
|
13687
|
+
const isProxyOrNetworkError = [
|
|
13688
|
+
599,
|
|
13689
|
+
500,
|
|
13690
|
+
502,
|
|
13691
|
+
503,
|
|
13692
|
+
504
|
|
13693
|
+
].includes(handledError.code);
|
|
13694
|
+
if (isProxyOrNetworkError) {
|
|
13695
|
+
const isProxyRequest = handledError.extra?.isProxyRequest === true;
|
|
13696
|
+
const errorType = 599 === handledError.code || isProxyRequest ? "代理错误" : "网络错误";
|
|
13697
|
+
const message = `图文发布失败,${errorType}:${handledError.message}${task.debug ? ` ${http.proxyInfo}` : ""}`;
|
|
13698
|
+
task.logger.error(`[douyinPublish] ${errorType},直接返回: ${message}`, stringifyError(handledError));
|
|
13699
|
+
await updateTaskState?.({
|
|
13700
|
+
state: __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.TaskState.FAILED,
|
|
13701
|
+
error: message
|
|
13702
|
+
});
|
|
13703
|
+
return {
|
|
13704
|
+
code: 414,
|
|
13705
|
+
data: "",
|
|
13706
|
+
message
|
|
13707
|
+
};
|
|
13708
|
+
}
|
|
13709
|
+
throw error;
|
|
13599
13710
|
}
|
|
13600
|
-
|
|
13601
|
-
|
|
13602
|
-
|
|
13603
|
-
|
|
13604
|
-
|
|
13605
|
-
|
|
13606
|
-
|
|
13607
|
-
|
|
13608
|
-
|
|
13609
|
-
|
|
13610
|
-
|
|
13611
|
-
|
|
13612
|
-
|
|
13613
|
-
|
|
13614
|
-
|
|
13615
|
-
|
|
13616
|
-
|
|
13711
|
+
task.logger.info(`[douyinPublish] decision值: ${JSON.stringify(decision)}, needsVerification(decision): ${needsVerification(decision)}`);
|
|
13712
|
+
if (needsVerification(decision)) {
|
|
13713
|
+
const details = [
|
|
13714
|
+
publishResult.status_msg,
|
|
13715
|
+
decision?.verify_title,
|
|
13716
|
+
decision?.verify_desc
|
|
13717
|
+
].filter(Boolean).join(" ");
|
|
13718
|
+
const message = `图文发布失败,原因:${details}${task.debug ? ` ${http.proxyInfo}` : ""}`;
|
|
13719
|
+
const safeDecision = safeSerialize(decision) ?? {};
|
|
13720
|
+
const mockData = {
|
|
13721
|
+
state: __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.TaskState.FAILED,
|
|
13722
|
+
error: message,
|
|
13723
|
+
result: {
|
|
13724
|
+
...safeDecision,
|
|
13725
|
+
data: safeDecision,
|
|
13726
|
+
uploadedImgList: JSON.stringify(publishData.item.common.images)
|
|
13727
|
+
}
|
|
13728
|
+
};
|
|
13729
|
+
await updateTaskState?.(mockData);
|
|
13730
|
+
return {
|
|
13731
|
+
code: 0,
|
|
13732
|
+
data: mockData,
|
|
13733
|
+
message: "操作成功"
|
|
13734
|
+
};
|
|
13617
13735
|
}
|
|
13618
|
-
|
|
13619
|
-
|
|
13620
|
-
|
|
13621
|
-
|
|
13622
|
-
|
|
13623
|
-
|
|
13624
|
-
|
|
13625
|
-
|
|
13626
|
-
|
|
13627
|
-
|
|
13628
|
-
|
|
13629
|
-
|
|
13630
|
-
|
|
13631
|
-
|
|
13632
|
-
|
|
13633
|
-
|
|
13634
|
-
|
|
13635
|
-
Accept: "application/json, text/plain, */*",
|
|
13636
|
-
"bd-ticket-guard-client-data": bdTicketGuardClientData["headers_bd_ticket_guard_client_data"],
|
|
13637
|
-
"bd-ticket-guard-ree-public-key": bdTicketGuardClientData["headers_bd_ticket_guard_ree_public_key"],
|
|
13638
|
-
"bd-ticket-guard-version": "2",
|
|
13639
|
-
"bd-ticket-guard-web-sign-type": "1",
|
|
13640
|
-
"bd-ticket-guard-web-version": "2",
|
|
13641
|
-
"x-secsdk-csrf-token": csrfToken,
|
|
13642
|
-
"x-tt-session-dtrait": sessionDtrait || ""
|
|
13643
|
-
})}`);
|
|
13644
|
-
task.logger.info(`[douyinPublish] url: https://creator.douyin.com/web/api/media/aweme/create_v2/?${publishQueryParams}`);
|
|
13645
|
-
let publishResult;
|
|
13646
|
-
try {
|
|
13647
|
-
publishResult = await proxyHttp.api({
|
|
13648
|
-
method: "post",
|
|
13649
|
-
url: `https://creator.douyin.com/web/api/media/aweme/create_v2/?${publishQueryParams}`,
|
|
13650
|
-
data: publishData,
|
|
13651
|
-
defaultErrorMsg: "发布异常,请稍后重试。",
|
|
13652
|
-
headers: {
|
|
13653
|
-
...headers,
|
|
13654
|
-
Referer: "https://creator.douyin.com/creator-micro/content/post/image?default-tab=3&enter_from=publish_page&media_type=image&type=new",
|
|
13655
|
-
"Content-Type": "application/json",
|
|
13656
|
-
Accept: "application/json, text/plain, */*",
|
|
13657
|
-
"bd-ticket-guard-client-data": bdTicketGuardClientData["headers_bd_ticket_guard_client_data"],
|
|
13658
|
-
"bd-ticket-guard-ree-public-key": bdTicketGuardClientData["headers_bd_ticket_guard_ree_public_key"],
|
|
13659
|
-
"bd-ticket-guard-version": "2",
|
|
13660
|
-
"bd-ticket-guard-web-sign-type": "1",
|
|
13661
|
-
"bd-ticket-guard-web-version": "2",
|
|
13662
|
-
"x-secsdk-csrf-token": csrfToken,
|
|
13663
|
-
"x-tt-session-dtrait": sessionDtrait || ""
|
|
13664
|
-
}
|
|
13665
|
-
}, {
|
|
13666
|
-
timeout: 60000,
|
|
13667
|
-
retries: 3,
|
|
13668
|
-
retryDelay: 2000
|
|
13669
|
-
});
|
|
13670
|
-
} catch (error) {
|
|
13671
|
-
const handledError = Http.handleApiError(error);
|
|
13672
|
-
const isProxyOrNetworkError = [
|
|
13673
|
-
599,
|
|
13674
|
-
500,
|
|
13675
|
-
502,
|
|
13676
|
-
503,
|
|
13677
|
-
504
|
|
13678
|
-
].includes(handledError.code);
|
|
13679
|
-
if (isProxyOrNetworkError) {
|
|
13680
|
-
const isProxyRequest = handledError.extra?.isProxyRequest === true;
|
|
13681
|
-
const errorType = 599 === handledError.code || isProxyRequest ? "代理错误" : "网络错误";
|
|
13682
|
-
const message = `图文发布失败,${errorType}:${handledError.message}${task.debug ? ` ${http.proxyInfo}` : ""}`;
|
|
13683
|
-
task.logger.error(`[douyinPublish] ${errorType},直接返回: ${message}`, stringifyError(handledError));
|
|
13736
|
+
reportLogger({
|
|
13737
|
+
token: params.huiwenToken || "",
|
|
13738
|
+
enverionment: task.enverionment || "development",
|
|
13739
|
+
postId: params.articleId,
|
|
13740
|
+
eip: proxyHttp.proxyInfo,
|
|
13741
|
+
proxyIp: params.localIP,
|
|
13742
|
+
accountId: params.accountId,
|
|
13743
|
+
uid: params.uid,
|
|
13744
|
+
platform: "douyin",
|
|
13745
|
+
publishParams: publishData
|
|
13746
|
+
});
|
|
13747
|
+
task.logger.info(`[douyinPublish] 发布结果 ${JSON.stringify(publishResult)}`);
|
|
13748
|
+
const isSuccess = 0 === publishResult.status_code;
|
|
13749
|
+
const message = `图文发布${isSuccess ? "成功" : `失败,原因:${publishResult.status_msg} ${decision?.verify_title} ${decision?.verify_desc}`}${task.debug ? ` ${http.proxyInfo}` : ""}`;
|
|
13750
|
+
const data = isSuccess ? publishResult.item_id || "" : "";
|
|
13751
|
+
if (!isSuccess) {
|
|
13752
|
+
const safeDecision = safeSerialize(decision) ?? {};
|
|
13684
13753
|
await updateTaskState?.({
|
|
13685
13754
|
state: __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.TaskState.FAILED,
|
|
13686
|
-
error: message
|
|
13755
|
+
error: message,
|
|
13756
|
+
result: {
|
|
13757
|
+
...safeDecision,
|
|
13758
|
+
data: safeDecision,
|
|
13759
|
+
uploadedImgList: JSON.stringify(publishData.item.common.images)
|
|
13760
|
+
}
|
|
13687
13761
|
});
|
|
13688
13762
|
return {
|
|
13689
13763
|
code: 414,
|
|
13690
|
-
data:
|
|
13764
|
+
data: safeDecision,
|
|
13691
13765
|
message
|
|
13692
13766
|
};
|
|
13693
13767
|
}
|
|
13694
|
-
|
|
13695
|
-
|
|
13696
|
-
task.logger.info(`[douyinPublish] decision值: ${JSON.stringify(decision)}, needsVerification(decision): ${needsVerification(decision)}`);
|
|
13697
|
-
if (needsVerification(decision)) {
|
|
13698
|
-
const details = [
|
|
13699
|
-
publishResult.status_msg,
|
|
13700
|
-
decision?.verify_title,
|
|
13701
|
-
decision?.verify_desc
|
|
13702
|
-
].filter(Boolean).join(" ");
|
|
13703
|
-
const message = `图文发布失败,原因:${details}${task.debug ? ` ${http.proxyInfo}` : ""}`;
|
|
13704
|
-
let decisionObj = {};
|
|
13705
|
-
if (decision) decisionObj = decision;
|
|
13706
|
-
const mockData = {
|
|
13707
|
-
state: __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.TaskState.FAILED,
|
|
13708
|
-
error: message,
|
|
13768
|
+
await updateTaskState?.({
|
|
13769
|
+
state: __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.TaskState.SUCCESS,
|
|
13709
13770
|
result: {
|
|
13710
|
-
|
|
13711
|
-
data: decision,
|
|
13712
|
-
uploadedImgList: JSON.stringify(publishData.item.common.images)
|
|
13771
|
+
response: data
|
|
13713
13772
|
}
|
|
13714
|
-
};
|
|
13715
|
-
|
|
13716
|
-
|
|
13717
|
-
|
|
13718
|
-
|
|
13719
|
-
|
|
13720
|
-
};
|
|
13721
|
-
}
|
|
13722
|
-
reportLogger({
|
|
13723
|
-
token: params.huiwenToken || "",
|
|
13724
|
-
enverionment: task.enverionment || "development",
|
|
13725
|
-
postId: params.articleId,
|
|
13726
|
-
eip: proxyHttp.proxyInfo,
|
|
13727
|
-
proxyIp: params.localIP,
|
|
13728
|
-
accountId: params.accountId,
|
|
13729
|
-
uid: params.uid,
|
|
13730
|
-
platform: "douyin",
|
|
13731
|
-
publishParams: publishData
|
|
13732
|
-
});
|
|
13733
|
-
task.logger.info(`[douyinPublish] 发布结果 ${JSON.stringify(publishResult)}`);
|
|
13734
|
-
const isSuccess = 0 === publishResult.status_code;
|
|
13735
|
-
const message = `图文发布${isSuccess ? "成功" : `失败,原因:${publishResult.status_msg} ${decision?.verify_title} ${decision?.verify_desc}`}${task.debug ? ` ${http.proxyInfo}` : ""}`;
|
|
13736
|
-
const data = isSuccess ? publishResult.item_id || "" : "";
|
|
13737
|
-
if (!isSuccess) {
|
|
13738
|
-
let decisionObj = {};
|
|
13739
|
-
if (decision) decisionObj = decision;
|
|
13773
|
+
});
|
|
13774
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(isSuccess ? 0 : 414, message, data);
|
|
13775
|
+
} catch (error) {
|
|
13776
|
+
const handledError = Http.handleApiError(error);
|
|
13777
|
+
const errorMsg = handledError.message || "发布失败";
|
|
13778
|
+
const errorCode = handledError.code || 500;
|
|
13779
|
+
task.logger.error(`[douyinPublish] 发布流程异常 (步骤: ${currentStep}): ${errorMsg}`, stringifyError(error), handledError.extra);
|
|
13740
13780
|
await updateTaskState?.({
|
|
13741
13781
|
state: __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.TaskState.FAILED,
|
|
13742
|
-
error:
|
|
13743
|
-
result: {
|
|
13744
|
-
...decisionObj,
|
|
13745
|
-
data: decision,
|
|
13746
|
-
uploadedImgList: JSON.stringify(publishData.item.common.images)
|
|
13747
|
-
}
|
|
13782
|
+
error: `${currentStep}失败: ${errorMsg}`
|
|
13748
13783
|
});
|
|
13749
|
-
return
|
|
13750
|
-
code: 414,
|
|
13751
|
-
data,
|
|
13752
|
-
message
|
|
13753
|
-
};
|
|
13784
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(errorCode, errorMsg, "");
|
|
13754
13785
|
}
|
|
13755
|
-
await updateTaskState?.({
|
|
13756
|
-
state: __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.TaskState.SUCCESS,
|
|
13757
|
-
result: {
|
|
13758
|
-
response: data
|
|
13759
|
-
}
|
|
13760
|
-
});
|
|
13761
|
-
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(isSuccess ? 0 : 414, message, data);
|
|
13762
13786
|
};
|
|
13763
13787
|
const douyinPublish_rpa_rpaAction = async (task, params)=>{
|
|
13764
13788
|
const commonCookies = {
|
|
@@ -18017,6 +18041,11 @@ class VideoChannelUploader {
|
|
|
18017
18041
|
this.concurrentLimit = config.concurrentLimit || 4;
|
|
18018
18042
|
this.singleFileSize = config.singleFileSize || 10485760;
|
|
18019
18043
|
this.http = config.http || new Http();
|
|
18044
|
+
this.reqOptions = {
|
|
18045
|
+
timeout: config.timeout ?? 60000,
|
|
18046
|
+
retries: config.retries ?? 3,
|
|
18047
|
+
retryDelay: config.retryDelay ?? 2000
|
|
18048
|
+
};
|
|
18020
18049
|
}
|
|
18021
18050
|
calculateMd5(buffer) {
|
|
18022
18051
|
const MAX_SIZE = 5242880;
|
|
@@ -18073,7 +18102,7 @@ class VideoChannelUploader {
|
|
|
18073
18102
|
url: filePath,
|
|
18074
18103
|
method: "get",
|
|
18075
18104
|
responseType: "arraybuffer"
|
|
18076
|
-
});
|
|
18105
|
+
}, this.reqOptions);
|
|
18077
18106
|
return Buffer.from(resp);
|
|
18078
18107
|
}
|
|
18079
18108
|
return __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].promises.readFile(filePath);
|
|
@@ -18103,7 +18132,7 @@ class VideoChannelUploader {
|
|
|
18103
18132
|
headers,
|
|
18104
18133
|
data: requestBody,
|
|
18105
18134
|
defaultErrorMsg: "获取UploadID失败"
|
|
18106
|
-
});
|
|
18135
|
+
}, this.reqOptions);
|
|
18107
18136
|
if (!resp?.UploadID) throw new Error(`获取 UploadID 失败: ${resp?.errMsg || "未知错误"}`);
|
|
18108
18137
|
return resp.UploadID;
|
|
18109
18138
|
}
|
|
@@ -18124,7 +18153,7 @@ class VideoChannelUploader {
|
|
|
18124
18153
|
headers,
|
|
18125
18154
|
data: chunk,
|
|
18126
18155
|
defaultErrorMsg: `分片 ${partNumber} 上传失败`
|
|
18127
|
-
});
|
|
18156
|
+
}, this.reqOptions);
|
|
18128
18157
|
if (resp?.errCode !== void 0 && 0 !== resp.errCode) throw new Error(`分片 ${partNumber} 上传失败: ${resp.errMsg}`);
|
|
18129
18158
|
if (onProgress) onProgress(chunk.length);
|
|
18130
18159
|
return resp.ETag || "";
|
|
@@ -18148,7 +18177,7 @@ class VideoChannelUploader {
|
|
|
18148
18177
|
headers,
|
|
18149
18178
|
data: requestBody,
|
|
18150
18179
|
defaultErrorMsg: "确认分片上传失败"
|
|
18151
|
-
});
|
|
18180
|
+
}, this.reqOptions);
|
|
18152
18181
|
if (resp?.ListPartsResult?.Part) return resp.ListPartsResult.Part.map((p)=>({
|
|
18153
18182
|
PartNumber: parseInt(p.PartNumber),
|
|
18154
18183
|
ETag: p.ETag
|
|
@@ -18174,7 +18203,7 @@ class VideoChannelUploader {
|
|
|
18174
18203
|
headers,
|
|
18175
18204
|
data: requestBody,
|
|
18176
18205
|
defaultErrorMsg: "完成上传失败"
|
|
18177
|
-
});
|
|
18206
|
+
}, this.reqOptions);
|
|
18178
18207
|
if (!resp?.DownloadURL) throw new Error(`完成上传失败: ${resp?.errMsg || "未知错误"}`);
|
|
18179
18208
|
return resp.DownloadURL;
|
|
18180
18209
|
}
|
|
@@ -18525,7 +18554,9 @@ const shipinhaoPublish_mock_mockAction = async (task, params)=>{
|
|
|
18525
18554
|
task.logger.info("[shipinhaoPublish] 开始执行视频号发布 - Mock API 方式");
|
|
18526
18555
|
const updateTaskState = task.taskStageStore?.update?.bind(task.taskStageStore, task.taskId || "");
|
|
18527
18556
|
if (!params.extraParam.fingerPrintDeviceId || !params.extraParam.aId) return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(400, "fingerPrintDeviceId和aId 不能为空", "");
|
|
18557
|
+
let currentStep = "初始化";
|
|
18528
18558
|
try {
|
|
18559
|
+
currentStep = "解析认证信息";
|
|
18529
18560
|
const cookieString = params.cookies.map((c)=>`${c.name}=${c.value}`).join("; ");
|
|
18530
18561
|
const fingerPrintDeviceId = params.extraParam.fingerPrintDeviceId;
|
|
18531
18562
|
const aId = params.extraParam.aId;
|
|
@@ -18546,8 +18577,10 @@ const shipinhaoPublish_mock_mockAction = async (task, params)=>{
|
|
|
18546
18577
|
headers
|
|
18547
18578
|
});
|
|
18548
18579
|
const proxyHttp = new Http(...args);
|
|
18580
|
+
currentStep = "验证发布参数";
|
|
18549
18581
|
if (!params.banners || 0 === params.banners.length) return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(400, "至少需要一张图片", "");
|
|
18550
18582
|
const images = params.banners.slice(0, 18).filter((img)=>"string" == typeof img);
|
|
18583
|
+
currentStep = "获取用户信息";
|
|
18551
18584
|
task.logger.info("[shipinhaoPublish] 获取用户信息...");
|
|
18552
18585
|
console.log("cookieString", cookieString);
|
|
18553
18586
|
const userInfo = await mock_getUserInfo(cookieString, http);
|
|
@@ -18558,6 +18591,7 @@ const shipinhaoPublish_mock_mockAction = async (task, params)=>{
|
|
|
18558
18591
|
}
|
|
18559
18592
|
const finderUsername = userInfo.data.finderUser.finderUsername;
|
|
18560
18593
|
console.log(finderUsername);
|
|
18594
|
+
currentStep = "获取上传认证密钥";
|
|
18561
18595
|
task.logger.info("[shipinhaoPublish] 获取上传认证密钥...");
|
|
18562
18596
|
const authKeyResponse = await getUploadAuthKey(cookieString, finderUsername, http);
|
|
18563
18597
|
if (0 !== authKeyResponse.errCode || !authKeyResponse.data?.authKey) return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(authKeyResponse.errCode || 500, `获取上传认证参数失败: ${authKeyResponse.errMsg}`, "");
|
|
@@ -18565,10 +18599,12 @@ const shipinhaoPublish_mock_mockAction = async (task, params)=>{
|
|
|
18565
18599
|
const uin = authKeyResponse.data.uin;
|
|
18566
18600
|
if (!uin) return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(500, "获取用户 uin 失败", "");
|
|
18567
18601
|
const taskId = String(generateUUID());
|
|
18602
|
+
currentStep = "上传图片";
|
|
18568
18603
|
task.logger.info(`[shipinhaoPublish] 开始上传 ${images.length} 张图片...`);
|
|
18569
18604
|
const uploadedImages = [];
|
|
18570
18605
|
for(let i = 0; i < images.length; i++){
|
|
18571
|
-
|
|
18606
|
+
currentStep = `上传图片 ${i + 1}/${images.length}`;
|
|
18607
|
+
task.logger.info(`[shipinhaoPublish] ${currentStep}...`);
|
|
18572
18608
|
const uploadResult = await uploadImageComplete(images[i], taskId, finderUsername, uin, authKey, http);
|
|
18573
18609
|
console.log(JSON.stringify(uploadResult));
|
|
18574
18610
|
if (!uploadResult.DownloadURL) return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(500, `图片上传失败: ${uploadResult.errMsg}`, "");
|
|
@@ -18585,6 +18621,7 @@ const shipinhaoPublish_mock_mockAction = async (task, params)=>{
|
|
|
18585
18621
|
urlCdnTaskId: ""
|
|
18586
18622
|
});
|
|
18587
18623
|
}
|
|
18624
|
+
currentStep = "发布图文内容";
|
|
18588
18625
|
task.logger.info("[shipinhaoPublish] 正在发布...");
|
|
18589
18626
|
const topicNames = params.topic || void 0;
|
|
18590
18627
|
const addressInfo = params.address ? {
|
|
@@ -18671,9 +18708,15 @@ const shipinhaoPublish_mock_mockAction = async (task, params)=>{
|
|
|
18671
18708
|
});
|
|
18672
18709
|
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(resultCode || 500, errorMessage, "");
|
|
18673
18710
|
} catch (error) {
|
|
18674
|
-
const
|
|
18675
|
-
|
|
18676
|
-
|
|
18711
|
+
const handledError = Http.handleApiError(error);
|
|
18712
|
+
const errorMsg = handledError.message || "发布失败,请稍后重试";
|
|
18713
|
+
const errorCode = handledError.code || 500;
|
|
18714
|
+
task.logger.error(`[shipinhaoPublish] 发布流程异常: ${errorMsg}`, stringifyError(error), handledError.extra);
|
|
18715
|
+
await updateTaskState?.({
|
|
18716
|
+
state: __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.TaskState.FAILED,
|
|
18717
|
+
error: errorMsg
|
|
18718
|
+
});
|
|
18719
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(errorCode, errorMsg, "");
|
|
18677
18720
|
}
|
|
18678
18721
|
};
|
|
18679
18722
|
const shipinhaoPublish_rpa_rpaAction = async (task, params)=>{
|
|
@@ -25179,7 +25222,7 @@ const bjhConfigDataSchema = schemas_object({
|
|
|
25179
25222
|
likeNumYesterday: schemas_number().nullable(),
|
|
25180
25223
|
commentNumYesterday: schemas_number().nullable()
|
|
25181
25224
|
});
|
|
25182
|
-
schemas_object({
|
|
25225
|
+
const douyinConfigDataSchema = schemas_object({
|
|
25183
25226
|
fansNum: schemas_number(),
|
|
25184
25227
|
favedNum: schemas_number(),
|
|
25185
25228
|
fansNumLastWeek: schemas_number(),
|
|
@@ -25189,7 +25232,7 @@ schemas_object({
|
|
|
25189
25232
|
shareNumLastWeek: schemas_number(),
|
|
25190
25233
|
visitNumLastWeek: schemas_number()
|
|
25191
25234
|
});
|
|
25192
|
-
schemas_object({
|
|
25235
|
+
const shipinhaoConfigDataSchema = schemas_object({
|
|
25193
25236
|
fansNum: schemas_number(),
|
|
25194
25237
|
feedsCount: schemas_number(),
|
|
25195
25238
|
fansNumYesterday: schemas_number().nullable(),
|
|
@@ -25479,6 +25522,7 @@ class Action {
|
|
|
25479
25522
|
}
|
|
25480
25523
|
}
|
|
25481
25524
|
var __webpack_exports__version = package_namespaceObject.i8;
|
|
25482
|
-
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 };
|
|
25525
|
+
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 };
|
|
25483
25526
|
|
|
25484
|
-
//# sourceMappingURL=index.mjs.map
|
|
25527
|
+
//# sourceMappingURL=index.mjs.map
|
|
25528
|
+
//# debugId=8b4e45ee-5a8e-53e3-b9eb-aaddbf5aef36
|