@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/bundle.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
/*! For license information please see bundle.js.LICENSE.txt */
|
|
2
|
+
|
|
3
|
+
!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]="029aefb0-580d-5097-84ee-1a7045670fcb")}catch(e){}}();
|
|
2
4
|
var __webpack_modules__ = {
|
|
3
5
|
"../../node_modules/.pnpm/agent-base@7.1.4/node_modules/agent-base/dist/helpers.js": function(__unused_webpack_module, exports1, __webpack_require__) {
|
|
4
6
|
"use strict";
|
|
@@ -12474,6 +12476,8 @@ var __webpack_exports__ = {};
|
|
|
12474
12476
|
bjhConfigDataSchema: ()=>bjhConfigDataSchema,
|
|
12475
12477
|
Action: ()=>Action,
|
|
12476
12478
|
ProxyAgent: ()=>ProxyAgent,
|
|
12479
|
+
douyinConfigDataSchema: ()=>douyinConfigDataSchema,
|
|
12480
|
+
shipinhaoConfigDataSchema: ()=>shipinhaoConfigDataSchema,
|
|
12477
12481
|
version: ()=>package_namespaceObject_0.i8
|
|
12478
12482
|
});
|
|
12479
12483
|
var common_utils_namespaceObject = {};
|
|
@@ -12488,7 +12492,7 @@ var __webpack_exports__ = {};
|
|
|
12488
12492
|
var package_namespaceObject = {
|
|
12489
12493
|
i8: "0.1.2"
|
|
12490
12494
|
};
|
|
12491
|
-
var package_namespaceObject_0 = JSON.parse('{"i8":"4.0.4-beta.
|
|
12495
|
+
var package_namespaceObject_0 = JSON.parse('{"i8":"4.0.4-beta.3"}');
|
|
12492
12496
|
const external_node_fs_namespaceObject = require("node:fs");
|
|
12493
12497
|
var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
|
|
12494
12498
|
const external_node_http_namespaceObject = require("node:http");
|
|
@@ -27268,11 +27272,12 @@ var __webpack_exports__ = {};
|
|
|
27268
27272
|
this.logger?.debug(`未处理的网络错误代码: ${error.code} ${error.message}`, {
|
|
27269
27273
|
errorString: stringifyError(error)
|
|
27270
27274
|
});
|
|
27271
|
-
_message =
|
|
27275
|
+
_message = `网络错误: ${error.message}`;
|
|
27272
27276
|
break;
|
|
27273
27277
|
}
|
|
27274
27278
|
}
|
|
27275
|
-
|
|
27279
|
+
if (error.code && !error.response?.data) errorResponse.message = _message || errorResponse.message;
|
|
27280
|
+
else errorResponse.message = errorResponse.message ? errorResponse.message : _message;
|
|
27276
27281
|
if ("canceled" === errorResponse.message) {
|
|
27277
27282
|
const message = errorResponse.extra?.isProxyRequest ? "代理连接建立超时,请更换区域或稍后重试!" : "网络请求超时,请稍后重试!";
|
|
27278
27283
|
errorResponse.message = message;
|
|
@@ -38511,400 +38516,421 @@ var __webpack_exports__ = {};
|
|
|
38511
38516
|
}
|
|
38512
38517
|
return randomString;
|
|
38513
38518
|
}
|
|
38519
|
+
function safeSerialize(obj) {
|
|
38520
|
+
if (!obj || "object" != typeof obj) return obj;
|
|
38521
|
+
try {
|
|
38522
|
+
return JSON.parse(JSON.stringify(obj));
|
|
38523
|
+
} catch (error) {
|
|
38524
|
+
return {};
|
|
38525
|
+
}
|
|
38526
|
+
}
|
|
38514
38527
|
const mock_mockAction = async (task, params)=>{
|
|
38515
38528
|
const updateTaskState = task.taskStageStore?.update?.bind(task.taskStageStore, task.taskId || "");
|
|
38516
38529
|
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 utils_response(414, "extraParam 参数缺失或不完整", "");
|
|
38517
|
-
|
|
38518
|
-
|
|
38519
|
-
|
|
38520
|
-
|
|
38521
|
-
|
|
38522
|
-
|
|
38523
|
-
|
|
38524
|
-
|
|
38525
|
-
|
|
38526
|
-
|
|
38527
|
-
|
|
38528
|
-
|
|
38529
|
-
|
|
38530
|
-
|
|
38531
|
-
|
|
38532
|
-
|
|
38533
|
-
|
|
38534
|
-
|
|
38535
|
-
|
|
38536
|
-
|
|
38537
|
-
|
|
38538
|
-
|
|
38539
|
-
|
|
38540
|
-
|
|
38541
|
-
|
|
38542
|
-
|
|
38543
|
-
|
|
38544
|
-
|
|
38545
|
-
|
|
38546
|
-
|
|
38547
|
-
|
|
38548
|
-
|
|
38549
|
-
|
|
38550
|
-
|
|
38551
|
-
|
|
38552
|
-
|
|
38553
|
-
|
|
38554
|
-
|
|
38555
|
-
|
|
38556
|
-
|
|
38557
|
-
|
|
38558
|
-
|
|
38559
|
-
|
|
38560
|
-
|
|
38561
|
-
|
|
38562
|
-
|
|
38563
|
-
|
|
38564
|
-
|
|
38565
|
-
|
|
38566
|
-
|
|
38567
|
-
|
|
38568
|
-
|
|
38569
|
-
|
|
38570
|
-
|
|
38571
|
-
|
|
38572
|
-
|
|
38573
|
-
|
|
38574
|
-
|
|
38575
|
-
|
|
38576
|
-
|
|
38577
|
-
|
|
38578
|
-
|
|
38579
|
-
|
|
38580
|
-
|
|
38581
|
-
|
|
38582
|
-
|
|
38583
|
-
|
|
38584
|
-
|
|
38585
|
-
|
|
38586
|
-
|
|
38587
|
-
|
|
38588
|
-
|
|
38589
|
-
|
|
38530
|
+
let currentStep = "初始化";
|
|
38531
|
+
try {
|
|
38532
|
+
currentStep = "验证账号信息";
|
|
38533
|
+
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";
|
|
38534
|
+
const sessionidCookie = params.cookies.find((it)=>"msToken" === it.name)?.value;
|
|
38535
|
+
if (!sessionidCookie) return {
|
|
38536
|
+
code: 414,
|
|
38537
|
+
message: "账号数据异常,请重新绑定账号后重试。",
|
|
38538
|
+
data: ""
|
|
38539
|
+
};
|
|
38540
|
+
currentStep = "准备请求参数";
|
|
38541
|
+
const headers = {
|
|
38542
|
+
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
38543
|
+
origin: "https://creator.douyin.com",
|
|
38544
|
+
referer: "https://creator.douyin.com/creator-micro/content/post/image?default-tab=3&enter_from=publish_page&media_type=image&type=new",
|
|
38545
|
+
Accept: "application/json, text/plain, */*",
|
|
38546
|
+
"Accept-Encoding": "gzip, deflate, br, zstd",
|
|
38547
|
+
"Content-Type": "application/json",
|
|
38548
|
+
pragma: "no-cache",
|
|
38549
|
+
"cache-control": "no-cache",
|
|
38550
|
+
"sec-ch-ua-platform": params.extraParam?.browserInfo?.["sec-ch-ua-platform"] || "",
|
|
38551
|
+
"sec-ch-ua": params.extraParam?.browserInfo?.["sec-ch-ua"] || "",
|
|
38552
|
+
"bd-ticket-guard-web-version": "2",
|
|
38553
|
+
"sec-ch-ua-mobile": "?0",
|
|
38554
|
+
"user-agent": userAgent,
|
|
38555
|
+
"sec-fetch-site": "same-origin",
|
|
38556
|
+
"sec-fetch-mode": "cors",
|
|
38557
|
+
"sec-fetch-dest": "empty",
|
|
38558
|
+
"accept-language": "zh-CN,zh;q=0.9",
|
|
38559
|
+
priority: "u=1, i"
|
|
38560
|
+
};
|
|
38561
|
+
const publishParams = {
|
|
38562
|
+
read_aid: "2906",
|
|
38563
|
+
aid: "1128",
|
|
38564
|
+
cookie_enabled: "true",
|
|
38565
|
+
screen_width: params.extraParam?.browserInfo.screen_width || "1920",
|
|
38566
|
+
screen_height: params.extraParam?.browserInfo.screen_height || "1080",
|
|
38567
|
+
browser_language: params.extraParam?.browserInfo.browser_language || "zh-CN",
|
|
38568
|
+
browser_platform: params.extraParam?.browserInfo.browser_platform || "Win32",
|
|
38569
|
+
browser_name: params.extraParam?.browserInfo.browser_name || "Mozilla",
|
|
38570
|
+
browser_version: userAgent,
|
|
38571
|
+
browser_online: "true",
|
|
38572
|
+
timezone_name: "Asia/Shanghai",
|
|
38573
|
+
support_h265: "1",
|
|
38574
|
+
msToken: params.cookies.find((e)=>"msToken" === e.name)?.value || "",
|
|
38575
|
+
a_bogus: ""
|
|
38576
|
+
};
|
|
38577
|
+
task.logger.info(`[douyinPublish] publishParams ${JSON.stringify(publishParams)}`);
|
|
38578
|
+
const publishData = {
|
|
38579
|
+
item: {
|
|
38580
|
+
common: {
|
|
38581
|
+
text: params.content,
|
|
38582
|
+
text_extra: params.textExtra,
|
|
38583
|
+
activity: "[]",
|
|
38584
|
+
challenges: params.challengeIds || "[]",
|
|
38585
|
+
hashtag_source: "",
|
|
38586
|
+
mentions: "[]",
|
|
38587
|
+
music_id: params.musicId || "",
|
|
38588
|
+
music_end_time: 1000 * (params.musicDuration || 0),
|
|
38589
|
+
hot_sentence: params.hotSentence || "",
|
|
38590
|
+
visibility_type: Number(params.visibleRange) || 0,
|
|
38591
|
+
download: params.allowSave ? 1 : 0,
|
|
38592
|
+
timing: params.isImmediatelyPublish ? -1 : params.scheduledPublish,
|
|
38593
|
+
media_type: Number(params.publishType) || 2,
|
|
38594
|
+
images: [],
|
|
38595
|
+
creation_id: ""
|
|
38596
|
+
},
|
|
38597
|
+
cover: {
|
|
38598
|
+
poster: ""
|
|
38599
|
+
},
|
|
38600
|
+
mix: params.mix ? {
|
|
38601
|
+
mix_id: params.mix.mix_id,
|
|
38602
|
+
mix_order: params.mix.mix_order || 0
|
|
38603
|
+
} : {},
|
|
38604
|
+
anchor: {},
|
|
38605
|
+
declare: {
|
|
38606
|
+
user_declare_info: "{}"
|
|
38607
|
+
}
|
|
38590
38608
|
}
|
|
38591
|
-
}
|
|
38592
|
-
|
|
38593
|
-
|
|
38594
|
-
|
|
38609
|
+
};
|
|
38610
|
+
const args = [
|
|
38611
|
+
{
|
|
38612
|
+
headers
|
|
38613
|
+
},
|
|
38614
|
+
task.logger,
|
|
38615
|
+
"",
|
|
38616
|
+
"",
|
|
38617
|
+
params.accountId,
|
|
38618
|
+
"douyin"
|
|
38619
|
+
];
|
|
38620
|
+
const http = new Http({
|
|
38595
38621
|
headers
|
|
38596
|
-
}
|
|
38597
|
-
|
|
38598
|
-
|
|
38599
|
-
|
|
38600
|
-
|
|
38601
|
-
|
|
38602
|
-
|
|
38603
|
-
|
|
38604
|
-
|
|
38605
|
-
|
|
38606
|
-
|
|
38607
|
-
|
|
38608
|
-
|
|
38609
|
-
|
|
38610
|
-
|
|
38611
|
-
|
|
38612
|
-
|
|
38613
|
-
|
|
38614
|
-
|
|
38615
|
-
|
|
38616
|
-
|
|
38617
|
-
|
|
38618
|
-
|
|
38619
|
-
|
|
38620
|
-
|
|
38621
|
-
|
|
38622
|
+
});
|
|
38623
|
+
const proxyHttp = new Http(...args);
|
|
38624
|
+
const uploadedImgList = params.uploadedImgList ? JSON.parse(params.uploadedImgList) : [];
|
|
38625
|
+
if (uploadedImgList.length > 0) publishData.item.common.images = uploadedImgList;
|
|
38626
|
+
else {
|
|
38627
|
+
const tmpCachePath = task.getTmpPath();
|
|
38628
|
+
const uploader = new DouyinImageUploader(proxyHttp, headers, publishParams, tmpCachePath);
|
|
38629
|
+
if (params.coverImage) {
|
|
38630
|
+
const cover = await uploader.uploadCover(params.coverImage);
|
|
38631
|
+
if (cover) {
|
|
38632
|
+
publishData.item.common.images.push({
|
|
38633
|
+
uri: cover.uri,
|
|
38634
|
+
width: cover.width,
|
|
38635
|
+
height: cover.height
|
|
38636
|
+
});
|
|
38637
|
+
publishData.item.cover = {
|
|
38638
|
+
poster: cover.uri
|
|
38639
|
+
};
|
|
38640
|
+
}
|
|
38641
|
+
}
|
|
38642
|
+
if (params.banners && params.banners.length > 0) {
|
|
38643
|
+
const banners = params.banners.filter((i)=>i !== params.coverImage);
|
|
38644
|
+
const uploadResults = await uploader.uploadImages(banners);
|
|
38645
|
+
publishData.item.common.images = publishData.item.common.images.concat(uploadResults.map((result)=>({
|
|
38646
|
+
uri: result.uri,
|
|
38647
|
+
width: result.width,
|
|
38648
|
+
height: result.height
|
|
38649
|
+
})));
|
|
38650
|
+
}
|
|
38651
|
+
}
|
|
38652
|
+
publishData.item.common.creation_id = generateRandomString(8) + Date.now();
|
|
38653
|
+
let decision = null;
|
|
38654
|
+
proxyHttp.addResponseInterceptor((response)=>{
|
|
38655
|
+
task.logger.info(`[douyinPublish] 拦截器收到响应response.headers: ${JSON.stringify(response.headers)} `);
|
|
38656
|
+
task.logger.info(`[douyinPublish] 拦截器收到响应response.data: ${JSON.stringify(response.data)} `);
|
|
38657
|
+
decision = parseVerifyPassportDecision(response.headers["x-tt-verify-passport-decision"]);
|
|
38658
|
+
if (needsVerification(decision)) {
|
|
38659
|
+
task.logger.info(`[douyinPublish] 检测到需要验证: ${JSON.stringify(decision)}`);
|
|
38660
|
+
return;
|
|
38661
|
+
}
|
|
38662
|
+
if (!response || !response.data) return;
|
|
38663
|
+
const responseData = response.data;
|
|
38664
|
+
if (response && responseData?.status_code && 0 !== responseData.status_code) {
|
|
38665
|
+
const errorCode = 4 === responseData.status_code ? 500 : responseData.status_code;
|
|
38666
|
+
if (4 === responseData.status_code) task.logger.warn(`[douyinPublish] 抖音服务器错误 status_code: 4,映射为 500 触发重试。原始响应: ${JSON.stringify(responseData)}`);
|
|
38667
|
+
return {
|
|
38668
|
+
code: errorCode,
|
|
38669
|
+
message: responseData.status_msg || "文章发布异常,请稍后重试。",
|
|
38670
|
+
data: responseData
|
|
38622
38671
|
};
|
|
38623
38672
|
}
|
|
38673
|
+
});
|
|
38674
|
+
task._timerRecord.PrePublish = Date.now();
|
|
38675
|
+
if (MockPublish) {
|
|
38676
|
+
const data = "123456789";
|
|
38677
|
+
const message = `图文模拟发布成功 ${http.proxyInfo}`;
|
|
38678
|
+
await updateTaskState?.({
|
|
38679
|
+
state: types_TaskState.SUCCESS,
|
|
38680
|
+
result: {
|
|
38681
|
+
response: data
|
|
38682
|
+
}
|
|
38683
|
+
});
|
|
38684
|
+
return utils_response(0, message, data);
|
|
38624
38685
|
}
|
|
38625
|
-
|
|
38626
|
-
|
|
38627
|
-
|
|
38628
|
-
|
|
38629
|
-
|
|
38630
|
-
|
|
38631
|
-
|
|
38632
|
-
|
|
38633
|
-
|
|
38634
|
-
|
|
38635
|
-
|
|
38636
|
-
|
|
38637
|
-
|
|
38638
|
-
|
|
38639
|
-
|
|
38640
|
-
|
|
38641
|
-
|
|
38642
|
-
|
|
38643
|
-
|
|
38686
|
+
let webProtectData;
|
|
38687
|
+
try {
|
|
38688
|
+
webProtectData = JSON.parse(JSON.parse(params.extraParam["security-sdk/s_sdk_sign_data_key/web_protect"] || "{}").data || "{}");
|
|
38689
|
+
if (!webProtectData.ticket || !webProtectData.ts_sign || !webProtectData.client_cert) {
|
|
38690
|
+
task.logger.error(`webProtectData 关键字段缺失: ${JSON.stringify(webProtectData)}`);
|
|
38691
|
+
return utils_response(414, "安全参数 webProtectData 不完整,请重新获取后重试", "");
|
|
38692
|
+
}
|
|
38693
|
+
} catch (error) {
|
|
38694
|
+
task.logger.error(`解析 webProtectData 失败: ${error}`);
|
|
38695
|
+
return utils_response(414, "安全参数 webProtectData 解析失败,请重新获取后重试", "");
|
|
38696
|
+
}
|
|
38697
|
+
let ticket = webProtectData.ticket;
|
|
38698
|
+
let ts_sign = webProtectData.ts_sign;
|
|
38699
|
+
const serverDataCookie = params.cookies.find((it)=>"bd_ticket_guard_server_data" === it.name)?.value;
|
|
38700
|
+
if (serverDataCookie) try {
|
|
38701
|
+
const decoded = JSON.parse(Buffer.from(decodeURIComponent(serverDataCookie), "base64").toString("utf8"));
|
|
38702
|
+
if (decoded.ticket && decoded.ts_sign) {
|
|
38703
|
+
if (decoded.ticket !== ticket) task.logger.info("[douyinPublish] 使用 cookie 中的最新 ticket(web_protect 已过期)");
|
|
38704
|
+
ticket = decoded.ticket;
|
|
38705
|
+
ts_sign = decoded.ts_sign;
|
|
38706
|
+
}
|
|
38707
|
+
} catch (error) {
|
|
38708
|
+
task.logger.info(`[douyinPublish] 解析 bd_ticket_guard_server_data 失败,回退到 web_protect: ${error}`);
|
|
38644
38709
|
}
|
|
38645
|
-
|
|
38646
|
-
|
|
38647
|
-
|
|
38648
|
-
|
|
38649
|
-
|
|
38650
|
-
|
|
38651
|
-
|
|
38652
|
-
|
|
38653
|
-
|
|
38654
|
-
|
|
38710
|
+
let ec_privateKey;
|
|
38711
|
+
try {
|
|
38712
|
+
ec_privateKey = JSON.parse(JSON.parse(params.extraParam["security-sdk/s_sdk_crypt_sdk"] || "{}").data || "{}").ec_privateKey;
|
|
38713
|
+
if (!ec_privateKey) {
|
|
38714
|
+
task.logger.error("[douyinPublish] ec_privateKey 为空");
|
|
38715
|
+
return utils_response(414, "安全参数 ec_privateKey 缺失,请重新获取后重试", "");
|
|
38716
|
+
}
|
|
38717
|
+
} catch (error) {
|
|
38718
|
+
task.logger.error(`[douyinPublish] 解析 ec_privateKey 失败: ${error}`);
|
|
38719
|
+
return utils_response(414, "安全参数 ec_privateKey 解析失败,请重新获取后重试", "");
|
|
38655
38720
|
}
|
|
38656
|
-
|
|
38657
|
-
|
|
38658
|
-
|
|
38659
|
-
|
|
38660
|
-
|
|
38661
|
-
|
|
38662
|
-
state: types_TaskState.SUCCESS,
|
|
38663
|
-
result: {
|
|
38664
|
-
response: data
|
|
38721
|
+
let certificate;
|
|
38722
|
+
try {
|
|
38723
|
+
certificate = JSON.parse(params.extraParam["security-sdk/s_sdk_server_cert_key"] || "{}").cert;
|
|
38724
|
+
if (!certificate) {
|
|
38725
|
+
task.logger.error("[douyinPublish] certificate 为空");
|
|
38726
|
+
return utils_response(414, "安全参数 certificate 缺失,请重新获取后重试", "");
|
|
38665
38727
|
}
|
|
38666
|
-
})
|
|
38667
|
-
|
|
38668
|
-
|
|
38669
|
-
let webProtectData;
|
|
38670
|
-
try {
|
|
38671
|
-
webProtectData = JSON.parse(JSON.parse(params.extraParam["security-sdk/s_sdk_sign_data_key/web_protect"] || "{}").data || "{}");
|
|
38672
|
-
if (!webProtectData.ticket || !webProtectData.ts_sign || !webProtectData.client_cert) {
|
|
38673
|
-
task.logger.error(`webProtectData 关键字段缺失: ${JSON.stringify(webProtectData)}`);
|
|
38674
|
-
return utils_response(414, "安全参数 webProtectData 不完整,请重新获取后重试", "");
|
|
38728
|
+
} catch (error) {
|
|
38729
|
+
task.logger.error(`[douyinPublish] 解析 certificate 失败: ${error}`);
|
|
38730
|
+
return utils_response(414, "安全参数 certificate 解析失败,请重新获取后重试", "");
|
|
38675
38731
|
}
|
|
38676
|
-
|
|
38677
|
-
|
|
38678
|
-
|
|
38679
|
-
|
|
38680
|
-
|
|
38681
|
-
|
|
38682
|
-
|
|
38683
|
-
|
|
38684
|
-
|
|
38685
|
-
|
|
38686
|
-
if (
|
|
38687
|
-
|
|
38688
|
-
|
|
38732
|
+
const ree_public_key = webProtectData.client_cert.replace("pub.", "");
|
|
38733
|
+
let bdTicketGuardClientData;
|
|
38734
|
+
try {
|
|
38735
|
+
bdTicketGuardClientData = getBdV2({
|
|
38736
|
+
ticket,
|
|
38737
|
+
ts_sign: ts_sign,
|
|
38738
|
+
ec_privateKey: ec_privateKey,
|
|
38739
|
+
certificate: certificate,
|
|
38740
|
+
bd_ticket_guard_ree_public_key: ree_public_key
|
|
38741
|
+
});
|
|
38742
|
+
if (!bdTicketGuardClientData || !bdTicketGuardClientData["headers_bd_ticket_guard_client_data"]) {
|
|
38743
|
+
task.logger.error(`[douyinPublish] bdTicketGuardClientData 生成失败或不完整: ${JSON.stringify(bdTicketGuardClientData)}`);
|
|
38744
|
+
return utils_response(414, "安全参数 bdTicketGuardClientData 生成失败,请重新获取后重试", "");
|
|
38745
|
+
}
|
|
38746
|
+
} catch (error) {
|
|
38747
|
+
task.logger.error(`[douyinPublish] 生成 bdTicketGuardClientData 失败: ${error}`);
|
|
38748
|
+
return utils_response(414, "安全参数 bdTicketGuardClientData 生成异常,请重新获取后重试", "");
|
|
38689
38749
|
}
|
|
38690
|
-
|
|
38691
|
-
|
|
38692
|
-
|
|
38693
|
-
|
|
38694
|
-
|
|
38695
|
-
|
|
38696
|
-
|
|
38697
|
-
|
|
38698
|
-
|
|
38750
|
+
task.logger.info("[douyinPublish] bdTicketGuardClientData 生成成功");
|
|
38751
|
+
const publishQuery = {
|
|
38752
|
+
...publishParams,
|
|
38753
|
+
a_bogus: ""
|
|
38754
|
+
};
|
|
38755
|
+
const queryString = new URLSearchParams(publishQuery).toString();
|
|
38756
|
+
let aBogus;
|
|
38757
|
+
try {
|
|
38758
|
+
aBogus = mock_getABogus(`https://creator.douyin.com/web/api/media/aweme/create_v2/?${queryString}`, publishData, userAgent);
|
|
38759
|
+
if (!aBogus || aBogus.length < 10) {
|
|
38760
|
+
task.logger.error(`[douyinPublish] a_bogus 生成异常,长度过短: ${aBogus}`);
|
|
38761
|
+
return utils_response(414, "安全参数 a_bogus 生成失败,请重试", "");
|
|
38762
|
+
}
|
|
38763
|
+
} catch (error) {
|
|
38764
|
+
task.logger.error(`[douyinPublish] 生成 a_bogus 失败: ${error}`);
|
|
38765
|
+
return utils_response(414, "安全参数 a_bogus 生成异常,请重试", "");
|
|
38699
38766
|
}
|
|
38700
|
-
|
|
38701
|
-
|
|
38702
|
-
|
|
38703
|
-
|
|
38704
|
-
|
|
38705
|
-
|
|
38706
|
-
|
|
38707
|
-
|
|
38708
|
-
|
|
38709
|
-
|
|
38767
|
+
publishQuery.a_bogus = aBogus;
|
|
38768
|
+
const publishQueryParams = new URLSearchParams(publishQuery).toString();
|
|
38769
|
+
let csrfToken;
|
|
38770
|
+
try {
|
|
38771
|
+
csrfToken = mock_generateCsrfTokenAdvanced({
|
|
38772
|
+
cookies: params.cookies,
|
|
38773
|
+
url: "https://creator.douyin.com/web/api/media/aweme/create_v2/",
|
|
38774
|
+
method: "POST",
|
|
38775
|
+
userAgent
|
|
38776
|
+
});
|
|
38777
|
+
if (!csrfToken || csrfToken.length < 10) {
|
|
38778
|
+
task.logger.error(`[douyinPublish] csrfToken 生成异常,长度过短: ${csrfToken}`);
|
|
38779
|
+
return utils_response(414, "安全参数 csrfToken 生成失败,请重试", "");
|
|
38780
|
+
}
|
|
38781
|
+
task.logger.info(`[douyinPublish] csrfToken 生成成功: ${csrfToken.substring(0, 20)}...`);
|
|
38782
|
+
} catch (error) {
|
|
38783
|
+
task.logger.error(`[douyinPublish] 生成 csrfToken 失败: ${error}`);
|
|
38784
|
+
return utils_response(414, "安全参数 csrfToken 生成异常,请重试", "");
|
|
38710
38785
|
}
|
|
38711
|
-
|
|
38712
|
-
|
|
38713
|
-
|
|
38714
|
-
|
|
38715
|
-
|
|
38716
|
-
|
|
38717
|
-
|
|
38718
|
-
bdTicketGuardClientData = getBdV2({
|
|
38719
|
-
ticket,
|
|
38720
|
-
ts_sign: ts_sign,
|
|
38721
|
-
ec_privateKey: ec_privateKey,
|
|
38722
|
-
certificate: certificate,
|
|
38723
|
-
bd_ticket_guard_ree_public_key: ree_public_key
|
|
38724
|
-
});
|
|
38725
|
-
if (!bdTicketGuardClientData || !bdTicketGuardClientData["headers_bd_ticket_guard_client_data"]) {
|
|
38726
|
-
task.logger.error(`[douyinPublish] bdTicketGuardClientData 生成失败或不完整: ${JSON.stringify(bdTicketGuardClientData)}`);
|
|
38727
|
-
return utils_response(414, "安全参数 bdTicketGuardClientData 生成失败,请重新获取后重试", "");
|
|
38786
|
+
let sessionDtrait;
|
|
38787
|
+
try {
|
|
38788
|
+
sessionDtrait = mock_generateDtrait("/web/api/media/aweme/create_v2/");
|
|
38789
|
+
task.logger.info(`[douyinPublish] sessionDtrait 生成成功: ${sessionDtrait || "(空)"}`);
|
|
38790
|
+
} catch (error) {
|
|
38791
|
+
task.logger.error(`[douyinPublish] 生成 sessionDtrait 失败: ${error}`);
|
|
38792
|
+
return utils_response(414, "安全参数 sessionDtrait 生成异常,请重试", "");
|
|
38728
38793
|
}
|
|
38729
|
-
|
|
38730
|
-
|
|
38731
|
-
|
|
38732
|
-
|
|
38733
|
-
|
|
38734
|
-
|
|
38735
|
-
|
|
38736
|
-
|
|
38737
|
-
|
|
38738
|
-
|
|
38739
|
-
|
|
38740
|
-
|
|
38741
|
-
|
|
38742
|
-
|
|
38743
|
-
|
|
38744
|
-
|
|
38794
|
+
task.logger.info(`[douyinPublish] headers: ${JSON.stringify({
|
|
38795
|
+
...headers,
|
|
38796
|
+
Referer: "https://creator.douyin.com/creator-micro/content/post/image?default-tab=3&enter_from=publish_page&media_type=image&type=new",
|
|
38797
|
+
"Content-Type": "application/json",
|
|
38798
|
+
Accept: "application/json, text/plain, */*",
|
|
38799
|
+
"bd-ticket-guard-client-data": bdTicketGuardClientData["headers_bd_ticket_guard_client_data"],
|
|
38800
|
+
"bd-ticket-guard-ree-public-key": bdTicketGuardClientData["headers_bd_ticket_guard_ree_public_key"],
|
|
38801
|
+
"bd-ticket-guard-version": "2",
|
|
38802
|
+
"bd-ticket-guard-web-sign-type": "1",
|
|
38803
|
+
"bd-ticket-guard-web-version": "2",
|
|
38804
|
+
"x-secsdk-csrf-token": csrfToken,
|
|
38805
|
+
"x-tt-session-dtrait": sessionDtrait || ""
|
|
38806
|
+
})}`);
|
|
38807
|
+
task.logger.info(`[douyinPublish] url: https://creator.douyin.com/web/api/media/aweme/create_v2/?${publishQueryParams}`);
|
|
38808
|
+
let publishResult;
|
|
38809
|
+
try {
|
|
38810
|
+
publishResult = await proxyHttp.api({
|
|
38811
|
+
method: "post",
|
|
38812
|
+
url: `https://creator.douyin.com/web/api/media/aweme/create_v2/?${publishQueryParams}`,
|
|
38813
|
+
data: publishData,
|
|
38814
|
+
defaultErrorMsg: "发布异常,请稍后重试。",
|
|
38815
|
+
headers: {
|
|
38816
|
+
...headers,
|
|
38817
|
+
Referer: "https://creator.douyin.com/creator-micro/content/post/image?default-tab=3&enter_from=publish_page&media_type=image&type=new",
|
|
38818
|
+
"Content-Type": "application/json",
|
|
38819
|
+
Accept: "application/json, text/plain, */*",
|
|
38820
|
+
"bd-ticket-guard-client-data": bdTicketGuardClientData["headers_bd_ticket_guard_client_data"],
|
|
38821
|
+
"bd-ticket-guard-ree-public-key": bdTicketGuardClientData["headers_bd_ticket_guard_ree_public_key"],
|
|
38822
|
+
"bd-ticket-guard-version": "2",
|
|
38823
|
+
"bd-ticket-guard-web-sign-type": "1",
|
|
38824
|
+
"bd-ticket-guard-web-version": "2",
|
|
38825
|
+
"x-secsdk-csrf-token": csrfToken,
|
|
38826
|
+
"x-tt-session-dtrait": sessionDtrait || ""
|
|
38827
|
+
}
|
|
38828
|
+
}, {
|
|
38829
|
+
timeout: 60000,
|
|
38830
|
+
retries: 3,
|
|
38831
|
+
retryDelay: 2000
|
|
38832
|
+
});
|
|
38833
|
+
} catch (error) {
|
|
38834
|
+
const handledError = Http.handleApiError(error);
|
|
38835
|
+
const isProxyOrNetworkError = [
|
|
38836
|
+
599,
|
|
38837
|
+
500,
|
|
38838
|
+
502,
|
|
38839
|
+
503,
|
|
38840
|
+
504
|
|
38841
|
+
].includes(handledError.code);
|
|
38842
|
+
if (isProxyOrNetworkError) {
|
|
38843
|
+
const isProxyRequest = handledError.extra?.isProxyRequest === true;
|
|
38844
|
+
const errorType = 599 === handledError.code || isProxyRequest ? "代理错误" : "网络错误";
|
|
38845
|
+
const message = `图文发布失败,${errorType}:${handledError.message}${task.debug ? ` ${http.proxyInfo}` : ""}`;
|
|
38846
|
+
task.logger.error(`[douyinPublish] ${errorType},直接返回: ${message}`, stringifyError(handledError));
|
|
38847
|
+
await updateTaskState?.({
|
|
38848
|
+
state: types_TaskState.FAILED,
|
|
38849
|
+
error: message
|
|
38850
|
+
});
|
|
38851
|
+
return {
|
|
38852
|
+
code: 414,
|
|
38853
|
+
data: "",
|
|
38854
|
+
message
|
|
38855
|
+
};
|
|
38856
|
+
}
|
|
38857
|
+
throw error;
|
|
38745
38858
|
}
|
|
38746
|
-
|
|
38747
|
-
|
|
38748
|
-
|
|
38749
|
-
|
|
38750
|
-
|
|
38751
|
-
|
|
38752
|
-
|
|
38753
|
-
|
|
38754
|
-
|
|
38755
|
-
|
|
38756
|
-
|
|
38757
|
-
|
|
38758
|
-
|
|
38759
|
-
|
|
38760
|
-
|
|
38761
|
-
|
|
38762
|
-
|
|
38859
|
+
task.logger.info(`[douyinPublish] decision值: ${JSON.stringify(decision)}, needsVerification(decision): ${needsVerification(decision)}`);
|
|
38860
|
+
if (needsVerification(decision)) {
|
|
38861
|
+
const details = [
|
|
38862
|
+
publishResult.status_msg,
|
|
38863
|
+
decision?.verify_title,
|
|
38864
|
+
decision?.verify_desc
|
|
38865
|
+
].filter(Boolean).join(" ");
|
|
38866
|
+
const message = `图文发布失败,原因:${details}${task.debug ? ` ${http.proxyInfo}` : ""}`;
|
|
38867
|
+
const safeDecision = safeSerialize(decision) ?? {};
|
|
38868
|
+
const mockData = {
|
|
38869
|
+
state: types_TaskState.FAILED,
|
|
38870
|
+
error: message,
|
|
38871
|
+
result: {
|
|
38872
|
+
...safeDecision,
|
|
38873
|
+
data: safeDecision,
|
|
38874
|
+
uploadedImgList: JSON.stringify(publishData.item.common.images)
|
|
38875
|
+
}
|
|
38876
|
+
};
|
|
38877
|
+
await updateTaskState?.(mockData);
|
|
38878
|
+
return {
|
|
38879
|
+
code: 0,
|
|
38880
|
+
data: mockData,
|
|
38881
|
+
message: "操作成功"
|
|
38882
|
+
};
|
|
38763
38883
|
}
|
|
38764
|
-
|
|
38765
|
-
|
|
38766
|
-
|
|
38767
|
-
|
|
38768
|
-
|
|
38769
|
-
|
|
38770
|
-
|
|
38771
|
-
|
|
38772
|
-
|
|
38773
|
-
|
|
38774
|
-
|
|
38775
|
-
|
|
38776
|
-
|
|
38777
|
-
|
|
38778
|
-
|
|
38779
|
-
|
|
38780
|
-
|
|
38781
|
-
Accept: "application/json, text/plain, */*",
|
|
38782
|
-
"bd-ticket-guard-client-data": bdTicketGuardClientData["headers_bd_ticket_guard_client_data"],
|
|
38783
|
-
"bd-ticket-guard-ree-public-key": bdTicketGuardClientData["headers_bd_ticket_guard_ree_public_key"],
|
|
38784
|
-
"bd-ticket-guard-version": "2",
|
|
38785
|
-
"bd-ticket-guard-web-sign-type": "1",
|
|
38786
|
-
"bd-ticket-guard-web-version": "2",
|
|
38787
|
-
"x-secsdk-csrf-token": csrfToken,
|
|
38788
|
-
"x-tt-session-dtrait": sessionDtrait || ""
|
|
38789
|
-
})}`);
|
|
38790
|
-
task.logger.info(`[douyinPublish] url: https://creator.douyin.com/web/api/media/aweme/create_v2/?${publishQueryParams}`);
|
|
38791
|
-
let publishResult;
|
|
38792
|
-
try {
|
|
38793
|
-
publishResult = await proxyHttp.api({
|
|
38794
|
-
method: "post",
|
|
38795
|
-
url: `https://creator.douyin.com/web/api/media/aweme/create_v2/?${publishQueryParams}`,
|
|
38796
|
-
data: publishData,
|
|
38797
|
-
defaultErrorMsg: "发布异常,请稍后重试。",
|
|
38798
|
-
headers: {
|
|
38799
|
-
...headers,
|
|
38800
|
-
Referer: "https://creator.douyin.com/creator-micro/content/post/image?default-tab=3&enter_from=publish_page&media_type=image&type=new",
|
|
38801
|
-
"Content-Type": "application/json",
|
|
38802
|
-
Accept: "application/json, text/plain, */*",
|
|
38803
|
-
"bd-ticket-guard-client-data": bdTicketGuardClientData["headers_bd_ticket_guard_client_data"],
|
|
38804
|
-
"bd-ticket-guard-ree-public-key": bdTicketGuardClientData["headers_bd_ticket_guard_ree_public_key"],
|
|
38805
|
-
"bd-ticket-guard-version": "2",
|
|
38806
|
-
"bd-ticket-guard-web-sign-type": "1",
|
|
38807
|
-
"bd-ticket-guard-web-version": "2",
|
|
38808
|
-
"x-secsdk-csrf-token": csrfToken,
|
|
38809
|
-
"x-tt-session-dtrait": sessionDtrait || ""
|
|
38810
|
-
}
|
|
38811
|
-
}, {
|
|
38812
|
-
timeout: 60000,
|
|
38813
|
-
retries: 3,
|
|
38814
|
-
retryDelay: 2000
|
|
38815
|
-
});
|
|
38816
|
-
} catch (error) {
|
|
38817
|
-
const handledError = Http.handleApiError(error);
|
|
38818
|
-
const isProxyOrNetworkError = [
|
|
38819
|
-
599,
|
|
38820
|
-
500,
|
|
38821
|
-
502,
|
|
38822
|
-
503,
|
|
38823
|
-
504
|
|
38824
|
-
].includes(handledError.code);
|
|
38825
|
-
if (isProxyOrNetworkError) {
|
|
38826
|
-
const isProxyRequest = handledError.extra?.isProxyRequest === true;
|
|
38827
|
-
const errorType = 599 === handledError.code || isProxyRequest ? "代理错误" : "网络错误";
|
|
38828
|
-
const message = `图文发布失败,${errorType}:${handledError.message}${task.debug ? ` ${http.proxyInfo}` : ""}`;
|
|
38829
|
-
task.logger.error(`[douyinPublish] ${errorType},直接返回: ${message}`, stringifyError(handledError));
|
|
38884
|
+
reportLogger({
|
|
38885
|
+
token: params.huiwenToken || "",
|
|
38886
|
+
enverionment: task.enverionment || "development",
|
|
38887
|
+
postId: params.articleId,
|
|
38888
|
+
eip: proxyHttp.proxyInfo,
|
|
38889
|
+
proxyIp: params.localIP,
|
|
38890
|
+
accountId: params.accountId,
|
|
38891
|
+
uid: params.uid,
|
|
38892
|
+
platform: "douyin",
|
|
38893
|
+
publishParams: publishData
|
|
38894
|
+
});
|
|
38895
|
+
task.logger.info(`[douyinPublish] 发布结果 ${JSON.stringify(publishResult)}`);
|
|
38896
|
+
const isSuccess = 0 === publishResult.status_code;
|
|
38897
|
+
const message = `图文发布${isSuccess ? "成功" : `失败,原因:${publishResult.status_msg} ${decision?.verify_title} ${decision?.verify_desc}`}${task.debug ? ` ${http.proxyInfo}` : ""}`;
|
|
38898
|
+
const data = isSuccess ? publishResult.item_id || "" : "";
|
|
38899
|
+
if (!isSuccess) {
|
|
38900
|
+
const safeDecision = safeSerialize(decision) ?? {};
|
|
38830
38901
|
await updateTaskState?.({
|
|
38831
38902
|
state: types_TaskState.FAILED,
|
|
38832
|
-
error: message
|
|
38903
|
+
error: message,
|
|
38904
|
+
result: {
|
|
38905
|
+
...safeDecision,
|
|
38906
|
+
data: safeDecision,
|
|
38907
|
+
uploadedImgList: JSON.stringify(publishData.item.common.images)
|
|
38908
|
+
}
|
|
38833
38909
|
});
|
|
38834
38910
|
return {
|
|
38835
38911
|
code: 414,
|
|
38836
|
-
data:
|
|
38912
|
+
data: safeDecision,
|
|
38837
38913
|
message
|
|
38838
38914
|
};
|
|
38839
38915
|
}
|
|
38840
|
-
|
|
38841
|
-
|
|
38842
|
-
task.logger.info(`[douyinPublish] decision值: ${JSON.stringify(decision)}, needsVerification(decision): ${needsVerification(decision)}`);
|
|
38843
|
-
if (needsVerification(decision)) {
|
|
38844
|
-
const details = [
|
|
38845
|
-
publishResult.status_msg,
|
|
38846
|
-
decision?.verify_title,
|
|
38847
|
-
decision?.verify_desc
|
|
38848
|
-
].filter(Boolean).join(" ");
|
|
38849
|
-
const message = `图文发布失败,原因:${details}${task.debug ? ` ${http.proxyInfo}` : ""}`;
|
|
38850
|
-
let decisionObj = {};
|
|
38851
|
-
if (decision) decisionObj = decision;
|
|
38852
|
-
const mockData = {
|
|
38853
|
-
state: types_TaskState.FAILED,
|
|
38854
|
-
error: message,
|
|
38916
|
+
await updateTaskState?.({
|
|
38917
|
+
state: types_TaskState.SUCCESS,
|
|
38855
38918
|
result: {
|
|
38856
|
-
|
|
38857
|
-
data: decision,
|
|
38858
|
-
uploadedImgList: JSON.stringify(publishData.item.common.images)
|
|
38919
|
+
response: data
|
|
38859
38920
|
}
|
|
38860
|
-
};
|
|
38861
|
-
|
|
38862
|
-
|
|
38863
|
-
|
|
38864
|
-
|
|
38865
|
-
|
|
38866
|
-
};
|
|
38867
|
-
}
|
|
38868
|
-
reportLogger({
|
|
38869
|
-
token: params.huiwenToken || "",
|
|
38870
|
-
enverionment: task.enverionment || "development",
|
|
38871
|
-
postId: params.articleId,
|
|
38872
|
-
eip: proxyHttp.proxyInfo,
|
|
38873
|
-
proxyIp: params.localIP,
|
|
38874
|
-
accountId: params.accountId,
|
|
38875
|
-
uid: params.uid,
|
|
38876
|
-
platform: "douyin",
|
|
38877
|
-
publishParams: publishData
|
|
38878
|
-
});
|
|
38879
|
-
task.logger.info(`[douyinPublish] 发布结果 ${JSON.stringify(publishResult)}`);
|
|
38880
|
-
const isSuccess = 0 === publishResult.status_code;
|
|
38881
|
-
const message = `图文发布${isSuccess ? "成功" : `失败,原因:${publishResult.status_msg} ${decision?.verify_title} ${decision?.verify_desc}`}${task.debug ? ` ${http.proxyInfo}` : ""}`;
|
|
38882
|
-
const data = isSuccess ? publishResult.item_id || "" : "";
|
|
38883
|
-
if (!isSuccess) {
|
|
38884
|
-
let decisionObj = {};
|
|
38885
|
-
if (decision) decisionObj = decision;
|
|
38921
|
+
});
|
|
38922
|
+
return utils_response(isSuccess ? 0 : 414, message, data);
|
|
38923
|
+
} catch (error) {
|
|
38924
|
+
const handledError = Http.handleApiError(error);
|
|
38925
|
+
const errorMsg = handledError.message || "发布失败";
|
|
38926
|
+
const errorCode = handledError.code || 500;
|
|
38927
|
+
task.logger.error(`[douyinPublish] 发布流程异常 (步骤: ${currentStep}): ${errorMsg}`, stringifyError(error), handledError.extra);
|
|
38886
38928
|
await updateTaskState?.({
|
|
38887
38929
|
state: types_TaskState.FAILED,
|
|
38888
|
-
error:
|
|
38889
|
-
result: {
|
|
38890
|
-
...decisionObj,
|
|
38891
|
-
data: decision,
|
|
38892
|
-
uploadedImgList: JSON.stringify(publishData.item.common.images)
|
|
38893
|
-
}
|
|
38930
|
+
error: `${currentStep}失败: ${errorMsg}`
|
|
38894
38931
|
});
|
|
38895
|
-
return
|
|
38896
|
-
code: 414,
|
|
38897
|
-
data,
|
|
38898
|
-
message
|
|
38899
|
-
};
|
|
38932
|
+
return utils_response(errorCode, errorMsg, "");
|
|
38900
38933
|
}
|
|
38901
|
-
await updateTaskState?.({
|
|
38902
|
-
state: types_TaskState.SUCCESS,
|
|
38903
|
-
result: {
|
|
38904
|
-
response: data
|
|
38905
|
-
}
|
|
38906
|
-
});
|
|
38907
|
-
return utils_response(isSuccess ? 0 : 414, message, data);
|
|
38908
38934
|
};
|
|
38909
38935
|
const douyinPublish_rpa_rpaAction = async (task, params)=>{
|
|
38910
38936
|
const commonCookies = {
|
|
@@ -43167,6 +43193,11 @@ var __webpack_exports__ = {};
|
|
|
43167
43193
|
this.concurrentLimit = config.concurrentLimit || 4;
|
|
43168
43194
|
this.singleFileSize = config.singleFileSize || 10485760;
|
|
43169
43195
|
this.http = config.http || new Http();
|
|
43196
|
+
this.reqOptions = {
|
|
43197
|
+
timeout: config.timeout ?? 60000,
|
|
43198
|
+
retries: config.retries ?? 3,
|
|
43199
|
+
retryDelay: config.retryDelay ?? 2000
|
|
43200
|
+
};
|
|
43170
43201
|
}
|
|
43171
43202
|
calculateMd5(buffer) {
|
|
43172
43203
|
const MAX_SIZE = 5242880;
|
|
@@ -43223,7 +43254,7 @@ var __webpack_exports__ = {};
|
|
|
43223
43254
|
url: filePath,
|
|
43224
43255
|
method: "get",
|
|
43225
43256
|
responseType: "arraybuffer"
|
|
43226
|
-
});
|
|
43257
|
+
}, this.reqOptions);
|
|
43227
43258
|
return Buffer.from(resp);
|
|
43228
43259
|
}
|
|
43229
43260
|
return external_node_fs_default().promises.readFile(filePath);
|
|
@@ -43253,7 +43284,7 @@ var __webpack_exports__ = {};
|
|
|
43253
43284
|
headers,
|
|
43254
43285
|
data: requestBody,
|
|
43255
43286
|
defaultErrorMsg: "获取UploadID失败"
|
|
43256
|
-
});
|
|
43287
|
+
}, this.reqOptions);
|
|
43257
43288
|
if (!resp?.UploadID) throw new Error(`获取 UploadID 失败: ${resp?.errMsg || "未知错误"}`);
|
|
43258
43289
|
return resp.UploadID;
|
|
43259
43290
|
}
|
|
@@ -43274,7 +43305,7 @@ var __webpack_exports__ = {};
|
|
|
43274
43305
|
headers,
|
|
43275
43306
|
data: chunk,
|
|
43276
43307
|
defaultErrorMsg: `分片 ${partNumber} 上传失败`
|
|
43277
|
-
});
|
|
43308
|
+
}, this.reqOptions);
|
|
43278
43309
|
if (resp?.errCode !== void 0 && 0 !== resp.errCode) throw new Error(`分片 ${partNumber} 上传失败: ${resp.errMsg}`);
|
|
43279
43310
|
if (onProgress) onProgress(chunk.length);
|
|
43280
43311
|
return resp.ETag || "";
|
|
@@ -43298,7 +43329,7 @@ var __webpack_exports__ = {};
|
|
|
43298
43329
|
headers,
|
|
43299
43330
|
data: requestBody,
|
|
43300
43331
|
defaultErrorMsg: "确认分片上传失败"
|
|
43301
|
-
});
|
|
43332
|
+
}, this.reqOptions);
|
|
43302
43333
|
if (resp?.ListPartsResult?.Part) return resp.ListPartsResult.Part.map((p)=>({
|
|
43303
43334
|
PartNumber: parseInt(p.PartNumber),
|
|
43304
43335
|
ETag: p.ETag
|
|
@@ -43324,7 +43355,7 @@ var __webpack_exports__ = {};
|
|
|
43324
43355
|
headers,
|
|
43325
43356
|
data: requestBody,
|
|
43326
43357
|
defaultErrorMsg: "完成上传失败"
|
|
43327
|
-
});
|
|
43358
|
+
}, this.reqOptions);
|
|
43328
43359
|
if (!resp?.DownloadURL) throw new Error(`完成上传失败: ${resp?.errMsg || "未知错误"}`);
|
|
43329
43360
|
return resp.DownloadURL;
|
|
43330
43361
|
}
|
|
@@ -43675,7 +43706,9 @@ var __webpack_exports__ = {};
|
|
|
43675
43706
|
task.logger.info("[shipinhaoPublish] 开始执行视频号发布 - Mock API 方式");
|
|
43676
43707
|
const updateTaskState = task.taskStageStore?.update?.bind(task.taskStageStore, task.taskId || "");
|
|
43677
43708
|
if (!params.extraParam.fingerPrintDeviceId || !params.extraParam.aId) return utils_response(400, "fingerPrintDeviceId和aId 不能为空", "");
|
|
43709
|
+
let currentStep = "初始化";
|
|
43678
43710
|
try {
|
|
43711
|
+
currentStep = "解析认证信息";
|
|
43679
43712
|
const cookieString = params.cookies.map((c)=>`${c.name}=${c.value}`).join("; ");
|
|
43680
43713
|
const fingerPrintDeviceId = params.extraParam.fingerPrintDeviceId;
|
|
43681
43714
|
const aId = params.extraParam.aId;
|
|
@@ -43696,8 +43729,10 @@ var __webpack_exports__ = {};
|
|
|
43696
43729
|
headers
|
|
43697
43730
|
});
|
|
43698
43731
|
const proxyHttp = new Http(...args);
|
|
43732
|
+
currentStep = "验证发布参数";
|
|
43699
43733
|
if (!params.banners || 0 === params.banners.length) return utils_response(400, "至少需要一张图片", "");
|
|
43700
43734
|
const images = params.banners.slice(0, 18).filter((img)=>"string" == typeof img);
|
|
43735
|
+
currentStep = "获取用户信息";
|
|
43701
43736
|
task.logger.info("[shipinhaoPublish] 获取用户信息...");
|
|
43702
43737
|
console.log("cookieString", cookieString);
|
|
43703
43738
|
const userInfo = await mock_getUserInfo(cookieString, http);
|
|
@@ -43708,6 +43743,7 @@ var __webpack_exports__ = {};
|
|
|
43708
43743
|
}
|
|
43709
43744
|
const finderUsername = userInfo.data.finderUser.finderUsername;
|
|
43710
43745
|
console.log(finderUsername);
|
|
43746
|
+
currentStep = "获取上传认证密钥";
|
|
43711
43747
|
task.logger.info("[shipinhaoPublish] 获取上传认证密钥...");
|
|
43712
43748
|
const authKeyResponse = await getUploadAuthKey(cookieString, finderUsername, http);
|
|
43713
43749
|
if (0 !== authKeyResponse.errCode || !authKeyResponse.data?.authKey) return utils_response(authKeyResponse.errCode || 500, `获取上传认证参数失败: ${authKeyResponse.errMsg}`, "");
|
|
@@ -43715,10 +43751,12 @@ var __webpack_exports__ = {};
|
|
|
43715
43751
|
const uin = authKeyResponse.data.uin;
|
|
43716
43752
|
if (!uin) return utils_response(500, "获取用户 uin 失败", "");
|
|
43717
43753
|
const taskId = String(generateUUID());
|
|
43754
|
+
currentStep = "上传图片";
|
|
43718
43755
|
task.logger.info(`[shipinhaoPublish] 开始上传 ${images.length} 张图片...`);
|
|
43719
43756
|
const uploadedImages = [];
|
|
43720
43757
|
for(let i = 0; i < images.length; i++){
|
|
43721
|
-
|
|
43758
|
+
currentStep = `上传图片 ${i + 1}/${images.length}`;
|
|
43759
|
+
task.logger.info(`[shipinhaoPublish] ${currentStep}...`);
|
|
43722
43760
|
const uploadResult = await uploadImageComplete(images[i], taskId, finderUsername, uin, authKey, http);
|
|
43723
43761
|
console.log(JSON.stringify(uploadResult));
|
|
43724
43762
|
if (!uploadResult.DownloadURL) return utils_response(500, `图片上传失败: ${uploadResult.errMsg}`, "");
|
|
@@ -43735,6 +43773,7 @@ var __webpack_exports__ = {};
|
|
|
43735
43773
|
urlCdnTaskId: ""
|
|
43736
43774
|
});
|
|
43737
43775
|
}
|
|
43776
|
+
currentStep = "发布图文内容";
|
|
43738
43777
|
task.logger.info("[shipinhaoPublish] 正在发布...");
|
|
43739
43778
|
const topicNames = params.topic || void 0;
|
|
43740
43779
|
const addressInfo = params.address ? {
|
|
@@ -43821,9 +43860,15 @@ var __webpack_exports__ = {};
|
|
|
43821
43860
|
});
|
|
43822
43861
|
return utils_response(resultCode || 500, errorMessage, "");
|
|
43823
43862
|
} catch (error) {
|
|
43824
|
-
const
|
|
43825
|
-
|
|
43826
|
-
|
|
43863
|
+
const handledError = Http.handleApiError(error);
|
|
43864
|
+
const errorMsg = handledError.message || "发布失败,请稍后重试";
|
|
43865
|
+
const errorCode = handledError.code || 500;
|
|
43866
|
+
task.logger.error(`[shipinhaoPublish] 发布流程异常: ${errorMsg}`, stringifyError(error), handledError.extra);
|
|
43867
|
+
await updateTaskState?.({
|
|
43868
|
+
state: types_TaskState.FAILED,
|
|
43869
|
+
error: errorMsg
|
|
43870
|
+
});
|
|
43871
|
+
return utils_response(errorCode, errorMsg, "");
|
|
43827
43872
|
}
|
|
43828
43873
|
};
|
|
43829
43874
|
const shipinhaoPublish_rpa_rpaAction = async (task, params)=>{
|
|
@@ -50329,7 +50374,7 @@ var __webpack_exports__ = {};
|
|
|
50329
50374
|
likeNumYesterday: classic_schemas_number().nullable(),
|
|
50330
50375
|
commentNumYesterday: classic_schemas_number().nullable()
|
|
50331
50376
|
});
|
|
50332
|
-
classic_schemas_object({
|
|
50377
|
+
const douyinConfigDataSchema = classic_schemas_object({
|
|
50333
50378
|
fansNum: classic_schemas_number(),
|
|
50334
50379
|
favedNum: classic_schemas_number(),
|
|
50335
50380
|
fansNumLastWeek: classic_schemas_number(),
|
|
@@ -50339,7 +50384,7 @@ var __webpack_exports__ = {};
|
|
|
50339
50384
|
shareNumLastWeek: classic_schemas_number(),
|
|
50340
50385
|
visitNumLastWeek: classic_schemas_number()
|
|
50341
50386
|
});
|
|
50342
|
-
classic_schemas_object({
|
|
50387
|
+
const shipinhaoConfigDataSchema = classic_schemas_object({
|
|
50343
50388
|
fansNum: classic_schemas_number(),
|
|
50344
50389
|
feedsCount: classic_schemas_number(),
|
|
50345
50390
|
fansNumYesterday: classic_schemas_number().nullable(),
|
|
@@ -50635,4 +50680,5 @@ if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_targe
|
|
|
50635
50680
|
value: true
|
|
50636
50681
|
});
|
|
50637
50682
|
|
|
50638
|
-
//# sourceMappingURL=bundle.js.map
|
|
50683
|
+
//# sourceMappingURL=bundle.js.map
|
|
50684
|
+
//# debugId=029aefb0-580d-5097-84ee-1a7045670fcb
|