@iflyrpa/actions 4.0.5 → 4.0.6-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions/searchAccountInfo/getDouyinInfo.d.ts +16 -0
- package/dist/actions/searchAccountInfo/getShipinhaoInfo.d.ts +14 -0
- package/dist/actions/searchAccountInfo/index.d.ts +4 -2
- package/dist/actions/searchAccountInfo/types.d.ts +21 -1
- package/dist/actions/searchPublishInfo/handleDouyinData.d.ts +17 -0
- package/dist/actions/searchPublishInfo/handleShipinhaoData.d.ts +17 -0
- package/dist/actions/searchPublishInfo/index.d.ts +7 -0
- package/dist/actions/searchPublishInfo/types.d.ts +97 -0
- package/dist/actions/shipinhaoPublish/uploader.d.ts +4 -0
- package/dist/actions/weixinPublish/index.d.ts +2 -2
- package/dist/actions/xiaohongshuPublish/index.d.ts +1 -1
- package/dist/bundle.js +1002 -395
- package/dist/bundle.js.map +1 -1
- package/dist/index.d.ts +79 -1
- package/dist/index.js +1007 -400
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1006 -401
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4394,13 +4394,13 @@ var __webpack_exports__ = {};
|
|
|
4394
4394
|
bjhConfigDataSchema: ()=>bjhConfigDataSchema,
|
|
4395
4395
|
Action: ()=>Action,
|
|
4396
4396
|
ProxyAgent: ()=>ProxyAgent,
|
|
4397
|
+
douyinConfigDataSchema: ()=>douyinConfigDataSchema,
|
|
4398
|
+
shipinhaoConfigDataSchema: ()=>shipinhaoConfigDataSchema,
|
|
4397
4399
|
version: ()=>package_namespaceObject.i8
|
|
4398
4400
|
});
|
|
4399
4401
|
const package_json_namespaceObject = require("@iflyrpa/share/package.json");
|
|
4400
4402
|
var package_json_default = /*#__PURE__*/ __webpack_require__.n(package_json_namespaceObject);
|
|
4401
|
-
var package_namespaceObject = {
|
|
4402
|
-
i8: "4.0.5"
|
|
4403
|
-
};
|
|
4403
|
+
var package_namespaceObject = JSON.parse('{"i8":"4.0.6-beta.0"}');
|
|
4404
4404
|
const share_namespaceObject = require("@iflyrpa/share");
|
|
4405
4405
|
const external_node_fs_namespaceObject = require("node:fs");
|
|
4406
4406
|
var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
|
|
@@ -4649,11 +4649,12 @@ var __webpack_exports__ = {};
|
|
|
4649
4649
|
this.logger?.debug(`未处理的网络错误代码: ${error.code} ${error.message}`, {
|
|
4650
4650
|
errorString: stringifyError(error)
|
|
4651
4651
|
});
|
|
4652
|
-
_message =
|
|
4652
|
+
_message = `网络错误: ${error.message}`;
|
|
4653
4653
|
break;
|
|
4654
4654
|
}
|
|
4655
4655
|
}
|
|
4656
|
-
|
|
4656
|
+
if (error.code && !error.response?.data) errorResponse.message = _message || errorResponse.message;
|
|
4657
|
+
else errorResponse.message = errorResponse.message ? errorResponse.message : _message;
|
|
4657
4658
|
if ("canceled" === errorResponse.message) {
|
|
4658
4659
|
const message = errorResponse.extra?.isProxyRequest ? "代理连接建立超时,请更换区域或稍后重试!" : "网络请求超时,请稍后重试!";
|
|
4659
4660
|
errorResponse.message = message;
|
|
@@ -13442,400 +13443,421 @@ var __webpack_exports__ = {};
|
|
|
13442
13443
|
}
|
|
13443
13444
|
return randomString;
|
|
13444
13445
|
}
|
|
13446
|
+
function safeSerialize(obj) {
|
|
13447
|
+
if (!obj || "object" != typeof obj) return obj;
|
|
13448
|
+
try {
|
|
13449
|
+
return JSON.parse(JSON.stringify(obj));
|
|
13450
|
+
} catch (error) {
|
|
13451
|
+
return {};
|
|
13452
|
+
}
|
|
13453
|
+
}
|
|
13445
13454
|
const mock_mockAction = async (task, params)=>{
|
|
13446
13455
|
const updateTaskState = task.taskStageStore?.update?.bind(task.taskStageStore, task.taskId || "");
|
|
13447
|
-
if (!params.extraParam || !params.extraParam["security-sdk/
|
|
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
|
-
|
|
13511
|
-
|
|
13512
|
-
|
|
13456
|
+
if (!params.extraParam || !params.extraParam["security-sdk/s_sdk_sign_data_key/web_protect"] || !params.extraParam["security-sdk/s_sdk_server_cert_key"] || !params.extraParam["security-sdk/s_sdk_crypt_sdk"]) return (0, share_namespaceObject.response)(414, "extraParam 参数缺失或不完整", "");
|
|
13457
|
+
let currentStep = "初始化";
|
|
13458
|
+
try {
|
|
13459
|
+
currentStep = "验证账号信息";
|
|
13460
|
+
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";
|
|
13461
|
+
const sessionidCookie = params.cookies.find((it)=>"msToken" === it.name)?.value;
|
|
13462
|
+
if (!sessionidCookie) return {
|
|
13463
|
+
code: 414,
|
|
13464
|
+
message: "账号数据异常,请重新绑定账号后重试。",
|
|
13465
|
+
data: ""
|
|
13466
|
+
};
|
|
13467
|
+
currentStep = "准备请求参数";
|
|
13468
|
+
const headers = {
|
|
13469
|
+
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
13470
|
+
origin: "https://creator.douyin.com",
|
|
13471
|
+
referer: "https://creator.douyin.com/creator-micro/content/post/image?default-tab=3&enter_from=publish_page&media_type=image&type=new",
|
|
13472
|
+
Accept: "application/json, text/plain, */*",
|
|
13473
|
+
"Accept-Encoding": "gzip, deflate, br, zstd",
|
|
13474
|
+
"Content-Type": "application/json",
|
|
13475
|
+
pragma: "no-cache",
|
|
13476
|
+
"cache-control": "no-cache",
|
|
13477
|
+
"sec-ch-ua-platform": params.extraParam?.browserInfo?.["sec-ch-ua-platform"] || "",
|
|
13478
|
+
"sec-ch-ua": params.extraParam?.browserInfo?.["sec-ch-ua"] || "",
|
|
13479
|
+
"bd-ticket-guard-web-version": "2",
|
|
13480
|
+
"sec-ch-ua-mobile": "?0",
|
|
13481
|
+
"user-agent": userAgent,
|
|
13482
|
+
"sec-fetch-site": "same-origin",
|
|
13483
|
+
"sec-fetch-mode": "cors",
|
|
13484
|
+
"sec-fetch-dest": "empty",
|
|
13485
|
+
"accept-language": "zh-CN,zh;q=0.9",
|
|
13486
|
+
priority: "u=1, i"
|
|
13487
|
+
};
|
|
13488
|
+
const publishParams = {
|
|
13489
|
+
read_aid: "2906",
|
|
13490
|
+
aid: "1128",
|
|
13491
|
+
cookie_enabled: "true",
|
|
13492
|
+
screen_width: params.extraParam?.browserInfo.screen_width || "1920",
|
|
13493
|
+
screen_height: params.extraParam?.browserInfo.screen_height || "1080",
|
|
13494
|
+
browser_language: params.extraParam?.browserInfo.browser_language || "zh-CN",
|
|
13495
|
+
browser_platform: params.extraParam?.browserInfo.browser_platform || "Win32",
|
|
13496
|
+
browser_name: params.extraParam?.browserInfo.browser_name || "Mozilla",
|
|
13497
|
+
browser_version: userAgent,
|
|
13498
|
+
browser_online: "true",
|
|
13499
|
+
timezone_name: "Asia/Shanghai",
|
|
13500
|
+
support_h265: "1",
|
|
13501
|
+
msToken: params.cookies.find((e)=>"msToken" === e.name)?.value || "",
|
|
13502
|
+
a_bogus: ""
|
|
13503
|
+
};
|
|
13504
|
+
task.logger.info(`[douyinPublish] publishParams ${JSON.stringify(publishParams)}`);
|
|
13505
|
+
const publishData = {
|
|
13506
|
+
item: {
|
|
13507
|
+
common: {
|
|
13508
|
+
text: params.content,
|
|
13509
|
+
text_extra: params.textExtra,
|
|
13510
|
+
activity: "[]",
|
|
13511
|
+
challenges: params.challengeIds || "[]",
|
|
13512
|
+
hashtag_source: "",
|
|
13513
|
+
mentions: "[]",
|
|
13514
|
+
music_id: params.musicId || "",
|
|
13515
|
+
music_end_time: 1000 * (params.musicDuration || 0),
|
|
13516
|
+
hot_sentence: params.hotSentence || "",
|
|
13517
|
+
visibility_type: Number(params.visibleRange) || 0,
|
|
13518
|
+
download: params.allowSave ? 1 : 0,
|
|
13519
|
+
timing: params.isImmediatelyPublish ? -1 : params.scheduledPublish,
|
|
13520
|
+
media_type: Number(params.publishType) || 2,
|
|
13521
|
+
images: [],
|
|
13522
|
+
creation_id: ""
|
|
13523
|
+
},
|
|
13524
|
+
cover: {
|
|
13525
|
+
poster: ""
|
|
13526
|
+
},
|
|
13527
|
+
mix: params.mix ? {
|
|
13528
|
+
mix_id: params.mix.mix_id,
|
|
13529
|
+
mix_order: params.mix.mix_order || 0
|
|
13530
|
+
} : {},
|
|
13531
|
+
anchor: {},
|
|
13532
|
+
declare: {
|
|
13533
|
+
user_declare_info: "{}"
|
|
13534
|
+
}
|
|
13535
|
+
}
|
|
13536
|
+
};
|
|
13537
|
+
const args = [
|
|
13538
|
+
{
|
|
13539
|
+
headers
|
|
13513
13540
|
},
|
|
13514
|
-
|
|
13515
|
-
|
|
13516
|
-
|
|
13517
|
-
|
|
13518
|
-
|
|
13519
|
-
|
|
13520
|
-
|
|
13541
|
+
task.logger,
|
|
13542
|
+
"",
|
|
13543
|
+
"",
|
|
13544
|
+
params.accountId,
|
|
13545
|
+
"douyin"
|
|
13546
|
+
];
|
|
13547
|
+
const http = new Http({
|
|
13548
|
+
headers
|
|
13549
|
+
});
|
|
13550
|
+
const proxyHttp = new Http(...args);
|
|
13551
|
+
const uploadedImgList = params.uploadedImgList ? JSON.parse(params.uploadedImgList) : [];
|
|
13552
|
+
if (uploadedImgList.length > 0) publishData.item.common.images = uploadedImgList;
|
|
13553
|
+
else {
|
|
13554
|
+
const tmpCachePath = task.getTmpPath();
|
|
13555
|
+
const uploader = new DouyinImageUploader(proxyHttp, headers, publishParams, tmpCachePath);
|
|
13556
|
+
if (params.coverImage) {
|
|
13557
|
+
const cover = await uploader.uploadCover(params.coverImage);
|
|
13558
|
+
if (cover) {
|
|
13559
|
+
publishData.item.common.images.push({
|
|
13560
|
+
uri: cover.uri,
|
|
13561
|
+
width: cover.width,
|
|
13562
|
+
height: cover.height
|
|
13563
|
+
});
|
|
13564
|
+
publishData.item.cover = {
|
|
13565
|
+
poster: cover.uri
|
|
13566
|
+
};
|
|
13567
|
+
}
|
|
13568
|
+
}
|
|
13569
|
+
if (params.banners && params.banners.length > 0) {
|
|
13570
|
+
const banners = params.banners.filter((i)=>i !== params.coverImage);
|
|
13571
|
+
const uploadResults = await uploader.uploadImages(banners);
|
|
13572
|
+
publishData.item.common.images = publishData.item.common.images.concat(uploadResults.map((result)=>({
|
|
13573
|
+
uri: result.uri,
|
|
13574
|
+
width: result.width,
|
|
13575
|
+
height: result.height
|
|
13576
|
+
})));
|
|
13521
13577
|
}
|
|
13522
13578
|
}
|
|
13523
|
-
|
|
13524
|
-
|
|
13525
|
-
{
|
|
13526
|
-
headers
|
|
13527
|
-
|
|
13528
|
-
|
|
13529
|
-
|
|
13530
|
-
|
|
13531
|
-
|
|
13532
|
-
|
|
13533
|
-
|
|
13534
|
-
|
|
13535
|
-
|
|
13536
|
-
|
|
13537
|
-
|
|
13538
|
-
|
|
13539
|
-
|
|
13540
|
-
|
|
13541
|
-
|
|
13542
|
-
const uploader = new DouyinImageUploader(proxyHttp, headers, publishParams, tmpCachePath);
|
|
13543
|
-
if (params.coverImage) {
|
|
13544
|
-
const cover = await uploader.uploadCover(params.coverImage);
|
|
13545
|
-
if (cover) {
|
|
13546
|
-
publishData.item.common.images.push({
|
|
13547
|
-
uri: cover.uri,
|
|
13548
|
-
width: cover.width,
|
|
13549
|
-
height: cover.height
|
|
13550
|
-
});
|
|
13551
|
-
publishData.item.cover = {
|
|
13552
|
-
poster: cover.uri
|
|
13579
|
+
publishData.item.common.creation_id = generateRandomString(8) + Date.now();
|
|
13580
|
+
let decision = null;
|
|
13581
|
+
proxyHttp.addResponseInterceptor((response)=>{
|
|
13582
|
+
task.logger.info(`[douyinPublish] 拦截器收到响应response.headers: ${JSON.stringify(response.headers)} `);
|
|
13583
|
+
task.logger.info(`[douyinPublish] 拦截器收到响应response.data: ${JSON.stringify(response.data)} `);
|
|
13584
|
+
decision = parseVerifyPassportDecision(response.headers["x-tt-verify-passport-decision"]);
|
|
13585
|
+
if (needsVerification(decision)) {
|
|
13586
|
+
task.logger.info(`[douyinPublish] 检测到需要验证: ${JSON.stringify(decision)}`);
|
|
13587
|
+
return;
|
|
13588
|
+
}
|
|
13589
|
+
if (!response || !response.data) return;
|
|
13590
|
+
const responseData = response.data;
|
|
13591
|
+
if (response && responseData?.status_code && 0 !== responseData.status_code) {
|
|
13592
|
+
const errorCode = 4 === responseData.status_code ? 500 : responseData.status_code;
|
|
13593
|
+
if (4 === responseData.status_code) task.logger.warn(`[douyinPublish] 抖音服务器错误 status_code: 4,映射为 500 触发重试。原始响应: ${JSON.stringify(responseData)}`);
|
|
13594
|
+
return {
|
|
13595
|
+
code: errorCode,
|
|
13596
|
+
message: responseData.status_msg || "文章发布异常,请稍后重试。",
|
|
13597
|
+
data: responseData
|
|
13553
13598
|
};
|
|
13554
13599
|
}
|
|
13600
|
+
});
|
|
13601
|
+
task._timerRecord.PrePublish = Date.now();
|
|
13602
|
+
if (MockPublish) {
|
|
13603
|
+
const data = "123456789";
|
|
13604
|
+
const message = `图文模拟发布成功 ${http.proxyInfo}`;
|
|
13605
|
+
await updateTaskState?.({
|
|
13606
|
+
state: share_namespaceObject.TaskState.SUCCESS,
|
|
13607
|
+
result: {
|
|
13608
|
+
response: data
|
|
13609
|
+
}
|
|
13610
|
+
});
|
|
13611
|
+
return (0, share_namespaceObject.response)(0, message, data);
|
|
13555
13612
|
}
|
|
13556
|
-
|
|
13557
|
-
|
|
13558
|
-
|
|
13559
|
-
|
|
13560
|
-
|
|
13561
|
-
|
|
13562
|
-
height: result.height
|
|
13563
|
-
})));
|
|
13564
|
-
}
|
|
13565
|
-
}
|
|
13566
|
-
publishData.item.common.creation_id = generateRandomString(8) + Date.now();
|
|
13567
|
-
let decision = null;
|
|
13568
|
-
proxyHttp.addResponseInterceptor((response)=>{
|
|
13569
|
-
task.logger.info(`[douyinPublish] 拦截器收到响应response.headers: ${JSON.stringify(response.headers)} `);
|
|
13570
|
-
task.logger.info(`[douyinPublish] 拦截器收到响应response.data: ${JSON.stringify(response.data)} `);
|
|
13571
|
-
decision = parseVerifyPassportDecision(response.headers["x-tt-verify-passport-decision"]);
|
|
13572
|
-
if (needsVerification(decision)) {
|
|
13573
|
-
task.logger.info(`[douyinPublish] 检测到需要验证: ${JSON.stringify(decision)}`);
|
|
13574
|
-
return;
|
|
13575
|
-
}
|
|
13576
|
-
if (!response || !response.data) return;
|
|
13577
|
-
const responseData = response.data;
|
|
13578
|
-
if (response && responseData?.status_code && 0 !== responseData.status_code) {
|
|
13579
|
-
const errorCode = 4 === responseData.status_code ? 500 : responseData.status_code;
|
|
13580
|
-
if (4 === responseData.status_code) task.logger.warn(`[douyinPublish] 抖音服务器错误 status_code: 4,映射为 500 触发重试。原始响应: ${JSON.stringify(responseData)}`);
|
|
13581
|
-
return {
|
|
13582
|
-
code: errorCode,
|
|
13583
|
-
message: responseData.status_msg || "文章发布异常,请稍后重试。",
|
|
13584
|
-
data: responseData
|
|
13585
|
-
};
|
|
13586
|
-
}
|
|
13587
|
-
});
|
|
13588
|
-
task._timerRecord.PrePublish = Date.now();
|
|
13589
|
-
if (MockPublish) {
|
|
13590
|
-
const data = "123456789";
|
|
13591
|
-
const message = `图文模拟发布成功 ${http.proxyInfo}`;
|
|
13592
|
-
await updateTaskState?.({
|
|
13593
|
-
state: share_namespaceObject.TaskState.SUCCESS,
|
|
13594
|
-
result: {
|
|
13595
|
-
response: data
|
|
13613
|
+
let webProtectData;
|
|
13614
|
+
try {
|
|
13615
|
+
webProtectData = JSON.parse(JSON.parse(params.extraParam["security-sdk/s_sdk_sign_data_key/web_protect"] || "{}").data || "{}");
|
|
13616
|
+
if (!webProtectData.ticket || !webProtectData.ts_sign || !webProtectData.client_cert) {
|
|
13617
|
+
task.logger.error(`webProtectData 关键字段缺失: ${JSON.stringify(webProtectData)}`);
|
|
13618
|
+
return (0, share_namespaceObject.response)(414, "安全参数 webProtectData 不完整,请重新获取后重试", "");
|
|
13596
13619
|
}
|
|
13597
|
-
})
|
|
13598
|
-
|
|
13599
|
-
|
|
13600
|
-
|
|
13601
|
-
|
|
13602
|
-
|
|
13603
|
-
|
|
13604
|
-
|
|
13605
|
-
|
|
13620
|
+
} catch (error) {
|
|
13621
|
+
task.logger.error(`解析 webProtectData 失败: ${error}`);
|
|
13622
|
+
return (0, share_namespaceObject.response)(414, "安全参数 webProtectData 解析失败,请重新获取后重试", "");
|
|
13623
|
+
}
|
|
13624
|
+
let ticket = webProtectData.ticket;
|
|
13625
|
+
let ts_sign = webProtectData.ts_sign;
|
|
13626
|
+
const serverDataCookie = params.cookies.find((it)=>"bd_ticket_guard_server_data" === it.name)?.value;
|
|
13627
|
+
if (serverDataCookie) try {
|
|
13628
|
+
const decoded = JSON.parse(Buffer.from(decodeURIComponent(serverDataCookie), "base64").toString("utf8"));
|
|
13629
|
+
if (decoded.ticket && decoded.ts_sign) {
|
|
13630
|
+
if (decoded.ticket !== ticket) task.logger.info("[douyinPublish] 使用 cookie 中的最新 ticket(web_protect 已过期)");
|
|
13631
|
+
ticket = decoded.ticket;
|
|
13632
|
+
ts_sign = decoded.ts_sign;
|
|
13633
|
+
}
|
|
13634
|
+
} catch (error) {
|
|
13635
|
+
task.logger.info(`[douyinPublish] 解析 bd_ticket_guard_server_data 失败,回退到 web_protect: ${error}`);
|
|
13606
13636
|
}
|
|
13607
|
-
|
|
13608
|
-
|
|
13609
|
-
|
|
13610
|
-
|
|
13611
|
-
|
|
13612
|
-
|
|
13613
|
-
|
|
13614
|
-
|
|
13615
|
-
|
|
13616
|
-
|
|
13617
|
-
if (decoded.ticket !== ticket) task.logger.info("[douyinPublish] 使用 cookie 中的最新 ticket(web_protect 已过期)");
|
|
13618
|
-
ticket = decoded.ticket;
|
|
13619
|
-
ts_sign = decoded.ts_sign;
|
|
13637
|
+
let ec_privateKey;
|
|
13638
|
+
try {
|
|
13639
|
+
ec_privateKey = JSON.parse(JSON.parse(params.extraParam["security-sdk/s_sdk_crypt_sdk"] || "{}").data || "{}").ec_privateKey;
|
|
13640
|
+
if (!ec_privateKey) {
|
|
13641
|
+
task.logger.error("[douyinPublish] ec_privateKey 为空");
|
|
13642
|
+
return (0, share_namespaceObject.response)(414, "安全参数 ec_privateKey 缺失,请重新获取后重试", "");
|
|
13643
|
+
}
|
|
13644
|
+
} catch (error) {
|
|
13645
|
+
task.logger.error(`[douyinPublish] 解析 ec_privateKey 失败: ${error}`);
|
|
13646
|
+
return (0, share_namespaceObject.response)(414, "安全参数 ec_privateKey 解析失败,请重新获取后重试", "");
|
|
13620
13647
|
}
|
|
13621
|
-
|
|
13622
|
-
|
|
13623
|
-
|
|
13624
|
-
|
|
13625
|
-
|
|
13626
|
-
|
|
13627
|
-
|
|
13628
|
-
|
|
13629
|
-
|
|
13648
|
+
let certificate;
|
|
13649
|
+
try {
|
|
13650
|
+
certificate = JSON.parse(params.extraParam["security-sdk/s_sdk_server_cert_key"] || "{}").cert;
|
|
13651
|
+
if (!certificate) {
|
|
13652
|
+
task.logger.error("[douyinPublish] certificate 为空");
|
|
13653
|
+
return (0, share_namespaceObject.response)(414, "安全参数 certificate 缺失,请重新获取后重试", "");
|
|
13654
|
+
}
|
|
13655
|
+
} catch (error) {
|
|
13656
|
+
task.logger.error(`[douyinPublish] 解析 certificate 失败: ${error}`);
|
|
13657
|
+
return (0, share_namespaceObject.response)(414, "安全参数 certificate 解析失败,请重新获取后重试", "");
|
|
13630
13658
|
}
|
|
13631
|
-
|
|
13632
|
-
|
|
13633
|
-
|
|
13634
|
-
|
|
13635
|
-
|
|
13636
|
-
|
|
13637
|
-
|
|
13638
|
-
|
|
13639
|
-
|
|
13640
|
-
|
|
13659
|
+
const ree_public_key = webProtectData.client_cert.replace("pub.", "");
|
|
13660
|
+
let bdTicketGuardClientData;
|
|
13661
|
+
try {
|
|
13662
|
+
bdTicketGuardClientData = getBdV2({
|
|
13663
|
+
ticket,
|
|
13664
|
+
ts_sign: ts_sign,
|
|
13665
|
+
ec_privateKey: ec_privateKey,
|
|
13666
|
+
certificate: certificate,
|
|
13667
|
+
bd_ticket_guard_ree_public_key: ree_public_key
|
|
13668
|
+
});
|
|
13669
|
+
if (!bdTicketGuardClientData || !bdTicketGuardClientData["headers_bd_ticket_guard_client_data"]) {
|
|
13670
|
+
task.logger.error(`[douyinPublish] bdTicketGuardClientData 生成失败或不完整: ${JSON.stringify(bdTicketGuardClientData)}`);
|
|
13671
|
+
return (0, share_namespaceObject.response)(414, "安全参数 bdTicketGuardClientData 生成失败,请重新获取后重试", "");
|
|
13672
|
+
}
|
|
13673
|
+
} catch (error) {
|
|
13674
|
+
task.logger.error(`[douyinPublish] 生成 bdTicketGuardClientData 失败: ${error}`);
|
|
13675
|
+
return (0, share_namespaceObject.response)(414, "安全参数 bdTicketGuardClientData 生成异常,请重新获取后重试", "");
|
|
13641
13676
|
}
|
|
13642
|
-
|
|
13643
|
-
|
|
13644
|
-
|
|
13645
|
-
|
|
13646
|
-
|
|
13647
|
-
|
|
13648
|
-
|
|
13649
|
-
|
|
13650
|
-
|
|
13651
|
-
|
|
13652
|
-
|
|
13653
|
-
|
|
13654
|
-
|
|
13655
|
-
})
|
|
13656
|
-
|
|
13657
|
-
|
|
13658
|
-
return (0, share_namespaceObject.response)(414, "安全参数 bdTicketGuardClientData 生成失败,请重新获取后重试", "");
|
|
13677
|
+
task.logger.info("[douyinPublish] bdTicketGuardClientData 生成成功");
|
|
13678
|
+
const publishQuery = {
|
|
13679
|
+
...publishParams,
|
|
13680
|
+
a_bogus: ""
|
|
13681
|
+
};
|
|
13682
|
+
const queryString = new URLSearchParams(publishQuery).toString();
|
|
13683
|
+
let aBogus;
|
|
13684
|
+
try {
|
|
13685
|
+
aBogus = mock_getABogus(`https://creator.douyin.com/web/api/media/aweme/create_v2/?${queryString}`, publishData, userAgent);
|
|
13686
|
+
if (!aBogus || aBogus.length < 10) {
|
|
13687
|
+
task.logger.error(`[douyinPublish] a_bogus 生成异常,长度过短: ${aBogus}`);
|
|
13688
|
+
return (0, share_namespaceObject.response)(414, "安全参数 a_bogus 生成失败,请重试", "");
|
|
13689
|
+
}
|
|
13690
|
+
} catch (error) {
|
|
13691
|
+
task.logger.error(`[douyinPublish] 生成 a_bogus 失败: ${error}`);
|
|
13692
|
+
return (0, share_namespaceObject.response)(414, "安全参数 a_bogus 生成异常,请重试", "");
|
|
13659
13693
|
}
|
|
13660
|
-
|
|
13661
|
-
|
|
13662
|
-
|
|
13663
|
-
|
|
13664
|
-
|
|
13665
|
-
|
|
13666
|
-
|
|
13667
|
-
|
|
13668
|
-
|
|
13669
|
-
|
|
13670
|
-
|
|
13671
|
-
|
|
13672
|
-
|
|
13673
|
-
|
|
13674
|
-
task.logger.
|
|
13675
|
-
|
|
13694
|
+
publishQuery.a_bogus = aBogus;
|
|
13695
|
+
const publishQueryParams = new URLSearchParams(publishQuery).toString();
|
|
13696
|
+
let csrfToken;
|
|
13697
|
+
try {
|
|
13698
|
+
csrfToken = mock_generateCsrfTokenAdvanced({
|
|
13699
|
+
cookies: params.cookies,
|
|
13700
|
+
url: "https://creator.douyin.com/web/api/media/aweme/create_v2/",
|
|
13701
|
+
method: "POST",
|
|
13702
|
+
userAgent
|
|
13703
|
+
});
|
|
13704
|
+
if (!csrfToken || csrfToken.length < 10) {
|
|
13705
|
+
task.logger.error(`[douyinPublish] csrfToken 生成异常,长度过短: ${csrfToken}`);
|
|
13706
|
+
return (0, share_namespaceObject.response)(414, "安全参数 csrfToken 生成失败,请重试", "");
|
|
13707
|
+
}
|
|
13708
|
+
task.logger.info(`[douyinPublish] csrfToken 生成成功: ${csrfToken.substring(0, 20)}...`);
|
|
13709
|
+
} catch (error) {
|
|
13710
|
+
task.logger.error(`[douyinPublish] 生成 csrfToken 失败: ${error}`);
|
|
13711
|
+
return (0, share_namespaceObject.response)(414, "安全参数 csrfToken 生成异常,请重试", "");
|
|
13676
13712
|
}
|
|
13677
|
-
|
|
13678
|
-
|
|
13679
|
-
|
|
13680
|
-
|
|
13681
|
-
|
|
13682
|
-
|
|
13683
|
-
|
|
13684
|
-
try {
|
|
13685
|
-
csrfToken = mock_generateCsrfTokenAdvanced({
|
|
13686
|
-
cookies: params.cookies,
|
|
13687
|
-
url: "https://creator.douyin.com/web/api/media/aweme/create_v2/",
|
|
13688
|
-
method: "POST",
|
|
13689
|
-
userAgent
|
|
13690
|
-
});
|
|
13691
|
-
if (!csrfToken || csrfToken.length < 10) {
|
|
13692
|
-
task.logger.error(`[douyinPublish] csrfToken 生成异常,长度过短: ${csrfToken}`);
|
|
13693
|
-
return (0, share_namespaceObject.response)(414, "安全参数 csrfToken 生成失败,请重试", "");
|
|
13713
|
+
let sessionDtrait;
|
|
13714
|
+
try {
|
|
13715
|
+
sessionDtrait = mock_generateDtrait("/web/api/media/aweme/create_v2/");
|
|
13716
|
+
task.logger.info(`[douyinPublish] sessionDtrait 生成成功: ${sessionDtrait || "(空)"}`);
|
|
13717
|
+
} catch (error) {
|
|
13718
|
+
task.logger.error(`[douyinPublish] 生成 sessionDtrait 失败: ${error}`);
|
|
13719
|
+
return (0, share_namespaceObject.response)(414, "安全参数 sessionDtrait 生成异常,请重试", "");
|
|
13694
13720
|
}
|
|
13695
|
-
task.logger.info(`[douyinPublish]
|
|
13696
|
-
|
|
13697
|
-
|
|
13698
|
-
|
|
13699
|
-
|
|
13700
|
-
|
|
13701
|
-
|
|
13702
|
-
|
|
13703
|
-
|
|
13704
|
-
|
|
13705
|
-
|
|
13706
|
-
|
|
13707
|
-
|
|
13708
|
-
|
|
13709
|
-
|
|
13710
|
-
|
|
13711
|
-
|
|
13712
|
-
|
|
13713
|
-
|
|
13714
|
-
|
|
13715
|
-
|
|
13716
|
-
|
|
13717
|
-
|
|
13718
|
-
|
|
13719
|
-
|
|
13720
|
-
|
|
13721
|
-
|
|
13722
|
-
|
|
13723
|
-
|
|
13724
|
-
|
|
13725
|
-
|
|
13726
|
-
|
|
13727
|
-
|
|
13728
|
-
|
|
13729
|
-
|
|
13730
|
-
|
|
13731
|
-
|
|
13732
|
-
|
|
13733
|
-
|
|
13734
|
-
|
|
13735
|
-
|
|
13736
|
-
|
|
13737
|
-
|
|
13738
|
-
|
|
13739
|
-
|
|
13740
|
-
|
|
13721
|
+
task.logger.info(`[douyinPublish] headers: ${JSON.stringify({
|
|
13722
|
+
...headers,
|
|
13723
|
+
Referer: "https://creator.douyin.com/creator-micro/content/post/image?default-tab=3&enter_from=publish_page&media_type=image&type=new",
|
|
13724
|
+
"Content-Type": "application/json",
|
|
13725
|
+
Accept: "application/json, text/plain, */*",
|
|
13726
|
+
"bd-ticket-guard-client-data": bdTicketGuardClientData["headers_bd_ticket_guard_client_data"],
|
|
13727
|
+
"bd-ticket-guard-ree-public-key": bdTicketGuardClientData["headers_bd_ticket_guard_ree_public_key"],
|
|
13728
|
+
"bd-ticket-guard-version": "2",
|
|
13729
|
+
"bd-ticket-guard-web-sign-type": "1",
|
|
13730
|
+
"bd-ticket-guard-web-version": "2",
|
|
13731
|
+
"x-secsdk-csrf-token": csrfToken,
|
|
13732
|
+
"x-tt-session-dtrait": sessionDtrait || ""
|
|
13733
|
+
})}`);
|
|
13734
|
+
task.logger.info(`[douyinPublish] url: https://creator.douyin.com/web/api/media/aweme/create_v2/?${publishQueryParams}`);
|
|
13735
|
+
let publishResult;
|
|
13736
|
+
try {
|
|
13737
|
+
publishResult = await proxyHttp.api({
|
|
13738
|
+
method: "post",
|
|
13739
|
+
url: `https://creator.douyin.com/web/api/media/aweme/create_v2/?${publishQueryParams}`,
|
|
13740
|
+
data: publishData,
|
|
13741
|
+
defaultErrorMsg: "发布异常,请稍后重试。",
|
|
13742
|
+
headers: {
|
|
13743
|
+
...headers,
|
|
13744
|
+
Referer: "https://creator.douyin.com/creator-micro/content/post/image?default-tab=3&enter_from=publish_page&media_type=image&type=new",
|
|
13745
|
+
"Content-Type": "application/json",
|
|
13746
|
+
Accept: "application/json, text/plain, */*",
|
|
13747
|
+
"bd-ticket-guard-client-data": bdTicketGuardClientData["headers_bd_ticket_guard_client_data"],
|
|
13748
|
+
"bd-ticket-guard-ree-public-key": bdTicketGuardClientData["headers_bd_ticket_guard_ree_public_key"],
|
|
13749
|
+
"bd-ticket-guard-version": "2",
|
|
13750
|
+
"bd-ticket-guard-web-sign-type": "1",
|
|
13751
|
+
"bd-ticket-guard-web-version": "2",
|
|
13752
|
+
"x-secsdk-csrf-token": csrfToken,
|
|
13753
|
+
"x-tt-session-dtrait": sessionDtrait || ""
|
|
13754
|
+
}
|
|
13755
|
+
}, {
|
|
13756
|
+
timeout: 60000,
|
|
13757
|
+
retries: 3,
|
|
13758
|
+
retryDelay: 2000
|
|
13759
|
+
});
|
|
13760
|
+
} catch (error) {
|
|
13761
|
+
const handledError = Http.handleApiError(error);
|
|
13762
|
+
const isProxyOrNetworkError = [
|
|
13763
|
+
599,
|
|
13764
|
+
500,
|
|
13765
|
+
502,
|
|
13766
|
+
503,
|
|
13767
|
+
504
|
|
13768
|
+
].includes(handledError.code);
|
|
13769
|
+
if (isProxyOrNetworkError) {
|
|
13770
|
+
const isProxyRequest = handledError.extra?.isProxyRequest === true;
|
|
13771
|
+
const errorType = 599 === handledError.code || isProxyRequest ? "代理错误" : "网络错误";
|
|
13772
|
+
const message = `图文发布失败,${errorType}:${handledError.message}${task.debug ? ` ${http.proxyInfo}` : ""}`;
|
|
13773
|
+
task.logger.error(`[douyinPublish] ${errorType},直接返回: ${message}`, stringifyError(handledError));
|
|
13774
|
+
await updateTaskState?.({
|
|
13775
|
+
state: share_namespaceObject.TaskState.FAILED,
|
|
13776
|
+
error: message
|
|
13777
|
+
});
|
|
13778
|
+
return {
|
|
13779
|
+
code: 414,
|
|
13780
|
+
data: "",
|
|
13781
|
+
message
|
|
13782
|
+
};
|
|
13741
13783
|
}
|
|
13742
|
-
|
|
13743
|
-
|
|
13744
|
-
|
|
13745
|
-
|
|
13746
|
-
|
|
13747
|
-
|
|
13748
|
-
|
|
13749
|
-
|
|
13750
|
-
|
|
13751
|
-
|
|
13752
|
-
|
|
13753
|
-
|
|
13754
|
-
504
|
|
13755
|
-
].includes(handledError.code);
|
|
13756
|
-
if (isProxyOrNetworkError) {
|
|
13757
|
-
const isProxyRequest = handledError.extra?.isProxyRequest === true;
|
|
13758
|
-
const errorType = 599 === handledError.code || isProxyRequest ? "代理错误" : "网络错误";
|
|
13759
|
-
const message = `图文发布失败,${errorType}:${handledError.message}${task.debug ? ` ${http.proxyInfo}` : ""}`;
|
|
13760
|
-
task.logger.error(`[douyinPublish] ${errorType},直接返回: ${message}`, stringifyError(handledError));
|
|
13761
|
-
await updateTaskState?.({
|
|
13784
|
+
throw error;
|
|
13785
|
+
}
|
|
13786
|
+
task.logger.info(`[douyinPublish] decision值: ${JSON.stringify(decision)}, needsVerification(decision): ${needsVerification(decision)}`);
|
|
13787
|
+
if (needsVerification(decision)) {
|
|
13788
|
+
const details = [
|
|
13789
|
+
publishResult.status_msg,
|
|
13790
|
+
decision?.verify_title,
|
|
13791
|
+
decision?.verify_desc
|
|
13792
|
+
].filter(Boolean).join(" ");
|
|
13793
|
+
const message = `图文发布失败,原因:${details}${task.debug ? ` ${http.proxyInfo}` : ""}`;
|
|
13794
|
+
const safeDecision = safeSerialize(decision) ?? {};
|
|
13795
|
+
const mockData = {
|
|
13762
13796
|
state: share_namespaceObject.TaskState.FAILED,
|
|
13763
|
-
error: message
|
|
13764
|
-
|
|
13797
|
+
error: message,
|
|
13798
|
+
result: {
|
|
13799
|
+
...safeDecision,
|
|
13800
|
+
data: decision,
|
|
13801
|
+
uploadedImgList: JSON.stringify(publishData.item.common.images)
|
|
13802
|
+
}
|
|
13803
|
+
};
|
|
13804
|
+
await updateTaskState?.(mockData);
|
|
13765
13805
|
return {
|
|
13766
|
-
code:
|
|
13767
|
-
data:
|
|
13768
|
-
message
|
|
13806
|
+
code: 0,
|
|
13807
|
+
data: mockData,
|
|
13808
|
+
message: "操作成功"
|
|
13809
|
+
};
|
|
13810
|
+
}
|
|
13811
|
+
reportLogger({
|
|
13812
|
+
token: params.huiwenToken || "",
|
|
13813
|
+
enverionment: task.enverionment || "development",
|
|
13814
|
+
postId: params.articleId,
|
|
13815
|
+
eip: proxyHttp.proxyInfo,
|
|
13816
|
+
proxyIp: params.localIP,
|
|
13817
|
+
accountId: params.accountId,
|
|
13818
|
+
uid: params.uid,
|
|
13819
|
+
platform: "douyin",
|
|
13820
|
+
publishParams: publishData
|
|
13821
|
+
});
|
|
13822
|
+
task.logger.info(`[douyinPublish] 发布结果 ${JSON.stringify(publishResult)}`);
|
|
13823
|
+
const isSuccess = 0 === publishResult.status_code;
|
|
13824
|
+
const message = `图文发布${isSuccess ? "成功" : `失败,原因:${publishResult.status_msg} ${decision?.verify_title} ${decision?.verify_desc}`}${task.debug ? ` ${http.proxyInfo}` : ""}`;
|
|
13825
|
+
const data = isSuccess ? publishResult.item_id || "" : "";
|
|
13826
|
+
if (!isSuccess) {
|
|
13827
|
+
const safeDecision = safeSerialize(decision) ?? {};
|
|
13828
|
+
await updateTaskState?.({
|
|
13829
|
+
state: share_namespaceObject.TaskState.FAILED,
|
|
13830
|
+
error: message,
|
|
13831
|
+
result: {
|
|
13832
|
+
...safeDecision,
|
|
13833
|
+
data: safeDecision,
|
|
13834
|
+
uploadedImgList: JSON.stringify(publishData.item.common.images)
|
|
13835
|
+
}
|
|
13836
|
+
});
|
|
13837
|
+
return {
|
|
13838
|
+
code: 414,
|
|
13839
|
+
data: safeDecision,
|
|
13840
|
+
message
|
|
13769
13841
|
};
|
|
13770
13842
|
}
|
|
13771
|
-
throw error;
|
|
13772
|
-
}
|
|
13773
|
-
task.logger.info(`[douyinPublish] decision值: ${JSON.stringify(decision)}, needsVerification(decision): ${needsVerification(decision)}`);
|
|
13774
|
-
if (needsVerification(decision)) {
|
|
13775
|
-
const details = [
|
|
13776
|
-
publishResult.status_msg,
|
|
13777
|
-
decision?.verify_title,
|
|
13778
|
-
decision?.verify_desc
|
|
13779
|
-
].filter(Boolean).join(" ");
|
|
13780
|
-
const message = `图文发布失败,原因:${details}${task.debug ? ` ${http.proxyInfo}` : ""}`;
|
|
13781
|
-
let decisionObj = {};
|
|
13782
|
-
if (decision) decisionObj = decision;
|
|
13783
|
-
const mockData = {
|
|
13784
|
-
state: share_namespaceObject.TaskState.FAILED,
|
|
13785
|
-
error: message,
|
|
13786
|
-
result: {
|
|
13787
|
-
...decisionObj,
|
|
13788
|
-
data: decision,
|
|
13789
|
-
uploadedImgList: JSON.stringify(publishData.item.common.images)
|
|
13790
|
-
}
|
|
13791
|
-
};
|
|
13792
|
-
await updateTaskState?.(mockData);
|
|
13793
|
-
return {
|
|
13794
|
-
code: 0,
|
|
13795
|
-
data: mockData,
|
|
13796
|
-
message: "操作成功"
|
|
13797
|
-
};
|
|
13798
|
-
}
|
|
13799
|
-
reportLogger({
|
|
13800
|
-
token: params.huiwenToken || "",
|
|
13801
|
-
enverionment: task.enverionment || "development",
|
|
13802
|
-
postId: params.articleId,
|
|
13803
|
-
eip: proxyHttp.proxyInfo,
|
|
13804
|
-
proxyIp: params.localIP,
|
|
13805
|
-
accountId: params.accountId,
|
|
13806
|
-
uid: params.uid,
|
|
13807
|
-
platform: "douyin",
|
|
13808
|
-
publishParams: publishData
|
|
13809
|
-
});
|
|
13810
|
-
task.logger.info(`[douyinPublish] 发布结果 ${JSON.stringify(publishResult)}`);
|
|
13811
|
-
const isSuccess = 0 === publishResult.status_code;
|
|
13812
|
-
const message = `图文发布${isSuccess ? "成功" : `失败,原因:${publishResult.status_msg} ${decision?.verify_title} ${decision?.verify_desc}`}${task.debug ? ` ${http.proxyInfo}` : ""}`;
|
|
13813
|
-
const data = isSuccess ? publishResult.item_id || "" : "";
|
|
13814
|
-
if (!isSuccess) {
|
|
13815
|
-
let decisionObj = {};
|
|
13816
|
-
if (decision) decisionObj = decision;
|
|
13817
13843
|
await updateTaskState?.({
|
|
13818
|
-
state: share_namespaceObject.TaskState.
|
|
13819
|
-
error: message,
|
|
13844
|
+
state: share_namespaceObject.TaskState.SUCCESS,
|
|
13820
13845
|
result: {
|
|
13821
|
-
|
|
13822
|
-
data: decision,
|
|
13823
|
-
uploadedImgList: JSON.stringify(publishData.item.common.images)
|
|
13846
|
+
response: data
|
|
13824
13847
|
}
|
|
13825
13848
|
});
|
|
13826
|
-
return
|
|
13827
|
-
|
|
13828
|
-
|
|
13829
|
-
|
|
13830
|
-
|
|
13849
|
+
return (0, share_namespaceObject.response)(isSuccess ? 0 : 414, message, data);
|
|
13850
|
+
} catch (error) {
|
|
13851
|
+
const handledError = Http.handleApiError(error);
|
|
13852
|
+
const errorMsg = handledError.message || "发布失败";
|
|
13853
|
+
const errorCode = handledError.code || 500;
|
|
13854
|
+
task.logger.error(`[douyinPublish] 发布流程异常 (步骤: ${currentStep}): ${errorMsg}`, stringifyError(error), handledError.extra);
|
|
13855
|
+
await updateTaskState?.({
|
|
13856
|
+
state: share_namespaceObject.TaskState.FAILED,
|
|
13857
|
+
error: `${currentStep}失败: ${errorMsg}`
|
|
13858
|
+
});
|
|
13859
|
+
return (0, share_namespaceObject.response)(errorCode, errorMsg, "");
|
|
13831
13860
|
}
|
|
13832
|
-
await updateTaskState?.({
|
|
13833
|
-
state: share_namespaceObject.TaskState.SUCCESS,
|
|
13834
|
-
result: {
|
|
13835
|
-
response: data
|
|
13836
|
-
}
|
|
13837
|
-
});
|
|
13838
|
-
return (0, share_namespaceObject.response)(isSuccess ? 0 : 414, message, data);
|
|
13839
13861
|
};
|
|
13840
13862
|
const douyinPublish_rpa_rpaAction = async (task, params)=>{
|
|
13841
13863
|
const commonCookies = {
|
|
@@ -15361,6 +15383,241 @@ var __webpack_exports__ = {};
|
|
|
15361
15383
|
};
|
|
15362
15384
|
return (0, share_namespaceObject.success)(bjhData, "百家号平台数据获取成功!");
|
|
15363
15385
|
}
|
|
15386
|
+
async function getDouyinData(_task, params) {
|
|
15387
|
+
try {
|
|
15388
|
+
const sessionidCookie = params.cookies.find((it)=>"sessionid" === it.name)?.value;
|
|
15389
|
+
if (!sessionidCookie) return types_errorResponse("抖音账号数据异常,请重新绑定账号后重试。", 414);
|
|
15390
|
+
const csrfToken = params.cookies.find((it)=>"passport_csrf_token" === it.name)?.value || "";
|
|
15391
|
+
const headers = {
|
|
15392
|
+
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
15393
|
+
referer: "https://creator.douyin.com/creator-micro/home",
|
|
15394
|
+
origin: "https://creator.douyin.com",
|
|
15395
|
+
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36",
|
|
15396
|
+
...csrfToken ? {
|
|
15397
|
+
"x-secsdk-csrf-token": csrfToken
|
|
15398
|
+
} : {}
|
|
15399
|
+
};
|
|
15400
|
+
const args = [
|
|
15401
|
+
{
|
|
15402
|
+
headers
|
|
15403
|
+
},
|
|
15404
|
+
_task.logger,
|
|
15405
|
+
params.proxyLoc,
|
|
15406
|
+
params.localIP,
|
|
15407
|
+
params.accountId
|
|
15408
|
+
];
|
|
15409
|
+
const http = new Http(...args);
|
|
15410
|
+
const toNum = (val)=>{
|
|
15411
|
+
if (null == val) return 0;
|
|
15412
|
+
const n = Number.parseInt(String(val).replace(/[+,]/g, ""), 10);
|
|
15413
|
+
return Number.isNaN(n) ? 0 : n;
|
|
15414
|
+
};
|
|
15415
|
+
const userProfileP = http.api({
|
|
15416
|
+
method: "get",
|
|
15417
|
+
url: "https://www.douyin.com/aweme/v1/web/user/profile/self/",
|
|
15418
|
+
params: {
|
|
15419
|
+
device_platform: "webapp",
|
|
15420
|
+
aid: "6383",
|
|
15421
|
+
channel: "channel_pc_web",
|
|
15422
|
+
pc_client_type: "1",
|
|
15423
|
+
version_code: "170400",
|
|
15424
|
+
version_name: "17.4.0",
|
|
15425
|
+
cookie_enabled: "true",
|
|
15426
|
+
platform: "PC"
|
|
15427
|
+
}
|
|
15428
|
+
}, {
|
|
15429
|
+
retries: 3,
|
|
15430
|
+
retryDelay: 100,
|
|
15431
|
+
timeout: 10000
|
|
15432
|
+
}).catch((e)=>{
|
|
15433
|
+
_task.logger.warn(`抖音用户信息获取失败: ${e instanceof Error ? e.message : String(e)}`);
|
|
15434
|
+
return null;
|
|
15435
|
+
});
|
|
15436
|
+
const overviewP = http.api({
|
|
15437
|
+
method: "get",
|
|
15438
|
+
url: "https://creator.douyin.com/aweme/janus/creator/data/overview/all/",
|
|
15439
|
+
params: {
|
|
15440
|
+
last_days_type: 1,
|
|
15441
|
+
aid: 2906,
|
|
15442
|
+
app_name: "aweme_creator_platform",
|
|
15443
|
+
device_platform: "web"
|
|
15444
|
+
}
|
|
15445
|
+
}, {
|
|
15446
|
+
retries: 3,
|
|
15447
|
+
retryDelay: 100,
|
|
15448
|
+
timeout: 5000
|
|
15449
|
+
}).catch((e)=>{
|
|
15450
|
+
_task.logger.warn(`抖音近7日数据获取失败(可能未开通数据中心或被风控): ${e instanceof Error ? e.message : String(e)}`);
|
|
15451
|
+
return null;
|
|
15452
|
+
});
|
|
15453
|
+
const [userProfile, overview] = await Promise.all([
|
|
15454
|
+
userProfileP,
|
|
15455
|
+
overviewP
|
|
15456
|
+
]);
|
|
15457
|
+
let fansNum = 0;
|
|
15458
|
+
let favedNum = 0;
|
|
15459
|
+
let followingNum = 0;
|
|
15460
|
+
if (userProfile?.status_code === 0 && userProfile.user) {
|
|
15461
|
+
const user = userProfile.user;
|
|
15462
|
+
fansNum = toNum(user.follower_count);
|
|
15463
|
+
followingNum = toNum(user.following_count);
|
|
15464
|
+
favedNum = toNum(user.total_favorited);
|
|
15465
|
+
} else _task.logger.warn(`用户信息接口返回异常: status_code=${userProfile?.status_code}, msg=${userProfile?.status_msg}`);
|
|
15466
|
+
const ov = overview?.data;
|
|
15467
|
+
const douyinData = {
|
|
15468
|
+
fansNum,
|
|
15469
|
+
favedNum,
|
|
15470
|
+
fansNumLastWeek: toNum(ov?.new_fans?.last_period_incr),
|
|
15471
|
+
watchNumLastWeek: toNum(ov?.play?.last_period_incr),
|
|
15472
|
+
likeNumLastWeek: toNum(ov?.digg?.last_period_incr),
|
|
15473
|
+
commentNumLastWeek: toNum(ov?.comment?.last_period_incr),
|
|
15474
|
+
shareNumLastWeek: toNum(ov?.share?.last_period_incr),
|
|
15475
|
+
visitNumLastWeek: toNum(ov?.profile?.last_period_incr)
|
|
15476
|
+
};
|
|
15477
|
+
return (0, share_namespaceObject.success)(douyinData, "抖音平台数据获取成功!");
|
|
15478
|
+
} catch (error) {
|
|
15479
|
+
if (error && "object" == typeof error && "code" in error && "message" in error) {
|
|
15480
|
+
const err = error;
|
|
15481
|
+
_task.logger.error(`抖音账号数据获取失败: ${err.message} (${err.code})`);
|
|
15482
|
+
return types_errorResponse(err.message, err.code);
|
|
15483
|
+
}
|
|
15484
|
+
const errMsg = error instanceof Error ? error.message : String(error);
|
|
15485
|
+
_task.logger.error(`抖音账号数据获取失败: ${errMsg}`);
|
|
15486
|
+
return types_errorResponse(errMsg || "抖音账号数据获取失败");
|
|
15487
|
+
}
|
|
15488
|
+
}
|
|
15489
|
+
async function getShipinhaoData(_task, params) {
|
|
15490
|
+
try {
|
|
15491
|
+
const sessionidCookie = params.cookies.find((it)=>"sessionid" === it.name)?.value;
|
|
15492
|
+
if (!sessionidCookie) return types_errorResponse("视频号账号数据异常,请重新绑定账号后重试。", 414);
|
|
15493
|
+
const uinCookie = params.cookies.find((it)=>"uin" === it.name || "wxuin" === it.name)?.value || "0000000000";
|
|
15494
|
+
const deviceIdCookie = params.cookies.find((it)=>"device_id" === it.name || "finger_print_device_id" === it.name)?.value;
|
|
15495
|
+
const aid = params.cookies.find((it)=>"_aid" === it.name)?.value || "9d3e0e9f-b842-498d-a273-4285d58df264";
|
|
15496
|
+
const finderId = params.cookies.find((it)=>"_log_finder_id" === it.name || "finder_id" === it.name)?.value || "";
|
|
15497
|
+
const headers = {
|
|
15498
|
+
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
15499
|
+
referer: "https://channels.weixin.qq.com/platform",
|
|
15500
|
+
origin: "https://channels.weixin.qq.com",
|
|
15501
|
+
"content-type": "application/json",
|
|
15502
|
+
"X-WECHAT-UIN": uinCookie,
|
|
15503
|
+
...deviceIdCookie ? {
|
|
15504
|
+
"finger-print-device-id": deviceIdCookie
|
|
15505
|
+
} : {}
|
|
15506
|
+
};
|
|
15507
|
+
const args = [
|
|
15508
|
+
{
|
|
15509
|
+
headers
|
|
15510
|
+
},
|
|
15511
|
+
_task.logger,
|
|
15512
|
+
params.proxyLoc,
|
|
15513
|
+
params.localIP,
|
|
15514
|
+
params.accountId
|
|
15515
|
+
];
|
|
15516
|
+
const http = new Http(...args);
|
|
15517
|
+
const authData = await http.api({
|
|
15518
|
+
method: "post",
|
|
15519
|
+
url: "https://channels.weixin.qq.com/cgi-bin/mmfinderassistant-bin/auth/auth_data",
|
|
15520
|
+
params: {
|
|
15521
|
+
_aid: aid,
|
|
15522
|
+
_rid: `${Date.now().toString(16)}-${Math.random().toString(36).substring(2, 9)}`,
|
|
15523
|
+
_pageUrl: encodeURIComponent("https://channels.weixin.qq.com/platform")
|
|
15524
|
+
},
|
|
15525
|
+
data: {
|
|
15526
|
+
timestamp: Date.now().toString(),
|
|
15527
|
+
_log_finder_uin: "",
|
|
15528
|
+
_log_finder_id: finderId,
|
|
15529
|
+
rawKeyBuff: "",
|
|
15530
|
+
pluginSessionId: null,
|
|
15531
|
+
scene: 7,
|
|
15532
|
+
reqScene: 7
|
|
15533
|
+
}
|
|
15534
|
+
}, {
|
|
15535
|
+
retries: 3,
|
|
15536
|
+
retryDelay: 100,
|
|
15537
|
+
timeout: 5000
|
|
15538
|
+
});
|
|
15539
|
+
const AUTH_ERROR_CODES = [
|
|
15540
|
+
300333,
|
|
15541
|
+
300334,
|
|
15542
|
+
300330,
|
|
15543
|
+
300331,
|
|
15544
|
+
300332
|
|
15545
|
+
];
|
|
15546
|
+
if (authData.errCode && AUTH_ERROR_CODES.includes(authData.errCode)) {
|
|
15547
|
+
_task.logger.warn(`视频号登录已失效:${authData.errMsg} (${authData.errCode})`);
|
|
15548
|
+
return types_errorResponse("视频号账号信息获取失败,请检查账号状态", 414);
|
|
15549
|
+
}
|
|
15550
|
+
if (authData.errCode) {
|
|
15551
|
+
_task.logger.warn(`视频号账号API错误:${authData.errMsg} (${authData.errCode})`);
|
|
15552
|
+
return types_errorResponse(`视频号账号信息获取失败:${authData.errMsg || "未知错误"}`, 414);
|
|
15553
|
+
}
|
|
15554
|
+
const finderUser = authData.data?.finderUser;
|
|
15555
|
+
const now = new Date();
|
|
15556
|
+
const yesterday = new Date(now.getFullYear(), now.getMonth(), now.getDate() - 2);
|
|
15557
|
+
const startTs = Math.floor(yesterday.getTime() / 1000);
|
|
15558
|
+
const endTs = startTs + 86400;
|
|
15559
|
+
_task.logger.info(`视频号昨日数据范围 start: ${startTs} ~ end: ${endTs}`);
|
|
15560
|
+
let fansNumYesterday = 0;
|
|
15561
|
+
let playNumYesterday = 0;
|
|
15562
|
+
let likeNumYesterday = 0;
|
|
15563
|
+
let commentNumYesterday = 0;
|
|
15564
|
+
try {
|
|
15565
|
+
const statsData = await http.api({
|
|
15566
|
+
method: "post",
|
|
15567
|
+
url: "https://channels.weixin.qq.com/cgi-bin/mmfinderassistant-bin/statistic/new_post_total_data",
|
|
15568
|
+
params: {
|
|
15569
|
+
_aid: aid,
|
|
15570
|
+
_rid: `${Date.now().toString(16)}-${Math.random().toString(36).substring(2, 9)}`,
|
|
15571
|
+
_pageUrl: encodeURIComponent("https://channels.weixin.qq.com/platform")
|
|
15572
|
+
},
|
|
15573
|
+
data: {
|
|
15574
|
+
startTs: startTs.toString(),
|
|
15575
|
+
endTs: endTs.toString(),
|
|
15576
|
+
interval: 3,
|
|
15577
|
+
timestamp: Date.now().toString(),
|
|
15578
|
+
_log_finder_uin: "",
|
|
15579
|
+
_log_finder_id: finderId,
|
|
15580
|
+
rawKeyBuff: "",
|
|
15581
|
+
pluginSessionId: null,
|
|
15582
|
+
scene: 7,
|
|
15583
|
+
reqScene: 7
|
|
15584
|
+
}
|
|
15585
|
+
}, {
|
|
15586
|
+
retries: 3,
|
|
15587
|
+
retryDelay: 100,
|
|
15588
|
+
timeout: 5000
|
|
15589
|
+
});
|
|
15590
|
+
if (!statsData.errCode && statsData.data?.totalData) {
|
|
15591
|
+
const data = statsData.data.totalData;
|
|
15592
|
+
fansNumYesterday = Number.parseInt(data.follow?.[1] || "0", 10) || 0;
|
|
15593
|
+
playNumYesterday = Number.parseInt(data.browse?.[1] || "0", 10) || 0;
|
|
15594
|
+
likeNumYesterday = Number.parseInt(data.like?.[1] || "0", 10) || 0;
|
|
15595
|
+
commentNumYesterday = Number.parseInt(data.comment?.[1] || "0", 10) || 0;
|
|
15596
|
+
}
|
|
15597
|
+
} catch (error) {
|
|
15598
|
+
const errMsg = error instanceof Error ? error.message : String(error);
|
|
15599
|
+
_task.logger.warn(`视频号昨日数据获取失败(降级为null): ${errMsg}`);
|
|
15600
|
+
}
|
|
15601
|
+
const shipinhaoData = {
|
|
15602
|
+
fansNum: finderUser?.fansCount || 0,
|
|
15603
|
+
feedsCount: finderUser?.feedsCount || 0,
|
|
15604
|
+
fansNumYesterday,
|
|
15605
|
+
playNumYesterday,
|
|
15606
|
+
likeNumYesterday,
|
|
15607
|
+
commentNumYesterday
|
|
15608
|
+
};
|
|
15609
|
+
return (0, share_namespaceObject.success)(shipinhaoData, "视频号平台数据获取成功!");
|
|
15610
|
+
} catch (error) {
|
|
15611
|
+
if (error && "object" == typeof error && "code" in error && "message" in error) {
|
|
15612
|
+
const err = error;
|
|
15613
|
+
_task.logger.error(`视频号账号数据获取失败: ${err.message} (${err.code})`);
|
|
15614
|
+
return types_errorResponse(err.message, err.code);
|
|
15615
|
+
}
|
|
15616
|
+
const errMsg = error instanceof Error ? error.message : String(error);
|
|
15617
|
+
_task.logger.error(`视频号账号数据获取失败: ${errMsg}`);
|
|
15618
|
+
return types_errorResponse(errMsg || "视频号账号数据获取失败");
|
|
15619
|
+
}
|
|
15620
|
+
}
|
|
15364
15621
|
async function getToutiaoData(_task, params) {
|
|
15365
15622
|
const http = new Http({
|
|
15366
15623
|
headers: {
|
|
@@ -15459,7 +15716,7 @@ var __webpack_exports__ = {};
|
|
|
15459
15716
|
userInfoHtmlPromise,
|
|
15460
15717
|
userSummaryHtmlPromise
|
|
15461
15718
|
]);
|
|
15462
|
-
if (userInfoHtml.includes("请重新<a id='jumpUrl' href='/'>登录</a>")) return types_errorResponse("
|
|
15719
|
+
if (userInfoHtml.includes("请重新<a id='jumpUrl' href='/'>登录</a>")) return types_errorResponse("微信公众号数据获取失败,请检查账号状态", 414);
|
|
15463
15720
|
const userInfoJson = exportWxCgiData(userInfoHtml);
|
|
15464
15721
|
const userSummaryJson = exportWxCgiData(userSummaryHtml);
|
|
15465
15722
|
const wxData = {
|
|
@@ -15536,7 +15793,9 @@ var __webpack_exports__ = {};
|
|
|
15536
15793
|
"toutiao",
|
|
15537
15794
|
"xiaohongshu",
|
|
15538
15795
|
"weixin",
|
|
15539
|
-
"baijiahao"
|
|
15796
|
+
"baijiahao",
|
|
15797
|
+
"douyin",
|
|
15798
|
+
"shipinhao"
|
|
15540
15799
|
])
|
|
15541
15800
|
});
|
|
15542
15801
|
const SearchAccountInfo = async (_task, params)=>{
|
|
@@ -15550,6 +15809,10 @@ var __webpack_exports__ = {};
|
|
|
15550
15809
|
return getWeixinData(_task, params);
|
|
15551
15810
|
case "baijiahao":
|
|
15552
15811
|
return getBaijiahaoData(_task, params);
|
|
15812
|
+
case "douyin":
|
|
15813
|
+
return getDouyinData(_task, params);
|
|
15814
|
+
case "shipinhao":
|
|
15815
|
+
return getShipinhaoData(_task, params);
|
|
15553
15816
|
default:
|
|
15554
15817
|
return (0, share_namespaceObject.success)(null, "暂不支持该平台");
|
|
15555
15818
|
}
|
|
@@ -15644,18 +15907,45 @@ var __webpack_exports__ = {};
|
|
|
15644
15907
|
collectNum: schemas_number(),
|
|
15645
15908
|
shareNum: schemas_number()
|
|
15646
15909
|
});
|
|
15910
|
+
const DouyinArticleSchema = BaseArticleSchema.extend({
|
|
15911
|
+
playNum: schemas_number(),
|
|
15912
|
+
likeNum: schemas_number(),
|
|
15913
|
+
commentNum: schemas_number(),
|
|
15914
|
+
shareNum: schemas_number(),
|
|
15915
|
+
collectNum: schemas_number(),
|
|
15916
|
+
awemeId: schemas_string(),
|
|
15917
|
+
awemeType: schemas_number(),
|
|
15918
|
+
duration: schemas_number().optional(),
|
|
15919
|
+
status: schemas_string(),
|
|
15920
|
+
publicUrl: schemas_string()
|
|
15921
|
+
});
|
|
15922
|
+
const ShipinhaoArticleSchema = BaseArticleSchema.extend({
|
|
15923
|
+
readNum: schemas_number(),
|
|
15924
|
+
likeNum: schemas_number(),
|
|
15925
|
+
commentNum: schemas_number(),
|
|
15926
|
+
forwardNum: schemas_number(),
|
|
15927
|
+
favNum: schemas_number(),
|
|
15928
|
+
objectId: schemas_string(),
|
|
15929
|
+
postType: schemas_string(),
|
|
15930
|
+
postStatus: schemas_number(),
|
|
15931
|
+
effectiveTime: schemas_number().optional()
|
|
15932
|
+
});
|
|
15647
15933
|
const FetchArticlesDataSchema = schemas_object({
|
|
15648
15934
|
articleCell: schemas_array(union([
|
|
15649
15935
|
ToutiaoArticleSchema,
|
|
15650
15936
|
WeixinArticleSchema,
|
|
15651
15937
|
BaijiahaoArticleSchema,
|
|
15652
|
-
XiaohongshuArticleSchema
|
|
15938
|
+
XiaohongshuArticleSchema,
|
|
15939
|
+
DouyinArticleSchema,
|
|
15940
|
+
ShipinhaoArticleSchema
|
|
15653
15941
|
])).optional(),
|
|
15654
15942
|
timerPublish: schemas_array(union([
|
|
15655
15943
|
ToutiaoArticleSchema,
|
|
15656
15944
|
WeixinArticleSchema,
|
|
15657
15945
|
BaijiahaoArticleSchema,
|
|
15658
|
-
XiaohongshuArticleSchema
|
|
15946
|
+
XiaohongshuArticleSchema,
|
|
15947
|
+
DouyinArticleSchema,
|
|
15948
|
+
ShipinhaoArticleSchema
|
|
15659
15949
|
])).optional(),
|
|
15660
15950
|
pagination: schemas_object({
|
|
15661
15951
|
total: schemas_number().optional(),
|
|
@@ -15770,6 +16060,269 @@ var __webpack_exports__ = {};
|
|
|
15770
16060
|
return searchPublishInfo_types_errorResponse(error instanceof Error ? error.message : "百家号文章数据获取失败");
|
|
15771
16061
|
}
|
|
15772
16062
|
}
|
|
16063
|
+
async function handleDouyinData(_task, params) {
|
|
16064
|
+
try {
|
|
16065
|
+
const { cookies, pageSize = 12, status = 0, showOriginalData = false, onlySuccess = false } = params;
|
|
16066
|
+
const pageNum = params.pageNum || 1;
|
|
16067
|
+
const headers = {
|
|
16068
|
+
cookie: cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
16069
|
+
referer: "https://creator.douyin.com"
|
|
16070
|
+
};
|
|
16071
|
+
const args = [
|
|
16072
|
+
{
|
|
16073
|
+
headers
|
|
16074
|
+
},
|
|
16075
|
+
_task.logger,
|
|
16076
|
+
params.proxyLoc,
|
|
16077
|
+
params.localIP,
|
|
16078
|
+
params.accountId
|
|
16079
|
+
];
|
|
16080
|
+
const http = new Http(...args);
|
|
16081
|
+
async function fetchWorks(cursor) {
|
|
16082
|
+
return await http.api({
|
|
16083
|
+
method: "get",
|
|
16084
|
+
url: "https://creator.douyin.com/janus/douyin/creator/pc/work_list",
|
|
16085
|
+
params: {
|
|
16086
|
+
scene: "star_atlas",
|
|
16087
|
+
device_platform: "android",
|
|
16088
|
+
aid: 1128,
|
|
16089
|
+
status,
|
|
16090
|
+
count: pageSize,
|
|
16091
|
+
max_cursor: cursor
|
|
16092
|
+
}
|
|
16093
|
+
}, {
|
|
16094
|
+
retries: 3,
|
|
16095
|
+
retryDelay: 100,
|
|
16096
|
+
timeout: 5000
|
|
16097
|
+
});
|
|
16098
|
+
}
|
|
16099
|
+
const isHasMore = (v)=>true === v || 1 === v;
|
|
16100
|
+
const skipCount = (pageNum - 1) * pageSize;
|
|
16101
|
+
const needCount = skipCount + pageSize;
|
|
16102
|
+
const workListResponse = await fetchWorks(0);
|
|
16103
|
+
if (!workListResponse || !Array.isArray(workListResponse.aweme_list)) return searchPublishInfo_types_errorResponse("抖音数据获取失败,请检查账号状态", 414);
|
|
16104
|
+
const allWorks = [
|
|
16105
|
+
...workListResponse.aweme_list
|
|
16106
|
+
];
|
|
16107
|
+
let hasMore = isHasMore(workListResponse.has_more);
|
|
16108
|
+
let currentCursor = workListResponse.cursor ?? workListResponse.max_cursor ?? 0;
|
|
16109
|
+
let guard = 0;
|
|
16110
|
+
while(allWorks.length < needCount && hasMore && guard < 20){
|
|
16111
|
+
const nextPageResponse = await fetchWorks(currentCursor);
|
|
16112
|
+
if (!Array.isArray(nextPageResponse.aweme_list) || 0 === nextPageResponse.aweme_list.length) break;
|
|
16113
|
+
allWorks.push(...nextPageResponse.aweme_list);
|
|
16114
|
+
hasMore = isHasMore(nextPageResponse.has_more);
|
|
16115
|
+
currentCursor = nextPageResponse.cursor ?? nextPageResponse.max_cursor ?? currentCursor;
|
|
16116
|
+
guard++;
|
|
16117
|
+
}
|
|
16118
|
+
const finalWorks = allWorks.slice(skipCount, needCount);
|
|
16119
|
+
const articleCell = finalWorks.map((item)=>{
|
|
16120
|
+
const workDetailUrl = `https://creator.douyin.com/creator-micro/work-management/work-detail/${item.aweme_id}`;
|
|
16121
|
+
const workPublicUrl = item.share_url || `https://www.douyin.com/video/${item.aweme_id}`;
|
|
16122
|
+
let statusText;
|
|
16123
|
+
statusText = item.status?.is_delete ? "deleted" : item.status?.is_private ? "private" : item.status?.in_reviewing ? "reviewing" : "public";
|
|
16124
|
+
return {
|
|
16125
|
+
title: item.desc || "无作品描述",
|
|
16126
|
+
imageUrl: item.Cover?.url_list?.[0] || "",
|
|
16127
|
+
createTime: item.create_time,
|
|
16128
|
+
redirectUrl: workDetailUrl,
|
|
16129
|
+
playNum: item.statistics?.play_count || 0,
|
|
16130
|
+
likeNum: item.statistics?.digg_count || 0,
|
|
16131
|
+
commentNum: item.statistics?.comment_count || 0,
|
|
16132
|
+
shareNum: item.statistics?.share_count || 0,
|
|
16133
|
+
collectNum: item.statistics?.collect_count || 0,
|
|
16134
|
+
awemeId: item.aweme_id,
|
|
16135
|
+
awemeType: item.aweme_type ?? 0,
|
|
16136
|
+
duration: item.duration,
|
|
16137
|
+
status: statusText,
|
|
16138
|
+
publicUrl: workPublicUrl,
|
|
16139
|
+
...showOriginalData ? {
|
|
16140
|
+
originalData: item
|
|
16141
|
+
} : {}
|
|
16142
|
+
};
|
|
16143
|
+
});
|
|
16144
|
+
return (0, share_namespaceObject.success)({
|
|
16145
|
+
articleCell,
|
|
16146
|
+
...onlySuccess ? {
|
|
16147
|
+
pagination: {
|
|
16148
|
+
total: workListResponse.total || allWorks.length,
|
|
16149
|
+
nextPage: hasMore,
|
|
16150
|
+
pageNum,
|
|
16151
|
+
pageSize
|
|
16152
|
+
}
|
|
16153
|
+
} : null
|
|
16154
|
+
}, "抖音数据获取成功");
|
|
16155
|
+
} catch (error) {
|
|
16156
|
+
return searchPublishInfo_types_errorResponse(error instanceof Error ? error.message : "抖音数据获取失败");
|
|
16157
|
+
}
|
|
16158
|
+
}
|
|
16159
|
+
async function handleShipinhaoData(_task, params) {
|
|
16160
|
+
try {
|
|
16161
|
+
const { cookies, postType = "all", pageSize = 10, showOriginalData = false } = params;
|
|
16162
|
+
const pageNum = params.pageNum || 1;
|
|
16163
|
+
const aidCookie = cookies.find((it)=>"_aid" === it.name)?.value;
|
|
16164
|
+
const aid = aidCookie || "9d3e0e9f-b842-498d-a273-4285d58df264";
|
|
16165
|
+
const uinCookie = cookies.find((it)=>"uin" === it.name || "wxuin" === it.name)?.value || "0000000000";
|
|
16166
|
+
const deviceIdCookie = cookies.find((it)=>"device_id" === it.name || "finger_print_device_id" === it.name)?.value;
|
|
16167
|
+
const headers = {
|
|
16168
|
+
cookie: cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
16169
|
+
referer: "https://channels.weixin.qq.com",
|
|
16170
|
+
origin: "https://channels.weixin.qq.com",
|
|
16171
|
+
"content-type": "application/json",
|
|
16172
|
+
"X-WECHAT-UIN": uinCookie,
|
|
16173
|
+
...deviceIdCookie ? {
|
|
16174
|
+
"finger-print-device-id": deviceIdCookie
|
|
16175
|
+
} : {}
|
|
16176
|
+
};
|
|
16177
|
+
const args = [
|
|
16178
|
+
{
|
|
16179
|
+
headers
|
|
16180
|
+
},
|
|
16181
|
+
_task.logger,
|
|
16182
|
+
params.proxyLoc,
|
|
16183
|
+
params.localIP,
|
|
16184
|
+
params.accountId
|
|
16185
|
+
];
|
|
16186
|
+
const http = new Http(...args);
|
|
16187
|
+
const finderIdCookie = cookies.find((it)=>"_log_finder_id" === it.name || "finder_id" === it.name)?.value || "";
|
|
16188
|
+
async function fetchPosts(currentPage, userpageType, pageUrl, rawKeyBuff = "") {
|
|
16189
|
+
return await http.api({
|
|
16190
|
+
method: "post",
|
|
16191
|
+
url: "https://channels.weixin.qq.com/micro/content/cgi-bin/mmfinderassistant-bin/post/post_list",
|
|
16192
|
+
params: {
|
|
16193
|
+
_aid: aid,
|
|
16194
|
+
_rid: `${Date.now().toString(16)}-${Math.random().toString(36).substring(2, 9)}`,
|
|
16195
|
+
_pageUrl: encodeURIComponent(pageUrl)
|
|
16196
|
+
},
|
|
16197
|
+
data: {
|
|
16198
|
+
pageSize,
|
|
16199
|
+
currentPage,
|
|
16200
|
+
userpageType,
|
|
16201
|
+
stickyOrder: true,
|
|
16202
|
+
timestamp: Date.now().toString(),
|
|
16203
|
+
_log_finder_uin: "",
|
|
16204
|
+
_log_finder_id: finderIdCookie,
|
|
16205
|
+
rawKeyBuff,
|
|
16206
|
+
pluginSessionId: null,
|
|
16207
|
+
scene: 7,
|
|
16208
|
+
reqScene: 7
|
|
16209
|
+
}
|
|
16210
|
+
}, {
|
|
16211
|
+
retries: 3,
|
|
16212
|
+
retryDelay: 100,
|
|
16213
|
+
timeout: 5000
|
|
16214
|
+
});
|
|
16215
|
+
}
|
|
16216
|
+
async function fetchAllPosts(userpageType, pageUrl) {
|
|
16217
|
+
const allPosts = [];
|
|
16218
|
+
let currentPage = 1;
|
|
16219
|
+
let rawKeyBuff = "";
|
|
16220
|
+
let continueFlag = true;
|
|
16221
|
+
let totalCount = 0;
|
|
16222
|
+
while(continueFlag){
|
|
16223
|
+
const response = await fetchPosts(currentPage, userpageType, pageUrl, rawKeyBuff);
|
|
16224
|
+
if (response.errCode && AUTH_ERROR_CODES.includes(response.errCode)) throw new Error(`AUTH_ERROR:${response.errMsg || "登录已失效"}`);
|
|
16225
|
+
if (response.errCode) {
|
|
16226
|
+
_task.logger.warn(`视频号API错误:${response.errMsg} (${response.errCode})`);
|
|
16227
|
+
throw new Error(`视频号API错误:${response.errMsg} (${response.errCode})`);
|
|
16228
|
+
}
|
|
16229
|
+
if (1 === currentPage) totalCount = response.data?.totalCount ?? 0;
|
|
16230
|
+
const posts = response.data?.list || response.posts || response.post_list || [];
|
|
16231
|
+
allPosts.push(...posts);
|
|
16232
|
+
continueFlag = response.data?.continueFlag ?? false;
|
|
16233
|
+
rawKeyBuff = response.data?.lastBuff || "";
|
|
16234
|
+
currentPage++;
|
|
16235
|
+
if (currentPage > 100) {
|
|
16236
|
+
_task.logger.warn("分页超过100页,停止请求");
|
|
16237
|
+
break;
|
|
16238
|
+
}
|
|
16239
|
+
}
|
|
16240
|
+
if (totalCount > 0 && allPosts.length !== totalCount) _task.logger.warn(`视频号分页可能不完整:期望${totalCount}条,实际${allPosts.length}条`);
|
|
16241
|
+
return {
|
|
16242
|
+
posts: allPosts,
|
|
16243
|
+
totalCount
|
|
16244
|
+
};
|
|
16245
|
+
}
|
|
16246
|
+
const mapPost = (item, forcePostType)=>{
|
|
16247
|
+
let imageUrl = "";
|
|
16248
|
+
if (item.desc?.media?.[0]?.thumbUrl) imageUrl = item.desc.media[0].thumbUrl;
|
|
16249
|
+
else if (item.desc?.media?.[0]?.coverUrl) imageUrl = item.desc.media[0].coverUrl;
|
|
16250
|
+
else if (item.cover?.url) imageUrl = item.cover.url;
|
|
16251
|
+
else if (item.media_url) imageUrl = item.media_url;
|
|
16252
|
+
const title = item.desc?.description || item.object_desc || "无标题";
|
|
16253
|
+
return {
|
|
16254
|
+
title,
|
|
16255
|
+
imageUrl,
|
|
16256
|
+
createTime: item.createTime || item.create_time,
|
|
16257
|
+
redirectUrl: "https://channels.weixin.qq.com/platform",
|
|
16258
|
+
readNum: item.readCount || item.read_count || 0,
|
|
16259
|
+
likeNum: item.likeCount || item.like_count || 0,
|
|
16260
|
+
commentNum: item.commentCount || item.comment_count || 0,
|
|
16261
|
+
forwardNum: item.forwardCount || item.forward_count || 0,
|
|
16262
|
+
favNum: item.favCount || item.fav_count || 0,
|
|
16263
|
+
objectId: item.exportId || item.objectId || "",
|
|
16264
|
+
postType: forcePostType,
|
|
16265
|
+
postStatus: item.status || item.post_status || 0,
|
|
16266
|
+
...item.effectiveTime ? {
|
|
16267
|
+
effectiveTime: item.effectiveTime
|
|
16268
|
+
} : {},
|
|
16269
|
+
...showOriginalData ? {
|
|
16270
|
+
originalData: item
|
|
16271
|
+
} : {}
|
|
16272
|
+
};
|
|
16273
|
+
};
|
|
16274
|
+
const allArticles = [];
|
|
16275
|
+
const needVideo = "all" === postType || "video" === postType;
|
|
16276
|
+
const needArticle = "all" === postType || "article" === postType;
|
|
16277
|
+
const AUTH_ERROR_CODES = [
|
|
16278
|
+
300333,
|
|
16279
|
+
300334,
|
|
16280
|
+
300330,
|
|
16281
|
+
300331,
|
|
16282
|
+
300332
|
|
16283
|
+
];
|
|
16284
|
+
let combinedTotal = 0;
|
|
16285
|
+
if (needVideo) try {
|
|
16286
|
+
const videoPageUrl = "https://channels.weixin.qq.com/micro/content/post/list";
|
|
16287
|
+
const { posts, totalCount } = await fetchAllPosts(11, videoPageUrl);
|
|
16288
|
+
const videoArticles = posts.filter((item)=>item.createTime || item.create_time).map((item)=>mapPost(item, "video"));
|
|
16289
|
+
allArticles.push(...videoArticles);
|
|
16290
|
+
combinedTotal += totalCount || videoArticles.length;
|
|
16291
|
+
} catch (error) {
|
|
16292
|
+
const errMsg = error instanceof Error ? error.message : String(error);
|
|
16293
|
+
if (errMsg.startsWith("AUTH_ERROR:")) throw error;
|
|
16294
|
+
_task.logger.warn(`获取视频号视频失败:${errMsg}`);
|
|
16295
|
+
}
|
|
16296
|
+
if (needArticle) try {
|
|
16297
|
+
const articlePageUrl = "https://channels.weixin.qq.com/micro/content/post/finderNewLifePostList";
|
|
16298
|
+
const { posts, totalCount } = await fetchAllPosts(10, articlePageUrl);
|
|
16299
|
+
const articleArticles = posts.filter((item)=>item.createTime || item.create_time).map((item)=>mapPost(item, "article"));
|
|
16300
|
+
allArticles.push(...articleArticles);
|
|
16301
|
+
combinedTotal += totalCount || articleArticles.length;
|
|
16302
|
+
} catch (error) {
|
|
16303
|
+
const errMsg = error instanceof Error ? error.message : String(error);
|
|
16304
|
+
if (errMsg.startsWith("AUTH_ERROR:")) throw error;
|
|
16305
|
+
_task.logger.warn(`获取视频号图文失败:${errMsg}`);
|
|
16306
|
+
}
|
|
16307
|
+
allArticles.sort((a, b)=>b.createTime - a.createTime);
|
|
16308
|
+
const total = allArticles.length;
|
|
16309
|
+
const start = (pageNum - 1) * pageSize;
|
|
16310
|
+
const pageItems = allArticles.slice(start, start + pageSize);
|
|
16311
|
+
return (0, share_namespaceObject.success)({
|
|
16312
|
+
articleCell: pageItems,
|
|
16313
|
+
pagination: {
|
|
16314
|
+
total,
|
|
16315
|
+
nextPage: start + pageSize < total,
|
|
16316
|
+
pageNum,
|
|
16317
|
+
pageSize
|
|
16318
|
+
}
|
|
16319
|
+
}, "视频号数据获取成功");
|
|
16320
|
+
} catch (error) {
|
|
16321
|
+
const errMsg = error instanceof Error ? error.message : String(error);
|
|
16322
|
+
if (errMsg.startsWith("AUTH_ERROR:")) return searchPublishInfo_types_errorResponse("视频号数据获取失败,请检查账号状态", 414);
|
|
16323
|
+
return searchPublishInfo_types_errorResponse(errMsg || "视频号数据获取失败");
|
|
16324
|
+
}
|
|
16325
|
+
}
|
|
15773
16326
|
async function handleToutiaoData(_task, params) {
|
|
15774
16327
|
try {
|
|
15775
16328
|
const { cookies, pageNum = 1, pageSize = 10, showOriginalData = false, onlySuccess = false, containsArticle = false } = params;
|
|
@@ -15802,7 +16355,7 @@ var __webpack_exports__ = {};
|
|
|
15802
16355
|
app_id: 1231
|
|
15803
16356
|
}
|
|
15804
16357
|
});
|
|
15805
|
-
if (0 !== visitedUid.code) return searchPublishInfo_types_errorResponse("
|
|
16358
|
+
if (0 !== visitedUid.code) return searchPublishInfo_types_errorResponse("头条号数据获取失败,请检查账号状态", 414);
|
|
15806
16359
|
const articleInfo = await http.api({
|
|
15807
16360
|
method: "get",
|
|
15808
16361
|
url: "https://mp.toutiao.com/api/feed/mp_provider/v1/",
|
|
@@ -15911,7 +16464,7 @@ var __webpack_exports__ = {};
|
|
|
15911
16464
|
const size = onlySuccess ? 10 : pageSize > 20 ? 20 : pageSize;
|
|
15912
16465
|
let begin = (lastPage ?? pageNum) - 1;
|
|
15913
16466
|
const rawArticlesInfo = await fetchArticles(begin * size, size, token);
|
|
15914
|
-
if (rawArticlesInfo.includes("请重新<a id='jumpUrl' href='/'>登录</a>")) return searchPublishInfo_types_errorResponse("
|
|
16467
|
+
if (rawArticlesInfo.includes("请重新<a id='jumpUrl' href='/'>登录</a>")) return searchPublishInfo_types_errorResponse("微信公众号数据获取失败,请检查账号状态", 414);
|
|
15915
16468
|
const articlesInfo = ParsePublishPage(rawArticlesInfo);
|
|
15916
16469
|
let articleCell = [];
|
|
15917
16470
|
if (!onlySuccess && pageSize > 20) {
|
|
@@ -16073,7 +16626,7 @@ var __webpack_exports__ = {};
|
|
|
16073
16626
|
const a1Cookie = cookies.find((it)=>"a1" === it.name)?.value;
|
|
16074
16627
|
if (!a1Cookie) return {
|
|
16075
16628
|
code: 414,
|
|
16076
|
-
message: "
|
|
16629
|
+
message: "小红书数据获取失败,请检查账号状态",
|
|
16077
16630
|
data: {}
|
|
16078
16631
|
};
|
|
16079
16632
|
if (onlySuccess && 10 !== pageSize) return {
|
|
@@ -16192,7 +16745,7 @@ var __webpack_exports__ = {};
|
|
|
16192
16745
|
}, "小红书文章数据获取成功");
|
|
16193
16746
|
}
|
|
16194
16747
|
const FetchArticlesParamsSchema = ActionCommonParamsSchema.extend({
|
|
16195
|
-
platform: schemas_string().describe("社交平台:weixin, toutiao, baijiahao, xiaohongshu"),
|
|
16748
|
+
platform: schemas_string().describe("社交平台:weixin, toutiao, baijiahao, xiaohongshu, douyin, shipinhao"),
|
|
16196
16749
|
token: union([
|
|
16197
16750
|
schemas_string(),
|
|
16198
16751
|
schemas_number()
|
|
@@ -16204,7 +16757,14 @@ var __webpack_exports__ = {};
|
|
|
16204
16757
|
showOriginalData: schemas_boolean().optional().describe("是否展示原始数据,默认false"),
|
|
16205
16758
|
cursor: schemas_number().optional().describe("仅用于微信分页游标,默认为空"),
|
|
16206
16759
|
lastPage: schemas_number().optional(),
|
|
16207
|
-
containsArticle: schemas_boolean().optional().describe("是否包含文章内容,默认false")
|
|
16760
|
+
containsArticle: schemas_boolean().optional().describe("是否包含文章内容,默认false"),
|
|
16761
|
+
status: schemas_number().optional().describe("抖音作品状态:0=全部"),
|
|
16762
|
+
includeAccount: schemas_boolean().optional().describe("是否包含账号数据,默认true"),
|
|
16763
|
+
postType: schemas_enum([
|
|
16764
|
+
"video",
|
|
16765
|
+
"article",
|
|
16766
|
+
"all"
|
|
16767
|
+
]).optional().describe("视频号作品类型:video=视频, article=图文, all=全部")
|
|
16208
16768
|
});
|
|
16209
16769
|
const FetchArticles = async (_task, params)=>{
|
|
16210
16770
|
const { platform } = params;
|
|
@@ -16217,6 +16777,10 @@ var __webpack_exports__ = {};
|
|
|
16217
16777
|
return handleBaijiahaoData(_task, params);
|
|
16218
16778
|
case "xiaohongshu":
|
|
16219
16779
|
return handleXiaohongshuData(_task, params);
|
|
16780
|
+
case "douyin":
|
|
16781
|
+
return handleDouyinData(_task, params);
|
|
16782
|
+
case "shipinhao":
|
|
16783
|
+
return handleShipinhaoData(_task, params);
|
|
16220
16784
|
default:
|
|
16221
16785
|
return (0, share_namespaceObject.success)({}, "暂不支持该平台");
|
|
16222
16786
|
}
|
|
@@ -17620,6 +18184,11 @@ var __webpack_exports__ = {};
|
|
|
17620
18184
|
this.concurrentLimit = config.concurrentLimit || 4;
|
|
17621
18185
|
this.singleFileSize = config.singleFileSize || 10485760;
|
|
17622
18186
|
this.http = config.http || new Http();
|
|
18187
|
+
this.reqOptions = {
|
|
18188
|
+
timeout: config.timeout ?? 60000,
|
|
18189
|
+
retries: config.retries ?? 3,
|
|
18190
|
+
retryDelay: config.retryDelay ?? 2000
|
|
18191
|
+
};
|
|
17623
18192
|
}
|
|
17624
18193
|
calculateMd5(buffer) {
|
|
17625
18194
|
const MAX_SIZE = 5242880;
|
|
@@ -17676,7 +18245,7 @@ var __webpack_exports__ = {};
|
|
|
17676
18245
|
url: filePath,
|
|
17677
18246
|
method: "get",
|
|
17678
18247
|
responseType: "arraybuffer"
|
|
17679
|
-
});
|
|
18248
|
+
}, this.reqOptions);
|
|
17680
18249
|
return Buffer.from(resp);
|
|
17681
18250
|
}
|
|
17682
18251
|
return external_node_fs_default().promises.readFile(filePath);
|
|
@@ -17706,7 +18275,7 @@ var __webpack_exports__ = {};
|
|
|
17706
18275
|
headers,
|
|
17707
18276
|
data: requestBody,
|
|
17708
18277
|
defaultErrorMsg: "获取UploadID失败"
|
|
17709
|
-
});
|
|
18278
|
+
}, this.reqOptions);
|
|
17710
18279
|
if (!resp?.UploadID) throw new Error(`获取 UploadID 失败: ${resp?.errMsg || "未知错误"}`);
|
|
17711
18280
|
return resp.UploadID;
|
|
17712
18281
|
}
|
|
@@ -17727,7 +18296,7 @@ var __webpack_exports__ = {};
|
|
|
17727
18296
|
headers,
|
|
17728
18297
|
data: chunk,
|
|
17729
18298
|
defaultErrorMsg: `分片 ${partNumber} 上传失败`
|
|
17730
|
-
});
|
|
18299
|
+
}, this.reqOptions);
|
|
17731
18300
|
if (resp?.errCode !== void 0 && 0 !== resp.errCode) throw new Error(`分片 ${partNumber} 上传失败: ${resp.errMsg}`);
|
|
17732
18301
|
if (onProgress) onProgress(chunk.length);
|
|
17733
18302
|
return resp.ETag || "";
|
|
@@ -17751,7 +18320,7 @@ var __webpack_exports__ = {};
|
|
|
17751
18320
|
headers,
|
|
17752
18321
|
data: requestBody,
|
|
17753
18322
|
defaultErrorMsg: "确认分片上传失败"
|
|
17754
|
-
});
|
|
18323
|
+
}, this.reqOptions);
|
|
17755
18324
|
if (resp?.ListPartsResult?.Part) return resp.ListPartsResult.Part.map((p)=>({
|
|
17756
18325
|
PartNumber: parseInt(p.PartNumber),
|
|
17757
18326
|
ETag: p.ETag
|
|
@@ -17777,7 +18346,7 @@ var __webpack_exports__ = {};
|
|
|
17777
18346
|
headers,
|
|
17778
18347
|
data: requestBody,
|
|
17779
18348
|
defaultErrorMsg: "完成上传失败"
|
|
17780
|
-
});
|
|
18349
|
+
}, this.reqOptions);
|
|
17781
18350
|
if (!resp?.DownloadURL) throw new Error(`完成上传失败: ${resp?.errMsg || "未知错误"}`);
|
|
17782
18351
|
return resp.DownloadURL;
|
|
17783
18352
|
}
|
|
@@ -18128,7 +18697,9 @@ var __webpack_exports__ = {};
|
|
|
18128
18697
|
task.logger.info("[shipinhaoPublish] 开始执行视频号发布 - Mock API 方式");
|
|
18129
18698
|
const updateTaskState = task.taskStageStore?.update?.bind(task.taskStageStore, task.taskId || "");
|
|
18130
18699
|
if (!params.extraParam.fingerPrintDeviceId || !params.extraParam.aId) return (0, share_namespaceObject.response)(400, "fingerPrintDeviceId和aId 不能为空", "");
|
|
18700
|
+
let currentStep = "初始化";
|
|
18131
18701
|
try {
|
|
18702
|
+
currentStep = "解析认证信息";
|
|
18132
18703
|
const cookieString = params.cookies.map((c)=>`${c.name}=${c.value}`).join("; ");
|
|
18133
18704
|
const fingerPrintDeviceId = params.extraParam.fingerPrintDeviceId;
|
|
18134
18705
|
const aId = params.extraParam.aId;
|
|
@@ -18149,8 +18720,10 @@ var __webpack_exports__ = {};
|
|
|
18149
18720
|
headers
|
|
18150
18721
|
});
|
|
18151
18722
|
const proxyHttp = new Http(...args);
|
|
18723
|
+
currentStep = "验证发布参数";
|
|
18152
18724
|
if (!params.banners || 0 === params.banners.length) return (0, share_namespaceObject.response)(400, "至少需要一张图片", "");
|
|
18153
18725
|
const images = params.banners.slice(0, 18).filter((img)=>"string" == typeof img);
|
|
18726
|
+
currentStep = "获取用户信息";
|
|
18154
18727
|
task.logger.info("[shipinhaoPublish] 获取用户信息...");
|
|
18155
18728
|
console.log("cookieString", cookieString);
|
|
18156
18729
|
const userInfo = await mock_getUserInfo(cookieString, http);
|
|
@@ -18161,6 +18734,7 @@ var __webpack_exports__ = {};
|
|
|
18161
18734
|
}
|
|
18162
18735
|
const finderUsername = userInfo.data.finderUser.finderUsername;
|
|
18163
18736
|
console.log(finderUsername);
|
|
18737
|
+
currentStep = "获取上传认证密钥";
|
|
18164
18738
|
task.logger.info("[shipinhaoPublish] 获取上传认证密钥...");
|
|
18165
18739
|
const authKeyResponse = await getUploadAuthKey(cookieString, finderUsername, http);
|
|
18166
18740
|
if (0 !== authKeyResponse.errCode || !authKeyResponse.data?.authKey) return (0, share_namespaceObject.response)(authKeyResponse.errCode || 500, `获取上传认证参数失败: ${authKeyResponse.errMsg}`, "");
|
|
@@ -18168,10 +18742,12 @@ var __webpack_exports__ = {};
|
|
|
18168
18742
|
const uin = authKeyResponse.data.uin;
|
|
18169
18743
|
if (!uin) return (0, share_namespaceObject.response)(500, "获取用户 uin 失败", "");
|
|
18170
18744
|
const taskId = String(generateUUID());
|
|
18745
|
+
currentStep = "上传图片";
|
|
18171
18746
|
task.logger.info(`[shipinhaoPublish] 开始上传 ${images.length} 张图片...`);
|
|
18172
18747
|
const uploadedImages = [];
|
|
18173
18748
|
for(let i = 0; i < images.length; i++){
|
|
18174
|
-
|
|
18749
|
+
currentStep = `上传图片 ${i + 1}/${images.length}`;
|
|
18750
|
+
task.logger.info(`[shipinhaoPublish] ${currentStep}...`);
|
|
18175
18751
|
const uploadResult = await uploadImageComplete(images[i], taskId, finderUsername, uin, authKey, http);
|
|
18176
18752
|
console.log(JSON.stringify(uploadResult));
|
|
18177
18753
|
if (!uploadResult.DownloadURL) return (0, share_namespaceObject.response)(500, `图片上传失败: ${uploadResult.errMsg}`, "");
|
|
@@ -18188,6 +18764,7 @@ var __webpack_exports__ = {};
|
|
|
18188
18764
|
urlCdnTaskId: ""
|
|
18189
18765
|
});
|
|
18190
18766
|
}
|
|
18767
|
+
currentStep = "发布图文内容";
|
|
18191
18768
|
task.logger.info("[shipinhaoPublish] 正在发布...");
|
|
18192
18769
|
const topicNames = params.topic || void 0;
|
|
18193
18770
|
const addressInfo = params.address ? {
|
|
@@ -18274,9 +18851,15 @@ var __webpack_exports__ = {};
|
|
|
18274
18851
|
});
|
|
18275
18852
|
return (0, share_namespaceObject.response)(resultCode || 500, errorMessage, "");
|
|
18276
18853
|
} catch (error) {
|
|
18277
|
-
const
|
|
18278
|
-
|
|
18279
|
-
|
|
18854
|
+
const handledError = Http.handleApiError(error);
|
|
18855
|
+
const errorMsg = handledError.message || "发布失败,请稍后重试";
|
|
18856
|
+
const errorCode = handledError.code || 500;
|
|
18857
|
+
task.logger.error(`[shipinhaoPublish] 发布流程异常: ${errorMsg}`, stringifyError(error), handledError.extra);
|
|
18858
|
+
await updateTaskState?.({
|
|
18859
|
+
state: share_namespaceObject.TaskState.FAILED,
|
|
18860
|
+
error: errorMsg
|
|
18861
|
+
});
|
|
18862
|
+
return (0, share_namespaceObject.response)(errorCode, errorMsg, "");
|
|
18280
18863
|
}
|
|
18281
18864
|
};
|
|
18282
18865
|
const shipinhaoPublish_rpa_rpaAction = async (task, params)=>{
|
|
@@ -22791,8 +23374,8 @@ var __webpack_exports__ = {};
|
|
|
22791
23374
|
params: fetchCoverParams
|
|
22792
23375
|
}, {
|
|
22793
23376
|
retries: 3,
|
|
22794
|
-
retryDelay:
|
|
22795
|
-
timeout:
|
|
23377
|
+
retryDelay: 500,
|
|
23378
|
+
timeout: 30000
|
|
22796
23379
|
});
|
|
22797
23380
|
for (const item of batchCoverIdInfo?.data?.uploadTempPermits ?? [])for (const fileId of item.fileIds)uploadInfos.push({
|
|
22798
23381
|
bucket: item.bucket || "",
|
|
@@ -22811,8 +23394,8 @@ var __webpack_exports__ = {};
|
|
|
22811
23394
|
params: fetchCoverParams
|
|
22812
23395
|
}, {
|
|
22813
23396
|
retries: 3,
|
|
22814
|
-
retryDelay:
|
|
22815
|
-
timeout:
|
|
23397
|
+
retryDelay: 500,
|
|
23398
|
+
timeout: 30000
|
|
22816
23399
|
});
|
|
22817
23400
|
for (const item of coverIdInfo?.data?.uploadTempPermits ?? [])for (const fileId of item.fileIds)uploadInfos.push({
|
|
22818
23401
|
bucket: item.bucket || "",
|
|
@@ -22873,7 +23456,9 @@ var __webpack_exports__ = {};
|
|
|
22873
23456
|
headers: {
|
|
22874
23457
|
"x-cos-security-token": ossToken
|
|
22875
23458
|
},
|
|
22876
|
-
defaultErrorMsg: "
|
|
23459
|
+
defaultErrorMsg: "图片上传异常,请稍后重试。"
|
|
23460
|
+
}, {
|
|
23461
|
+
timeout: 60000
|
|
22877
23462
|
});
|
|
22878
23463
|
return {
|
|
22879
23464
|
ossFileId,
|
|
@@ -22883,6 +23468,8 @@ var __webpack_exports__ = {};
|
|
|
22883
23468
|
originSize
|
|
22884
23469
|
};
|
|
22885
23470
|
} catch (error) {
|
|
23471
|
+
const e = Http.handleApiError(error);
|
|
23472
|
+
task.logger.warn(`[xhs upload] 第${attempt + 1}次失败 index=${index} bucket=${ossBucketIndex} domain=${ossDomain} fileId=${ossFileId} code=${e.code} msg=${e.message} data=${stringifyError(e.data)}`);
|
|
22886
23473
|
attempt++;
|
|
22887
23474
|
}
|
|
22888
23475
|
}
|
|
@@ -23862,8 +24449,8 @@ var __webpack_exports__ = {};
|
|
|
23862
24449
|
params: fetchCoverParams
|
|
23863
24450
|
}, {
|
|
23864
24451
|
retries: 3,
|
|
23865
|
-
retryDelay:
|
|
23866
|
-
timeout:
|
|
24452
|
+
retryDelay: 500,
|
|
24453
|
+
timeout: 8000
|
|
23867
24454
|
});
|
|
23868
24455
|
for (const item of batchCoverIdInfo?.data?.uploadTempPermits ?? [])for (const fileId of item?.fileIds ?? [])uploadInfos.push({
|
|
23869
24456
|
bucket: item.bucket || "",
|
|
@@ -23882,8 +24469,8 @@ var __webpack_exports__ = {};
|
|
|
23882
24469
|
params: fetchCoverParams
|
|
23883
24470
|
}, {
|
|
23884
24471
|
retries: 3,
|
|
23885
|
-
retryDelay:
|
|
23886
|
-
timeout:
|
|
24472
|
+
retryDelay: 500,
|
|
24473
|
+
timeout: 8000
|
|
23887
24474
|
});
|
|
23888
24475
|
for (const item of coverIdInfo?.data?.uploadTempPermits ?? [])for (const fileId of item?.fileIds ?? [])uploadInfos.push({
|
|
23889
24476
|
bucket: item.bucket || "",
|
|
@@ -23928,6 +24515,8 @@ var __webpack_exports__ = {};
|
|
|
23928
24515
|
"x-cos-security-token": ossToken
|
|
23929
24516
|
},
|
|
23930
24517
|
defaultErrorMsg: "图片上传异常,请稍后重试发布。"
|
|
24518
|
+
}, {
|
|
24519
|
+
timeout: 60000
|
|
23931
24520
|
});
|
|
23932
24521
|
return {
|
|
23933
24522
|
ossFileId,
|
|
@@ -24782,6 +25371,24 @@ var __webpack_exports__ = {};
|
|
|
24782
25371
|
likeNumYesterday: schemas_number().nullable(),
|
|
24783
25372
|
commentNumYesterday: schemas_number().nullable()
|
|
24784
25373
|
});
|
|
25374
|
+
const douyinConfigDataSchema = schemas_object({
|
|
25375
|
+
fansNum: schemas_number(),
|
|
25376
|
+
favedNum: schemas_number(),
|
|
25377
|
+
fansNumLastWeek: schemas_number(),
|
|
25378
|
+
watchNumLastWeek: schemas_number(),
|
|
25379
|
+
likeNumLastWeek: schemas_number(),
|
|
25380
|
+
commentNumLastWeek: schemas_number(),
|
|
25381
|
+
shareNumLastWeek: schemas_number(),
|
|
25382
|
+
visitNumLastWeek: schemas_number()
|
|
25383
|
+
});
|
|
25384
|
+
const shipinhaoConfigDataSchema = schemas_object({
|
|
25385
|
+
fansNum: schemas_number(),
|
|
25386
|
+
feedsCount: schemas_number(),
|
|
25387
|
+
fansNumYesterday: schemas_number().nullable(),
|
|
25388
|
+
playNumYesterday: schemas_number().nullable(),
|
|
25389
|
+
likeNumYesterday: schemas_number().nullable(),
|
|
25390
|
+
commentNumYesterday: schemas_number().nullable()
|
|
25391
|
+
});
|
|
24785
25392
|
const BetaFlag = "HuiwenCanary";
|
|
24786
25393
|
class Action {
|
|
24787
25394
|
constructor(task){
|