@iflyrpa/actions 4.0.0-beta.0 → 4.0.0-beta.10

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/index.js CHANGED
@@ -5489,9 +5489,7 @@ var __webpack_exports__ = {};
5489
5489
  });
5490
5490
  const package_json_namespaceObject = require("@iflyrpa/share/package.json");
5491
5491
  var package_json_default = /*#__PURE__*/ __webpack_require__.n(package_json_namespaceObject);
5492
- var package_namespaceObject = {
5493
- i8: "3.0.4"
5494
- };
5492
+ var package_namespaceObject = JSON.parse('{"i8":"4.0.0-beta.9"}');
5495
5493
  const share_namespaceObject = require("@iflyrpa/share");
5496
5494
  const external_node_fs_namespaceObject = require("node:fs");
5497
5495
  var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
@@ -5596,6 +5594,13 @@ var __webpack_exports__ = {};
5596
5594
  }
5597
5595
  };
5598
5596
  if (foundError) Object.assign(errorResponse, foundError);
5597
+ if (error.response?.status === 403) {
5598
+ this.logger?.warn(`[403 详细信息] URL: ${error.config?.url}`);
5599
+ this.logger?.warn(`[403 响应头] ${JSON.stringify(error.response?.headers || {})}`);
5600
+ this.logger?.warn(`[403 响应体] ${JSON.stringify(error.response?.data || null)}`);
5601
+ const verifyDecision = error.response?.headers?.["x-tt-verify-passport-decision"];
5602
+ if (verifyDecision) this.logger?.warn(`[403 验证决策] x-tt-verify-passport-decision: ${verifyDecision}`);
5603
+ }
5599
5604
  if (error.response?.data) {
5600
5605
  if ("object" == typeof error.response.data) {
5601
5606
  const serverError = error.response.data;
@@ -5687,7 +5692,7 @@ var __webpack_exports__ = {};
5687
5692
  599
5688
5693
  ].includes(handledError.code);
5689
5694
  if (Rtimes < retries && isRetry) {
5690
- this.logger?.info(`进入第${Rtimes + 1}次重试!`);
5695
+ this.logger?.info(`进入第${Rtimes + 1}次重试!错误码: ${handledError.code}`);
5691
5696
  await new Promise((resolve)=>setTimeout(resolve, retryDelay));
5692
5697
  return sessionRt(Rtimes + 1);
5693
5698
  }
@@ -11891,16 +11896,35 @@ var __webpack_exports__ = {};
11891
11896
  }, "微信账号有效性检测完成!");
11892
11897
  };
11893
11898
  const XhsSessionCheck = async (_task, params)=>{
11899
+ const logger = _task.logger;
11900
+ const startedAt = Date.now();
11894
11901
  const check = {
11895
11902
  isValidSession: false,
11896
11903
  isValidWebSession: false
11897
11904
  };
11905
+ const cookieNames = params.cookies.map((it)=>it.name);
11906
+ logger?.info("[XhsSessionCheck] 开始执行小红书账号有效性检测", {
11907
+ accountId: params.accountId,
11908
+ proxyLoc: params.proxyLoc,
11909
+ localIP: params.localIP,
11910
+ willUseProxyAgent: !!params.localIP,
11911
+ cookieCount: params.cookies.length,
11912
+ cookieNames,
11913
+ hasA1: cookieNames.includes("a1"),
11914
+ hasWebSession: cookieNames.includes("web_session")
11915
+ });
11898
11916
  const a1Cookie = params.cookies.find((it)=>"a1" === it.name)?.value;
11899
- if (!a1Cookie) return {
11900
- code: 414,
11901
- message: "账号数据异常,请重新绑定账号后重试。",
11902
- data: check
11903
- };
11917
+ if (!a1Cookie) {
11918
+ logger?.warn("[XhsSessionCheck] 缺失关键 cookie a1,提前返回", {
11919
+ accountId: params.accountId,
11920
+ cookieNames
11921
+ });
11922
+ return {
11923
+ code: 414,
11924
+ message: "账号数据异常,请重新绑定账号后重试。",
11925
+ data: check
11926
+ };
11927
+ }
11904
11928
  const headers = {
11905
11929
  cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
11906
11930
  referer: "https://creator.xiaohongshu.com/new/home?source=official"
@@ -11928,6 +11952,7 @@ var __webpack_exports__ = {};
11928
11952
  return acc;
11929
11953
  }, {});
11930
11954
  const loginBaseXsHeader = sessionCheck_xsEncrypt.signHeadersGet(loginBasePath, recordCookie, "xhs-pc-web", null);
11955
+ const baseInfoStart = Date.now();
11931
11956
  const _baseInfo = http.api({
11932
11957
  method: "get",
11933
11958
  baseURL: "https://creator.xiaohongshu.com",
@@ -11937,7 +11962,28 @@ var __webpack_exports__ = {};
11937
11962
  retries: 3,
11938
11963
  retryDelay: 20,
11939
11964
  timeout: 3000
11940
- }).catch((e)=>e.data);
11965
+ }).then((res)=>{
11966
+ logger?.info("[XhsSessionCheck] creator base 接口请求成功", {
11967
+ accountId: params.accountId,
11968
+ duration: Date.now() - baseInfoStart,
11969
+ code: res?.code,
11970
+ msg: res?.msg,
11971
+ proxyInfo: http.proxyInfo
11972
+ });
11973
+ return res;
11974
+ }).catch((e)=>{
11975
+ logger?.warn("[XhsSessionCheck] creator base 接口请求失败", {
11976
+ accountId: params.accountId,
11977
+ duration: Date.now() - baseInfoStart,
11978
+ code: e?.code,
11979
+ message: e?.message,
11980
+ data: e?.data,
11981
+ extra: e?.extra,
11982
+ proxyInfo: http.proxyInfo
11983
+ });
11984
+ return e.data;
11985
+ });
11986
+ const webSessionStart = Date.now();
11941
11987
  const _web_session = http.api({
11942
11988
  method: "get",
11943
11989
  url: "https://edith.xiaohongshu.com/api/sns/web/unread_count"
@@ -11945,6 +11991,26 @@ var __webpack_exports__ = {};
11945
11991
  retries: 3,
11946
11992
  retryDelay: 20,
11947
11993
  timeout: 3000
11994
+ }).then((res)=>{
11995
+ logger?.info("[XhsSessionCheck] edith unread_count 接口请求成功", {
11996
+ accountId: params.accountId,
11997
+ duration: Date.now() - webSessionStart,
11998
+ code: res?.code,
11999
+ msg: res?.msg,
12000
+ proxyInfo: http.proxyInfo
12001
+ });
12002
+ return res;
12003
+ }).catch((e)=>{
12004
+ logger?.warn("[XhsSessionCheck] edith unread_count 接口请求失败", {
12005
+ accountId: params.accountId,
12006
+ duration: Date.now() - webSessionStart,
12007
+ code: e?.code,
12008
+ message: e?.message,
12009
+ data: e?.data,
12010
+ extra: e?.extra,
12011
+ proxyInfo: http.proxyInfo
12012
+ });
12013
+ throw e;
11948
12014
  });
11949
12015
  const [baseInfo, web_session] = await Promise.all([
11950
12016
  _baseInfo,
@@ -11952,8 +12018,18 @@ var __webpack_exports__ = {};
11952
12018
  ]);
11953
12019
  if (baseInfo?.code === 0) check.isValidSession = true;
11954
12020
  if (0 === web_session.code) check.isValidWebSession = true;
11955
- baseInfo?.code, web_session.code;
12021
+ const _isSuccess = baseInfo?.code === web_session.code;
11956
12022
  const message = `小红书账号有效性检测成功${_task.debug ? ` ${http.proxyInfo}` : ""}`;
12023
+ logger?.info("[XhsSessionCheck] 检测完成", {
12024
+ accountId: params.accountId,
12025
+ totalDuration: Date.now() - startedAt,
12026
+ baseInfoCode: baseInfo?.code,
12027
+ webSessionCode: web_session?.code,
12028
+ isValidSession: check.isValidSession,
12029
+ isValidWebSession: check.isValidWebSession,
12030
+ codeAligned: _isSuccess,
12031
+ proxyInfo: http.proxyInfo
12032
+ });
11957
12033
  return (0, share_namespaceObject.success)(check, message);
11958
12034
  };
11959
12035
  const BjhSessionCheck = async (_task, params)=>{
@@ -14487,7 +14563,10 @@ var __webpack_exports__ = {};
14487
14563
  task.logger.info(`拦截器收到响应response.data: ${JSON.stringify(response.data)} `);
14488
14564
  decision = parseVerifyPassportDecision(response.headers["x-tt-verify-passport-decision"]);
14489
14565
  if (needsVerification(decision)) {
14490
- task.logger.info(`需要验证: ${JSON.stringify(decision)}`);
14566
+ task.logger.warn(`检测到需要验证: ${JSON.stringify(decision)}`);
14567
+ task.logger.warn(`验证类型: ${decision?.verify_ways?.join(", ")}`);
14568
+ task.logger.warn(`验证标题: ${decision?.verify_title}`);
14569
+ task.logger.warn(`验证描述: ${decision?.verify_desc}`);
14491
14570
  return;
14492
14571
  }
14493
14572
  if (!response || !response.data) return;
@@ -14514,38 +14593,105 @@ var __webpack_exports__ = {};
14514
14593
  });
14515
14594
  return (0, share_namespaceObject.response)(0, message, data);
14516
14595
  }
14517
- const webProtectData = JSON.parse(JSON.parse(params.extraParam["security-sdk/s_sdk_sign_data_key/web_protect"] || "{}").data || "{}");
14596
+ let webProtectData;
14597
+ try {
14598
+ webProtectData = JSON.parse(JSON.parse(params.extraParam["security-sdk/s_sdk_sign_data_key/web_protect"] || "{}").data || "{}");
14599
+ if (!webProtectData.ticket || !webProtectData.ts_sign || !webProtectData.client_cert) {
14600
+ task.logger.error(`webProtectData 关键字段缺失: ${JSON.stringify(webProtectData)}`);
14601
+ return (0, share_namespaceObject.response)(414, "安全参数 webProtectData 不完整,请重新获取后重试", "");
14602
+ }
14603
+ } catch (error) {
14604
+ task.logger.error(`解析 webProtectData 失败: ${error}`);
14605
+ return (0, share_namespaceObject.response)(414, "安全参数 webProtectData 解析失败,请重新获取后重试", "");
14606
+ }
14518
14607
  const ticket = webProtectData.ticket;
14519
14608
  const ts_sign = webProtectData.ts_sign;
14520
- const ec_privateKey = JSON.parse(JSON.parse(params.extraParam["security-sdk/s_sdk_crypt_sdk"] || "{}").data || "{}").ec_privateKey;
14521
- const certificate = JSON.parse(params.extraParam["security-sdk/s_sdk_server_cert_key"] || "{}").cert;
14609
+ let ec_privateKey;
14610
+ try {
14611
+ ec_privateKey = JSON.parse(JSON.parse(params.extraParam["security-sdk/s_sdk_crypt_sdk"] || "{}").data || "{}").ec_privateKey;
14612
+ if (!ec_privateKey) {
14613
+ task.logger.error("ec_privateKey 为空");
14614
+ return (0, share_namespaceObject.response)(414, "安全参数 ec_privateKey 缺失,请重新获取后重试", "");
14615
+ }
14616
+ } catch (error) {
14617
+ task.logger.error(`解析 ec_privateKey 失败: ${error}`);
14618
+ return (0, share_namespaceObject.response)(414, "安全参数 ec_privateKey 解析失败,请重新获取后重试", "");
14619
+ }
14620
+ let certificate;
14621
+ try {
14622
+ certificate = JSON.parse(params.extraParam["security-sdk/s_sdk_server_cert_key"] || "{}").cert;
14623
+ if (!certificate) {
14624
+ task.logger.error("certificate 为空");
14625
+ return (0, share_namespaceObject.response)(414, "安全参数 certificate 缺失,请重新获取后重试", "");
14626
+ }
14627
+ } catch (error) {
14628
+ task.logger.error(`解析 certificate 失败: ${error}`);
14629
+ return (0, share_namespaceObject.response)(414, "安全参数 certificate 解析失败,请重新获取后重试", "");
14630
+ }
14522
14631
  const ree_public_key = webProtectData.client_cert.replace("pub.", "");
14523
- task.logger.info(`生成 bdTicketGuardClientData 的参数: ticket: ${ticket}, ts_sign: ${ts_sign}, ec_privateKey: ${ec_privateKey}, certificate: ${certificate}, ree_public_key: ${ree_public_key}`);
14524
- const bdTicketGuardClientData = getBdV2({
14525
- ticket,
14526
- ts_sign: ts_sign,
14527
- ec_privateKey: ec_privateKey,
14528
- certificate: certificate,
14529
- bd_ticket_guard_ree_public_key: ree_public_key
14530
- });
14531
- task.logger.info("bdTicketGuardClientData", {
14532
- bdTicketGuardClientData
14533
- });
14632
+ task.logger.info(`生成 bdTicketGuardClientData 的参数: ticket: ${ticket?.substring(0, 20)}..., ts_sign: ${ts_sign}, ree_public_key: ${ree_public_key?.substring(0, 20)}...`);
14633
+ let bdTicketGuardClientData;
14634
+ try {
14635
+ bdTicketGuardClientData = getBdV2({
14636
+ ticket,
14637
+ ts_sign: ts_sign,
14638
+ ec_privateKey: ec_privateKey,
14639
+ certificate: certificate,
14640
+ bd_ticket_guard_ree_public_key: ree_public_key
14641
+ });
14642
+ if (!bdTicketGuardClientData || !bdTicketGuardClientData["headers_bd_ticket_guard_client_data"]) {
14643
+ task.logger.error(`bdTicketGuardClientData 生成失败或不完整: ${JSON.stringify(bdTicketGuardClientData)}`);
14644
+ return (0, share_namespaceObject.response)(414, "安全参数 bdTicketGuardClientData 生成失败,请重新获取后重试", "");
14645
+ }
14646
+ } catch (error) {
14647
+ task.logger.error(`生成 bdTicketGuardClientData 失败: ${error}`);
14648
+ return (0, share_namespaceObject.response)(414, "安全参数 bdTicketGuardClientData 生成异常,请重新获取后重试", "");
14649
+ }
14650
+ task.logger.info("bdTicketGuardClientData 生成成功");
14534
14651
  const publishQuery = {
14535
14652
  ...publishParams,
14536
14653
  a_bogus: ""
14537
14654
  };
14538
14655
  const queryString = new URLSearchParams(publishQuery).toString();
14539
- const aBogus = mock_getABogus(`https://creator.douyin.com/web/api/media/aweme/create_v2/?${queryString}`, publishData, userAgent);
14656
+ let aBogus;
14657
+ try {
14658
+ aBogus = mock_getABogus(`https://creator.douyin.com/web/api/media/aweme/create_v2/?${queryString}`, publishData, userAgent);
14659
+ if (!aBogus || aBogus.length < 10) {
14660
+ task.logger.error(`a_bogus 生成异常,长度过短: ${aBogus}`);
14661
+ return (0, share_namespaceObject.response)(414, "安全参数 a_bogus 生成失败,请重试", "");
14662
+ }
14663
+ task.logger.info(`a_bogus 生成成功: ${aBogus.substring(0, 20)}...`);
14664
+ } catch (error) {
14665
+ task.logger.error(`生成 a_bogus 失败: ${error}`);
14666
+ return (0, share_namespaceObject.response)(414, "安全参数 a_bogus 生成异常,请重试", "");
14667
+ }
14540
14668
  publishQuery.a_bogus = aBogus;
14541
14669
  const publishQueryParams = new URLSearchParams(publishQuery).toString();
14542
- const csrfToken = mock_generateCsrfTokenAdvanced({
14543
- cookies: params.cookies,
14544
- url: "https://creator.douyin.com/web/api/media/aweme/create_v2/",
14545
- method: "POST",
14546
- userAgent
14547
- });
14548
- const sessionDtrait = mock_generateDtrait("/web/api/media/aweme/create_v2/");
14670
+ let csrfToken;
14671
+ try {
14672
+ csrfToken = mock_generateCsrfTokenAdvanced({
14673
+ cookies: params.cookies,
14674
+ url: "https://creator.douyin.com/web/api/media/aweme/create_v2/",
14675
+ method: "POST",
14676
+ userAgent
14677
+ });
14678
+ if (!csrfToken || csrfToken.length < 10) {
14679
+ task.logger.error(`csrfToken 生成异常,长度过短: ${csrfToken}`);
14680
+ return (0, share_namespaceObject.response)(414, "安全参数 csrfToken 生成失败,请重试", "");
14681
+ }
14682
+ task.logger.info(`csrfToken 生成成功: ${csrfToken.substring(0, 20)}...`);
14683
+ } catch (error) {
14684
+ task.logger.error(`生成 csrfToken 失败: ${error}`);
14685
+ return (0, share_namespaceObject.response)(414, "安全参数 csrfToken 生成异常,请重试", "");
14686
+ }
14687
+ let sessionDtrait;
14688
+ try {
14689
+ sessionDtrait = mock_generateDtrait("/web/api/media/aweme/create_v2/");
14690
+ task.logger.info(`sessionDtrait 生成成功: ${sessionDtrait || "(空)"}`);
14691
+ } catch (error) {
14692
+ task.logger.error(`生成 sessionDtrait 失败: ${error}`);
14693
+ return (0, share_namespaceObject.response)(414, "安全参数 sessionDtrait 生成异常,请重试", "");
14694
+ }
14549
14695
  task.logger.info("发布数据", {
14550
14696
  data: JSON.stringify(publishData)
14551
14697
  });
@@ -14587,6 +14733,35 @@ var __webpack_exports__ = {};
14587
14733
  retries: 3,
14588
14734
  retryDelay: 2000
14589
14735
  });
14736
+ task.logger.info("========== api调用完成 ==========");
14737
+ task.logger.info(`decision值: ${JSON.stringify(decision)}, needsVerification(decision): ${needsVerification(decision)}`);
14738
+ if (needsVerification(decision)) {
14739
+ const details = [
14740
+ publishResult.status_msg,
14741
+ decision?.verify_title,
14742
+ decision?.verify_desc
14743
+ ].filter(Boolean).join(" ");
14744
+ const message = `图文发布失败,原因:${details}${task.debug ? ` ${http.proxyInfo}` : ""}`;
14745
+ task.logger.warn(`TaskId:${task.taskId},检测到需要验证,准备返回验证信息`);
14746
+ let decisionObj = {};
14747
+ if (decision) decisionObj = decision;
14748
+ const mockData = {
14749
+ state: share_namespaceObject.TaskState.FAILED,
14750
+ error: message,
14751
+ result: {
14752
+ ...decisionObj,
14753
+ data: decision,
14754
+ uploadedImgList: JSON.stringify(publishData.item.common.images)
14755
+ }
14756
+ };
14757
+ await updateTaskState?.(mockData);
14758
+ return {
14759
+ code: 0,
14760
+ data: mockData,
14761
+ message: "操作成功"
14762
+ };
14763
+ }
14764
+ task.logger.info("不需要验证,继续正常流程");
14590
14765
  reportLogger({
14591
14766
  token: params.huiwenToken || "",
14592
14767
  enverionment: task.enverionment || "development",
@@ -14604,10 +14779,13 @@ var __webpack_exports__ = {};
14604
14779
  const message = `图文发布${isSuccess ? "成功" : `失败,原因:${publishResult.status_msg} ${decision?.verify_title} ${decision?.verify_desc}`}${task.debug ? ` ${http.proxyInfo}` : ""}`;
14605
14780
  const data = isSuccess ? publishResult.item_id || "" : "";
14606
14781
  if (!isSuccess) {
14782
+ let decisionObj = {};
14783
+ if (decision) decisionObj = decision;
14607
14784
  await updateTaskState?.({
14608
14785
  state: share_namespaceObject.TaskState.FAILED,
14609
14786
  error: message,
14610
14787
  result: {
14788
+ ...decisionObj,
14611
14789
  data: decision,
14612
14790
  uploadedImgList: JSON.stringify(publishData.item.common.images)
14613
14791
  }
@@ -15282,15 +15460,41 @@ var __webpack_exports__ = {};
15282
15460
  }
15283
15461
  task.logger?.info("准备发布...");
15284
15462
  await page.waitForTimeout(1000);
15285
- const response = await new Promise((resolve, reject)=>{
15463
+ const result = await new Promise((resolve, reject)=>{
15286
15464
  const handleResponse = async (res)=>{
15287
15465
  if (res.url().includes("/web/api/media/aweme/create_v2")) {
15288
15466
  task.logger?.info("匹配到发布接口响应");
15467
+ let decision = null;
15468
+ try {
15469
+ const headers = await res.allHeaders();
15470
+ decision = parseVerifyPassportDecision(headers["x-tt-verify-passport-decision"]);
15471
+ } catch (error) {
15472
+ task.logger?.warn(`解析验证决策头失败: ${error}`);
15473
+ }
15289
15474
  const jsonResponse = await res.json();
15290
15475
  task.logger?.info(`发布接口响应数据: ${JSON.stringify(jsonResponse)}`);
15291
15476
  page.off("response", handleResponse);
15292
- if (jsonResponse?.status_code === 0) resolve(jsonResponse?.data?.item_id || jsonResponse?.item_id || "");
15293
- else reject(new Error(jsonResponse?.status_msg || "发布失败"));
15477
+ if (needsVerification(decision)) {
15478
+ task.logger?.warn("检测到需要二次验证,文章未真正发布");
15479
+ resolve({
15480
+ itemId: "",
15481
+ decision
15482
+ });
15483
+ return;
15484
+ }
15485
+ if (jsonResponse?.status_code !== 0) {
15486
+ reject(new Error(jsonResponse?.status_msg || "发布失败"));
15487
+ return;
15488
+ }
15489
+ const itemId = jsonResponse?.data?.item_id || jsonResponse?.item_id || "";
15490
+ if (!itemId) {
15491
+ reject(new Error(jsonResponse?.status_msg || "发布异常:未返回作品ID,文章可能未真正发布"));
15492
+ return;
15493
+ }
15494
+ resolve({
15495
+ itemId,
15496
+ decision: null
15497
+ });
15294
15498
  }
15295
15499
  };
15296
15500
  page.on("response", handleResponse);
@@ -15312,20 +15516,42 @@ var __webpack_exports__ = {};
15312
15516
  await page.close();
15313
15517
  return null;
15314
15518
  });
15315
- if (!response && "" !== response) return {
15519
+ if (!result) return {
15316
15520
  code: 414,
15317
15521
  message: "发布失败",
15318
15522
  data: ""
15319
15523
  };
15320
- task.logger?.info(`✓ 发布成功,item_id: ${response}`);
15524
+ if (needsVerification(result.decision)) {
15525
+ const decision = result.decision;
15526
+ const details = [
15527
+ decision?.verify_title,
15528
+ decision?.verify_desc
15529
+ ].filter(Boolean).join(" ");
15530
+ const message = `发布失败,需要二次验证${details ? `:${details}` : ""}`;
15531
+ task.logger?.warn(message);
15532
+ await updateTaskState?.({
15533
+ state: share_namespaceObject.TaskState.FAILED,
15534
+ error: message,
15535
+ result: {
15536
+ data: decision
15537
+ }
15538
+ });
15539
+ await page.close();
15540
+ return {
15541
+ code: 414,
15542
+ message,
15543
+ data: ""
15544
+ };
15545
+ }
15546
+ task.logger?.info(`✓ 发布成功,item_id: ${result.itemId}`);
15321
15547
  await updateTaskState?.({
15322
15548
  state: share_namespaceObject.TaskState.SUCCESS,
15323
15549
  result: {
15324
- response
15550
+ response: result.itemId
15325
15551
  }
15326
15552
  });
15327
15553
  await page.close();
15328
- return (0, share_namespaceObject.success)(response);
15554
+ return (0, share_namespaceObject.success)(result.itemId);
15329
15555
  };
15330
15556
  const DouyinPublishParamsSchema = ActionCommonParamsSchema.extend({
15331
15557
  title: schemas_string(),
@@ -16105,26 +16331,26 @@ var __webpack_exports__ = {};
16105
16331
  const http = new Http({
16106
16332
  headers: {
16107
16333
  cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
16108
- referer: "https://mp.toutiao.com/profile_v4/graphic/publish"
16334
+ referer: "https://mp.toutiao.com/profile_v4/graphic/publish",
16335
+ "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36"
16336
+ }
16337
+ });
16338
+ const totalData = await http.api({
16339
+ method: "get",
16340
+ url: "https://mp.toutiao.com/mp/fe_api/home/merge_v2",
16341
+ params: {
16342
+ app_id: 1231
16343
+ }
16344
+ });
16345
+ await new Promise((r)=>setTimeout(r, 1000));
16346
+ const contentDataYesterday = await http.api({
16347
+ method: "get",
16348
+ url: "https://mp.toutiao.com/mp/agw/statistic/v2/content_stat",
16349
+ params: {
16350
+ type: 0,
16351
+ app_id: 1231
16109
16352
  }
16110
16353
  });
16111
- const [totalData, contentDataYesterday] = await Promise.all([
16112
- http.api({
16113
- method: "get",
16114
- url: "https://mp.toutiao.com/mp/fe_api/home/merge_v2",
16115
- params: {
16116
- app_id: 1231
16117
- }
16118
- }),
16119
- http.api({
16120
- method: "get",
16121
- url: "https://mp.toutiao.com/mp/agw/statistic/v2/content_stat",
16122
- params: {
16123
- type: 0,
16124
- app_id: 1231
16125
- }
16126
- })
16127
- ]);
16128
16354
  const isSuccess = !!(totalData?.data?.statistic && contentDataYesterday?.author_stat);
16129
16355
  if (!isSuccess || !totalData?.data || !contentDataYesterday?.author_stat) return types_errorResponse(totalData?.message || contentDataYesterday?.message || "头条号数据获取失败,请检查Cookie是否有效", 414);
16130
16356
  const ttData = {
@@ -20301,8 +20527,10 @@ var __webpack_exports__ = {};
20301
20527
  tuwen_wtt_trans_flag: params.settingInfo?.toutiaoTransWtt ? "2" : "0",
20302
20528
  info_source: sourceData,
20303
20529
  ...location ? {
20304
- city: location.label,
20305
- city_code: location.value
20530
+ manual_selected_city: JSON.stringify({
20531
+ city: location.label,
20532
+ city_code: location.value
20533
+ })
20306
20534
  } : null,
20307
20535
  ...params.settingInfo?.toutiaoCollectionId ? {
20308
20536
  want_join_collection_id: params.settingInfo.toutiaoCollectionId
@@ -20352,6 +20580,12 @@ var __webpack_exports__ = {};
20352
20580
  claim_exclusive: toutiaoExclusive ? toutiaoExclusive : toutiaoOriginal?.includes("exclusive") ? 1 : 0
20353
20581
  };
20354
20582
  task._timerRecord.PrePublish = Date.now();
20583
+ task.logger.info(`[toutiaoPublish] ${"draft" === params.saveType ? "同步草稿" : "发布文章"}参数`, {
20584
+ saveType: params.saveType,
20585
+ title: params.title,
20586
+ extra: extraData,
20587
+ publishData
20588
+ });
20355
20589
  const msToken = params.cookies.find((it)=>"msToken" === it.name)?.value;
20356
20590
  let publishOption = {};
20357
20591
  if (msToken) {
@@ -21547,8 +21781,8 @@ var __webpack_exports__ = {};
21547
21781
  headers
21548
21782
  });
21549
21783
  const proxyHttp = new Http(...args);
21550
- proxyHttp.addResponseInterceptor((response)=>{
21551
- const responseData = response.data;
21784
+ const baseRespFinder = (response)=>{
21785
+ const responseData = response?.data;
21552
21786
  const msgType = "draft" === params.saveType ? "同步" : "发布";
21553
21787
  if (response && responseData?.base_resp && 0 !== responseData.base_resp.ret && !ignoreErrno.includes(responseData.base_resp.ret)) {
21554
21788
  const errmsg = weixinPublish_mock_errnoMap[responseData.base_resp.ret] || response.config.defaultErrorMsg || responseData.base_resp.err_msg || `文章${msgType}异常,请稍后重试。`;
@@ -21558,7 +21792,9 @@ var __webpack_exports__ = {};
21558
21792
  data: responseData
21559
21793
  };
21560
21794
  }
21561
- });
21795
+ };
21796
+ http.addResponseInterceptor(baseRespFinder);
21797
+ proxyHttp.addResponseInterceptor(baseRespFinder);
21562
21798
  await http.api({
21563
21799
  method: "get",
21564
21800
  url: "https://mp.weixin.qq.com/cgi-bin/appmsgpublish",