@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.js
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]="6b7b33da-d2a4-5623-b09a-756a2fe8a917")}catch(e){}}();
|
|
1
3
|
var __webpack_modules__ = {
|
|
2
4
|
"./src/utils/XhsXsCommonEnc.js": function(module) {
|
|
3
5
|
var encrypt_lookup = [
|
|
@@ -4394,11 +4396,13 @@ var __webpack_exports__ = {};
|
|
|
4394
4396
|
bjhConfigDataSchema: ()=>bjhConfigDataSchema,
|
|
4395
4397
|
Action: ()=>Action,
|
|
4396
4398
|
ProxyAgent: ()=>ProxyAgent,
|
|
4399
|
+
douyinConfigDataSchema: ()=>douyinConfigDataSchema,
|
|
4400
|
+
shipinhaoConfigDataSchema: ()=>shipinhaoConfigDataSchema,
|
|
4397
4401
|
version: ()=>package_namespaceObject.i8
|
|
4398
4402
|
});
|
|
4399
4403
|
const package_json_namespaceObject = require("@iflyrpa/share/package.json");
|
|
4400
4404
|
var package_json_default = /*#__PURE__*/ __webpack_require__.n(package_json_namespaceObject);
|
|
4401
|
-
var package_namespaceObject = JSON.parse('{"i8":"4.0.4-beta.
|
|
4405
|
+
var package_namespaceObject = JSON.parse('{"i8":"4.0.4-beta.3"}');
|
|
4402
4406
|
const share_namespaceObject = require("@iflyrpa/share");
|
|
4403
4407
|
const external_node_fs_namespaceObject = require("node:fs");
|
|
4404
4408
|
var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
|
|
@@ -4647,11 +4651,12 @@ var __webpack_exports__ = {};
|
|
|
4647
4651
|
this.logger?.debug(`未处理的网络错误代码: ${error.code} ${error.message}`, {
|
|
4648
4652
|
errorString: stringifyError(error)
|
|
4649
4653
|
});
|
|
4650
|
-
_message =
|
|
4654
|
+
_message = `网络错误: ${error.message}`;
|
|
4651
4655
|
break;
|
|
4652
4656
|
}
|
|
4653
4657
|
}
|
|
4654
|
-
|
|
4658
|
+
if (error.code && !error.response?.data) errorResponse.message = _message || errorResponse.message;
|
|
4659
|
+
else errorResponse.message = errorResponse.message ? errorResponse.message : _message;
|
|
4655
4660
|
if ("canceled" === errorResponse.message) {
|
|
4656
4661
|
const message = errorResponse.extra?.isProxyRequest ? "代理连接建立超时,请更换区域或稍后重试!" : "网络请求超时,请稍后重试!";
|
|
4657
4662
|
errorResponse.message = message;
|
|
@@ -13440,400 +13445,421 @@ var __webpack_exports__ = {};
|
|
|
13440
13445
|
}
|
|
13441
13446
|
return randomString;
|
|
13442
13447
|
}
|
|
13448
|
+
function safeSerialize(obj) {
|
|
13449
|
+
if (!obj || "object" != typeof obj) return obj;
|
|
13450
|
+
try {
|
|
13451
|
+
return JSON.parse(JSON.stringify(obj));
|
|
13452
|
+
} catch (error) {
|
|
13453
|
+
return {};
|
|
13454
|
+
}
|
|
13455
|
+
}
|
|
13443
13456
|
const mock_mockAction = async (task, params)=>{
|
|
13444
13457
|
const updateTaskState = task.taskStageStore?.update?.bind(task.taskStageStore, task.taskId || "");
|
|
13445
13458
|
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, share_namespaceObject.response)(414, "extraParam 参数缺失或不完整", "");
|
|
13446
|
-
|
|
13447
|
-
|
|
13448
|
-
|
|
13449
|
-
|
|
13450
|
-
|
|
13451
|
-
|
|
13452
|
-
|
|
13453
|
-
|
|
13454
|
-
|
|
13455
|
-
|
|
13456
|
-
|
|
13457
|
-
|
|
13458
|
-
|
|
13459
|
-
|
|
13460
|
-
|
|
13461
|
-
|
|
13462
|
-
|
|
13463
|
-
|
|
13464
|
-
|
|
13465
|
-
|
|
13466
|
-
|
|
13467
|
-
|
|
13468
|
-
|
|
13469
|
-
|
|
13470
|
-
|
|
13471
|
-
|
|
13472
|
-
|
|
13473
|
-
|
|
13474
|
-
|
|
13475
|
-
|
|
13476
|
-
|
|
13477
|
-
|
|
13478
|
-
|
|
13479
|
-
|
|
13480
|
-
|
|
13481
|
-
|
|
13482
|
-
|
|
13483
|
-
|
|
13484
|
-
|
|
13485
|
-
|
|
13486
|
-
|
|
13487
|
-
|
|
13488
|
-
|
|
13489
|
-
|
|
13490
|
-
|
|
13491
|
-
|
|
13492
|
-
|
|
13493
|
-
|
|
13494
|
-
|
|
13495
|
-
|
|
13496
|
-
|
|
13497
|
-
|
|
13498
|
-
|
|
13499
|
-
|
|
13500
|
-
|
|
13501
|
-
|
|
13502
|
-
|
|
13503
|
-
|
|
13504
|
-
|
|
13505
|
-
|
|
13506
|
-
|
|
13507
|
-
|
|
13508
|
-
|
|
13509
|
-
|
|
13510
|
-
|
|
13459
|
+
let currentStep = "初始化";
|
|
13460
|
+
try {
|
|
13461
|
+
currentStep = "验证账号信息";
|
|
13462
|
+
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";
|
|
13463
|
+
const sessionidCookie = params.cookies.find((it)=>"msToken" === it.name)?.value;
|
|
13464
|
+
if (!sessionidCookie) return {
|
|
13465
|
+
code: 414,
|
|
13466
|
+
message: "账号数据异常,请重新绑定账号后重试。",
|
|
13467
|
+
data: ""
|
|
13468
|
+
};
|
|
13469
|
+
currentStep = "准备请求参数";
|
|
13470
|
+
const headers = {
|
|
13471
|
+
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
13472
|
+
origin: "https://creator.douyin.com",
|
|
13473
|
+
referer: "https://creator.douyin.com/creator-micro/content/post/image?default-tab=3&enter_from=publish_page&media_type=image&type=new",
|
|
13474
|
+
Accept: "application/json, text/plain, */*",
|
|
13475
|
+
"Accept-Encoding": "gzip, deflate, br, zstd",
|
|
13476
|
+
"Content-Type": "application/json",
|
|
13477
|
+
pragma: "no-cache",
|
|
13478
|
+
"cache-control": "no-cache",
|
|
13479
|
+
"sec-ch-ua-platform": params.extraParam?.browserInfo?.["sec-ch-ua-platform"] || "",
|
|
13480
|
+
"sec-ch-ua": params.extraParam?.browserInfo?.["sec-ch-ua"] || "",
|
|
13481
|
+
"bd-ticket-guard-web-version": "2",
|
|
13482
|
+
"sec-ch-ua-mobile": "?0",
|
|
13483
|
+
"user-agent": userAgent,
|
|
13484
|
+
"sec-fetch-site": "same-origin",
|
|
13485
|
+
"sec-fetch-mode": "cors",
|
|
13486
|
+
"sec-fetch-dest": "empty",
|
|
13487
|
+
"accept-language": "zh-CN,zh;q=0.9",
|
|
13488
|
+
priority: "u=1, i"
|
|
13489
|
+
};
|
|
13490
|
+
const publishParams = {
|
|
13491
|
+
read_aid: "2906",
|
|
13492
|
+
aid: "1128",
|
|
13493
|
+
cookie_enabled: "true",
|
|
13494
|
+
screen_width: params.extraParam?.browserInfo.screen_width || "1920",
|
|
13495
|
+
screen_height: params.extraParam?.browserInfo.screen_height || "1080",
|
|
13496
|
+
browser_language: params.extraParam?.browserInfo.browser_language || "zh-CN",
|
|
13497
|
+
browser_platform: params.extraParam?.browserInfo.browser_platform || "Win32",
|
|
13498
|
+
browser_name: params.extraParam?.browserInfo.browser_name || "Mozilla",
|
|
13499
|
+
browser_version: userAgent,
|
|
13500
|
+
browser_online: "true",
|
|
13501
|
+
timezone_name: "Asia/Shanghai",
|
|
13502
|
+
support_h265: "1",
|
|
13503
|
+
msToken: params.cookies.find((e)=>"msToken" === e.name)?.value || "",
|
|
13504
|
+
a_bogus: ""
|
|
13505
|
+
};
|
|
13506
|
+
task.logger.info(`[douyinPublish] publishParams ${JSON.stringify(publishParams)}`);
|
|
13507
|
+
const publishData = {
|
|
13508
|
+
item: {
|
|
13509
|
+
common: {
|
|
13510
|
+
text: params.content,
|
|
13511
|
+
text_extra: params.textExtra,
|
|
13512
|
+
activity: "[]",
|
|
13513
|
+
challenges: params.challengeIds || "[]",
|
|
13514
|
+
hashtag_source: "",
|
|
13515
|
+
mentions: "[]",
|
|
13516
|
+
music_id: params.musicId || "",
|
|
13517
|
+
music_end_time: 1000 * (params.musicDuration || 0),
|
|
13518
|
+
hot_sentence: params.hotSentence || "",
|
|
13519
|
+
visibility_type: Number(params.visibleRange) || 0,
|
|
13520
|
+
download: params.allowSave ? 1 : 0,
|
|
13521
|
+
timing: params.isImmediatelyPublish ? -1 : params.scheduledPublish,
|
|
13522
|
+
media_type: Number(params.publishType) || 2,
|
|
13523
|
+
images: [],
|
|
13524
|
+
creation_id: ""
|
|
13525
|
+
},
|
|
13526
|
+
cover: {
|
|
13527
|
+
poster: ""
|
|
13528
|
+
},
|
|
13529
|
+
mix: params.mix ? {
|
|
13530
|
+
mix_id: params.mix.mix_id,
|
|
13531
|
+
mix_order: params.mix.mix_order || 0
|
|
13532
|
+
} : {},
|
|
13533
|
+
anchor: {},
|
|
13534
|
+
declare: {
|
|
13535
|
+
user_declare_info: "{}"
|
|
13536
|
+
}
|
|
13537
|
+
}
|
|
13538
|
+
};
|
|
13539
|
+
const args = [
|
|
13540
|
+
{
|
|
13541
|
+
headers
|
|
13511
13542
|
},
|
|
13512
|
-
|
|
13513
|
-
|
|
13514
|
-
|
|
13515
|
-
|
|
13516
|
-
|
|
13517
|
-
|
|
13518
|
-
|
|
13543
|
+
task.logger,
|
|
13544
|
+
"",
|
|
13545
|
+
"",
|
|
13546
|
+
params.accountId,
|
|
13547
|
+
"douyin"
|
|
13548
|
+
];
|
|
13549
|
+
const http = new Http({
|
|
13550
|
+
headers
|
|
13551
|
+
});
|
|
13552
|
+
const proxyHttp = new Http(...args);
|
|
13553
|
+
const uploadedImgList = params.uploadedImgList ? JSON.parse(params.uploadedImgList) : [];
|
|
13554
|
+
if (uploadedImgList.length > 0) publishData.item.common.images = uploadedImgList;
|
|
13555
|
+
else {
|
|
13556
|
+
const tmpCachePath = task.getTmpPath();
|
|
13557
|
+
const uploader = new DouyinImageUploader(proxyHttp, headers, publishParams, tmpCachePath);
|
|
13558
|
+
if (params.coverImage) {
|
|
13559
|
+
const cover = await uploader.uploadCover(params.coverImage);
|
|
13560
|
+
if (cover) {
|
|
13561
|
+
publishData.item.common.images.push({
|
|
13562
|
+
uri: cover.uri,
|
|
13563
|
+
width: cover.width,
|
|
13564
|
+
height: cover.height
|
|
13565
|
+
});
|
|
13566
|
+
publishData.item.cover = {
|
|
13567
|
+
poster: cover.uri
|
|
13568
|
+
};
|
|
13569
|
+
}
|
|
13570
|
+
}
|
|
13571
|
+
if (params.banners && params.banners.length > 0) {
|
|
13572
|
+
const banners = params.banners.filter((i)=>i !== params.coverImage);
|
|
13573
|
+
const uploadResults = await uploader.uploadImages(banners);
|
|
13574
|
+
publishData.item.common.images = publishData.item.common.images.concat(uploadResults.map((result)=>({
|
|
13575
|
+
uri: result.uri,
|
|
13576
|
+
width: result.width,
|
|
13577
|
+
height: result.height
|
|
13578
|
+
})));
|
|
13519
13579
|
}
|
|
13520
13580
|
}
|
|
13521
|
-
|
|
13522
|
-
|
|
13523
|
-
{
|
|
13524
|
-
headers
|
|
13525
|
-
|
|
13526
|
-
|
|
13527
|
-
|
|
13528
|
-
|
|
13529
|
-
|
|
13530
|
-
|
|
13531
|
-
|
|
13532
|
-
|
|
13533
|
-
|
|
13534
|
-
|
|
13535
|
-
|
|
13536
|
-
|
|
13537
|
-
|
|
13538
|
-
|
|
13539
|
-
|
|
13540
|
-
const uploader = new DouyinImageUploader(proxyHttp, headers, publishParams, tmpCachePath);
|
|
13541
|
-
if (params.coverImage) {
|
|
13542
|
-
const cover = await uploader.uploadCover(params.coverImage);
|
|
13543
|
-
if (cover) {
|
|
13544
|
-
publishData.item.common.images.push({
|
|
13545
|
-
uri: cover.uri,
|
|
13546
|
-
width: cover.width,
|
|
13547
|
-
height: cover.height
|
|
13548
|
-
});
|
|
13549
|
-
publishData.item.cover = {
|
|
13550
|
-
poster: cover.uri
|
|
13581
|
+
publishData.item.common.creation_id = generateRandomString(8) + Date.now();
|
|
13582
|
+
let decision = null;
|
|
13583
|
+
proxyHttp.addResponseInterceptor((response)=>{
|
|
13584
|
+
task.logger.info(`[douyinPublish] 拦截器收到响应response.headers: ${JSON.stringify(response.headers)} `);
|
|
13585
|
+
task.logger.info(`[douyinPublish] 拦截器收到响应response.data: ${JSON.stringify(response.data)} `);
|
|
13586
|
+
decision = parseVerifyPassportDecision(response.headers["x-tt-verify-passport-decision"]);
|
|
13587
|
+
if (needsVerification(decision)) {
|
|
13588
|
+
task.logger.info(`[douyinPublish] 检测到需要验证: ${JSON.stringify(decision)}`);
|
|
13589
|
+
return;
|
|
13590
|
+
}
|
|
13591
|
+
if (!response || !response.data) return;
|
|
13592
|
+
const responseData = response.data;
|
|
13593
|
+
if (response && responseData?.status_code && 0 !== responseData.status_code) {
|
|
13594
|
+
const errorCode = 4 === responseData.status_code ? 500 : responseData.status_code;
|
|
13595
|
+
if (4 === responseData.status_code) task.logger.warn(`[douyinPublish] 抖音服务器错误 status_code: 4,映射为 500 触发重试。原始响应: ${JSON.stringify(responseData)}`);
|
|
13596
|
+
return {
|
|
13597
|
+
code: errorCode,
|
|
13598
|
+
message: responseData.status_msg || "文章发布异常,请稍后重试。",
|
|
13599
|
+
data: responseData
|
|
13551
13600
|
};
|
|
13552
13601
|
}
|
|
13602
|
+
});
|
|
13603
|
+
task._timerRecord.PrePublish = Date.now();
|
|
13604
|
+
if (MockPublish) {
|
|
13605
|
+
const data = "123456789";
|
|
13606
|
+
const message = `图文模拟发布成功 ${http.proxyInfo}`;
|
|
13607
|
+
await updateTaskState?.({
|
|
13608
|
+
state: share_namespaceObject.TaskState.SUCCESS,
|
|
13609
|
+
result: {
|
|
13610
|
+
response: data
|
|
13611
|
+
}
|
|
13612
|
+
});
|
|
13613
|
+
return (0, share_namespaceObject.response)(0, message, data);
|
|
13553
13614
|
}
|
|
13554
|
-
|
|
13555
|
-
|
|
13556
|
-
|
|
13557
|
-
|
|
13558
|
-
|
|
13559
|
-
|
|
13560
|
-
|
|
13561
|
-
|
|
13562
|
-
|
|
13563
|
-
|
|
13564
|
-
|
|
13565
|
-
|
|
13566
|
-
|
|
13567
|
-
|
|
13568
|
-
|
|
13569
|
-
|
|
13570
|
-
|
|
13571
|
-
|
|
13572
|
-
|
|
13615
|
+
let webProtectData;
|
|
13616
|
+
try {
|
|
13617
|
+
webProtectData = JSON.parse(JSON.parse(params.extraParam["security-sdk/s_sdk_sign_data_key/web_protect"] || "{}").data || "{}");
|
|
13618
|
+
if (!webProtectData.ticket || !webProtectData.ts_sign || !webProtectData.client_cert) {
|
|
13619
|
+
task.logger.error(`webProtectData 关键字段缺失: ${JSON.stringify(webProtectData)}`);
|
|
13620
|
+
return (0, share_namespaceObject.response)(414, "安全参数 webProtectData 不完整,请重新获取后重试", "");
|
|
13621
|
+
}
|
|
13622
|
+
} catch (error) {
|
|
13623
|
+
task.logger.error(`解析 webProtectData 失败: ${error}`);
|
|
13624
|
+
return (0, share_namespaceObject.response)(414, "安全参数 webProtectData 解析失败,请重新获取后重试", "");
|
|
13625
|
+
}
|
|
13626
|
+
let ticket = webProtectData.ticket;
|
|
13627
|
+
let ts_sign = webProtectData.ts_sign;
|
|
13628
|
+
const serverDataCookie = params.cookies.find((it)=>"bd_ticket_guard_server_data" === it.name)?.value;
|
|
13629
|
+
if (serverDataCookie) try {
|
|
13630
|
+
const decoded = JSON.parse(Buffer.from(decodeURIComponent(serverDataCookie), "base64").toString("utf8"));
|
|
13631
|
+
if (decoded.ticket && decoded.ts_sign) {
|
|
13632
|
+
if (decoded.ticket !== ticket) task.logger.info("[douyinPublish] 使用 cookie 中的最新 ticket(web_protect 已过期)");
|
|
13633
|
+
ticket = decoded.ticket;
|
|
13634
|
+
ts_sign = decoded.ts_sign;
|
|
13635
|
+
}
|
|
13636
|
+
} catch (error) {
|
|
13637
|
+
task.logger.info(`[douyinPublish] 解析 bd_ticket_guard_server_data 失败,回退到 web_protect: ${error}`);
|
|
13573
13638
|
}
|
|
13574
|
-
|
|
13575
|
-
|
|
13576
|
-
|
|
13577
|
-
|
|
13578
|
-
|
|
13579
|
-
|
|
13580
|
-
|
|
13581
|
-
|
|
13582
|
-
|
|
13583
|
-
|
|
13639
|
+
let ec_privateKey;
|
|
13640
|
+
try {
|
|
13641
|
+
ec_privateKey = JSON.parse(JSON.parse(params.extraParam["security-sdk/s_sdk_crypt_sdk"] || "{}").data || "{}").ec_privateKey;
|
|
13642
|
+
if (!ec_privateKey) {
|
|
13643
|
+
task.logger.error("[douyinPublish] ec_privateKey 为空");
|
|
13644
|
+
return (0, share_namespaceObject.response)(414, "安全参数 ec_privateKey 缺失,请重新获取后重试", "");
|
|
13645
|
+
}
|
|
13646
|
+
} catch (error) {
|
|
13647
|
+
task.logger.error(`[douyinPublish] 解析 ec_privateKey 失败: ${error}`);
|
|
13648
|
+
return (0, share_namespaceObject.response)(414, "安全参数 ec_privateKey 解析失败,请重新获取后重试", "");
|
|
13584
13649
|
}
|
|
13585
|
-
|
|
13586
|
-
|
|
13587
|
-
|
|
13588
|
-
|
|
13589
|
-
|
|
13590
|
-
|
|
13591
|
-
state: share_namespaceObject.TaskState.SUCCESS,
|
|
13592
|
-
result: {
|
|
13593
|
-
response: data
|
|
13650
|
+
let certificate;
|
|
13651
|
+
try {
|
|
13652
|
+
certificate = JSON.parse(params.extraParam["security-sdk/s_sdk_server_cert_key"] || "{}").cert;
|
|
13653
|
+
if (!certificate) {
|
|
13654
|
+
task.logger.error("[douyinPublish] certificate 为空");
|
|
13655
|
+
return (0, share_namespaceObject.response)(414, "安全参数 certificate 缺失,请重新获取后重试", "");
|
|
13594
13656
|
}
|
|
13595
|
-
})
|
|
13596
|
-
|
|
13597
|
-
|
|
13598
|
-
let webProtectData;
|
|
13599
|
-
try {
|
|
13600
|
-
webProtectData = JSON.parse(JSON.parse(params.extraParam["security-sdk/s_sdk_sign_data_key/web_protect"] || "{}").data || "{}");
|
|
13601
|
-
if (!webProtectData.ticket || !webProtectData.ts_sign || !webProtectData.client_cert) {
|
|
13602
|
-
task.logger.error(`webProtectData 关键字段缺失: ${JSON.stringify(webProtectData)}`);
|
|
13603
|
-
return (0, share_namespaceObject.response)(414, "安全参数 webProtectData 不完整,请重新获取后重试", "");
|
|
13657
|
+
} catch (error) {
|
|
13658
|
+
task.logger.error(`[douyinPublish] 解析 certificate 失败: ${error}`);
|
|
13659
|
+
return (0, share_namespaceObject.response)(414, "安全参数 certificate 解析失败,请重新获取后重试", "");
|
|
13604
13660
|
}
|
|
13605
|
-
|
|
13606
|
-
|
|
13607
|
-
|
|
13608
|
-
|
|
13609
|
-
|
|
13610
|
-
|
|
13611
|
-
|
|
13612
|
-
|
|
13613
|
-
|
|
13614
|
-
|
|
13615
|
-
if (
|
|
13616
|
-
|
|
13617
|
-
|
|
13661
|
+
const ree_public_key = webProtectData.client_cert.replace("pub.", "");
|
|
13662
|
+
let bdTicketGuardClientData;
|
|
13663
|
+
try {
|
|
13664
|
+
bdTicketGuardClientData = getBdV2({
|
|
13665
|
+
ticket,
|
|
13666
|
+
ts_sign: ts_sign,
|
|
13667
|
+
ec_privateKey: ec_privateKey,
|
|
13668
|
+
certificate: certificate,
|
|
13669
|
+
bd_ticket_guard_ree_public_key: ree_public_key
|
|
13670
|
+
});
|
|
13671
|
+
if (!bdTicketGuardClientData || !bdTicketGuardClientData["headers_bd_ticket_guard_client_data"]) {
|
|
13672
|
+
task.logger.error(`[douyinPublish] bdTicketGuardClientData 生成失败或不完整: ${JSON.stringify(bdTicketGuardClientData)}`);
|
|
13673
|
+
return (0, share_namespaceObject.response)(414, "安全参数 bdTicketGuardClientData 生成失败,请重新获取后重试", "");
|
|
13674
|
+
}
|
|
13675
|
+
} catch (error) {
|
|
13676
|
+
task.logger.error(`[douyinPublish] 生成 bdTicketGuardClientData 失败: ${error}`);
|
|
13677
|
+
return (0, share_namespaceObject.response)(414, "安全参数 bdTicketGuardClientData 生成异常,请重新获取后重试", "");
|
|
13618
13678
|
}
|
|
13619
|
-
|
|
13620
|
-
|
|
13621
|
-
|
|
13622
|
-
|
|
13623
|
-
|
|
13624
|
-
|
|
13625
|
-
|
|
13626
|
-
|
|
13627
|
-
|
|
13679
|
+
task.logger.info("[douyinPublish] bdTicketGuardClientData 生成成功");
|
|
13680
|
+
const publishQuery = {
|
|
13681
|
+
...publishParams,
|
|
13682
|
+
a_bogus: ""
|
|
13683
|
+
};
|
|
13684
|
+
const queryString = new URLSearchParams(publishQuery).toString();
|
|
13685
|
+
let aBogus;
|
|
13686
|
+
try {
|
|
13687
|
+
aBogus = mock_getABogus(`https://creator.douyin.com/web/api/media/aweme/create_v2/?${queryString}`, publishData, userAgent);
|
|
13688
|
+
if (!aBogus || aBogus.length < 10) {
|
|
13689
|
+
task.logger.error(`[douyinPublish] a_bogus 生成异常,长度过短: ${aBogus}`);
|
|
13690
|
+
return (0, share_namespaceObject.response)(414, "安全参数 a_bogus 生成失败,请重试", "");
|
|
13691
|
+
}
|
|
13692
|
+
} catch (error) {
|
|
13693
|
+
task.logger.error(`[douyinPublish] 生成 a_bogus 失败: ${error}`);
|
|
13694
|
+
return (0, share_namespaceObject.response)(414, "安全参数 a_bogus 生成异常,请重试", "");
|
|
13628
13695
|
}
|
|
13629
|
-
|
|
13630
|
-
|
|
13631
|
-
|
|
13632
|
-
|
|
13633
|
-
|
|
13634
|
-
|
|
13635
|
-
|
|
13636
|
-
|
|
13637
|
-
|
|
13638
|
-
|
|
13696
|
+
publishQuery.a_bogus = aBogus;
|
|
13697
|
+
const publishQueryParams = new URLSearchParams(publishQuery).toString();
|
|
13698
|
+
let csrfToken;
|
|
13699
|
+
try {
|
|
13700
|
+
csrfToken = mock_generateCsrfTokenAdvanced({
|
|
13701
|
+
cookies: params.cookies,
|
|
13702
|
+
url: "https://creator.douyin.com/web/api/media/aweme/create_v2/",
|
|
13703
|
+
method: "POST",
|
|
13704
|
+
userAgent
|
|
13705
|
+
});
|
|
13706
|
+
if (!csrfToken || csrfToken.length < 10) {
|
|
13707
|
+
task.logger.error(`[douyinPublish] csrfToken 生成异常,长度过短: ${csrfToken}`);
|
|
13708
|
+
return (0, share_namespaceObject.response)(414, "安全参数 csrfToken 生成失败,请重试", "");
|
|
13709
|
+
}
|
|
13710
|
+
task.logger.info(`[douyinPublish] csrfToken 生成成功: ${csrfToken.substring(0, 20)}...`);
|
|
13711
|
+
} catch (error) {
|
|
13712
|
+
task.logger.error(`[douyinPublish] 生成 csrfToken 失败: ${error}`);
|
|
13713
|
+
return (0, share_namespaceObject.response)(414, "安全参数 csrfToken 生成异常,请重试", "");
|
|
13639
13714
|
}
|
|
13640
|
-
|
|
13641
|
-
|
|
13642
|
-
|
|
13643
|
-
|
|
13644
|
-
|
|
13645
|
-
|
|
13646
|
-
|
|
13647
|
-
bdTicketGuardClientData = getBdV2({
|
|
13648
|
-
ticket,
|
|
13649
|
-
ts_sign: ts_sign,
|
|
13650
|
-
ec_privateKey: ec_privateKey,
|
|
13651
|
-
certificate: certificate,
|
|
13652
|
-
bd_ticket_guard_ree_public_key: ree_public_key
|
|
13653
|
-
});
|
|
13654
|
-
if (!bdTicketGuardClientData || !bdTicketGuardClientData["headers_bd_ticket_guard_client_data"]) {
|
|
13655
|
-
task.logger.error(`[douyinPublish] bdTicketGuardClientData 生成失败或不完整: ${JSON.stringify(bdTicketGuardClientData)}`);
|
|
13656
|
-
return (0, share_namespaceObject.response)(414, "安全参数 bdTicketGuardClientData 生成失败,请重新获取后重试", "");
|
|
13715
|
+
let sessionDtrait;
|
|
13716
|
+
try {
|
|
13717
|
+
sessionDtrait = mock_generateDtrait("/web/api/media/aweme/create_v2/");
|
|
13718
|
+
task.logger.info(`[douyinPublish] sessionDtrait 生成成功: ${sessionDtrait || "(空)"}`);
|
|
13719
|
+
} catch (error) {
|
|
13720
|
+
task.logger.error(`[douyinPublish] 生成 sessionDtrait 失败: ${error}`);
|
|
13721
|
+
return (0, share_namespaceObject.response)(414, "安全参数 sessionDtrait 生成异常,请重试", "");
|
|
13657
13722
|
}
|
|
13658
|
-
|
|
13659
|
-
|
|
13660
|
-
|
|
13661
|
-
|
|
13662
|
-
|
|
13663
|
-
|
|
13664
|
-
|
|
13665
|
-
|
|
13666
|
-
|
|
13667
|
-
|
|
13668
|
-
|
|
13669
|
-
|
|
13670
|
-
|
|
13671
|
-
|
|
13672
|
-
|
|
13673
|
-
|
|
13723
|
+
task.logger.info(`[douyinPublish] headers: ${JSON.stringify({
|
|
13724
|
+
...headers,
|
|
13725
|
+
Referer: "https://creator.douyin.com/creator-micro/content/post/image?default-tab=3&enter_from=publish_page&media_type=image&type=new",
|
|
13726
|
+
"Content-Type": "application/json",
|
|
13727
|
+
Accept: "application/json, text/plain, */*",
|
|
13728
|
+
"bd-ticket-guard-client-data": bdTicketGuardClientData["headers_bd_ticket_guard_client_data"],
|
|
13729
|
+
"bd-ticket-guard-ree-public-key": bdTicketGuardClientData["headers_bd_ticket_guard_ree_public_key"],
|
|
13730
|
+
"bd-ticket-guard-version": "2",
|
|
13731
|
+
"bd-ticket-guard-web-sign-type": "1",
|
|
13732
|
+
"bd-ticket-guard-web-version": "2",
|
|
13733
|
+
"x-secsdk-csrf-token": csrfToken,
|
|
13734
|
+
"x-tt-session-dtrait": sessionDtrait || ""
|
|
13735
|
+
})}`);
|
|
13736
|
+
task.logger.info(`[douyinPublish] url: https://creator.douyin.com/web/api/media/aweme/create_v2/?${publishQueryParams}`);
|
|
13737
|
+
let publishResult;
|
|
13738
|
+
try {
|
|
13739
|
+
publishResult = await proxyHttp.api({
|
|
13740
|
+
method: "post",
|
|
13741
|
+
url: `https://creator.douyin.com/web/api/media/aweme/create_v2/?${publishQueryParams}`,
|
|
13742
|
+
data: publishData,
|
|
13743
|
+
defaultErrorMsg: "发布异常,请稍后重试。",
|
|
13744
|
+
headers: {
|
|
13745
|
+
...headers,
|
|
13746
|
+
Referer: "https://creator.douyin.com/creator-micro/content/post/image?default-tab=3&enter_from=publish_page&media_type=image&type=new",
|
|
13747
|
+
"Content-Type": "application/json",
|
|
13748
|
+
Accept: "application/json, text/plain, */*",
|
|
13749
|
+
"bd-ticket-guard-client-data": bdTicketGuardClientData["headers_bd_ticket_guard_client_data"],
|
|
13750
|
+
"bd-ticket-guard-ree-public-key": bdTicketGuardClientData["headers_bd_ticket_guard_ree_public_key"],
|
|
13751
|
+
"bd-ticket-guard-version": "2",
|
|
13752
|
+
"bd-ticket-guard-web-sign-type": "1",
|
|
13753
|
+
"bd-ticket-guard-web-version": "2",
|
|
13754
|
+
"x-secsdk-csrf-token": csrfToken,
|
|
13755
|
+
"x-tt-session-dtrait": sessionDtrait || ""
|
|
13756
|
+
}
|
|
13757
|
+
}, {
|
|
13758
|
+
timeout: 60000,
|
|
13759
|
+
retries: 3,
|
|
13760
|
+
retryDelay: 2000
|
|
13761
|
+
});
|
|
13762
|
+
} catch (error) {
|
|
13763
|
+
const handledError = Http.handleApiError(error);
|
|
13764
|
+
const isProxyOrNetworkError = [
|
|
13765
|
+
599,
|
|
13766
|
+
500,
|
|
13767
|
+
502,
|
|
13768
|
+
503,
|
|
13769
|
+
504
|
|
13770
|
+
].includes(handledError.code);
|
|
13771
|
+
if (isProxyOrNetworkError) {
|
|
13772
|
+
const isProxyRequest = handledError.extra?.isProxyRequest === true;
|
|
13773
|
+
const errorType = 599 === handledError.code || isProxyRequest ? "代理错误" : "网络错误";
|
|
13774
|
+
const message = `图文发布失败,${errorType}:${handledError.message}${task.debug ? ` ${http.proxyInfo}` : ""}`;
|
|
13775
|
+
task.logger.error(`[douyinPublish] ${errorType},直接返回: ${message}`, stringifyError(handledError));
|
|
13776
|
+
await updateTaskState?.({
|
|
13777
|
+
state: share_namespaceObject.TaskState.FAILED,
|
|
13778
|
+
error: message
|
|
13779
|
+
});
|
|
13780
|
+
return {
|
|
13781
|
+
code: 414,
|
|
13782
|
+
data: "",
|
|
13783
|
+
message
|
|
13784
|
+
};
|
|
13785
|
+
}
|
|
13786
|
+
throw error;
|
|
13674
13787
|
}
|
|
13675
|
-
|
|
13676
|
-
|
|
13677
|
-
|
|
13678
|
-
|
|
13679
|
-
|
|
13680
|
-
|
|
13681
|
-
|
|
13682
|
-
|
|
13683
|
-
|
|
13684
|
-
|
|
13685
|
-
|
|
13686
|
-
|
|
13687
|
-
|
|
13688
|
-
|
|
13689
|
-
|
|
13690
|
-
|
|
13691
|
-
|
|
13788
|
+
task.logger.info(`[douyinPublish] decision值: ${JSON.stringify(decision)}, needsVerification(decision): ${needsVerification(decision)}`);
|
|
13789
|
+
if (needsVerification(decision)) {
|
|
13790
|
+
const details = [
|
|
13791
|
+
publishResult.status_msg,
|
|
13792
|
+
decision?.verify_title,
|
|
13793
|
+
decision?.verify_desc
|
|
13794
|
+
].filter(Boolean).join(" ");
|
|
13795
|
+
const message = `图文发布失败,原因:${details}${task.debug ? ` ${http.proxyInfo}` : ""}`;
|
|
13796
|
+
const safeDecision = safeSerialize(decision) ?? {};
|
|
13797
|
+
const mockData = {
|
|
13798
|
+
state: share_namespaceObject.TaskState.FAILED,
|
|
13799
|
+
error: message,
|
|
13800
|
+
result: {
|
|
13801
|
+
...safeDecision,
|
|
13802
|
+
data: safeDecision,
|
|
13803
|
+
uploadedImgList: JSON.stringify(publishData.item.common.images)
|
|
13804
|
+
}
|
|
13805
|
+
};
|
|
13806
|
+
await updateTaskState?.(mockData);
|
|
13807
|
+
return {
|
|
13808
|
+
code: 0,
|
|
13809
|
+
data: mockData,
|
|
13810
|
+
message: "操作成功"
|
|
13811
|
+
};
|
|
13692
13812
|
}
|
|
13693
|
-
|
|
13694
|
-
|
|
13695
|
-
|
|
13696
|
-
|
|
13697
|
-
|
|
13698
|
-
|
|
13699
|
-
|
|
13700
|
-
|
|
13701
|
-
|
|
13702
|
-
|
|
13703
|
-
|
|
13704
|
-
|
|
13705
|
-
|
|
13706
|
-
|
|
13707
|
-
|
|
13708
|
-
|
|
13709
|
-
|
|
13710
|
-
Accept: "application/json, text/plain, */*",
|
|
13711
|
-
"bd-ticket-guard-client-data": bdTicketGuardClientData["headers_bd_ticket_guard_client_data"],
|
|
13712
|
-
"bd-ticket-guard-ree-public-key": bdTicketGuardClientData["headers_bd_ticket_guard_ree_public_key"],
|
|
13713
|
-
"bd-ticket-guard-version": "2",
|
|
13714
|
-
"bd-ticket-guard-web-sign-type": "1",
|
|
13715
|
-
"bd-ticket-guard-web-version": "2",
|
|
13716
|
-
"x-secsdk-csrf-token": csrfToken,
|
|
13717
|
-
"x-tt-session-dtrait": sessionDtrait || ""
|
|
13718
|
-
})}`);
|
|
13719
|
-
task.logger.info(`[douyinPublish] url: https://creator.douyin.com/web/api/media/aweme/create_v2/?${publishQueryParams}`);
|
|
13720
|
-
let publishResult;
|
|
13721
|
-
try {
|
|
13722
|
-
publishResult = await proxyHttp.api({
|
|
13723
|
-
method: "post",
|
|
13724
|
-
url: `https://creator.douyin.com/web/api/media/aweme/create_v2/?${publishQueryParams}`,
|
|
13725
|
-
data: publishData,
|
|
13726
|
-
defaultErrorMsg: "发布异常,请稍后重试。",
|
|
13727
|
-
headers: {
|
|
13728
|
-
...headers,
|
|
13729
|
-
Referer: "https://creator.douyin.com/creator-micro/content/post/image?default-tab=3&enter_from=publish_page&media_type=image&type=new",
|
|
13730
|
-
"Content-Type": "application/json",
|
|
13731
|
-
Accept: "application/json, text/plain, */*",
|
|
13732
|
-
"bd-ticket-guard-client-data": bdTicketGuardClientData["headers_bd_ticket_guard_client_data"],
|
|
13733
|
-
"bd-ticket-guard-ree-public-key": bdTicketGuardClientData["headers_bd_ticket_guard_ree_public_key"],
|
|
13734
|
-
"bd-ticket-guard-version": "2",
|
|
13735
|
-
"bd-ticket-guard-web-sign-type": "1",
|
|
13736
|
-
"bd-ticket-guard-web-version": "2",
|
|
13737
|
-
"x-secsdk-csrf-token": csrfToken,
|
|
13738
|
-
"x-tt-session-dtrait": sessionDtrait || ""
|
|
13739
|
-
}
|
|
13740
|
-
}, {
|
|
13741
|
-
timeout: 60000,
|
|
13742
|
-
retries: 3,
|
|
13743
|
-
retryDelay: 2000
|
|
13744
|
-
});
|
|
13745
|
-
} catch (error) {
|
|
13746
|
-
const handledError = Http.handleApiError(error);
|
|
13747
|
-
const isProxyOrNetworkError = [
|
|
13748
|
-
599,
|
|
13749
|
-
500,
|
|
13750
|
-
502,
|
|
13751
|
-
503,
|
|
13752
|
-
504
|
|
13753
|
-
].includes(handledError.code);
|
|
13754
|
-
if (isProxyOrNetworkError) {
|
|
13755
|
-
const isProxyRequest = handledError.extra?.isProxyRequest === true;
|
|
13756
|
-
const errorType = 599 === handledError.code || isProxyRequest ? "代理错误" : "网络错误";
|
|
13757
|
-
const message = `图文发布失败,${errorType}:${handledError.message}${task.debug ? ` ${http.proxyInfo}` : ""}`;
|
|
13758
|
-
task.logger.error(`[douyinPublish] ${errorType},直接返回: ${message}`, stringifyError(handledError));
|
|
13813
|
+
reportLogger({
|
|
13814
|
+
token: params.huiwenToken || "",
|
|
13815
|
+
enverionment: task.enverionment || "development",
|
|
13816
|
+
postId: params.articleId,
|
|
13817
|
+
eip: proxyHttp.proxyInfo,
|
|
13818
|
+
proxyIp: params.localIP,
|
|
13819
|
+
accountId: params.accountId,
|
|
13820
|
+
uid: params.uid,
|
|
13821
|
+
platform: "douyin",
|
|
13822
|
+
publishParams: publishData
|
|
13823
|
+
});
|
|
13824
|
+
task.logger.info(`[douyinPublish] 发布结果 ${JSON.stringify(publishResult)}`);
|
|
13825
|
+
const isSuccess = 0 === publishResult.status_code;
|
|
13826
|
+
const message = `图文发布${isSuccess ? "成功" : `失败,原因:${publishResult.status_msg} ${decision?.verify_title} ${decision?.verify_desc}`}${task.debug ? ` ${http.proxyInfo}` : ""}`;
|
|
13827
|
+
const data = isSuccess ? publishResult.item_id || "" : "";
|
|
13828
|
+
if (!isSuccess) {
|
|
13829
|
+
const safeDecision = safeSerialize(decision) ?? {};
|
|
13759
13830
|
await updateTaskState?.({
|
|
13760
13831
|
state: share_namespaceObject.TaskState.FAILED,
|
|
13761
|
-
error: message
|
|
13832
|
+
error: message,
|
|
13833
|
+
result: {
|
|
13834
|
+
...safeDecision,
|
|
13835
|
+
data: safeDecision,
|
|
13836
|
+
uploadedImgList: JSON.stringify(publishData.item.common.images)
|
|
13837
|
+
}
|
|
13762
13838
|
});
|
|
13763
13839
|
return {
|
|
13764
13840
|
code: 414,
|
|
13765
|
-
data:
|
|
13841
|
+
data: safeDecision,
|
|
13766
13842
|
message
|
|
13767
13843
|
};
|
|
13768
13844
|
}
|
|
13769
|
-
|
|
13770
|
-
|
|
13771
|
-
task.logger.info(`[douyinPublish] decision值: ${JSON.stringify(decision)}, needsVerification(decision): ${needsVerification(decision)}`);
|
|
13772
|
-
if (needsVerification(decision)) {
|
|
13773
|
-
const details = [
|
|
13774
|
-
publishResult.status_msg,
|
|
13775
|
-
decision?.verify_title,
|
|
13776
|
-
decision?.verify_desc
|
|
13777
|
-
].filter(Boolean).join(" ");
|
|
13778
|
-
const message = `图文发布失败,原因:${details}${task.debug ? ` ${http.proxyInfo}` : ""}`;
|
|
13779
|
-
let decisionObj = {};
|
|
13780
|
-
if (decision) decisionObj = decision;
|
|
13781
|
-
const mockData = {
|
|
13782
|
-
state: share_namespaceObject.TaskState.FAILED,
|
|
13783
|
-
error: message,
|
|
13845
|
+
await updateTaskState?.({
|
|
13846
|
+
state: share_namespaceObject.TaskState.SUCCESS,
|
|
13784
13847
|
result: {
|
|
13785
|
-
|
|
13786
|
-
data: decision,
|
|
13787
|
-
uploadedImgList: JSON.stringify(publishData.item.common.images)
|
|
13848
|
+
response: data
|
|
13788
13849
|
}
|
|
13789
|
-
};
|
|
13790
|
-
|
|
13791
|
-
|
|
13792
|
-
|
|
13793
|
-
|
|
13794
|
-
|
|
13795
|
-
};
|
|
13796
|
-
}
|
|
13797
|
-
reportLogger({
|
|
13798
|
-
token: params.huiwenToken || "",
|
|
13799
|
-
enverionment: task.enverionment || "development",
|
|
13800
|
-
postId: params.articleId,
|
|
13801
|
-
eip: proxyHttp.proxyInfo,
|
|
13802
|
-
proxyIp: params.localIP,
|
|
13803
|
-
accountId: params.accountId,
|
|
13804
|
-
uid: params.uid,
|
|
13805
|
-
platform: "douyin",
|
|
13806
|
-
publishParams: publishData
|
|
13807
|
-
});
|
|
13808
|
-
task.logger.info(`[douyinPublish] 发布结果 ${JSON.stringify(publishResult)}`);
|
|
13809
|
-
const isSuccess = 0 === publishResult.status_code;
|
|
13810
|
-
const message = `图文发布${isSuccess ? "成功" : `失败,原因:${publishResult.status_msg} ${decision?.verify_title} ${decision?.verify_desc}`}${task.debug ? ` ${http.proxyInfo}` : ""}`;
|
|
13811
|
-
const data = isSuccess ? publishResult.item_id || "" : "";
|
|
13812
|
-
if (!isSuccess) {
|
|
13813
|
-
let decisionObj = {};
|
|
13814
|
-
if (decision) decisionObj = decision;
|
|
13850
|
+
});
|
|
13851
|
+
return (0, share_namespaceObject.response)(isSuccess ? 0 : 414, message, data);
|
|
13852
|
+
} catch (error) {
|
|
13853
|
+
const handledError = Http.handleApiError(error);
|
|
13854
|
+
const errorMsg = handledError.message || "发布失败";
|
|
13855
|
+
const errorCode = handledError.code || 500;
|
|
13856
|
+
task.logger.error(`[douyinPublish] 发布流程异常 (步骤: ${currentStep}): ${errorMsg}`, stringifyError(error), handledError.extra);
|
|
13815
13857
|
await updateTaskState?.({
|
|
13816
13858
|
state: share_namespaceObject.TaskState.FAILED,
|
|
13817
|
-
error:
|
|
13818
|
-
result: {
|
|
13819
|
-
...decisionObj,
|
|
13820
|
-
data: decision,
|
|
13821
|
-
uploadedImgList: JSON.stringify(publishData.item.common.images)
|
|
13822
|
-
}
|
|
13859
|
+
error: `${currentStep}失败: ${errorMsg}`
|
|
13823
13860
|
});
|
|
13824
|
-
return
|
|
13825
|
-
code: 414,
|
|
13826
|
-
data,
|
|
13827
|
-
message
|
|
13828
|
-
};
|
|
13861
|
+
return (0, share_namespaceObject.response)(errorCode, errorMsg, "");
|
|
13829
13862
|
}
|
|
13830
|
-
await updateTaskState?.({
|
|
13831
|
-
state: share_namespaceObject.TaskState.SUCCESS,
|
|
13832
|
-
result: {
|
|
13833
|
-
response: data
|
|
13834
|
-
}
|
|
13835
|
-
});
|
|
13836
|
-
return (0, share_namespaceObject.response)(isSuccess ? 0 : 414, message, data);
|
|
13837
13863
|
};
|
|
13838
13864
|
const douyinPublish_rpa_rpaAction = async (task, params)=>{
|
|
13839
13865
|
const commonCookies = {
|
|
@@ -18096,6 +18122,11 @@ var __webpack_exports__ = {};
|
|
|
18096
18122
|
this.concurrentLimit = config.concurrentLimit || 4;
|
|
18097
18123
|
this.singleFileSize = config.singleFileSize || 10485760;
|
|
18098
18124
|
this.http = config.http || new Http();
|
|
18125
|
+
this.reqOptions = {
|
|
18126
|
+
timeout: config.timeout ?? 60000,
|
|
18127
|
+
retries: config.retries ?? 3,
|
|
18128
|
+
retryDelay: config.retryDelay ?? 2000
|
|
18129
|
+
};
|
|
18099
18130
|
}
|
|
18100
18131
|
calculateMd5(buffer) {
|
|
18101
18132
|
const MAX_SIZE = 5242880;
|
|
@@ -18152,7 +18183,7 @@ var __webpack_exports__ = {};
|
|
|
18152
18183
|
url: filePath,
|
|
18153
18184
|
method: "get",
|
|
18154
18185
|
responseType: "arraybuffer"
|
|
18155
|
-
});
|
|
18186
|
+
}, this.reqOptions);
|
|
18156
18187
|
return Buffer.from(resp);
|
|
18157
18188
|
}
|
|
18158
18189
|
return external_node_fs_default().promises.readFile(filePath);
|
|
@@ -18182,7 +18213,7 @@ var __webpack_exports__ = {};
|
|
|
18182
18213
|
headers,
|
|
18183
18214
|
data: requestBody,
|
|
18184
18215
|
defaultErrorMsg: "获取UploadID失败"
|
|
18185
|
-
});
|
|
18216
|
+
}, this.reqOptions);
|
|
18186
18217
|
if (!resp?.UploadID) throw new Error(`获取 UploadID 失败: ${resp?.errMsg || "未知错误"}`);
|
|
18187
18218
|
return resp.UploadID;
|
|
18188
18219
|
}
|
|
@@ -18203,7 +18234,7 @@ var __webpack_exports__ = {};
|
|
|
18203
18234
|
headers,
|
|
18204
18235
|
data: chunk,
|
|
18205
18236
|
defaultErrorMsg: `分片 ${partNumber} 上传失败`
|
|
18206
|
-
});
|
|
18237
|
+
}, this.reqOptions);
|
|
18207
18238
|
if (resp?.errCode !== void 0 && 0 !== resp.errCode) throw new Error(`分片 ${partNumber} 上传失败: ${resp.errMsg}`);
|
|
18208
18239
|
if (onProgress) onProgress(chunk.length);
|
|
18209
18240
|
return resp.ETag || "";
|
|
@@ -18227,7 +18258,7 @@ var __webpack_exports__ = {};
|
|
|
18227
18258
|
headers,
|
|
18228
18259
|
data: requestBody,
|
|
18229
18260
|
defaultErrorMsg: "确认分片上传失败"
|
|
18230
|
-
});
|
|
18261
|
+
}, this.reqOptions);
|
|
18231
18262
|
if (resp?.ListPartsResult?.Part) return resp.ListPartsResult.Part.map((p)=>({
|
|
18232
18263
|
PartNumber: parseInt(p.PartNumber),
|
|
18233
18264
|
ETag: p.ETag
|
|
@@ -18253,7 +18284,7 @@ var __webpack_exports__ = {};
|
|
|
18253
18284
|
headers,
|
|
18254
18285
|
data: requestBody,
|
|
18255
18286
|
defaultErrorMsg: "完成上传失败"
|
|
18256
|
-
});
|
|
18287
|
+
}, this.reqOptions);
|
|
18257
18288
|
if (!resp?.DownloadURL) throw new Error(`完成上传失败: ${resp?.errMsg || "未知错误"}`);
|
|
18258
18289
|
return resp.DownloadURL;
|
|
18259
18290
|
}
|
|
@@ -18604,7 +18635,9 @@ var __webpack_exports__ = {};
|
|
|
18604
18635
|
task.logger.info("[shipinhaoPublish] 开始执行视频号发布 - Mock API 方式");
|
|
18605
18636
|
const updateTaskState = task.taskStageStore?.update?.bind(task.taskStageStore, task.taskId || "");
|
|
18606
18637
|
if (!params.extraParam.fingerPrintDeviceId || !params.extraParam.aId) return (0, share_namespaceObject.response)(400, "fingerPrintDeviceId和aId 不能为空", "");
|
|
18638
|
+
let currentStep = "初始化";
|
|
18607
18639
|
try {
|
|
18640
|
+
currentStep = "解析认证信息";
|
|
18608
18641
|
const cookieString = params.cookies.map((c)=>`${c.name}=${c.value}`).join("; ");
|
|
18609
18642
|
const fingerPrintDeviceId = params.extraParam.fingerPrintDeviceId;
|
|
18610
18643
|
const aId = params.extraParam.aId;
|
|
@@ -18625,8 +18658,10 @@ var __webpack_exports__ = {};
|
|
|
18625
18658
|
headers
|
|
18626
18659
|
});
|
|
18627
18660
|
const proxyHttp = new Http(...args);
|
|
18661
|
+
currentStep = "验证发布参数";
|
|
18628
18662
|
if (!params.banners || 0 === params.banners.length) return (0, share_namespaceObject.response)(400, "至少需要一张图片", "");
|
|
18629
18663
|
const images = params.banners.slice(0, 18).filter((img)=>"string" == typeof img);
|
|
18664
|
+
currentStep = "获取用户信息";
|
|
18630
18665
|
task.logger.info("[shipinhaoPublish] 获取用户信息...");
|
|
18631
18666
|
console.log("cookieString", cookieString);
|
|
18632
18667
|
const userInfo = await mock_getUserInfo(cookieString, http);
|
|
@@ -18637,6 +18672,7 @@ var __webpack_exports__ = {};
|
|
|
18637
18672
|
}
|
|
18638
18673
|
const finderUsername = userInfo.data.finderUser.finderUsername;
|
|
18639
18674
|
console.log(finderUsername);
|
|
18675
|
+
currentStep = "获取上传认证密钥";
|
|
18640
18676
|
task.logger.info("[shipinhaoPublish] 获取上传认证密钥...");
|
|
18641
18677
|
const authKeyResponse = await getUploadAuthKey(cookieString, finderUsername, http);
|
|
18642
18678
|
if (0 !== authKeyResponse.errCode || !authKeyResponse.data?.authKey) return (0, share_namespaceObject.response)(authKeyResponse.errCode || 500, `获取上传认证参数失败: ${authKeyResponse.errMsg}`, "");
|
|
@@ -18644,10 +18680,12 @@ var __webpack_exports__ = {};
|
|
|
18644
18680
|
const uin = authKeyResponse.data.uin;
|
|
18645
18681
|
if (!uin) return (0, share_namespaceObject.response)(500, "获取用户 uin 失败", "");
|
|
18646
18682
|
const taskId = String(generateUUID());
|
|
18683
|
+
currentStep = "上传图片";
|
|
18647
18684
|
task.logger.info(`[shipinhaoPublish] 开始上传 ${images.length} 张图片...`);
|
|
18648
18685
|
const uploadedImages = [];
|
|
18649
18686
|
for(let i = 0; i < images.length; i++){
|
|
18650
|
-
|
|
18687
|
+
currentStep = `上传图片 ${i + 1}/${images.length}`;
|
|
18688
|
+
task.logger.info(`[shipinhaoPublish] ${currentStep}...`);
|
|
18651
18689
|
const uploadResult = await uploadImageComplete(images[i], taskId, finderUsername, uin, authKey, http);
|
|
18652
18690
|
console.log(JSON.stringify(uploadResult));
|
|
18653
18691
|
if (!uploadResult.DownloadURL) return (0, share_namespaceObject.response)(500, `图片上传失败: ${uploadResult.errMsg}`, "");
|
|
@@ -18664,6 +18702,7 @@ var __webpack_exports__ = {};
|
|
|
18664
18702
|
urlCdnTaskId: ""
|
|
18665
18703
|
});
|
|
18666
18704
|
}
|
|
18705
|
+
currentStep = "发布图文内容";
|
|
18667
18706
|
task.logger.info("[shipinhaoPublish] 正在发布...");
|
|
18668
18707
|
const topicNames = params.topic || void 0;
|
|
18669
18708
|
const addressInfo = params.address ? {
|
|
@@ -18750,9 +18789,15 @@ var __webpack_exports__ = {};
|
|
|
18750
18789
|
});
|
|
18751
18790
|
return (0, share_namespaceObject.response)(resultCode || 500, errorMessage, "");
|
|
18752
18791
|
} catch (error) {
|
|
18753
|
-
const
|
|
18754
|
-
|
|
18755
|
-
|
|
18792
|
+
const handledError = Http.handleApiError(error);
|
|
18793
|
+
const errorMsg = handledError.message || "发布失败,请稍后重试";
|
|
18794
|
+
const errorCode = handledError.code || 500;
|
|
18795
|
+
task.logger.error(`[shipinhaoPublish] 发布流程异常: ${errorMsg}`, stringifyError(error), handledError.extra);
|
|
18796
|
+
await updateTaskState?.({
|
|
18797
|
+
state: share_namespaceObject.TaskState.FAILED,
|
|
18798
|
+
error: errorMsg
|
|
18799
|
+
});
|
|
18800
|
+
return (0, share_namespaceObject.response)(errorCode, errorMsg, "");
|
|
18756
18801
|
}
|
|
18757
18802
|
};
|
|
18758
18803
|
const shipinhaoPublish_rpa_rpaAction = async (task, params)=>{
|
|
@@ -25258,7 +25303,7 @@ var __webpack_exports__ = {};
|
|
|
25258
25303
|
likeNumYesterday: schemas_number().nullable(),
|
|
25259
25304
|
commentNumYesterday: schemas_number().nullable()
|
|
25260
25305
|
});
|
|
25261
|
-
schemas_object({
|
|
25306
|
+
const douyinConfigDataSchema = schemas_object({
|
|
25262
25307
|
fansNum: schemas_number(),
|
|
25263
25308
|
favedNum: schemas_number(),
|
|
25264
25309
|
fansNumLastWeek: schemas_number(),
|
|
@@ -25268,7 +25313,7 @@ var __webpack_exports__ = {};
|
|
|
25268
25313
|
shareNumLastWeek: schemas_number(),
|
|
25269
25314
|
visitNumLastWeek: schemas_number()
|
|
25270
25315
|
});
|
|
25271
|
-
schemas_object({
|
|
25316
|
+
const shipinhaoConfigDataSchema = schemas_object({
|
|
25272
25317
|
fansNum: schemas_number(),
|
|
25273
25318
|
feedsCount: schemas_number(),
|
|
25274
25319
|
fansNumYesterday: schemas_number().nullable(),
|
|
@@ -25564,4 +25609,5 @@ if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_targe
|
|
|
25564
25609
|
value: true
|
|
25565
25610
|
});
|
|
25566
25611
|
|
|
25567
|
-
//# sourceMappingURL=index.js.map
|
|
25612
|
+
//# sourceMappingURL=index.js.map
|
|
25613
|
+
//# debugId=6b7b33da-d2a4-5623-b09a-756a2fe8a917
|