@iflyrpa/actions 4.0.4-beta.7 → 4.0.5
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/index.d.ts +2 -4
- package/dist/actions/searchAccountInfo/types.d.ts +1 -21
- package/dist/actions/searchPublishInfo/index.d.ts +0 -7
- package/dist/actions/searchPublishInfo/types.d.ts +0 -97
- package/dist/actions/shipinhaoPublish/uploader.d.ts +0 -4
- package/dist/actions/weixinPublish/index.d.ts +2 -2
- package/dist/actions/xiaohongshuPublish/index.d.ts +1 -1
- package/dist/bundle.js +379 -995
- package/dist/bundle.js.map +1 -1
- package/dist/index.d.ts +1 -79
- package/dist/index.js +377 -993
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +379 -993
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/actions/searchAccountInfo/getDouyinInfo.d.ts +0 -16
- package/dist/actions/searchAccountInfo/getShipinhaoInfo.d.ts +0 -14
- package/dist/actions/searchPublishInfo/handleDouyinData.d.ts +0 -17
- package/dist/actions/searchPublishInfo/handleShipinhaoData.d.ts +0 -17
package/dist/index.mjs
CHANGED
|
@@ -4350,7 +4350,9 @@ function __webpack_require__(moduleId) {
|
|
|
4350
4350
|
return module;
|
|
4351
4351
|
};
|
|
4352
4352
|
})();
|
|
4353
|
-
var package_namespaceObject =
|
|
4353
|
+
var package_namespaceObject = {
|
|
4354
|
+
i8: "4.0.5"
|
|
4355
|
+
};
|
|
4354
4356
|
const PROXY_CREDENTIALS = [
|
|
4355
4357
|
{
|
|
4356
4358
|
ip: "47.110.131.129",
|
|
@@ -4583,12 +4585,11 @@ class Http {
|
|
|
4583
4585
|
this.logger?.debug(`未处理的网络错误代码: ${error.code} ${error.message}`, {
|
|
4584
4586
|
errorString: stringifyError(error)
|
|
4585
4587
|
});
|
|
4586
|
-
_message =
|
|
4588
|
+
_message = `未知网络错误: ${error.message}`;
|
|
4587
4589
|
break;
|
|
4588
4590
|
}
|
|
4589
4591
|
}
|
|
4590
|
-
|
|
4591
|
-
else errorResponse.message = errorResponse.message ? errorResponse.message : _message;
|
|
4592
|
+
errorResponse.message = errorResponse.message ? errorResponse.message : _message;
|
|
4592
4593
|
if ("canceled" === errorResponse.message) {
|
|
4593
4594
|
const message = errorResponse.extra?.isProxyRequest ? "代理连接建立超时,请更换区域或稍后重试!" : "网络请求超时,请稍后重试!";
|
|
4594
4595
|
errorResponse.message = message;
|
|
@@ -13366,288 +13367,291 @@ function generateRandomString(length) {
|
|
|
13366
13367
|
}
|
|
13367
13368
|
return randomString;
|
|
13368
13369
|
}
|
|
13369
|
-
function safeSerialize(obj) {
|
|
13370
|
-
if (!obj || "object" != typeof obj) return obj;
|
|
13371
|
-
try {
|
|
13372
|
-
return JSON.parse(JSON.stringify(obj));
|
|
13373
|
-
} catch (error) {
|
|
13374
|
-
return {};
|
|
13375
|
-
}
|
|
13376
|
-
}
|
|
13377
13370
|
const mock_mockAction = async (task, params)=>{
|
|
13378
13371
|
const updateTaskState = task.taskStageStore?.update?.bind(task.taskStageStore, task.taskId || "");
|
|
13379
13372
|
if (!params.extraParam || !params.extraParam["security-sdk/s_sdk_pri_key"] || !params.extraParam["security-sdk/s_sdk_pub_key"] || !params.extraParam["security-sdk/s_sdk_sign_data_key/web_protect"] || !params.extraParam["security-sdk/s_sdk_server_cert_key"] || !params.extraParam["security-sdk/s_sdk_crypt_sdk"]) return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "extraParam 参数缺失或不完整", "");
|
|
13380
|
-
|
|
13381
|
-
|
|
13382
|
-
|
|
13383
|
-
|
|
13384
|
-
|
|
13385
|
-
|
|
13386
|
-
|
|
13387
|
-
|
|
13388
|
-
|
|
13389
|
-
|
|
13390
|
-
|
|
13391
|
-
|
|
13392
|
-
|
|
13393
|
-
|
|
13394
|
-
|
|
13395
|
-
|
|
13396
|
-
|
|
13397
|
-
|
|
13398
|
-
|
|
13399
|
-
|
|
13400
|
-
|
|
13401
|
-
|
|
13402
|
-
|
|
13403
|
-
|
|
13404
|
-
|
|
13405
|
-
|
|
13406
|
-
|
|
13407
|
-
|
|
13408
|
-
|
|
13409
|
-
|
|
13410
|
-
|
|
13411
|
-
|
|
13412
|
-
|
|
13413
|
-
|
|
13414
|
-
|
|
13415
|
-
|
|
13416
|
-
|
|
13417
|
-
|
|
13418
|
-
|
|
13419
|
-
|
|
13420
|
-
|
|
13421
|
-
|
|
13422
|
-
|
|
13423
|
-
|
|
13424
|
-
|
|
13425
|
-
|
|
13426
|
-
|
|
13427
|
-
|
|
13428
|
-
|
|
13429
|
-
|
|
13430
|
-
|
|
13431
|
-
|
|
13432
|
-
|
|
13433
|
-
|
|
13434
|
-
|
|
13435
|
-
|
|
13436
|
-
|
|
13437
|
-
|
|
13438
|
-
|
|
13439
|
-
|
|
13440
|
-
|
|
13441
|
-
|
|
13442
|
-
timing: params.isImmediatelyPublish ? -1 : params.scheduledPublish,
|
|
13443
|
-
media_type: Number(params.publishType) || 2,
|
|
13444
|
-
images: [],
|
|
13445
|
-
creation_id: ""
|
|
13446
|
-
},
|
|
13447
|
-
cover: {
|
|
13448
|
-
poster: ""
|
|
13449
|
-
},
|
|
13450
|
-
mix: params.mix ? {
|
|
13451
|
-
mix_id: params.mix.mix_id,
|
|
13452
|
-
mix_order: params.mix.mix_order || 0
|
|
13453
|
-
} : {},
|
|
13454
|
-
anchor: {},
|
|
13455
|
-
declare: {
|
|
13456
|
-
user_declare_info: "{}"
|
|
13457
|
-
}
|
|
13458
|
-
}
|
|
13459
|
-
};
|
|
13460
|
-
const args = [
|
|
13461
|
-
{
|
|
13462
|
-
headers
|
|
13373
|
+
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";
|
|
13374
|
+
const sessionidCookie = params.cookies.find((it)=>"msToken" === it.name)?.value;
|
|
13375
|
+
if (!sessionidCookie) return {
|
|
13376
|
+
code: 414,
|
|
13377
|
+
message: "账号数据异常,请重新绑定账号后重试。",
|
|
13378
|
+
data: ""
|
|
13379
|
+
};
|
|
13380
|
+
const headers = {
|
|
13381
|
+
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
13382
|
+
origin: "https://creator.douyin.com",
|
|
13383
|
+
referer: "https://creator.douyin.com/creator-micro/content/post/image?default-tab=3&enter_from=publish_page&media_type=image&type=new",
|
|
13384
|
+
Accept: "application/json, text/plain, */*",
|
|
13385
|
+
"Accept-Encoding": "gzip, deflate, br, zstd",
|
|
13386
|
+
"Content-Type": "application/json",
|
|
13387
|
+
pragma: "no-cache",
|
|
13388
|
+
"cache-control": "no-cache",
|
|
13389
|
+
"sec-ch-ua-platform": params.extraParam?.browserInfo?.["sec-ch-ua-platform"] || "",
|
|
13390
|
+
"sec-ch-ua": params.extraParam?.browserInfo?.["sec-ch-ua"] || "",
|
|
13391
|
+
"bd-ticket-guard-web-version": "2",
|
|
13392
|
+
"sec-ch-ua-mobile": "?0",
|
|
13393
|
+
"user-agent": userAgent,
|
|
13394
|
+
"sec-fetch-site": "same-origin",
|
|
13395
|
+
"sec-fetch-mode": "cors",
|
|
13396
|
+
"sec-fetch-dest": "empty",
|
|
13397
|
+
"accept-language": "zh-CN,zh;q=0.9",
|
|
13398
|
+
priority: "u=1, i"
|
|
13399
|
+
};
|
|
13400
|
+
const publishParams = {
|
|
13401
|
+
read_aid: "2906",
|
|
13402
|
+
aid: "1128",
|
|
13403
|
+
cookie_enabled: "true",
|
|
13404
|
+
screen_width: params.extraParam?.browserInfo.screen_width || "1920",
|
|
13405
|
+
screen_height: params.extraParam?.browserInfo.screen_height || "1080",
|
|
13406
|
+
browser_language: params.extraParam?.browserInfo.browser_language || "zh-CN",
|
|
13407
|
+
browser_platform: params.extraParam?.browserInfo.browser_platform || "Win32",
|
|
13408
|
+
browser_name: params.extraParam?.browserInfo.browser_name || "Mozilla",
|
|
13409
|
+
browser_version: userAgent,
|
|
13410
|
+
browser_online: "true",
|
|
13411
|
+
timezone_name: "Asia/Shanghai",
|
|
13412
|
+
support_h265: "1",
|
|
13413
|
+
msToken: params.cookies.find((e)=>"msToken" === e.name)?.value || "",
|
|
13414
|
+
a_bogus: ""
|
|
13415
|
+
};
|
|
13416
|
+
task.logger.info(`[douyinPublish] publishParams ${JSON.stringify(publishParams)}`);
|
|
13417
|
+
const publishData = {
|
|
13418
|
+
item: {
|
|
13419
|
+
common: {
|
|
13420
|
+
text: params.content,
|
|
13421
|
+
text_extra: params.textExtra,
|
|
13422
|
+
activity: "[]",
|
|
13423
|
+
challenges: params.challengeIds || "[]",
|
|
13424
|
+
hashtag_source: "",
|
|
13425
|
+
mentions: "[]",
|
|
13426
|
+
music_id: params.musicId || "",
|
|
13427
|
+
music_end_time: 1000 * (params.musicDuration || 0),
|
|
13428
|
+
hot_sentence: params.hotSentence || "",
|
|
13429
|
+
visibility_type: Number(params.visibleRange) || 0,
|
|
13430
|
+
download: params.allowSave ? 1 : 0,
|
|
13431
|
+
timing: params.isImmediatelyPublish ? -1 : params.scheduledPublish,
|
|
13432
|
+
media_type: Number(params.publishType) || 2,
|
|
13433
|
+
images: [],
|
|
13434
|
+
creation_id: ""
|
|
13463
13435
|
},
|
|
13464
|
-
|
|
13465
|
-
|
|
13466
|
-
|
|
13467
|
-
params.
|
|
13468
|
-
|
|
13469
|
-
|
|
13470
|
-
|
|
13471
|
-
|
|
13472
|
-
|
|
13473
|
-
|
|
13474
|
-
const uploadedImgList = params.uploadedImgList ? JSON.parse(params.uploadedImgList) : [];
|
|
13475
|
-
if (uploadedImgList.length > 0) publishData.item.common.images = uploadedImgList;
|
|
13476
|
-
else {
|
|
13477
|
-
const tmpCachePath = task.getTmpPath();
|
|
13478
|
-
const uploader = new DouyinImageUploader(proxyHttp, headers, publishParams, tmpCachePath);
|
|
13479
|
-
if (params.coverImage) {
|
|
13480
|
-
const cover = await uploader.uploadCover(params.coverImage);
|
|
13481
|
-
if (cover) {
|
|
13482
|
-
publishData.item.common.images.push({
|
|
13483
|
-
uri: cover.uri,
|
|
13484
|
-
width: cover.width,
|
|
13485
|
-
height: cover.height
|
|
13486
|
-
});
|
|
13487
|
-
publishData.item.cover = {
|
|
13488
|
-
poster: cover.uri
|
|
13489
|
-
};
|
|
13490
|
-
}
|
|
13491
|
-
}
|
|
13492
|
-
if (params.banners && params.banners.length > 0) {
|
|
13493
|
-
const banners = params.banners.filter((i)=>i !== params.coverImage);
|
|
13494
|
-
const uploadResults = await uploader.uploadImages(banners);
|
|
13495
|
-
publishData.item.common.images = publishData.item.common.images.concat(uploadResults.map((result)=>({
|
|
13496
|
-
uri: result.uri,
|
|
13497
|
-
width: result.width,
|
|
13498
|
-
height: result.height
|
|
13499
|
-
})));
|
|
13436
|
+
cover: {
|
|
13437
|
+
poster: ""
|
|
13438
|
+
},
|
|
13439
|
+
mix: params.mix ? {
|
|
13440
|
+
mix_id: params.mix.mix_id,
|
|
13441
|
+
mix_order: params.mix.mix_order || 0
|
|
13442
|
+
} : {},
|
|
13443
|
+
anchor: {},
|
|
13444
|
+
declare: {
|
|
13445
|
+
user_declare_info: "{}"
|
|
13500
13446
|
}
|
|
13501
13447
|
}
|
|
13502
|
-
|
|
13503
|
-
|
|
13504
|
-
|
|
13505
|
-
|
|
13506
|
-
|
|
13507
|
-
|
|
13508
|
-
|
|
13509
|
-
|
|
13510
|
-
|
|
13511
|
-
|
|
13512
|
-
|
|
13513
|
-
|
|
13514
|
-
|
|
13515
|
-
|
|
13516
|
-
|
|
13517
|
-
|
|
13518
|
-
|
|
13519
|
-
|
|
13520
|
-
|
|
13448
|
+
};
|
|
13449
|
+
const args = [
|
|
13450
|
+
{
|
|
13451
|
+
headers
|
|
13452
|
+
},
|
|
13453
|
+
task.logger,
|
|
13454
|
+
"",
|
|
13455
|
+
"",
|
|
13456
|
+
params.accountId,
|
|
13457
|
+
"douyin"
|
|
13458
|
+
];
|
|
13459
|
+
const http = new Http({
|
|
13460
|
+
headers
|
|
13461
|
+
});
|
|
13462
|
+
const proxyHttp = new Http(...args);
|
|
13463
|
+
const uploadedImgList = params.uploadedImgList ? JSON.parse(params.uploadedImgList) : [];
|
|
13464
|
+
if (uploadedImgList.length > 0) publishData.item.common.images = uploadedImgList;
|
|
13465
|
+
else {
|
|
13466
|
+
const tmpCachePath = task.getTmpPath();
|
|
13467
|
+
const uploader = new DouyinImageUploader(proxyHttp, headers, publishParams, tmpCachePath);
|
|
13468
|
+
if (params.coverImage) {
|
|
13469
|
+
const cover = await uploader.uploadCover(params.coverImage);
|
|
13470
|
+
if (cover) {
|
|
13471
|
+
publishData.item.common.images.push({
|
|
13472
|
+
uri: cover.uri,
|
|
13473
|
+
width: cover.width,
|
|
13474
|
+
height: cover.height
|
|
13475
|
+
});
|
|
13476
|
+
publishData.item.cover = {
|
|
13477
|
+
poster: cover.uri
|
|
13521
13478
|
};
|
|
13522
13479
|
}
|
|
13523
|
-
});
|
|
13524
|
-
task._timerRecord.PrePublish = Date.now();
|
|
13525
|
-
if (MockPublish) {
|
|
13526
|
-
const data = "123456789";
|
|
13527
|
-
const message = `图文模拟发布成功 ${http.proxyInfo}`;
|
|
13528
|
-
await updateTaskState?.({
|
|
13529
|
-
state: __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.TaskState.SUCCESS,
|
|
13530
|
-
result: {
|
|
13531
|
-
response: data
|
|
13532
|
-
}
|
|
13533
|
-
});
|
|
13534
|
-
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(0, message, data);
|
|
13535
13480
|
}
|
|
13536
|
-
|
|
13537
|
-
|
|
13538
|
-
|
|
13539
|
-
|
|
13540
|
-
|
|
13541
|
-
|
|
13542
|
-
|
|
13543
|
-
|
|
13544
|
-
task.logger.error(`解析 webProtectData 失败: ${error}`);
|
|
13545
|
-
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "安全参数 webProtectData 解析失败,请重新获取后重试", "");
|
|
13546
|
-
}
|
|
13547
|
-
let ticket = webProtectData.ticket;
|
|
13548
|
-
let ts_sign = webProtectData.ts_sign;
|
|
13549
|
-
const serverDataCookie = params.cookies.find((it)=>"bd_ticket_guard_server_data" === it.name)?.value;
|
|
13550
|
-
if (serverDataCookie) try {
|
|
13551
|
-
const decoded = JSON.parse(Buffer.from(decodeURIComponent(serverDataCookie), "base64").toString("utf8"));
|
|
13552
|
-
if (decoded.ticket && decoded.ts_sign) {
|
|
13553
|
-
if (decoded.ticket !== ticket) task.logger.info("[douyinPublish] 使用 cookie 中的最新 ticket(web_protect 已过期)");
|
|
13554
|
-
ticket = decoded.ticket;
|
|
13555
|
-
ts_sign = decoded.ts_sign;
|
|
13556
|
-
}
|
|
13557
|
-
} catch (error) {
|
|
13558
|
-
task.logger.info(`[douyinPublish] 解析 bd_ticket_guard_server_data 失败,回退到 web_protect: ${error}`);
|
|
13481
|
+
if (params.banners && params.banners.length > 0) {
|
|
13482
|
+
const banners = params.banners.filter((i)=>i !== params.coverImage);
|
|
13483
|
+
const uploadResults = await uploader.uploadImages(banners);
|
|
13484
|
+
publishData.item.common.images = publishData.item.common.images.concat(uploadResults.map((result)=>({
|
|
13485
|
+
uri: result.uri,
|
|
13486
|
+
width: result.width,
|
|
13487
|
+
height: result.height
|
|
13488
|
+
})));
|
|
13559
13489
|
}
|
|
13560
|
-
|
|
13561
|
-
|
|
13562
|
-
|
|
13563
|
-
|
|
13564
|
-
|
|
13565
|
-
|
|
13566
|
-
|
|
13567
|
-
|
|
13568
|
-
task.logger.
|
|
13569
|
-
return
|
|
13490
|
+
}
|
|
13491
|
+
publishData.item.common.creation_id = generateRandomString(8) + Date.now();
|
|
13492
|
+
let decision = null;
|
|
13493
|
+
proxyHttp.addResponseInterceptor((response)=>{
|
|
13494
|
+
task.logger.info(`[douyinPublish] 拦截器收到响应response.headers: ${JSON.stringify(response.headers)} `);
|
|
13495
|
+
task.logger.info(`[douyinPublish] 拦截器收到响应response.data: ${JSON.stringify(response.data)} `);
|
|
13496
|
+
decision = parseVerifyPassportDecision(response.headers["x-tt-verify-passport-decision"]);
|
|
13497
|
+
if (needsVerification(decision)) {
|
|
13498
|
+
task.logger.info(`[douyinPublish] 检测到需要验证: ${JSON.stringify(decision)}`);
|
|
13499
|
+
return;
|
|
13570
13500
|
}
|
|
13571
|
-
|
|
13572
|
-
|
|
13573
|
-
|
|
13574
|
-
|
|
13575
|
-
|
|
13576
|
-
|
|
13577
|
-
|
|
13578
|
-
|
|
13579
|
-
|
|
13580
|
-
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "安全参数 certificate 解析失败,请重新获取后重试", "");
|
|
13581
|
-
}
|
|
13582
|
-
const ree_public_key = webProtectData.client_cert.replace("pub.", "");
|
|
13583
|
-
const MAX_SIGN_RETRIES = 3;
|
|
13584
|
-
const SIGN_RETRY_DELAY = 2000;
|
|
13585
|
-
const signAndPublish = async ()=>{
|
|
13586
|
-
let bdTicketGuardClientData;
|
|
13587
|
-
try {
|
|
13588
|
-
bdTicketGuardClientData = getBdV2({
|
|
13589
|
-
ticket,
|
|
13590
|
-
ts_sign: ts_sign,
|
|
13591
|
-
ec_privateKey: ec_privateKey,
|
|
13592
|
-
certificate: certificate,
|
|
13593
|
-
bd_ticket_guard_ree_public_key: ree_public_key
|
|
13594
|
-
});
|
|
13595
|
-
if (!bdTicketGuardClientData || !bdTicketGuardClientData["headers_bd_ticket_guard_client_data"]) {
|
|
13596
|
-
task.logger.error(`[douyinPublish] bdTicketGuardClientData 生成失败或不完整: ${JSON.stringify(bdTicketGuardClientData)}`);
|
|
13597
|
-
throw (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "安全参数 bdTicketGuardClientData 生成失败,请重新获取后重试", "");
|
|
13598
|
-
}
|
|
13599
|
-
} catch (error) {
|
|
13600
|
-
if (error && "object" == typeof error && "code" in error) throw error;
|
|
13601
|
-
task.logger.error(`[douyinPublish] 生成 bdTicketGuardClientData 失败: ${error}`);
|
|
13602
|
-
throw (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "安全参数 bdTicketGuardClientData 生成异常,请重新获取后重试", "");
|
|
13603
|
-
}
|
|
13604
|
-
task.logger.info("[douyinPublish] bdTicketGuardClientData 生成成功");
|
|
13605
|
-
const publishQuery = {
|
|
13606
|
-
...publishParams,
|
|
13607
|
-
a_bogus: ""
|
|
13501
|
+
if (!response || !response.data) return;
|
|
13502
|
+
const responseData = response.data;
|
|
13503
|
+
if (response && responseData?.status_code && 0 !== responseData.status_code) {
|
|
13504
|
+
const errorCode = 4 === responseData.status_code ? 500 : responseData.status_code;
|
|
13505
|
+
if (4 === responseData.status_code) task.logger.warn(`[douyinPublish] 抖音服务器错误 status_code: 4,映射为 500 触发重试。原始响应: ${JSON.stringify(responseData)}`);
|
|
13506
|
+
return {
|
|
13507
|
+
code: errorCode,
|
|
13508
|
+
message: responseData.status_msg || "文章发布异常,请稍后重试。",
|
|
13509
|
+
data: responseData
|
|
13608
13510
|
};
|
|
13609
|
-
|
|
13610
|
-
|
|
13611
|
-
|
|
13612
|
-
|
|
13613
|
-
|
|
13614
|
-
|
|
13615
|
-
|
|
13616
|
-
|
|
13617
|
-
|
|
13618
|
-
|
|
13619
|
-
task.logger.error(`[douyinPublish] 生成 a_bogus 失败: ${error}`);
|
|
13620
|
-
throw (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "安全参数 a_bogus 生成异常,请重试", "");
|
|
13621
|
-
}
|
|
13622
|
-
publishQuery.a_bogus = aBogus;
|
|
13623
|
-
const publishQueryParams = new URLSearchParams(publishQuery).toString();
|
|
13624
|
-
let csrfToken;
|
|
13625
|
-
try {
|
|
13626
|
-
csrfToken = mock_generateCsrfTokenAdvanced({
|
|
13627
|
-
cookies: params.cookies,
|
|
13628
|
-
url: "https://creator.douyin.com/web/api/media/aweme/create_v2/",
|
|
13629
|
-
method: "POST",
|
|
13630
|
-
userAgent
|
|
13631
|
-
});
|
|
13632
|
-
if (!csrfToken || csrfToken.length < 10) {
|
|
13633
|
-
task.logger.error(`[douyinPublish] csrfToken 生成异常,长度过短: ${csrfToken}`);
|
|
13634
|
-
throw (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "安全参数 csrfToken 生成失败,请重试", "");
|
|
13635
|
-
}
|
|
13636
|
-
task.logger.info(`[douyinPublish] csrfToken 生成成功: ${csrfToken.substring(0, 20)}...`);
|
|
13637
|
-
} catch (error) {
|
|
13638
|
-
if (error && "object" == typeof error && "code" in error) throw error;
|
|
13639
|
-
task.logger.error(`[douyinPublish] 生成 csrfToken 失败: ${error}`);
|
|
13640
|
-
throw (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "安全参数 csrfToken 生成异常,请重试", "");
|
|
13641
|
-
}
|
|
13642
|
-
let sessionDtrait;
|
|
13643
|
-
try {
|
|
13644
|
-
sessionDtrait = mock_generateDtrait("/web/api/media/aweme/create_v2/");
|
|
13645
|
-
task.logger.info(`[douyinPublish] sessionDtrait 生成成功: ${sessionDtrait || "(空)"}`);
|
|
13646
|
-
} catch (error) {
|
|
13647
|
-
task.logger.error(`[douyinPublish] 生成 sessionDtrait 失败: ${error}`);
|
|
13648
|
-
throw (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "安全参数 sessionDtrait 生成异常,请重试", "");
|
|
13511
|
+
}
|
|
13512
|
+
});
|
|
13513
|
+
task._timerRecord.PrePublish = Date.now();
|
|
13514
|
+
if (MockPublish) {
|
|
13515
|
+
const data = "123456789";
|
|
13516
|
+
const message = `图文模拟发布成功 ${http.proxyInfo}`;
|
|
13517
|
+
await updateTaskState?.({
|
|
13518
|
+
state: __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.TaskState.SUCCESS,
|
|
13519
|
+
result: {
|
|
13520
|
+
response: data
|
|
13649
13521
|
}
|
|
13650
|
-
|
|
13522
|
+
});
|
|
13523
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(0, message, data);
|
|
13524
|
+
}
|
|
13525
|
+
let webProtectData;
|
|
13526
|
+
try {
|
|
13527
|
+
webProtectData = JSON.parse(JSON.parse(params.extraParam["security-sdk/s_sdk_sign_data_key/web_protect"] || "{}").data || "{}");
|
|
13528
|
+
if (!webProtectData.ticket || !webProtectData.ts_sign || !webProtectData.client_cert) {
|
|
13529
|
+
task.logger.error(`webProtectData 关键字段缺失: ${JSON.stringify(webProtectData)}`);
|
|
13530
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "安全参数 webProtectData 不完整,请重新获取后重试", "");
|
|
13531
|
+
}
|
|
13532
|
+
} catch (error) {
|
|
13533
|
+
task.logger.error(`解析 webProtectData 失败: ${error}`);
|
|
13534
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "安全参数 webProtectData 解析失败,请重新获取后重试", "");
|
|
13535
|
+
}
|
|
13536
|
+
let ticket = webProtectData.ticket;
|
|
13537
|
+
let ts_sign = webProtectData.ts_sign;
|
|
13538
|
+
const serverDataCookie = params.cookies.find((it)=>"bd_ticket_guard_server_data" === it.name)?.value;
|
|
13539
|
+
if (serverDataCookie) try {
|
|
13540
|
+
const decoded = JSON.parse(Buffer.from(decodeURIComponent(serverDataCookie), "base64").toString("utf8"));
|
|
13541
|
+
if (decoded.ticket && decoded.ts_sign) {
|
|
13542
|
+
if (decoded.ticket !== ticket) task.logger.info("[douyinPublish] 使用 cookie 中的最新 ticket(web_protect 已过期)");
|
|
13543
|
+
ticket = decoded.ticket;
|
|
13544
|
+
ts_sign = decoded.ts_sign;
|
|
13545
|
+
}
|
|
13546
|
+
} catch (error) {
|
|
13547
|
+
task.logger.info(`[douyinPublish] 解析 bd_ticket_guard_server_data 失败,回退到 web_protect: ${error}`);
|
|
13548
|
+
}
|
|
13549
|
+
let ec_privateKey;
|
|
13550
|
+
try {
|
|
13551
|
+
ec_privateKey = JSON.parse(JSON.parse(params.extraParam["security-sdk/s_sdk_crypt_sdk"] || "{}").data || "{}").ec_privateKey;
|
|
13552
|
+
if (!ec_privateKey) {
|
|
13553
|
+
task.logger.error("[douyinPublish] ec_privateKey 为空");
|
|
13554
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "安全参数 ec_privateKey 缺失,请重新获取后重试", "");
|
|
13555
|
+
}
|
|
13556
|
+
} catch (error) {
|
|
13557
|
+
task.logger.error(`[douyinPublish] 解析 ec_privateKey 失败: ${error}`);
|
|
13558
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "安全参数 ec_privateKey 解析失败,请重新获取后重试", "");
|
|
13559
|
+
}
|
|
13560
|
+
let certificate;
|
|
13561
|
+
try {
|
|
13562
|
+
certificate = JSON.parse(params.extraParam["security-sdk/s_sdk_server_cert_key"] || "{}").cert;
|
|
13563
|
+
if (!certificate) {
|
|
13564
|
+
task.logger.error("[douyinPublish] certificate 为空");
|
|
13565
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "安全参数 certificate 缺失,请重新获取后重试", "");
|
|
13566
|
+
}
|
|
13567
|
+
} catch (error) {
|
|
13568
|
+
task.logger.error(`[douyinPublish] 解析 certificate 失败: ${error}`);
|
|
13569
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "安全参数 certificate 解析失败,请重新获取后重试", "");
|
|
13570
|
+
}
|
|
13571
|
+
const ree_public_key = webProtectData.client_cert.replace("pub.", "");
|
|
13572
|
+
let bdTicketGuardClientData;
|
|
13573
|
+
try {
|
|
13574
|
+
bdTicketGuardClientData = getBdV2({
|
|
13575
|
+
ticket,
|
|
13576
|
+
ts_sign: ts_sign,
|
|
13577
|
+
ec_privateKey: ec_privateKey,
|
|
13578
|
+
certificate: certificate,
|
|
13579
|
+
bd_ticket_guard_ree_public_key: ree_public_key
|
|
13580
|
+
});
|
|
13581
|
+
if (!bdTicketGuardClientData || !bdTicketGuardClientData["headers_bd_ticket_guard_client_data"]) {
|
|
13582
|
+
task.logger.error(`[douyinPublish] bdTicketGuardClientData 生成失败或不完整: ${JSON.stringify(bdTicketGuardClientData)}`);
|
|
13583
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "安全参数 bdTicketGuardClientData 生成失败,请重新获取后重试", "");
|
|
13584
|
+
}
|
|
13585
|
+
} catch (error) {
|
|
13586
|
+
task.logger.error(`[douyinPublish] 生成 bdTicketGuardClientData 失败: ${error}`);
|
|
13587
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "安全参数 bdTicketGuardClientData 生成异常,请重新获取后重试", "");
|
|
13588
|
+
}
|
|
13589
|
+
task.logger.info("[douyinPublish] bdTicketGuardClientData 生成成功");
|
|
13590
|
+
const publishQuery = {
|
|
13591
|
+
...publishParams,
|
|
13592
|
+
a_bogus: ""
|
|
13593
|
+
};
|
|
13594
|
+
const queryString = new URLSearchParams(publishQuery).toString();
|
|
13595
|
+
let aBogus;
|
|
13596
|
+
try {
|
|
13597
|
+
aBogus = mock_getABogus(`https://creator.douyin.com/web/api/media/aweme/create_v2/?${queryString}`, publishData, userAgent);
|
|
13598
|
+
if (!aBogus || aBogus.length < 10) {
|
|
13599
|
+
task.logger.error(`[douyinPublish] a_bogus 生成异常,长度过短: ${aBogus}`);
|
|
13600
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "安全参数 a_bogus 生成失败,请重试", "");
|
|
13601
|
+
}
|
|
13602
|
+
} catch (error) {
|
|
13603
|
+
task.logger.error(`[douyinPublish] 生成 a_bogus 失败: ${error}`);
|
|
13604
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "安全参数 a_bogus 生成异常,请重试", "");
|
|
13605
|
+
}
|
|
13606
|
+
publishQuery.a_bogus = aBogus;
|
|
13607
|
+
const publishQueryParams = new URLSearchParams(publishQuery).toString();
|
|
13608
|
+
let csrfToken;
|
|
13609
|
+
try {
|
|
13610
|
+
csrfToken = mock_generateCsrfTokenAdvanced({
|
|
13611
|
+
cookies: params.cookies,
|
|
13612
|
+
url: "https://creator.douyin.com/web/api/media/aweme/create_v2/",
|
|
13613
|
+
method: "POST",
|
|
13614
|
+
userAgent
|
|
13615
|
+
});
|
|
13616
|
+
if (!csrfToken || csrfToken.length < 10) {
|
|
13617
|
+
task.logger.error(`[douyinPublish] csrfToken 生成异常,长度过短: ${csrfToken}`);
|
|
13618
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "安全参数 csrfToken 生成失败,请重试", "");
|
|
13619
|
+
}
|
|
13620
|
+
task.logger.info(`[douyinPublish] csrfToken 生成成功: ${csrfToken.substring(0, 20)}...`);
|
|
13621
|
+
} catch (error) {
|
|
13622
|
+
task.logger.error(`[douyinPublish] 生成 csrfToken 失败: ${error}`);
|
|
13623
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "安全参数 csrfToken 生成异常,请重试", "");
|
|
13624
|
+
}
|
|
13625
|
+
let sessionDtrait;
|
|
13626
|
+
try {
|
|
13627
|
+
sessionDtrait = mock_generateDtrait("/web/api/media/aweme/create_v2/");
|
|
13628
|
+
task.logger.info(`[douyinPublish] sessionDtrait 生成成功: ${sessionDtrait || "(空)"}`);
|
|
13629
|
+
} catch (error) {
|
|
13630
|
+
task.logger.error(`[douyinPublish] 生成 sessionDtrait 失败: ${error}`);
|
|
13631
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "安全参数 sessionDtrait 生成异常,请重试", "");
|
|
13632
|
+
}
|
|
13633
|
+
task.logger.info(`[douyinPublish] headers: ${JSON.stringify({
|
|
13634
|
+
...headers,
|
|
13635
|
+
Referer: "https://creator.douyin.com/creator-micro/content/post/image?default-tab=3&enter_from=publish_page&media_type=image&type=new",
|
|
13636
|
+
"Content-Type": "application/json",
|
|
13637
|
+
Accept: "application/json, text/plain, */*",
|
|
13638
|
+
"bd-ticket-guard-client-data": bdTicketGuardClientData["headers_bd_ticket_guard_client_data"],
|
|
13639
|
+
"bd-ticket-guard-ree-public-key": bdTicketGuardClientData["headers_bd_ticket_guard_ree_public_key"],
|
|
13640
|
+
"bd-ticket-guard-version": "2",
|
|
13641
|
+
"bd-ticket-guard-web-sign-type": "1",
|
|
13642
|
+
"bd-ticket-guard-web-version": "2",
|
|
13643
|
+
"x-secsdk-csrf-token": csrfToken,
|
|
13644
|
+
"x-tt-session-dtrait": sessionDtrait || ""
|
|
13645
|
+
})}`);
|
|
13646
|
+
task.logger.info(`[douyinPublish] url: https://creator.douyin.com/web/api/media/aweme/create_v2/?${publishQueryParams}`);
|
|
13647
|
+
let publishResult;
|
|
13648
|
+
try {
|
|
13649
|
+
publishResult = await proxyHttp.api({
|
|
13650
|
+
method: "post",
|
|
13651
|
+
url: `https://creator.douyin.com/web/api/media/aweme/create_v2/?${publishQueryParams}`,
|
|
13652
|
+
data: publishData,
|
|
13653
|
+
defaultErrorMsg: "发布异常,请稍后重试。",
|
|
13654
|
+
headers: {
|
|
13651
13655
|
...headers,
|
|
13652
13656
|
Referer: "https://creator.douyin.com/creator-micro/content/post/image?default-tab=3&enter_from=publish_page&media_type=image&type=new",
|
|
13653
13657
|
"Content-Type": "application/json",
|
|
@@ -13659,137 +13663,104 @@ const mock_mockAction = async (task, params)=>{
|
|
|
13659
13663
|
"bd-ticket-guard-web-version": "2",
|
|
13660
13664
|
"x-secsdk-csrf-token": csrfToken,
|
|
13661
13665
|
"x-tt-session-dtrait": sessionDtrait || ""
|
|
13662
|
-
};
|
|
13663
|
-
task.logger.info(`[douyinPublish] headers: ${JSON.stringify(requestHeaders)}`);
|
|
13664
|
-
task.logger.info(`[douyinPublish] url: https://creator.douyin.com/web/api/media/aweme/create_v2/?${publishQueryParams}`);
|
|
13665
|
-
return proxyHttp.api({
|
|
13666
|
-
method: "post",
|
|
13667
|
-
url: `https://creator.douyin.com/web/api/media/aweme/create_v2/?${publishQueryParams}`,
|
|
13668
|
-
data: publishData,
|
|
13669
|
-
defaultErrorMsg: "发布异常,请稍后重试。",
|
|
13670
|
-
headers: requestHeaders
|
|
13671
|
-
}, {
|
|
13672
|
-
timeout: 60000,
|
|
13673
|
-
retries: 0
|
|
13674
|
-
});
|
|
13675
|
-
};
|
|
13676
|
-
let publishResult;
|
|
13677
|
-
for(let attempt = 0; attempt < MAX_SIGN_RETRIES; attempt++){
|
|
13678
|
-
if (attempt > 0) {
|
|
13679
|
-
task.logger.warn(`[douyinPublish] 第 ${attempt} 次重新签名后重试(上次为 ticket-guard 拒绝)`);
|
|
13680
|
-
await new Promise((resolve)=>setTimeout(resolve, SIGN_RETRY_DELAY));
|
|
13681
|
-
}
|
|
13682
|
-
try {
|
|
13683
|
-
publishResult = await signAndPublish();
|
|
13684
|
-
break;
|
|
13685
|
-
} catch (error) {
|
|
13686
|
-
const handledError = Http.handleApiError(error);
|
|
13687
|
-
if (590 === handledError.code) {
|
|
13688
|
-
if (attempt < MAX_SIGN_RETRIES - 1) continue;
|
|
13689
|
-
task.logger.error(`[douyinPublish] ticket-guard 拒绝重试已用尽(${MAX_SIGN_RETRIES} 次),走兜底`);
|
|
13690
|
-
throw error;
|
|
13691
|
-
}
|
|
13692
|
-
const isProxyOrNetworkError = [
|
|
13693
|
-
599,
|
|
13694
|
-
500,
|
|
13695
|
-
502,
|
|
13696
|
-
503,
|
|
13697
|
-
504
|
|
13698
|
-
].includes(handledError.code);
|
|
13699
|
-
if (isProxyOrNetworkError) {
|
|
13700
|
-
const isProxyRequest = handledError.extra?.isProxyRequest === true;
|
|
13701
|
-
const errorType = 599 === handledError.code || isProxyRequest ? "代理错误" : "网络错误";
|
|
13702
|
-
const message = `图文发布失败,${errorType}:${handledError.message}${task.debug ? ` ${http.proxyInfo}` : ""}`;
|
|
13703
|
-
task.logger.error(`[douyinPublish] ${errorType},直接返回: ${message}`, stringifyError(handledError));
|
|
13704
|
-
await updateTaskState?.({
|
|
13705
|
-
state: __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.TaskState.FAILED,
|
|
13706
|
-
error: message
|
|
13707
|
-
});
|
|
13708
|
-
return {
|
|
13709
|
-
code: 414,
|
|
13710
|
-
data: "",
|
|
13711
|
-
message
|
|
13712
|
-
};
|
|
13713
|
-
}
|
|
13714
|
-
throw error;
|
|
13715
13666
|
}
|
|
13716
|
-
}
|
|
13717
|
-
|
|
13718
|
-
|
|
13719
|
-
|
|
13720
|
-
const details = [
|
|
13721
|
-
publishResult.status_msg,
|
|
13722
|
-
decision?.verify_title,
|
|
13723
|
-
decision?.verify_desc
|
|
13724
|
-
].filter(Boolean).join(" ");
|
|
13725
|
-
const message = `图文发布失败,原因:${details}${task.debug ? ` ${http.proxyInfo}` : ""}`;
|
|
13726
|
-
const safeDecision = safeSerialize(decision) ?? {};
|
|
13727
|
-
const mockData = {
|
|
13728
|
-
state: __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.TaskState.FAILED,
|
|
13729
|
-
error: message,
|
|
13730
|
-
result: {
|
|
13731
|
-
...safeDecision,
|
|
13732
|
-
data: decision,
|
|
13733
|
-
uploadedImgList: JSON.stringify(publishData.item.common.images)
|
|
13734
|
-
}
|
|
13735
|
-
};
|
|
13736
|
-
await updateTaskState?.(mockData);
|
|
13737
|
-
return {
|
|
13738
|
-
code: 0,
|
|
13739
|
-
data: mockData,
|
|
13740
|
-
message: "操作成功"
|
|
13741
|
-
};
|
|
13742
|
-
}
|
|
13743
|
-
reportLogger({
|
|
13744
|
-
token: params.huiwenToken || "",
|
|
13745
|
-
enverionment: task.enverionment || "development",
|
|
13746
|
-
postId: params.articleId,
|
|
13747
|
-
eip: proxyHttp.proxyInfo,
|
|
13748
|
-
proxyIp: params.localIP,
|
|
13749
|
-
accountId: params.accountId,
|
|
13750
|
-
uid: params.uid,
|
|
13751
|
-
platform: "douyin",
|
|
13752
|
-
publishParams: publishData
|
|
13667
|
+
}, {
|
|
13668
|
+
timeout: 60000,
|
|
13669
|
+
retries: 3,
|
|
13670
|
+
retryDelay: 2000
|
|
13753
13671
|
});
|
|
13754
|
-
|
|
13755
|
-
const
|
|
13756
|
-
const
|
|
13757
|
-
|
|
13758
|
-
|
|
13759
|
-
|
|
13672
|
+
} catch (error) {
|
|
13673
|
+
const handledError = Http.handleApiError(error);
|
|
13674
|
+
const isProxyOrNetworkError = [
|
|
13675
|
+
599,
|
|
13676
|
+
500,
|
|
13677
|
+
502,
|
|
13678
|
+
503,
|
|
13679
|
+
504
|
|
13680
|
+
].includes(handledError.code);
|
|
13681
|
+
if (isProxyOrNetworkError) {
|
|
13682
|
+
const isProxyRequest = handledError.extra?.isProxyRequest === true;
|
|
13683
|
+
const errorType = 599 === handledError.code || isProxyRequest ? "代理错误" : "网络错误";
|
|
13684
|
+
const message = `图文发布失败,${errorType}:${handledError.message}${task.debug ? ` ${http.proxyInfo}` : ""}`;
|
|
13685
|
+
task.logger.error(`[douyinPublish] ${errorType},直接返回: ${message}`, stringifyError(handledError));
|
|
13760
13686
|
await updateTaskState?.({
|
|
13761
13687
|
state: __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.TaskState.FAILED,
|
|
13762
|
-
error: message
|
|
13763
|
-
result: {
|
|
13764
|
-
...safeDecision,
|
|
13765
|
-
data: safeDecision,
|
|
13766
|
-
uploadedImgList: JSON.stringify(publishData.item.common.images)
|
|
13767
|
-
}
|
|
13688
|
+
error: message
|
|
13768
13689
|
});
|
|
13769
13690
|
return {
|
|
13770
13691
|
code: 414,
|
|
13771
|
-
data:
|
|
13692
|
+
data: "",
|
|
13772
13693
|
message
|
|
13773
13694
|
};
|
|
13774
|
-
}
|
|
13775
|
-
|
|
13776
|
-
|
|
13695
|
+
}
|
|
13696
|
+
throw error;
|
|
13697
|
+
}
|
|
13698
|
+
task.logger.info(`[douyinPublish] decision值: ${JSON.stringify(decision)}, needsVerification(decision): ${needsVerification(decision)}`);
|
|
13699
|
+
if (needsVerification(decision)) {
|
|
13700
|
+
const details = [
|
|
13701
|
+
publishResult.status_msg,
|
|
13702
|
+
decision?.verify_title,
|
|
13703
|
+
decision?.verify_desc
|
|
13704
|
+
].filter(Boolean).join(" ");
|
|
13705
|
+
const message = `图文发布失败,原因:${details}${task.debug ? ` ${http.proxyInfo}` : ""}`;
|
|
13706
|
+
let decisionObj = {};
|
|
13707
|
+
if (decision) decisionObj = decision;
|
|
13708
|
+
const mockData = {
|
|
13709
|
+
state: __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.TaskState.FAILED,
|
|
13710
|
+
error: message,
|
|
13777
13711
|
result: {
|
|
13778
|
-
|
|
13712
|
+
...decisionObj,
|
|
13713
|
+
data: decision,
|
|
13714
|
+
uploadedImgList: JSON.stringify(publishData.item.common.images)
|
|
13779
13715
|
}
|
|
13780
|
-
}
|
|
13781
|
-
|
|
13782
|
-
|
|
13783
|
-
|
|
13784
|
-
|
|
13785
|
-
|
|
13786
|
-
|
|
13716
|
+
};
|
|
13717
|
+
await updateTaskState?.(mockData);
|
|
13718
|
+
return {
|
|
13719
|
+
code: 0,
|
|
13720
|
+
data: mockData,
|
|
13721
|
+
message: "操作成功"
|
|
13722
|
+
};
|
|
13723
|
+
}
|
|
13724
|
+
reportLogger({
|
|
13725
|
+
token: params.huiwenToken || "",
|
|
13726
|
+
enverionment: task.enverionment || "development",
|
|
13727
|
+
postId: params.articleId,
|
|
13728
|
+
eip: proxyHttp.proxyInfo,
|
|
13729
|
+
proxyIp: params.localIP,
|
|
13730
|
+
accountId: params.accountId,
|
|
13731
|
+
uid: params.uid,
|
|
13732
|
+
platform: "douyin",
|
|
13733
|
+
publishParams: publishData
|
|
13734
|
+
});
|
|
13735
|
+
task.logger.info(`[douyinPublish] 发布结果 ${JSON.stringify(publishResult)}`);
|
|
13736
|
+
const isSuccess = 0 === publishResult.status_code;
|
|
13737
|
+
const message = `图文发布${isSuccess ? "成功" : `失败,原因:${publishResult.status_msg} ${decision?.verify_title} ${decision?.verify_desc}`}${task.debug ? ` ${http.proxyInfo}` : ""}`;
|
|
13738
|
+
const data = isSuccess ? publishResult.item_id || "" : "";
|
|
13739
|
+
if (!isSuccess) {
|
|
13740
|
+
let decisionObj = {};
|
|
13741
|
+
if (decision) decisionObj = decision;
|
|
13787
13742
|
await updateTaskState?.({
|
|
13788
13743
|
state: __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.TaskState.FAILED,
|
|
13789
|
-
error:
|
|
13744
|
+
error: message,
|
|
13745
|
+
result: {
|
|
13746
|
+
...decisionObj,
|
|
13747
|
+
data: decision,
|
|
13748
|
+
uploadedImgList: JSON.stringify(publishData.item.common.images)
|
|
13749
|
+
}
|
|
13790
13750
|
});
|
|
13791
|
-
return
|
|
13751
|
+
return {
|
|
13752
|
+
code: 414,
|
|
13753
|
+
data,
|
|
13754
|
+
message
|
|
13755
|
+
};
|
|
13792
13756
|
}
|
|
13757
|
+
await updateTaskState?.({
|
|
13758
|
+
state: __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.TaskState.SUCCESS,
|
|
13759
|
+
result: {
|
|
13760
|
+
response: data
|
|
13761
|
+
}
|
|
13762
|
+
});
|
|
13763
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(isSuccess ? 0 : 414, message, data);
|
|
13793
13764
|
};
|
|
13794
13765
|
const douyinPublish_rpa_rpaAction = async (task, params)=>{
|
|
13795
13766
|
const commonCookies = {
|
|
@@ -15315,243 +15286,6 @@ async function getBaijiahaoData(_task, params) {
|
|
|
15315
15286
|
};
|
|
15316
15287
|
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(bjhData, "百家号平台数据获取成功!");
|
|
15317
15288
|
}
|
|
15318
|
-
async function getDouyinData(_task, params) {
|
|
15319
|
-
try {
|
|
15320
|
-
const sessionidCookie = params.cookies.find((it)=>"sessionid" === it.name)?.value;
|
|
15321
|
-
if (!sessionidCookie) return types_errorResponse("抖音账号数据异常,请重新绑定账号后重试。", 414);
|
|
15322
|
-
const csrfToken = params.cookies.find((it)=>"passport_csrf_token" === it.name)?.value || "";
|
|
15323
|
-
const headers = {
|
|
15324
|
-
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
15325
|
-
referer: "https://creator.douyin.com/creator-micro/home",
|
|
15326
|
-
origin: "https://creator.douyin.com",
|
|
15327
|
-
"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",
|
|
15328
|
-
...csrfToken ? {
|
|
15329
|
-
"x-secsdk-csrf-token": csrfToken
|
|
15330
|
-
} : {}
|
|
15331
|
-
};
|
|
15332
|
-
const args = [
|
|
15333
|
-
{
|
|
15334
|
-
headers
|
|
15335
|
-
},
|
|
15336
|
-
_task.logger,
|
|
15337
|
-
params.proxyLoc,
|
|
15338
|
-
params.localIP,
|
|
15339
|
-
params.accountId
|
|
15340
|
-
];
|
|
15341
|
-
const http = new Http(...args);
|
|
15342
|
-
const toNum = (val)=>{
|
|
15343
|
-
if (null == val) return 0;
|
|
15344
|
-
const n = Number.parseInt(String(val).replace(/[+,]/g, ""), 10);
|
|
15345
|
-
return Number.isNaN(n) ? 0 : n;
|
|
15346
|
-
};
|
|
15347
|
-
const userProfileP = http.api({
|
|
15348
|
-
method: "get",
|
|
15349
|
-
url: "https://www.douyin.com/aweme/v1/web/user/profile/self/",
|
|
15350
|
-
params: {
|
|
15351
|
-
device_platform: "webapp",
|
|
15352
|
-
aid: "6383",
|
|
15353
|
-
channel: "channel_pc_web",
|
|
15354
|
-
pc_client_type: "1",
|
|
15355
|
-
version_code: "170400",
|
|
15356
|
-
version_name: "17.4.0",
|
|
15357
|
-
cookie_enabled: "true",
|
|
15358
|
-
platform: "PC"
|
|
15359
|
-
}
|
|
15360
|
-
}, {
|
|
15361
|
-
retries: 3,
|
|
15362
|
-
retryDelay: 100,
|
|
15363
|
-
timeout: 10000
|
|
15364
|
-
}).catch((e)=>{
|
|
15365
|
-
_task.logger.warn(`抖音用户信息获取失败: ${e instanceof Error ? e.message : String(e)}`);
|
|
15366
|
-
return null;
|
|
15367
|
-
});
|
|
15368
|
-
const overviewP = http.api({
|
|
15369
|
-
method: "get",
|
|
15370
|
-
url: "https://creator.douyin.com/aweme/janus/creator/data/overview/all/",
|
|
15371
|
-
params: {
|
|
15372
|
-
last_days_type: 1,
|
|
15373
|
-
aid: 2906,
|
|
15374
|
-
app_name: "aweme_creator_platform",
|
|
15375
|
-
device_platform: "web"
|
|
15376
|
-
}
|
|
15377
|
-
}, {
|
|
15378
|
-
retries: 3,
|
|
15379
|
-
retryDelay: 100,
|
|
15380
|
-
timeout: 5000
|
|
15381
|
-
}).catch((e)=>{
|
|
15382
|
-
_task.logger.warn(`抖音近7日数据获取失败(可能未开通数据中心或被风控): ${e instanceof Error ? e.message : String(e)}`);
|
|
15383
|
-
return null;
|
|
15384
|
-
});
|
|
15385
|
-
const [userProfile, overview] = await Promise.all([
|
|
15386
|
-
userProfileP,
|
|
15387
|
-
overviewP
|
|
15388
|
-
]);
|
|
15389
|
-
let fansNum = 0;
|
|
15390
|
-
let favedNum = 0;
|
|
15391
|
-
let followingNum = 0;
|
|
15392
|
-
if (userProfile?.status_code === 0 && userProfile.user) {
|
|
15393
|
-
const user = userProfile.user;
|
|
15394
|
-
fansNum = toNum(user.follower_count);
|
|
15395
|
-
followingNum = toNum(user.following_count);
|
|
15396
|
-
favedNum = toNum(user.total_favorited);
|
|
15397
|
-
_task.logger.info(`提取用户数据 - 昵称: ${user.nickname}, 粉丝: ${fansNum}, 关注: ${followingNum}, 获赞: ${favedNum}, 作品: ${user.aweme_count}`);
|
|
15398
|
-
} else _task.logger.warn(`用户信息接口返回异常: status_code=${userProfile?.status_code}, msg=${userProfile?.status_msg}`);
|
|
15399
|
-
const ov = overview?.data;
|
|
15400
|
-
const douyinData = {
|
|
15401
|
-
fansNum,
|
|
15402
|
-
favedNum,
|
|
15403
|
-
fansNumLastWeek: toNum(ov?.new_fans?.last_period_incr),
|
|
15404
|
-
watchNumLastWeek: toNum(ov?.play?.last_period_incr),
|
|
15405
|
-
likeNumLastWeek: toNum(ov?.digg?.last_period_incr),
|
|
15406
|
-
commentNumLastWeek: toNum(ov?.comment?.last_period_incr),
|
|
15407
|
-
shareNumLastWeek: toNum(ov?.share?.last_period_incr),
|
|
15408
|
-
visitNumLastWeek: toNum(ov?.profile?.last_period_incr)
|
|
15409
|
-
};
|
|
15410
|
-
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(douyinData, "抖音平台数据获取成功!");
|
|
15411
|
-
} catch (error) {
|
|
15412
|
-
if (error && "object" == typeof error && "code" in error && "message" in error) {
|
|
15413
|
-
const err = error;
|
|
15414
|
-
_task.logger.error(`抖音账号数据获取失败: ${err.message} (${err.code})`);
|
|
15415
|
-
return types_errorResponse(err.message, err.code);
|
|
15416
|
-
}
|
|
15417
|
-
const errMsg = error instanceof Error ? error.message : String(error);
|
|
15418
|
-
_task.logger.error(`抖音账号数据获取失败: ${errMsg}`);
|
|
15419
|
-
return types_errorResponse(errMsg || "抖音账号数据获取失败");
|
|
15420
|
-
}
|
|
15421
|
-
}
|
|
15422
|
-
async function getShipinhaoData(_task, params) {
|
|
15423
|
-
try {
|
|
15424
|
-
const sessionidCookie = params.cookies.find((it)=>"sessionid" === it.name)?.value;
|
|
15425
|
-
if (!sessionidCookie) return types_errorResponse("视频号账号数据异常,请重新绑定账号后重试。", 414);
|
|
15426
|
-
const uinCookie = params.cookies.find((it)=>"uin" === it.name || "wxuin" === it.name)?.value || "0000000000";
|
|
15427
|
-
const deviceIdCookie = params.cookies.find((it)=>"device_id" === it.name || "finger_print_device_id" === it.name)?.value;
|
|
15428
|
-
const aid = params.cookies.find((it)=>"_aid" === it.name)?.value || "9d3e0e9f-b842-498d-a273-4285d58df264";
|
|
15429
|
-
const finderId = params.cookies.find((it)=>"_log_finder_id" === it.name || "finder_id" === it.name)?.value || "";
|
|
15430
|
-
const headers = {
|
|
15431
|
-
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
15432
|
-
referer: "https://channels.weixin.qq.com/platform",
|
|
15433
|
-
origin: "https://channels.weixin.qq.com",
|
|
15434
|
-
"content-type": "application/json",
|
|
15435
|
-
"X-WECHAT-UIN": uinCookie,
|
|
15436
|
-
...deviceIdCookie ? {
|
|
15437
|
-
"finger-print-device-id": deviceIdCookie
|
|
15438
|
-
} : {}
|
|
15439
|
-
};
|
|
15440
|
-
const args = [
|
|
15441
|
-
{
|
|
15442
|
-
headers
|
|
15443
|
-
},
|
|
15444
|
-
_task.logger,
|
|
15445
|
-
params.proxyLoc,
|
|
15446
|
-
params.localIP,
|
|
15447
|
-
params.accountId
|
|
15448
|
-
];
|
|
15449
|
-
const http = new Http(...args);
|
|
15450
|
-
const authData = await http.api({
|
|
15451
|
-
method: "post",
|
|
15452
|
-
url: "https://channels.weixin.qq.com/cgi-bin/mmfinderassistant-bin/auth/auth_data",
|
|
15453
|
-
params: {
|
|
15454
|
-
_aid: aid,
|
|
15455
|
-
_rid: `${Date.now().toString(16)}-${Math.random().toString(36).substring(2, 9)}`,
|
|
15456
|
-
_pageUrl: encodeURIComponent("https://channels.weixin.qq.com/platform")
|
|
15457
|
-
},
|
|
15458
|
-
data: {
|
|
15459
|
-
timestamp: Date.now().toString(),
|
|
15460
|
-
_log_finder_uin: "",
|
|
15461
|
-
_log_finder_id: finderId,
|
|
15462
|
-
rawKeyBuff: "",
|
|
15463
|
-
pluginSessionId: null,
|
|
15464
|
-
scene: 7,
|
|
15465
|
-
reqScene: 7
|
|
15466
|
-
}
|
|
15467
|
-
}, {
|
|
15468
|
-
retries: 3,
|
|
15469
|
-
retryDelay: 100,
|
|
15470
|
-
timeout: 5000
|
|
15471
|
-
});
|
|
15472
|
-
const AUTH_ERROR_CODES = [
|
|
15473
|
-
300333,
|
|
15474
|
-
300334,
|
|
15475
|
-
300330,
|
|
15476
|
-
300331,
|
|
15477
|
-
300332
|
|
15478
|
-
];
|
|
15479
|
-
if (authData.errCode && AUTH_ERROR_CODES.includes(authData.errCode)) {
|
|
15480
|
-
_task.logger.warn(`视频号登录已失效:${authData.errMsg} (${authData.errCode})`);
|
|
15481
|
-
return types_errorResponse("视频号账号信息获取失败,请检查账号状态", 414);
|
|
15482
|
-
}
|
|
15483
|
-
if (authData.errCode) {
|
|
15484
|
-
_task.logger.warn(`视频号账号API错误:${authData.errMsg} (${authData.errCode})`);
|
|
15485
|
-
return types_errorResponse(`视频号账号信息获取失败:${authData.errMsg || "未知错误"}`, 414);
|
|
15486
|
-
}
|
|
15487
|
-
const finderUser = authData.data?.finderUser;
|
|
15488
|
-
const now = new Date();
|
|
15489
|
-
const yesterday = new Date(now.getFullYear(), now.getMonth(), now.getDate() - 2);
|
|
15490
|
-
const startTs = Math.floor(yesterday.getTime() / 1000);
|
|
15491
|
-
const endTs = startTs + 86400;
|
|
15492
|
-
_task.logger.info(`视频号昨日数据范围 start: ${startTs} ~ end: ${endTs}`);
|
|
15493
|
-
let fansNumYesterday = 0;
|
|
15494
|
-
let playNumYesterday = 0;
|
|
15495
|
-
let likeNumYesterday = 0;
|
|
15496
|
-
let commentNumYesterday = 0;
|
|
15497
|
-
try {
|
|
15498
|
-
const statsData = await http.api({
|
|
15499
|
-
method: "post",
|
|
15500
|
-
url: "https://channels.weixin.qq.com/cgi-bin/mmfinderassistant-bin/statistic/new_post_total_data",
|
|
15501
|
-
params: {
|
|
15502
|
-
_aid: aid,
|
|
15503
|
-
_rid: `${Date.now().toString(16)}-${Math.random().toString(36).substring(2, 9)}`,
|
|
15504
|
-
_pageUrl: encodeURIComponent("https://channels.weixin.qq.com/platform")
|
|
15505
|
-
},
|
|
15506
|
-
data: {
|
|
15507
|
-
startTs: startTs.toString(),
|
|
15508
|
-
endTs: endTs.toString(),
|
|
15509
|
-
interval: 3,
|
|
15510
|
-
timestamp: Date.now().toString(),
|
|
15511
|
-
_log_finder_uin: "",
|
|
15512
|
-
_log_finder_id: finderId,
|
|
15513
|
-
rawKeyBuff: "",
|
|
15514
|
-
pluginSessionId: null,
|
|
15515
|
-
scene: 7,
|
|
15516
|
-
reqScene: 7
|
|
15517
|
-
}
|
|
15518
|
-
}, {
|
|
15519
|
-
retries: 3,
|
|
15520
|
-
retryDelay: 100,
|
|
15521
|
-
timeout: 5000
|
|
15522
|
-
});
|
|
15523
|
-
if (!statsData.errCode && statsData.data?.totalData) {
|
|
15524
|
-
const data = statsData.data.totalData;
|
|
15525
|
-
fansNumYesterday = Number.parseInt(data.follow?.[1] || "0", 10) || 0;
|
|
15526
|
-
playNumYesterday = Number.parseInt(data.browse?.[1] || "0", 10) || 0;
|
|
15527
|
-
likeNumYesterday = Number.parseInt(data.like?.[1] || "0", 10) || 0;
|
|
15528
|
-
commentNumYesterday = Number.parseInt(data.comment?.[1] || "0", 10) || 0;
|
|
15529
|
-
_task.logger.info(`视频号昨日数据提取成功 - 净增关注:${fansNumYesterday}, 播放:${playNumYesterday}, 喜欢:${likeNumYesterday}, 评论:${commentNumYesterday}`);
|
|
15530
|
-
}
|
|
15531
|
-
} catch (error) {
|
|
15532
|
-
const errMsg = error instanceof Error ? error.message : String(error);
|
|
15533
|
-
_task.logger.warn(`视频号昨日数据获取失败(降级为null): ${errMsg}`);
|
|
15534
|
-
}
|
|
15535
|
-
const shipinhaoData = {
|
|
15536
|
-
fansNum: finderUser?.fansCount || 0,
|
|
15537
|
-
feedsCount: finderUser?.feedsCount || 0,
|
|
15538
|
-
fansNumYesterday,
|
|
15539
|
-
playNumYesterday,
|
|
15540
|
-
likeNumYesterday,
|
|
15541
|
-
commentNumYesterday
|
|
15542
|
-
};
|
|
15543
|
-
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(shipinhaoData, "视频号平台数据获取成功!");
|
|
15544
|
-
} catch (error) {
|
|
15545
|
-
if (error && "object" == typeof error && "code" in error && "message" in error) {
|
|
15546
|
-
const err = error;
|
|
15547
|
-
_task.logger.error(`视频号账号数据获取失败: ${err.message} (${err.code})`);
|
|
15548
|
-
return types_errorResponse(err.message, err.code);
|
|
15549
|
-
}
|
|
15550
|
-
const errMsg = error instanceof Error ? error.message : String(error);
|
|
15551
|
-
_task.logger.error(`视频号账号数据获取失败: ${errMsg}`);
|
|
15552
|
-
return types_errorResponse(errMsg || "视频号账号数据获取失败");
|
|
15553
|
-
}
|
|
15554
|
-
}
|
|
15555
15289
|
async function getToutiaoData(_task, params) {
|
|
15556
15290
|
const http = new Http({
|
|
15557
15291
|
headers: {
|
|
@@ -15648,7 +15382,7 @@ async function getWeixinData(_task, params) {
|
|
|
15648
15382
|
userInfoHtmlPromise,
|
|
15649
15383
|
userSummaryHtmlPromise
|
|
15650
15384
|
]);
|
|
15651
|
-
if (userInfoHtml.includes("请重新<a id='jumpUrl' href='/'>登录</a>")) return types_errorResponse("
|
|
15385
|
+
if (userInfoHtml.includes("请重新<a id='jumpUrl' href='/'>登录</a>")) return types_errorResponse("Token已失效,请重新获取", 414);
|
|
15652
15386
|
const userInfoJson = exportWxCgiData(userInfoHtml);
|
|
15653
15387
|
const userSummaryJson = exportWxCgiData(userSummaryHtml);
|
|
15654
15388
|
const wxData = {
|
|
@@ -15725,9 +15459,7 @@ const SearchAccountInfoParamsSchema = ActionCommonParamsSchema.extend({
|
|
|
15725
15459
|
"toutiao",
|
|
15726
15460
|
"xiaohongshu",
|
|
15727
15461
|
"weixin",
|
|
15728
|
-
"baijiahao"
|
|
15729
|
-
"douyin",
|
|
15730
|
-
"shipinhao"
|
|
15462
|
+
"baijiahao"
|
|
15731
15463
|
])
|
|
15732
15464
|
});
|
|
15733
15465
|
const SearchAccountInfo = async (_task, params)=>{
|
|
@@ -15741,10 +15473,6 @@ const SearchAccountInfo = async (_task, params)=>{
|
|
|
15741
15473
|
return getWeixinData(_task, params);
|
|
15742
15474
|
case "baijiahao":
|
|
15743
15475
|
return getBaijiahaoData(_task, params);
|
|
15744
|
-
case "douyin":
|
|
15745
|
-
return getDouyinData(_task, params);
|
|
15746
|
-
case "shipinhao":
|
|
15747
|
-
return getShipinhaoData(_task, params);
|
|
15748
15476
|
default:
|
|
15749
15477
|
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(null, "暂不支持该平台");
|
|
15750
15478
|
}
|
|
@@ -15839,45 +15567,18 @@ const XiaohongshuArticleSchema = BaseArticleSchema.extend({
|
|
|
15839
15567
|
collectNum: schemas_number(),
|
|
15840
15568
|
shareNum: schemas_number()
|
|
15841
15569
|
});
|
|
15842
|
-
const DouyinArticleSchema = BaseArticleSchema.extend({
|
|
15843
|
-
playNum: schemas_number(),
|
|
15844
|
-
likeNum: schemas_number(),
|
|
15845
|
-
commentNum: schemas_number(),
|
|
15846
|
-
shareNum: schemas_number(),
|
|
15847
|
-
collectNum: schemas_number(),
|
|
15848
|
-
awemeId: schemas_string(),
|
|
15849
|
-
awemeType: schemas_number(),
|
|
15850
|
-
duration: schemas_number().optional(),
|
|
15851
|
-
status: schemas_string(),
|
|
15852
|
-
publicUrl: schemas_string()
|
|
15853
|
-
});
|
|
15854
|
-
const ShipinhaoArticleSchema = BaseArticleSchema.extend({
|
|
15855
|
-
readNum: schemas_number(),
|
|
15856
|
-
likeNum: schemas_number(),
|
|
15857
|
-
commentNum: schemas_number(),
|
|
15858
|
-
forwardNum: schemas_number(),
|
|
15859
|
-
favNum: schemas_number(),
|
|
15860
|
-
objectId: schemas_string(),
|
|
15861
|
-
postType: schemas_string(),
|
|
15862
|
-
postStatus: schemas_number(),
|
|
15863
|
-
effectiveTime: schemas_number().optional()
|
|
15864
|
-
});
|
|
15865
15570
|
const FetchArticlesDataSchema = schemas_object({
|
|
15866
15571
|
articleCell: schemas_array(union([
|
|
15867
15572
|
ToutiaoArticleSchema,
|
|
15868
15573
|
WeixinArticleSchema,
|
|
15869
15574
|
BaijiahaoArticleSchema,
|
|
15870
|
-
XiaohongshuArticleSchema
|
|
15871
|
-
DouyinArticleSchema,
|
|
15872
|
-
ShipinhaoArticleSchema
|
|
15575
|
+
XiaohongshuArticleSchema
|
|
15873
15576
|
])).optional(),
|
|
15874
15577
|
timerPublish: schemas_array(union([
|
|
15875
15578
|
ToutiaoArticleSchema,
|
|
15876
15579
|
WeixinArticleSchema,
|
|
15877
15580
|
BaijiahaoArticleSchema,
|
|
15878
|
-
XiaohongshuArticleSchema
|
|
15879
|
-
DouyinArticleSchema,
|
|
15880
|
-
ShipinhaoArticleSchema
|
|
15581
|
+
XiaohongshuArticleSchema
|
|
15881
15582
|
])).optional(),
|
|
15882
15583
|
pagination: schemas_object({
|
|
15883
15584
|
total: schemas_number().optional(),
|
|
@@ -15992,273 +15693,6 @@ async function handleBaijiahaoData(_task, params) {
|
|
|
15992
15693
|
return searchPublishInfo_types_errorResponse(error instanceof Error ? error.message : "百家号文章数据获取失败");
|
|
15993
15694
|
}
|
|
15994
15695
|
}
|
|
15995
|
-
async function handleDouyinData(_task, params) {
|
|
15996
|
-
try {
|
|
15997
|
-
const { cookies, pageSize = 12, status = 0, showOriginalData = false, onlySuccess = false } = params;
|
|
15998
|
-
const pageNum = params.pageNum || 1;
|
|
15999
|
-
const headers = {
|
|
16000
|
-
cookie: cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
16001
|
-
referer: "https://creator.douyin.com"
|
|
16002
|
-
};
|
|
16003
|
-
const args = [
|
|
16004
|
-
{
|
|
16005
|
-
headers
|
|
16006
|
-
},
|
|
16007
|
-
_task.logger,
|
|
16008
|
-
params.proxyLoc,
|
|
16009
|
-
params.localIP,
|
|
16010
|
-
params.accountId
|
|
16011
|
-
];
|
|
16012
|
-
const http = new Http(...args);
|
|
16013
|
-
async function fetchWorks(cursor) {
|
|
16014
|
-
return await http.api({
|
|
16015
|
-
method: "get",
|
|
16016
|
-
url: "https://creator.douyin.com/janus/douyin/creator/pc/work_list",
|
|
16017
|
-
params: {
|
|
16018
|
-
scene: "star_atlas",
|
|
16019
|
-
device_platform: "android",
|
|
16020
|
-
aid: 1128,
|
|
16021
|
-
status,
|
|
16022
|
-
count: pageSize,
|
|
16023
|
-
max_cursor: cursor
|
|
16024
|
-
}
|
|
16025
|
-
}, {
|
|
16026
|
-
retries: 3,
|
|
16027
|
-
retryDelay: 100,
|
|
16028
|
-
timeout: 5000
|
|
16029
|
-
});
|
|
16030
|
-
}
|
|
16031
|
-
const isHasMore = (v)=>true === v || 1 === v;
|
|
16032
|
-
const skipCount = (pageNum - 1) * pageSize;
|
|
16033
|
-
const needCount = skipCount + pageSize;
|
|
16034
|
-
const workListResponse = await fetchWorks(0);
|
|
16035
|
-
if (!workListResponse || !Array.isArray(workListResponse.aweme_list)) return searchPublishInfo_types_errorResponse("抖音数据获取失败,请检查账号状态", 414);
|
|
16036
|
-
const allWorks = [
|
|
16037
|
-
...workListResponse.aweme_list
|
|
16038
|
-
];
|
|
16039
|
-
let hasMore = isHasMore(workListResponse.has_more);
|
|
16040
|
-
let currentCursor = workListResponse.cursor ?? workListResponse.max_cursor ?? 0;
|
|
16041
|
-
let guard = 0;
|
|
16042
|
-
while(allWorks.length < needCount && hasMore && guard < 20){
|
|
16043
|
-
const nextPageResponse = await fetchWorks(currentCursor);
|
|
16044
|
-
if (!Array.isArray(nextPageResponse.aweme_list) || 0 === nextPageResponse.aweme_list.length) break;
|
|
16045
|
-
allWorks.push(...nextPageResponse.aweme_list);
|
|
16046
|
-
hasMore = isHasMore(nextPageResponse.has_more);
|
|
16047
|
-
currentCursor = nextPageResponse.cursor ?? nextPageResponse.max_cursor ?? currentCursor;
|
|
16048
|
-
guard++;
|
|
16049
|
-
}
|
|
16050
|
-
const finalWorks = allWorks.slice(skipCount, needCount);
|
|
16051
|
-
const articleCell = finalWorks.map((item)=>{
|
|
16052
|
-
const workDetailUrl = `https://creator.douyin.com/creator-micro/work-management/work-detail/${item.aweme_id}`;
|
|
16053
|
-
const workPublicUrl = item.share_url || `https://www.douyin.com/video/${item.aweme_id}`;
|
|
16054
|
-
let statusText;
|
|
16055
|
-
statusText = item.status?.is_delete ? "deleted" : item.status?.is_private ? "private" : item.status?.in_reviewing ? "reviewing" : "public";
|
|
16056
|
-
return {
|
|
16057
|
-
title: item.desc || "无作品描述",
|
|
16058
|
-
imageUrl: item.Cover?.url_list?.[0] || "",
|
|
16059
|
-
createTime: item.create_time,
|
|
16060
|
-
redirectUrl: workDetailUrl,
|
|
16061
|
-
playNum: item.statistics?.play_count || 0,
|
|
16062
|
-
likeNum: item.statistics?.digg_count || 0,
|
|
16063
|
-
commentNum: item.statistics?.comment_count || 0,
|
|
16064
|
-
shareNum: item.statistics?.share_count || 0,
|
|
16065
|
-
collectNum: item.statistics?.collect_count || 0,
|
|
16066
|
-
awemeId: item.aweme_id,
|
|
16067
|
-
awemeType: item.aweme_type ?? 0,
|
|
16068
|
-
duration: item.duration,
|
|
16069
|
-
status: statusText,
|
|
16070
|
-
publicUrl: workPublicUrl,
|
|
16071
|
-
...showOriginalData ? {
|
|
16072
|
-
originalData: item
|
|
16073
|
-
} : {}
|
|
16074
|
-
};
|
|
16075
|
-
});
|
|
16076
|
-
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)({
|
|
16077
|
-
articleCell,
|
|
16078
|
-
...onlySuccess ? {
|
|
16079
|
-
pagination: {
|
|
16080
|
-
total: workListResponse.total || allWorks.length,
|
|
16081
|
-
nextPage: hasMore,
|
|
16082
|
-
pageNum,
|
|
16083
|
-
pageSize
|
|
16084
|
-
}
|
|
16085
|
-
} : null
|
|
16086
|
-
}, "抖音数据获取成功");
|
|
16087
|
-
} catch (error) {
|
|
16088
|
-
return searchPublishInfo_types_errorResponse(error instanceof Error ? error.message : "抖音数据获取失败");
|
|
16089
|
-
}
|
|
16090
|
-
}
|
|
16091
|
-
async function handleShipinhaoData(_task, params) {
|
|
16092
|
-
try {
|
|
16093
|
-
const { cookies, postType = "all", pageSize = 10, showOriginalData = false } = params;
|
|
16094
|
-
const pageNum = params.pageNum || 1;
|
|
16095
|
-
const aidCookie = cookies.find((it)=>"_aid" === it.name)?.value;
|
|
16096
|
-
const aid = aidCookie || "9d3e0e9f-b842-498d-a273-4285d58df264";
|
|
16097
|
-
const uinCookie = cookies.find((it)=>"uin" === it.name || "wxuin" === it.name)?.value || "0000000000";
|
|
16098
|
-
const deviceIdCookie = cookies.find((it)=>"device_id" === it.name || "finger_print_device_id" === it.name)?.value;
|
|
16099
|
-
const headers = {
|
|
16100
|
-
cookie: cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
16101
|
-
referer: "https://channels.weixin.qq.com",
|
|
16102
|
-
origin: "https://channels.weixin.qq.com",
|
|
16103
|
-
"content-type": "application/json",
|
|
16104
|
-
"X-WECHAT-UIN": uinCookie,
|
|
16105
|
-
...deviceIdCookie ? {
|
|
16106
|
-
"finger-print-device-id": deviceIdCookie
|
|
16107
|
-
} : {}
|
|
16108
|
-
};
|
|
16109
|
-
const args = [
|
|
16110
|
-
{
|
|
16111
|
-
headers
|
|
16112
|
-
},
|
|
16113
|
-
_task.logger,
|
|
16114
|
-
params.proxyLoc,
|
|
16115
|
-
params.localIP,
|
|
16116
|
-
params.accountId
|
|
16117
|
-
];
|
|
16118
|
-
const http = new Http(...args);
|
|
16119
|
-
const finderIdCookie = cookies.find((it)=>"_log_finder_id" === it.name || "finder_id" === it.name)?.value || "";
|
|
16120
|
-
async function fetchPosts(currentPage, userpageType, pageUrl, rawKeyBuff = "") {
|
|
16121
|
-
return await http.api({
|
|
16122
|
-
method: "post",
|
|
16123
|
-
url: "https://channels.weixin.qq.com/micro/content/cgi-bin/mmfinderassistant-bin/post/post_list",
|
|
16124
|
-
params: {
|
|
16125
|
-
_aid: aid,
|
|
16126
|
-
_rid: `${Date.now().toString(16)}-${Math.random().toString(36).substring(2, 9)}`,
|
|
16127
|
-
_pageUrl: encodeURIComponent(pageUrl)
|
|
16128
|
-
},
|
|
16129
|
-
data: {
|
|
16130
|
-
pageSize,
|
|
16131
|
-
currentPage,
|
|
16132
|
-
userpageType,
|
|
16133
|
-
stickyOrder: true,
|
|
16134
|
-
timestamp: Date.now().toString(),
|
|
16135
|
-
_log_finder_uin: "",
|
|
16136
|
-
_log_finder_id: finderIdCookie,
|
|
16137
|
-
rawKeyBuff,
|
|
16138
|
-
pluginSessionId: null,
|
|
16139
|
-
scene: 7,
|
|
16140
|
-
reqScene: 7
|
|
16141
|
-
}
|
|
16142
|
-
}, {
|
|
16143
|
-
retries: 3,
|
|
16144
|
-
retryDelay: 100,
|
|
16145
|
-
timeout: 5000
|
|
16146
|
-
});
|
|
16147
|
-
}
|
|
16148
|
-
async function fetchAllPosts(userpageType, pageUrl) {
|
|
16149
|
-
const allPosts = [];
|
|
16150
|
-
let currentPage = 1;
|
|
16151
|
-
let rawKeyBuff = "";
|
|
16152
|
-
let continueFlag = true;
|
|
16153
|
-
let totalCount = 0;
|
|
16154
|
-
while(continueFlag){
|
|
16155
|
-
const response = await fetchPosts(currentPage, userpageType, pageUrl, rawKeyBuff);
|
|
16156
|
-
if (response.errCode && AUTH_ERROR_CODES.includes(response.errCode)) throw new Error(`AUTH_ERROR:${response.errMsg || "登录已失效"}`);
|
|
16157
|
-
if (response.errCode) {
|
|
16158
|
-
_task.logger.warn(`视频号API错误:${response.errMsg} (${response.errCode})`);
|
|
16159
|
-
throw new Error(`视频号API错误:${response.errMsg} (${response.errCode})`);
|
|
16160
|
-
}
|
|
16161
|
-
if (1 === currentPage) totalCount = response.data?.totalCount ?? 0;
|
|
16162
|
-
const posts = response.data?.list || response.posts || response.post_list || [];
|
|
16163
|
-
allPosts.push(...posts);
|
|
16164
|
-
continueFlag = response.data?.continueFlag ?? false;
|
|
16165
|
-
rawKeyBuff = response.data?.lastBuff || "";
|
|
16166
|
-
_task.logger.info(`获取${11 === userpageType ? "视频" : "图文"}第${currentPage}页,本页${posts.length}条,累计${allPosts.length}条,continueFlag=${continueFlag}`);
|
|
16167
|
-
currentPage++;
|
|
16168
|
-
if (currentPage > 100) {
|
|
16169
|
-
_task.logger.warn("分页超过100页,停止请求");
|
|
16170
|
-
break;
|
|
16171
|
-
}
|
|
16172
|
-
}
|
|
16173
|
-
if (totalCount > 0 && allPosts.length !== totalCount) _task.logger.warn(`视频号分页可能不完整:期望${totalCount}条,实际${allPosts.length}条`);
|
|
16174
|
-
return {
|
|
16175
|
-
posts: allPosts,
|
|
16176
|
-
totalCount
|
|
16177
|
-
};
|
|
16178
|
-
}
|
|
16179
|
-
const mapPost = (item, forcePostType)=>{
|
|
16180
|
-
let imageUrl = "";
|
|
16181
|
-
if (item.desc?.media?.[0]?.thumbUrl) imageUrl = item.desc.media[0].thumbUrl;
|
|
16182
|
-
else if (item.desc?.media?.[0]?.coverUrl) imageUrl = item.desc.media[0].coverUrl;
|
|
16183
|
-
else if (item.cover?.url) imageUrl = item.cover.url;
|
|
16184
|
-
else if (item.media_url) imageUrl = item.media_url;
|
|
16185
|
-
const title = item.desc?.description || item.object_desc || "无标题";
|
|
16186
|
-
return {
|
|
16187
|
-
title,
|
|
16188
|
-
imageUrl,
|
|
16189
|
-
createTime: item.createTime || item.create_time,
|
|
16190
|
-
redirectUrl: "https://channels.weixin.qq.com/platform",
|
|
16191
|
-
readNum: item.readCount || item.read_count || 0,
|
|
16192
|
-
likeNum: item.likeCount || item.like_count || 0,
|
|
16193
|
-
commentNum: item.commentCount || item.comment_count || 0,
|
|
16194
|
-
forwardNum: item.forwardCount || item.forward_count || 0,
|
|
16195
|
-
favNum: item.favCount || item.fav_count || 0,
|
|
16196
|
-
objectId: item.exportId || item.objectId || "",
|
|
16197
|
-
postType: forcePostType,
|
|
16198
|
-
postStatus: item.status || item.post_status || 0,
|
|
16199
|
-
...item.effectiveTime ? {
|
|
16200
|
-
effectiveTime: item.effectiveTime
|
|
16201
|
-
} : {},
|
|
16202
|
-
...showOriginalData ? {
|
|
16203
|
-
originalData: item
|
|
16204
|
-
} : {}
|
|
16205
|
-
};
|
|
16206
|
-
};
|
|
16207
|
-
const allArticles = [];
|
|
16208
|
-
const needVideo = "all" === postType || "video" === postType;
|
|
16209
|
-
const needArticle = "all" === postType || "article" === postType;
|
|
16210
|
-
const AUTH_ERROR_CODES = [
|
|
16211
|
-
300333,
|
|
16212
|
-
300334,
|
|
16213
|
-
300330,
|
|
16214
|
-
300331,
|
|
16215
|
-
300332
|
|
16216
|
-
];
|
|
16217
|
-
let combinedTotal = 0;
|
|
16218
|
-
if (needVideo) try {
|
|
16219
|
-
const videoPageUrl = "https://channels.weixin.qq.com/micro/content/post/list";
|
|
16220
|
-
const { posts, totalCount } = await fetchAllPosts(11, videoPageUrl);
|
|
16221
|
-
_task.logger.info(`视频号视频获取响应:共${posts.length}条,totalCount=${totalCount}`);
|
|
16222
|
-
const videoArticles = posts.filter((item)=>item.createTime || item.create_time).map((item)=>mapPost(item, "video"));
|
|
16223
|
-
allArticles.push(...videoArticles);
|
|
16224
|
-
combinedTotal += totalCount || videoArticles.length;
|
|
16225
|
-
} catch (error) {
|
|
16226
|
-
const errMsg = error instanceof Error ? error.message : String(error);
|
|
16227
|
-
if (errMsg.startsWith("AUTH_ERROR:")) throw error;
|
|
16228
|
-
_task.logger.warn(`获取视频号视频失败:${errMsg}`);
|
|
16229
|
-
}
|
|
16230
|
-
if (needArticle) try {
|
|
16231
|
-
const articlePageUrl = "https://channels.weixin.qq.com/micro/content/post/finderNewLifePostList";
|
|
16232
|
-
const { posts, totalCount } = await fetchAllPosts(10, articlePageUrl);
|
|
16233
|
-
_task.logger.info(`视频号图文获取响应:共${posts.length}条,totalCount=${totalCount}`);
|
|
16234
|
-
const articleArticles = posts.filter((item)=>item.createTime || item.create_time).map((item)=>mapPost(item, "article"));
|
|
16235
|
-
allArticles.push(...articleArticles);
|
|
16236
|
-
combinedTotal += totalCount || articleArticles.length;
|
|
16237
|
-
} catch (error) {
|
|
16238
|
-
const errMsg = error instanceof Error ? error.message : String(error);
|
|
16239
|
-
if (errMsg.startsWith("AUTH_ERROR:")) throw error;
|
|
16240
|
-
_task.logger.warn(`获取视频号图文失败:${errMsg}`);
|
|
16241
|
-
}
|
|
16242
|
-
allArticles.sort((a, b)=>b.createTime - a.createTime);
|
|
16243
|
-
const total = allArticles.length;
|
|
16244
|
-
const start = (pageNum - 1) * pageSize;
|
|
16245
|
-
const pageItems = allArticles.slice(start, start + pageSize);
|
|
16246
|
-
_task.logger.info(`视频号数据获取成功,合计${total}条,第${pageNum}页返回${pageItems.length}条`);
|
|
16247
|
-
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)({
|
|
16248
|
-
articleCell: pageItems,
|
|
16249
|
-
pagination: {
|
|
16250
|
-
total,
|
|
16251
|
-
nextPage: start + pageSize < total,
|
|
16252
|
-
pageNum,
|
|
16253
|
-
pageSize
|
|
16254
|
-
}
|
|
16255
|
-
}, "视频号数据获取成功");
|
|
16256
|
-
} catch (error) {
|
|
16257
|
-
const errMsg = error instanceof Error ? error.message : String(error);
|
|
16258
|
-
if (errMsg.startsWith("AUTH_ERROR:")) return searchPublishInfo_types_errorResponse("视频号数据获取失败,请检查账号状态", 414);
|
|
16259
|
-
return searchPublishInfo_types_errorResponse(errMsg || "视频号数据获取失败");
|
|
16260
|
-
}
|
|
16261
|
-
}
|
|
16262
15696
|
async function handleToutiaoData(_task, params) {
|
|
16263
15697
|
try {
|
|
16264
15698
|
const { cookies, pageNum = 1, pageSize = 10, showOriginalData = false, onlySuccess = false, containsArticle = false } = params;
|
|
@@ -16291,7 +15725,7 @@ async function handleToutiaoData(_task, params) {
|
|
|
16291
15725
|
app_id: 1231
|
|
16292
15726
|
}
|
|
16293
15727
|
});
|
|
16294
|
-
if (0 !== visitedUid.code) return searchPublishInfo_types_errorResponse("
|
|
15728
|
+
if (0 !== visitedUid.code) return searchPublishInfo_types_errorResponse("头条号账号信息获取失败,请检查账号状态", 414);
|
|
16295
15729
|
const articleInfo = await http.api({
|
|
16296
15730
|
method: "get",
|
|
16297
15731
|
url: "https://mp.toutiao.com/api/feed/mp_provider/v1/",
|
|
@@ -16398,7 +15832,7 @@ async function handleWeixinData(_task, params) {
|
|
|
16398
15832
|
const size = onlySuccess ? 10 : pageSize > 20 ? 20 : pageSize;
|
|
16399
15833
|
let begin = (lastPage ?? pageNum) - 1;
|
|
16400
15834
|
const rawArticlesInfo = await fetchArticles(begin * size, size, token);
|
|
16401
|
-
if (rawArticlesInfo.includes("请重新<a id='jumpUrl' href='/'>登录</a>")) return searchPublishInfo_types_errorResponse("
|
|
15835
|
+
if (rawArticlesInfo.includes("请重新<a id='jumpUrl' href='/'>登录</a>")) return searchPublishInfo_types_errorResponse("登陆已失效,请重新登陆!", 414);
|
|
16402
15836
|
const articlesInfo = ParsePublishPage(rawArticlesInfo);
|
|
16403
15837
|
let articleCell = [];
|
|
16404
15838
|
if (!onlySuccess && pageSize > 20) {
|
|
@@ -16560,7 +15994,7 @@ async function handleXiaohongshuData(_task, params) {
|
|
|
16560
15994
|
const a1Cookie = cookies.find((it)=>"a1" === it.name)?.value;
|
|
16561
15995
|
if (!a1Cookie) return {
|
|
16562
15996
|
code: 414,
|
|
16563
|
-
message: "
|
|
15997
|
+
message: "账号数据异常",
|
|
16564
15998
|
data: {}
|
|
16565
15999
|
};
|
|
16566
16000
|
if (onlySuccess && 10 !== pageSize) return {
|
|
@@ -16679,7 +16113,7 @@ async function handleXiaohongshuData(_task, params) {
|
|
|
16679
16113
|
}, "小红书文章数据获取成功");
|
|
16680
16114
|
}
|
|
16681
16115
|
const FetchArticlesParamsSchema = ActionCommonParamsSchema.extend({
|
|
16682
|
-
platform: schemas_string().describe("社交平台:weixin, toutiao, baijiahao, xiaohongshu
|
|
16116
|
+
platform: schemas_string().describe("社交平台:weixin, toutiao, baijiahao, xiaohongshu"),
|
|
16683
16117
|
token: union([
|
|
16684
16118
|
schemas_string(),
|
|
16685
16119
|
schemas_number()
|
|
@@ -16691,14 +16125,7 @@ const FetchArticlesParamsSchema = ActionCommonParamsSchema.extend({
|
|
|
16691
16125
|
showOriginalData: schemas_boolean().optional().describe("是否展示原始数据,默认false"),
|
|
16692
16126
|
cursor: schemas_number().optional().describe("仅用于微信分页游标,默认为空"),
|
|
16693
16127
|
lastPage: schemas_number().optional(),
|
|
16694
|
-
containsArticle: schemas_boolean().optional().describe("是否包含文章内容,默认false")
|
|
16695
|
-
status: schemas_number().optional().describe("抖音作品状态:0=全部"),
|
|
16696
|
-
includeAccount: schemas_boolean().optional().describe("是否包含账号数据,默认true"),
|
|
16697
|
-
postType: schemas_enum([
|
|
16698
|
-
"video",
|
|
16699
|
-
"article",
|
|
16700
|
-
"all"
|
|
16701
|
-
]).optional().describe("视频号作品类型:video=视频, article=图文, all=全部")
|
|
16128
|
+
containsArticle: schemas_boolean().optional().describe("是否包含文章内容,默认false")
|
|
16702
16129
|
});
|
|
16703
16130
|
const FetchArticles = async (_task, params)=>{
|
|
16704
16131
|
const { platform } = params;
|
|
@@ -16711,10 +16138,6 @@ const FetchArticles = async (_task, params)=>{
|
|
|
16711
16138
|
return handleBaijiahaoData(_task, params);
|
|
16712
16139
|
case "xiaohongshu":
|
|
16713
16140
|
return handleXiaohongshuData(_task, params);
|
|
16714
|
-
case "douyin":
|
|
16715
|
-
return handleDouyinData(_task, params);
|
|
16716
|
-
case "shipinhao":
|
|
16717
|
-
return handleShipinhaoData(_task, params);
|
|
16718
16141
|
default:
|
|
16719
16142
|
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)({}, "暂不支持该平台");
|
|
16720
16143
|
}
|
|
@@ -18118,11 +17541,6 @@ class VideoChannelUploader {
|
|
|
18118
17541
|
this.concurrentLimit = config.concurrentLimit || 4;
|
|
18119
17542
|
this.singleFileSize = config.singleFileSize || 10485760;
|
|
18120
17543
|
this.http = config.http || new Http();
|
|
18121
|
-
this.reqOptions = {
|
|
18122
|
-
timeout: config.timeout ?? 60000,
|
|
18123
|
-
retries: config.retries ?? 3,
|
|
18124
|
-
retryDelay: config.retryDelay ?? 2000
|
|
18125
|
-
};
|
|
18126
17544
|
}
|
|
18127
17545
|
calculateMd5(buffer) {
|
|
18128
17546
|
const MAX_SIZE = 5242880;
|
|
@@ -18179,7 +17597,7 @@ class VideoChannelUploader {
|
|
|
18179
17597
|
url: filePath,
|
|
18180
17598
|
method: "get",
|
|
18181
17599
|
responseType: "arraybuffer"
|
|
18182
|
-
}
|
|
17600
|
+
});
|
|
18183
17601
|
return Buffer.from(resp);
|
|
18184
17602
|
}
|
|
18185
17603
|
return __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].promises.readFile(filePath);
|
|
@@ -18209,7 +17627,7 @@ class VideoChannelUploader {
|
|
|
18209
17627
|
headers,
|
|
18210
17628
|
data: requestBody,
|
|
18211
17629
|
defaultErrorMsg: "获取UploadID失败"
|
|
18212
|
-
}
|
|
17630
|
+
});
|
|
18213
17631
|
if (!resp?.UploadID) throw new Error(`获取 UploadID 失败: ${resp?.errMsg || "未知错误"}`);
|
|
18214
17632
|
return resp.UploadID;
|
|
18215
17633
|
}
|
|
@@ -18230,7 +17648,7 @@ class VideoChannelUploader {
|
|
|
18230
17648
|
headers,
|
|
18231
17649
|
data: chunk,
|
|
18232
17650
|
defaultErrorMsg: `分片 ${partNumber} 上传失败`
|
|
18233
|
-
}
|
|
17651
|
+
});
|
|
18234
17652
|
if (resp?.errCode !== void 0 && 0 !== resp.errCode) throw new Error(`分片 ${partNumber} 上传失败: ${resp.errMsg}`);
|
|
18235
17653
|
if (onProgress) onProgress(chunk.length);
|
|
18236
17654
|
return resp.ETag || "";
|
|
@@ -18254,7 +17672,7 @@ class VideoChannelUploader {
|
|
|
18254
17672
|
headers,
|
|
18255
17673
|
data: requestBody,
|
|
18256
17674
|
defaultErrorMsg: "确认分片上传失败"
|
|
18257
|
-
}
|
|
17675
|
+
});
|
|
18258
17676
|
if (resp?.ListPartsResult?.Part) return resp.ListPartsResult.Part.map((p)=>({
|
|
18259
17677
|
PartNumber: parseInt(p.PartNumber),
|
|
18260
17678
|
ETag: p.ETag
|
|
@@ -18280,7 +17698,7 @@ class VideoChannelUploader {
|
|
|
18280
17698
|
headers,
|
|
18281
17699
|
data: requestBody,
|
|
18282
17700
|
defaultErrorMsg: "完成上传失败"
|
|
18283
|
-
}
|
|
17701
|
+
});
|
|
18284
17702
|
if (!resp?.DownloadURL) throw new Error(`完成上传失败: ${resp?.errMsg || "未知错误"}`);
|
|
18285
17703
|
return resp.DownloadURL;
|
|
18286
17704
|
}
|
|
@@ -18631,9 +18049,7 @@ const shipinhaoPublish_mock_mockAction = async (task, params)=>{
|
|
|
18631
18049
|
task.logger.info("[shipinhaoPublish] 开始执行视频号发布 - Mock API 方式");
|
|
18632
18050
|
const updateTaskState = task.taskStageStore?.update?.bind(task.taskStageStore, task.taskId || "");
|
|
18633
18051
|
if (!params.extraParam.fingerPrintDeviceId || !params.extraParam.aId) return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(400, "fingerPrintDeviceId和aId 不能为空", "");
|
|
18634
|
-
let currentStep = "初始化";
|
|
18635
18052
|
try {
|
|
18636
|
-
currentStep = "解析认证信息";
|
|
18637
18053
|
const cookieString = params.cookies.map((c)=>`${c.name}=${c.value}`).join("; ");
|
|
18638
18054
|
const fingerPrintDeviceId = params.extraParam.fingerPrintDeviceId;
|
|
18639
18055
|
const aId = params.extraParam.aId;
|
|
@@ -18654,10 +18070,8 @@ const shipinhaoPublish_mock_mockAction = async (task, params)=>{
|
|
|
18654
18070
|
headers
|
|
18655
18071
|
});
|
|
18656
18072
|
const proxyHttp = new Http(...args);
|
|
18657
|
-
currentStep = "验证发布参数";
|
|
18658
18073
|
if (!params.banners || 0 === params.banners.length) return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(400, "至少需要一张图片", "");
|
|
18659
18074
|
const images = params.banners.slice(0, 18).filter((img)=>"string" == typeof img);
|
|
18660
|
-
currentStep = "获取用户信息";
|
|
18661
18075
|
task.logger.info("[shipinhaoPublish] 获取用户信息...");
|
|
18662
18076
|
console.log("cookieString", cookieString);
|
|
18663
18077
|
const userInfo = await mock_getUserInfo(cookieString, http);
|
|
@@ -18668,7 +18082,6 @@ const shipinhaoPublish_mock_mockAction = async (task, params)=>{
|
|
|
18668
18082
|
}
|
|
18669
18083
|
const finderUsername = userInfo.data.finderUser.finderUsername;
|
|
18670
18084
|
console.log(finderUsername);
|
|
18671
|
-
currentStep = "获取上传认证密钥";
|
|
18672
18085
|
task.logger.info("[shipinhaoPublish] 获取上传认证密钥...");
|
|
18673
18086
|
const authKeyResponse = await getUploadAuthKey(cookieString, finderUsername, http);
|
|
18674
18087
|
if (0 !== authKeyResponse.errCode || !authKeyResponse.data?.authKey) return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(authKeyResponse.errCode || 500, `获取上传认证参数失败: ${authKeyResponse.errMsg}`, "");
|
|
@@ -18676,12 +18089,10 @@ const shipinhaoPublish_mock_mockAction = async (task, params)=>{
|
|
|
18676
18089
|
const uin = authKeyResponse.data.uin;
|
|
18677
18090
|
if (!uin) return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(500, "获取用户 uin 失败", "");
|
|
18678
18091
|
const taskId = String(generateUUID());
|
|
18679
|
-
currentStep = "上传图片";
|
|
18680
18092
|
task.logger.info(`[shipinhaoPublish] 开始上传 ${images.length} 张图片...`);
|
|
18681
18093
|
const uploadedImages = [];
|
|
18682
18094
|
for(let i = 0; i < images.length; i++){
|
|
18683
|
-
|
|
18684
|
-
task.logger.info(`[shipinhaoPublish] ${currentStep}...`);
|
|
18095
|
+
task.logger.info(`[shipinhaoPublish] 上传图片 ${i + 1}/${images.length}...`);
|
|
18685
18096
|
const uploadResult = await uploadImageComplete(images[i], taskId, finderUsername, uin, authKey, http);
|
|
18686
18097
|
console.log(JSON.stringify(uploadResult));
|
|
18687
18098
|
if (!uploadResult.DownloadURL) return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(500, `图片上传失败: ${uploadResult.errMsg}`, "");
|
|
@@ -18698,7 +18109,6 @@ const shipinhaoPublish_mock_mockAction = async (task, params)=>{
|
|
|
18698
18109
|
urlCdnTaskId: ""
|
|
18699
18110
|
});
|
|
18700
18111
|
}
|
|
18701
|
-
currentStep = "发布图文内容";
|
|
18702
18112
|
task.logger.info("[shipinhaoPublish] 正在发布...");
|
|
18703
18113
|
const topicNames = params.topic || void 0;
|
|
18704
18114
|
const addressInfo = params.address ? {
|
|
@@ -18785,15 +18195,9 @@ const shipinhaoPublish_mock_mockAction = async (task, params)=>{
|
|
|
18785
18195
|
});
|
|
18786
18196
|
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(resultCode || 500, errorMessage, "");
|
|
18787
18197
|
} catch (error) {
|
|
18788
|
-
const
|
|
18789
|
-
|
|
18790
|
-
|
|
18791
|
-
task.logger.error(`[shipinhaoPublish] 发布流程异常: ${errorMsg}`, stringifyError(error), handledError.extra);
|
|
18792
|
-
await updateTaskState?.({
|
|
18793
|
-
state: __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.TaskState.FAILED,
|
|
18794
|
-
error: errorMsg
|
|
18795
|
-
});
|
|
18796
|
-
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(errorCode, errorMsg, "");
|
|
18198
|
+
const errorMsg = error instanceof Error ? error.message : "发布失败";
|
|
18199
|
+
task.logger.error(`[shipinhaoPublish] 发布异常: ${errorMsg}`);
|
|
18200
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(500, errorMsg, "");
|
|
18797
18201
|
}
|
|
18798
18202
|
};
|
|
18799
18203
|
const shipinhaoPublish_rpa_rpaAction = async (task, params)=>{
|
|
@@ -25299,24 +24703,6 @@ const bjhConfigDataSchema = schemas_object({
|
|
|
25299
24703
|
likeNumYesterday: schemas_number().nullable(),
|
|
25300
24704
|
commentNumYesterday: schemas_number().nullable()
|
|
25301
24705
|
});
|
|
25302
|
-
const douyinConfigDataSchema = schemas_object({
|
|
25303
|
-
fansNum: schemas_number(),
|
|
25304
|
-
favedNum: schemas_number(),
|
|
25305
|
-
fansNumLastWeek: schemas_number(),
|
|
25306
|
-
watchNumLastWeek: schemas_number(),
|
|
25307
|
-
likeNumLastWeek: schemas_number(),
|
|
25308
|
-
commentNumLastWeek: schemas_number(),
|
|
25309
|
-
shareNumLastWeek: schemas_number(),
|
|
25310
|
-
visitNumLastWeek: schemas_number()
|
|
25311
|
-
});
|
|
25312
|
-
const shipinhaoConfigDataSchema = schemas_object({
|
|
25313
|
-
fansNum: schemas_number(),
|
|
25314
|
-
feedsCount: schemas_number(),
|
|
25315
|
-
fansNumYesterday: schemas_number().nullable(),
|
|
25316
|
-
playNumYesterday: schemas_number().nullable(),
|
|
25317
|
-
likeNumYesterday: schemas_number().nullable(),
|
|
25318
|
-
commentNumYesterday: schemas_number().nullable()
|
|
25319
|
-
});
|
|
25320
24706
|
const BetaFlag = "HuiwenCanary";
|
|
25321
24707
|
class Action {
|
|
25322
24708
|
constructor(task){
|
|
@@ -25599,6 +24985,6 @@ class Action {
|
|
|
25599
24985
|
}
|
|
25600
24986
|
}
|
|
25601
24987
|
var __webpack_exports__version = package_namespaceObject.i8;
|
|
25602
|
-
export { Action, ActionCommonParamsSchema, BaijiahaoPublishParamsSchema, BetaFlag, CollectionDetailSchema, ConfigDataSchema, DouyinCheckVerifyQrCodeParamsSchema, DouyinCreateCommentReplyParamsSchema, DouyinGetCollectionParamsSchema, DouyinGetCommentListParamsSchema, DouyinGetCommentReplyListParamsSchema, DouyinGetHotParamsSchema, DouyinGetLocationParamsSchema, DouyinGetMusicByCategoryParamsSchema, DouyinGetMusicCategoryParamsSchema, DouyinGetMusicParamsSchema, DouyinGetTopicsParamsSchema, DouyinGetVerifyQrCodeParamsSchema, DouyinGetWorkListParamsSchema, DouyinPublishParamsSchema, FetchArticlesDataSchema, FetchArticlesParamsSchema, Http, ProxyAgent, SearchAccountInfoParamsSchema, SessionCheckResultSchema, ShipinhaoCheckLinkValidateParamsSchema, ShipinhaoGetLocationParamsSchema, ShipinhaoGetMsgParamsSchema, ShipinhaoPublishParamsSchema, ShipinhaoSendMsgParamsSchema, ToutiaoPublishParamsSchema, UnreadCountSchema, WeixinPublishParamsSchema, WxBjhSessionParamsSchema, XhsWebSearchParamsSchema, XiaohongshuPublishParamsSchema, bjhConfigDataSchema,
|
|
24988
|
+
export { Action, ActionCommonParamsSchema, BaijiahaoPublishParamsSchema, BetaFlag, CollectionDetailSchema, ConfigDataSchema, DouyinCheckVerifyQrCodeParamsSchema, DouyinCreateCommentReplyParamsSchema, DouyinGetCollectionParamsSchema, DouyinGetCommentListParamsSchema, DouyinGetCommentReplyListParamsSchema, DouyinGetHotParamsSchema, DouyinGetLocationParamsSchema, DouyinGetMusicByCategoryParamsSchema, DouyinGetMusicCategoryParamsSchema, DouyinGetMusicParamsSchema, DouyinGetTopicsParamsSchema, DouyinGetVerifyQrCodeParamsSchema, DouyinGetWorkListParamsSchema, DouyinPublishParamsSchema, FetchArticlesDataSchema, FetchArticlesParamsSchema, Http, ProxyAgent, SearchAccountInfoParamsSchema, SessionCheckResultSchema, ShipinhaoCheckLinkValidateParamsSchema, ShipinhaoGetLocationParamsSchema, ShipinhaoGetMsgParamsSchema, ShipinhaoPublishParamsSchema, ShipinhaoSendMsgParamsSchema, ToutiaoPublishParamsSchema, UnreadCountSchema, WeixinPublishParamsSchema, WxBjhSessionParamsSchema, XhsWebSearchParamsSchema, XiaohongshuPublishParamsSchema, bjhConfigDataSchema, getFileState, reportLogger, rpaAction_Server_Mock, ttConfigDataSchema, wxConfigDataSchema, xhsConfigDataSchema, __webpack_exports__version as version };
|
|
25603
24989
|
|
|
25604
24990
|
//# sourceMappingURL=index.mjs.map
|