@iflyrpa/actions 4.0.4 → 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/bundle.js CHANGED
@@ -1,6 +1,4 @@
1
1
  /*! For license information please see bundle.js.LICENSE.txt */
2
-
3
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="aed90b90-6fd5-5e1b-ba81-6ede67b0dc32")}catch(e){}}();
4
2
  var __webpack_modules__ = {
5
3
  "../../node_modules/.pnpm/agent-base@7.1.4/node_modules/agent-base/dist/helpers.js": function(__unused_webpack_module, exports1, __webpack_require__) {
6
4
  "use strict";
@@ -12476,8 +12474,6 @@ var __webpack_exports__ = {};
12476
12474
  bjhConfigDataSchema: ()=>bjhConfigDataSchema,
12477
12475
  Action: ()=>Action,
12478
12476
  ProxyAgent: ()=>ProxyAgent,
12479
- douyinConfigDataSchema: ()=>douyinConfigDataSchema,
12480
- shipinhaoConfigDataSchema: ()=>shipinhaoConfigDataSchema,
12481
12477
  version: ()=>package_namespaceObject_0.i8
12482
12478
  });
12483
12479
  var common_utils_namespaceObject = {};
@@ -12493,7 +12489,7 @@ var __webpack_exports__ = {};
12493
12489
  i8: "0.1.2"
12494
12490
  };
12495
12491
  var package_namespaceObject_0 = {
12496
- i8: "4.0.4"
12492
+ i8: "4.0.5"
12497
12493
  };
12498
12494
  const external_node_fs_namespaceObject = require("node:fs");
12499
12495
  var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
@@ -27274,12 +27270,11 @@ var __webpack_exports__ = {};
27274
27270
  this.logger?.debug(`未处理的网络错误代码: ${error.code} ${error.message}`, {
27275
27271
  errorString: stringifyError(error)
27276
27272
  });
27277
- _message = `网络错误: ${error.message}`;
27273
+ _message = `未知网络错误: ${error.message}`;
27278
27274
  break;
27279
27275
  }
27280
27276
  }
27281
- if (error.code && !error.response?.data) errorResponse.message = _message || errorResponse.message;
27282
- else errorResponse.message = errorResponse.message ? errorResponse.message : _message;
27277
+ errorResponse.message = errorResponse.message ? errorResponse.message : _message;
27283
27278
  if ("canceled" === errorResponse.message) {
27284
27279
  const message = errorResponse.extra?.isProxyRequest ? "代理连接建立超时,请更换区域或稍后重试!" : "网络请求超时,请稍后重试!";
27285
27280
  errorResponse.message = message;
@@ -38518,421 +38513,400 @@ var __webpack_exports__ = {};
38518
38513
  }
38519
38514
  return randomString;
38520
38515
  }
38521
- function safeSerialize(obj) {
38522
- if (!obj || "object" != typeof obj) return obj;
38523
- try {
38524
- return JSON.parse(JSON.stringify(obj));
38525
- } catch (error) {
38526
- return {};
38527
- }
38528
- }
38529
38516
  const mock_mockAction = async (task, params)=>{
38530
38517
  const updateTaskState = task.taskStageStore?.update?.bind(task.taskStageStore, task.taskId || "");
38531
38518
  if (!params.extraParam || !params.extraParam["security-sdk/s_sdk_pri_key"] || !params.extraParam["security-sdk/s_sdk_pub_key"] || !params.extraParam["security-sdk/s_sdk_sign_data_key/web_protect"] || !params.extraParam["security-sdk/s_sdk_server_cert_key"] || !params.extraParam["security-sdk/s_sdk_crypt_sdk"]) return utils_response(414, "extraParam 参数缺失或不完整", "");
38532
- let currentStep = "初始化";
38533
- try {
38534
- currentStep = "验证账号信息";
38535
- 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";
38536
- const sessionidCookie = params.cookies.find((it)=>"msToken" === it.name)?.value;
38537
- if (!sessionidCookie) return {
38538
- code: 414,
38539
- message: "账号数据异常,请重新绑定账号后重试。",
38540
- data: ""
38541
- };
38542
- currentStep = "准备请求参数";
38543
- const headers = {
38544
- cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
38545
- origin: "https://creator.douyin.com",
38546
- referer: "https://creator.douyin.com/creator-micro/content/post/image?default-tab=3&enter_from=publish_page&media_type=image&type=new",
38547
- Accept: "application/json, text/plain, */*",
38548
- "Accept-Encoding": "gzip, deflate, br, zstd",
38549
- "Content-Type": "application/json",
38550
- pragma: "no-cache",
38551
- "cache-control": "no-cache",
38552
- "sec-ch-ua-platform": params.extraParam?.browserInfo?.["sec-ch-ua-platform"] || "",
38553
- "sec-ch-ua": params.extraParam?.browserInfo?.["sec-ch-ua"] || "",
38554
- "bd-ticket-guard-web-version": "2",
38555
- "sec-ch-ua-mobile": "?0",
38556
- "user-agent": userAgent,
38557
- "sec-fetch-site": "same-origin",
38558
- "sec-fetch-mode": "cors",
38559
- "sec-fetch-dest": "empty",
38560
- "accept-language": "zh-CN,zh;q=0.9",
38561
- priority: "u=1, i"
38562
- };
38563
- const publishParams = {
38564
- read_aid: "2906",
38565
- aid: "1128",
38566
- cookie_enabled: "true",
38567
- screen_width: params.extraParam?.browserInfo.screen_width || "1920",
38568
- screen_height: params.extraParam?.browserInfo.screen_height || "1080",
38569
- browser_language: params.extraParam?.browserInfo.browser_language || "zh-CN",
38570
- browser_platform: params.extraParam?.browserInfo.browser_platform || "Win32",
38571
- browser_name: params.extraParam?.browserInfo.browser_name || "Mozilla",
38572
- browser_version: userAgent,
38573
- browser_online: "true",
38574
- timezone_name: "Asia/Shanghai",
38575
- support_h265: "1",
38576
- msToken: params.cookies.find((e)=>"msToken" === e.name)?.value || "",
38577
- a_bogus: ""
38578
- };
38579
- task.logger.info(`[douyinPublish] publishParams ${JSON.stringify(publishParams)}`);
38580
- const publishData = {
38581
- item: {
38582
- common: {
38583
- text: params.content,
38584
- text_extra: params.textExtra,
38585
- activity: "[]",
38586
- challenges: params.challengeIds || "[]",
38587
- hashtag_source: "",
38588
- mentions: "[]",
38589
- music_id: params.musicId || "",
38590
- music_end_time: 1000 * (params.musicDuration || 0),
38591
- hot_sentence: params.hotSentence || "",
38592
- visibility_type: Number(params.visibleRange) || 0,
38593
- download: params.allowSave ? 1 : 0,
38594
- timing: params.isImmediatelyPublish ? -1 : params.scheduledPublish,
38595
- media_type: Number(params.publishType) || 2,
38596
- images: [],
38597
- creation_id: ""
38598
- },
38599
- cover: {
38600
- poster: ""
38601
- },
38602
- mix: params.mix ? {
38603
- mix_id: params.mix.mix_id,
38604
- mix_order: params.mix.mix_order || 0
38605
- } : {},
38606
- anchor: {},
38607
- declare: {
38608
- user_declare_info: "{}"
38609
- }
38610
- }
38611
- };
38612
- const args = [
38613
- {
38614
- headers
38519
+ 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";
38520
+ const sessionidCookie = params.cookies.find((it)=>"msToken" === it.name)?.value;
38521
+ if (!sessionidCookie) return {
38522
+ code: 414,
38523
+ message: "账号数据异常,请重新绑定账号后重试。",
38524
+ data: ""
38525
+ };
38526
+ const headers = {
38527
+ cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
38528
+ origin: "https://creator.douyin.com",
38529
+ referer: "https://creator.douyin.com/creator-micro/content/post/image?default-tab=3&enter_from=publish_page&media_type=image&type=new",
38530
+ Accept: "application/json, text/plain, */*",
38531
+ "Accept-Encoding": "gzip, deflate, br, zstd",
38532
+ "Content-Type": "application/json",
38533
+ pragma: "no-cache",
38534
+ "cache-control": "no-cache",
38535
+ "sec-ch-ua-platform": params.extraParam?.browserInfo?.["sec-ch-ua-platform"] || "",
38536
+ "sec-ch-ua": params.extraParam?.browserInfo?.["sec-ch-ua"] || "",
38537
+ "bd-ticket-guard-web-version": "2",
38538
+ "sec-ch-ua-mobile": "?0",
38539
+ "user-agent": userAgent,
38540
+ "sec-fetch-site": "same-origin",
38541
+ "sec-fetch-mode": "cors",
38542
+ "sec-fetch-dest": "empty",
38543
+ "accept-language": "zh-CN,zh;q=0.9",
38544
+ priority: "u=1, i"
38545
+ };
38546
+ const publishParams = {
38547
+ read_aid: "2906",
38548
+ aid: "1128",
38549
+ cookie_enabled: "true",
38550
+ screen_width: params.extraParam?.browserInfo.screen_width || "1920",
38551
+ screen_height: params.extraParam?.browserInfo.screen_height || "1080",
38552
+ browser_language: params.extraParam?.browserInfo.browser_language || "zh-CN",
38553
+ browser_platform: params.extraParam?.browserInfo.browser_platform || "Win32",
38554
+ browser_name: params.extraParam?.browserInfo.browser_name || "Mozilla",
38555
+ browser_version: userAgent,
38556
+ browser_online: "true",
38557
+ timezone_name: "Asia/Shanghai",
38558
+ support_h265: "1",
38559
+ msToken: params.cookies.find((e)=>"msToken" === e.name)?.value || "",
38560
+ a_bogus: ""
38561
+ };
38562
+ task.logger.info(`[douyinPublish] publishParams ${JSON.stringify(publishParams)}`);
38563
+ const publishData = {
38564
+ item: {
38565
+ common: {
38566
+ text: params.content,
38567
+ text_extra: params.textExtra,
38568
+ activity: "[]",
38569
+ challenges: params.challengeIds || "[]",
38570
+ hashtag_source: "",
38571
+ mentions: "[]",
38572
+ music_id: params.musicId || "",
38573
+ music_end_time: 1000 * (params.musicDuration || 0),
38574
+ hot_sentence: params.hotSentence || "",
38575
+ visibility_type: Number(params.visibleRange) || 0,
38576
+ download: params.allowSave ? 1 : 0,
38577
+ timing: params.isImmediatelyPublish ? -1 : params.scheduledPublish,
38578
+ media_type: Number(params.publishType) || 2,
38579
+ images: [],
38580
+ creation_id: ""
38615
38581
  },
38616
- task.logger,
38617
- "",
38618
- "",
38619
- params.accountId,
38620
- "douyin"
38621
- ];
38622
- const http = new Http({
38623
- headers
38624
- });
38625
- const proxyHttp = new Http(...args);
38626
- const uploadedImgList = params.uploadedImgList ? JSON.parse(params.uploadedImgList) : [];
38627
- if (uploadedImgList.length > 0) publishData.item.common.images = uploadedImgList;
38628
- else {
38629
- const tmpCachePath = task.getTmpPath();
38630
- const uploader = new DouyinImageUploader(proxyHttp, headers, publishParams, tmpCachePath);
38631
- if (params.coverImage) {
38632
- const cover = await uploader.uploadCover(params.coverImage);
38633
- if (cover) {
38634
- publishData.item.common.images.push({
38635
- uri: cover.uri,
38636
- width: cover.width,
38637
- height: cover.height
38638
- });
38639
- publishData.item.cover = {
38640
- poster: cover.uri
38641
- };
38642
- }
38643
- }
38644
- if (params.banners && params.banners.length > 0) {
38645
- const banners = params.banners.filter((i)=>i !== params.coverImage);
38646
- const uploadResults = await uploader.uploadImages(banners);
38647
- publishData.item.common.images = publishData.item.common.images.concat(uploadResults.map((result)=>({
38648
- uri: result.uri,
38649
- width: result.width,
38650
- height: result.height
38651
- })));
38652
- }
38653
- }
38654
- publishData.item.common.creation_id = generateRandomString(8) + Date.now();
38655
- let decision = null;
38656
- proxyHttp.addResponseInterceptor((response)=>{
38657
- task.logger.info(`[douyinPublish] 拦截器收到响应response.headers: ${JSON.stringify(response.headers)} `);
38658
- task.logger.info(`[douyinPublish] 拦截器收到响应response.data: ${JSON.stringify(response.data)} `);
38659
- decision = parseVerifyPassportDecision(response.headers["x-tt-verify-passport-decision"]);
38660
- if (needsVerification(decision)) {
38661
- task.logger.info(`[douyinPublish] 检测到需要验证: ${JSON.stringify(decision)}`);
38662
- return;
38582
+ cover: {
38583
+ poster: ""
38584
+ },
38585
+ mix: params.mix ? {
38586
+ mix_id: params.mix.mix_id,
38587
+ mix_order: params.mix.mix_order || 0
38588
+ } : {},
38589
+ anchor: {},
38590
+ declare: {
38591
+ user_declare_info: "{}"
38663
38592
  }
38664
- if (!response || !response.data) return;
38665
- const responseData = response.data;
38666
- if (response && responseData?.status_code && 0 !== responseData.status_code) {
38667
- const errorCode = 4 === responseData.status_code ? 500 : responseData.status_code;
38668
- if (4 === responseData.status_code) task.logger.warn(`[douyinPublish] 抖音服务器错误 status_code: 4,映射为 500 触发重试。原始响应: ${JSON.stringify(responseData)}`);
38669
- return {
38670
- code: errorCode,
38671
- message: responseData.status_msg || "文章发布异常,请稍后重试。",
38672
- data: responseData
38593
+ }
38594
+ };
38595
+ const args = [
38596
+ {
38597
+ headers
38598
+ },
38599
+ task.logger,
38600
+ "",
38601
+ "",
38602
+ params.accountId,
38603
+ "douyin"
38604
+ ];
38605
+ const http = new Http({
38606
+ headers
38607
+ });
38608
+ const proxyHttp = new Http(...args);
38609
+ const uploadedImgList = params.uploadedImgList ? JSON.parse(params.uploadedImgList) : [];
38610
+ if (uploadedImgList.length > 0) publishData.item.common.images = uploadedImgList;
38611
+ else {
38612
+ const tmpCachePath = task.getTmpPath();
38613
+ const uploader = new DouyinImageUploader(proxyHttp, headers, publishParams, tmpCachePath);
38614
+ if (params.coverImage) {
38615
+ const cover = await uploader.uploadCover(params.coverImage);
38616
+ if (cover) {
38617
+ publishData.item.common.images.push({
38618
+ uri: cover.uri,
38619
+ width: cover.width,
38620
+ height: cover.height
38621
+ });
38622
+ publishData.item.cover = {
38623
+ poster: cover.uri
38673
38624
  };
38674
38625
  }
38675
- });
38676
- task._timerRecord.PrePublish = Date.now();
38677
- if (MockPublish) {
38678
- const data = "123456789";
38679
- const message = `图文模拟发布成功 ${http.proxyInfo}`;
38680
- await updateTaskState?.({
38681
- state: types_TaskState.SUCCESS,
38682
- result: {
38683
- response: data
38684
- }
38685
- });
38686
- return utils_response(0, message, data);
38687
38626
  }
38688
- let webProtectData;
38689
- try {
38690
- webProtectData = JSON.parse(JSON.parse(params.extraParam["security-sdk/s_sdk_sign_data_key/web_protect"] || "{}").data || "{}");
38691
- if (!webProtectData.ticket || !webProtectData.ts_sign || !webProtectData.client_cert) {
38692
- task.logger.error(`webProtectData 关键字段缺失: ${JSON.stringify(webProtectData)}`);
38693
- return utils_response(414, "安全参数 webProtectData 不完整,请重新获取后重试", "");
38694
- }
38695
- } catch (error) {
38696
- task.logger.error(`解析 webProtectData 失败: ${error}`);
38697
- return utils_response(414, "安全参数 webProtectData 解析失败,请重新获取后重试", "");
38698
- }
38699
- let ticket = webProtectData.ticket;
38700
- let ts_sign = webProtectData.ts_sign;
38701
- const serverDataCookie = params.cookies.find((it)=>"bd_ticket_guard_server_data" === it.name)?.value;
38702
- if (serverDataCookie) try {
38703
- const decoded = JSON.parse(Buffer.from(decodeURIComponent(serverDataCookie), "base64").toString("utf8"));
38704
- if (decoded.ticket && decoded.ts_sign) {
38705
- if (decoded.ticket !== ticket) task.logger.info("[douyinPublish] 使用 cookie 中的最新 ticket(web_protect 已过期)");
38706
- ticket = decoded.ticket;
38707
- ts_sign = decoded.ts_sign;
38708
- }
38709
- } catch (error) {
38710
- task.logger.info(`[douyinPublish] 解析 bd_ticket_guard_server_data 失败,回退到 web_protect: ${error}`);
38627
+ if (params.banners && params.banners.length > 0) {
38628
+ const banners = params.banners.filter((i)=>i !== params.coverImage);
38629
+ const uploadResults = await uploader.uploadImages(banners);
38630
+ publishData.item.common.images = publishData.item.common.images.concat(uploadResults.map((result)=>({
38631
+ uri: result.uri,
38632
+ width: result.width,
38633
+ height: result.height
38634
+ })));
38711
38635
  }
38712
- let ec_privateKey;
38713
- try {
38714
- ec_privateKey = JSON.parse(JSON.parse(params.extraParam["security-sdk/s_sdk_crypt_sdk"] || "{}").data || "{}").ec_privateKey;
38715
- if (!ec_privateKey) {
38716
- task.logger.error("[douyinPublish] ec_privateKey 为空");
38717
- return utils_response(414, "安全参数 ec_privateKey 缺失,请重新获取后重试", "");
38718
- }
38719
- } catch (error) {
38720
- task.logger.error(`[douyinPublish] 解析 ec_privateKey 失败: ${error}`);
38721
- return utils_response(414, "安全参数 ec_privateKey 解析失败,请重新获取后重试", "");
38636
+ }
38637
+ publishData.item.common.creation_id = generateRandomString(8) + Date.now();
38638
+ let decision = null;
38639
+ proxyHttp.addResponseInterceptor((response)=>{
38640
+ task.logger.info(`[douyinPublish] 拦截器收到响应response.headers: ${JSON.stringify(response.headers)} `);
38641
+ task.logger.info(`[douyinPublish] 拦截器收到响应response.data: ${JSON.stringify(response.data)} `);
38642
+ decision = parseVerifyPassportDecision(response.headers["x-tt-verify-passport-decision"]);
38643
+ if (needsVerification(decision)) {
38644
+ task.logger.info(`[douyinPublish] 检测到需要验证: ${JSON.stringify(decision)}`);
38645
+ return;
38722
38646
  }
38723
- let certificate;
38724
- try {
38725
- certificate = JSON.parse(params.extraParam["security-sdk/s_sdk_server_cert_key"] || "{}").cert;
38726
- if (!certificate) {
38727
- task.logger.error("[douyinPublish] certificate 为空");
38728
- return utils_response(414, "安全参数 certificate 缺失,请重新获取后重试", "");
38729
- }
38730
- } catch (error) {
38731
- task.logger.error(`[douyinPublish] 解析 certificate 失败: ${error}`);
38732
- return utils_response(414, "安全参数 certificate 解析失败,请重新获取后重试", "");
38647
+ if (!response || !response.data) return;
38648
+ const responseData = response.data;
38649
+ if (response && responseData?.status_code && 0 !== responseData.status_code) {
38650
+ const errorCode = 4 === responseData.status_code ? 500 : responseData.status_code;
38651
+ if (4 === responseData.status_code) task.logger.warn(`[douyinPublish] 抖音服务器错误 status_code: 4,映射为 500 触发重试。原始响应: ${JSON.stringify(responseData)}`);
38652
+ return {
38653
+ code: errorCode,
38654
+ message: responseData.status_msg || "文章发布异常,请稍后重试。",
38655
+ data: responseData
38656
+ };
38733
38657
  }
38734
- const ree_public_key = webProtectData.client_cert.replace("pub.", "");
38735
- let bdTicketGuardClientData;
38736
- try {
38737
- bdTicketGuardClientData = getBdV2({
38738
- ticket,
38739
- ts_sign: ts_sign,
38740
- ec_privateKey: ec_privateKey,
38741
- certificate: certificate,
38742
- bd_ticket_guard_ree_public_key: ree_public_key
38743
- });
38744
- if (!bdTicketGuardClientData || !bdTicketGuardClientData["headers_bd_ticket_guard_client_data"]) {
38745
- task.logger.error(`[douyinPublish] bdTicketGuardClientData 生成失败或不完整: ${JSON.stringify(bdTicketGuardClientData)}`);
38746
- return utils_response(414, "安全参数 bdTicketGuardClientData 生成失败,请重新获取后重试", "");
38658
+ });
38659
+ task._timerRecord.PrePublish = Date.now();
38660
+ if (MockPublish) {
38661
+ const data = "123456789";
38662
+ const message = `图文模拟发布成功 ${http.proxyInfo}`;
38663
+ await updateTaskState?.({
38664
+ state: types_TaskState.SUCCESS,
38665
+ result: {
38666
+ response: data
38747
38667
  }
38748
- } catch (error) {
38749
- task.logger.error(`[douyinPublish] 生成 bdTicketGuardClientData 失败: ${error}`);
38750
- return utils_response(414, "安全参数 bdTicketGuardClientData 生成异常,请重新获取后重试", "");
38668
+ });
38669
+ return utils_response(0, message, data);
38670
+ }
38671
+ let webProtectData;
38672
+ try {
38673
+ webProtectData = JSON.parse(JSON.parse(params.extraParam["security-sdk/s_sdk_sign_data_key/web_protect"] || "{}").data || "{}");
38674
+ if (!webProtectData.ticket || !webProtectData.ts_sign || !webProtectData.client_cert) {
38675
+ task.logger.error(`webProtectData 关键字段缺失: ${JSON.stringify(webProtectData)}`);
38676
+ return utils_response(414, "安全参数 webProtectData 不完整,请重新获取后重试", "");
38751
38677
  }
38752
- task.logger.info("[douyinPublish] bdTicketGuardClientData 生成成功");
38753
- const publishQuery = {
38754
- ...publishParams,
38755
- a_bogus: ""
38756
- };
38757
- const queryString = new URLSearchParams(publishQuery).toString();
38758
- let aBogus;
38759
- try {
38760
- aBogus = mock_getABogus(`https://creator.douyin.com/web/api/media/aweme/create_v2/?${queryString}`, publishData, userAgent);
38761
- if (!aBogus || aBogus.length < 10) {
38762
- task.logger.error(`[douyinPublish] a_bogus 生成异常,长度过短: ${aBogus}`);
38763
- return utils_response(414, "安全参数 a_bogus 生成失败,请重试", "");
38764
- }
38765
- } catch (error) {
38766
- task.logger.error(`[douyinPublish] 生成 a_bogus 失败: ${error}`);
38767
- return utils_response(414, "安全参数 a_bogus 生成异常,请重试", "");
38678
+ } catch (error) {
38679
+ task.logger.error(`解析 webProtectData 失败: ${error}`);
38680
+ return utils_response(414, "安全参数 webProtectData 解析失败,请重新获取后重试", "");
38681
+ }
38682
+ let ticket = webProtectData.ticket;
38683
+ let ts_sign = webProtectData.ts_sign;
38684
+ const serverDataCookie = params.cookies.find((it)=>"bd_ticket_guard_server_data" === it.name)?.value;
38685
+ if (serverDataCookie) try {
38686
+ const decoded = JSON.parse(Buffer.from(decodeURIComponent(serverDataCookie), "base64").toString("utf8"));
38687
+ if (decoded.ticket && decoded.ts_sign) {
38688
+ if (decoded.ticket !== ticket) task.logger.info("[douyinPublish] 使用 cookie 中的最新 ticket(web_protect 已过期)");
38689
+ ticket = decoded.ticket;
38690
+ ts_sign = decoded.ts_sign;
38768
38691
  }
38769
- publishQuery.a_bogus = aBogus;
38770
- const publishQueryParams = new URLSearchParams(publishQuery).toString();
38771
- let csrfToken;
38772
- try {
38773
- csrfToken = mock_generateCsrfTokenAdvanced({
38774
- cookies: params.cookies,
38775
- url: "https://creator.douyin.com/web/api/media/aweme/create_v2/",
38776
- method: "POST",
38777
- userAgent
38778
- });
38779
- if (!csrfToken || csrfToken.length < 10) {
38780
- task.logger.error(`[douyinPublish] csrfToken 生成异常,长度过短: ${csrfToken}`);
38781
- return utils_response(414, "安全参数 csrfToken 生成失败,请重试", "");
38782
- }
38783
- task.logger.info(`[douyinPublish] csrfToken 生成成功: ${csrfToken.substring(0, 20)}...`);
38784
- } catch (error) {
38785
- task.logger.error(`[douyinPublish] 生成 csrfToken 失败: ${error}`);
38786
- return utils_response(414, "安全参数 csrfToken 生成异常,请重试", "");
38692
+ } catch (error) {
38693
+ task.logger.info(`[douyinPublish] 解析 bd_ticket_guard_server_data 失败,回退到 web_protect: ${error}`);
38694
+ }
38695
+ let ec_privateKey;
38696
+ try {
38697
+ ec_privateKey = JSON.parse(JSON.parse(params.extraParam["security-sdk/s_sdk_crypt_sdk"] || "{}").data || "{}").ec_privateKey;
38698
+ if (!ec_privateKey) {
38699
+ task.logger.error("[douyinPublish] ec_privateKey 为空");
38700
+ return utils_response(414, "安全参数 ec_privateKey 缺失,请重新获取后重试", "");
38787
38701
  }
38788
- let sessionDtrait;
38789
- try {
38790
- sessionDtrait = mock_generateDtrait("/web/api/media/aweme/create_v2/");
38791
- task.logger.info(`[douyinPublish] sessionDtrait 生成成功: ${sessionDtrait || "(空)"}`);
38792
- } catch (error) {
38793
- task.logger.error(`[douyinPublish] 生成 sessionDtrait 失败: ${error}`);
38794
- return utils_response(414, "安全参数 sessionDtrait 生成异常,请重试", "");
38702
+ } catch (error) {
38703
+ task.logger.error(`[douyinPublish] 解析 ec_privateKey 失败: ${error}`);
38704
+ return utils_response(414, "安全参数 ec_privateKey 解析失败,请重新获取后重试", "");
38705
+ }
38706
+ let certificate;
38707
+ try {
38708
+ certificate = JSON.parse(params.extraParam["security-sdk/s_sdk_server_cert_key"] || "{}").cert;
38709
+ if (!certificate) {
38710
+ task.logger.error("[douyinPublish] certificate 为空");
38711
+ return utils_response(414, "安全参数 certificate 缺失,请重新获取后重试", "");
38795
38712
  }
38796
- task.logger.info(`[douyinPublish] headers: ${JSON.stringify({
38797
- ...headers,
38798
- Referer: "https://creator.douyin.com/creator-micro/content/post/image?default-tab=3&enter_from=publish_page&media_type=image&type=new",
38799
- "Content-Type": "application/json",
38800
- Accept: "application/json, text/plain, */*",
38801
- "bd-ticket-guard-client-data": bdTicketGuardClientData["headers_bd_ticket_guard_client_data"],
38802
- "bd-ticket-guard-ree-public-key": bdTicketGuardClientData["headers_bd_ticket_guard_ree_public_key"],
38803
- "bd-ticket-guard-version": "2",
38804
- "bd-ticket-guard-web-sign-type": "1",
38805
- "bd-ticket-guard-web-version": "2",
38806
- "x-secsdk-csrf-token": csrfToken,
38807
- "x-tt-session-dtrait": sessionDtrait || ""
38808
- })}`);
38809
- task.logger.info(`[douyinPublish] url: https://creator.douyin.com/web/api/media/aweme/create_v2/?${publishQueryParams}`);
38810
- let publishResult;
38811
- try {
38812
- publishResult = await proxyHttp.api({
38813
- method: "post",
38814
- url: `https://creator.douyin.com/web/api/media/aweme/create_v2/?${publishQueryParams}`,
38815
- data: publishData,
38816
- defaultErrorMsg: "发布异常,请稍后重试。",
38817
- headers: {
38818
- ...headers,
38819
- Referer: "https://creator.douyin.com/creator-micro/content/post/image?default-tab=3&enter_from=publish_page&media_type=image&type=new",
38820
- "Content-Type": "application/json",
38821
- Accept: "application/json, text/plain, */*",
38822
- "bd-ticket-guard-client-data": bdTicketGuardClientData["headers_bd_ticket_guard_client_data"],
38823
- "bd-ticket-guard-ree-public-key": bdTicketGuardClientData["headers_bd_ticket_guard_ree_public_key"],
38824
- "bd-ticket-guard-version": "2",
38825
- "bd-ticket-guard-web-sign-type": "1",
38826
- "bd-ticket-guard-web-version": "2",
38827
- "x-secsdk-csrf-token": csrfToken,
38828
- "x-tt-session-dtrait": sessionDtrait || ""
38829
- }
38830
- }, {
38831
- timeout: 60000,
38832
- retries: 3,
38833
- retryDelay: 2000
38834
- });
38835
- } catch (error) {
38836
- const handledError = Http.handleApiError(error);
38837
- const isProxyOrNetworkError = [
38838
- 599,
38839
- 500,
38840
- 502,
38841
- 503,
38842
- 504
38843
- ].includes(handledError.code);
38844
- if (isProxyOrNetworkError) {
38845
- const isProxyRequest = handledError.extra?.isProxyRequest === true;
38846
- const errorType = 599 === handledError.code || isProxyRequest ? "代理错误" : "网络错误";
38847
- const message = `图文发布失败,${errorType}:${handledError.message}${task.debug ? ` ${http.proxyInfo}` : ""}`;
38848
- task.logger.error(`[douyinPublish] ${errorType},直接返回: ${message}`, stringifyError(handledError));
38849
- await updateTaskState?.({
38850
- state: types_TaskState.FAILED,
38851
- error: message
38852
- });
38853
- return {
38854
- code: 414,
38855
- data: "",
38856
- message
38857
- };
38858
- }
38859
- throw error;
38713
+ } catch (error) {
38714
+ task.logger.error(`[douyinPublish] 解析 certificate 失败: ${error}`);
38715
+ return utils_response(414, "安全参数 certificate 解析失败,请重新获取后重试", "");
38716
+ }
38717
+ const ree_public_key = webProtectData.client_cert.replace("pub.", "");
38718
+ let bdTicketGuardClientData;
38719
+ try {
38720
+ bdTicketGuardClientData = getBdV2({
38721
+ ticket,
38722
+ ts_sign: ts_sign,
38723
+ ec_privateKey: ec_privateKey,
38724
+ certificate: certificate,
38725
+ bd_ticket_guard_ree_public_key: ree_public_key
38726
+ });
38727
+ if (!bdTicketGuardClientData || !bdTicketGuardClientData["headers_bd_ticket_guard_client_data"]) {
38728
+ task.logger.error(`[douyinPublish] bdTicketGuardClientData 生成失败或不完整: ${JSON.stringify(bdTicketGuardClientData)}`);
38729
+ return utils_response(414, "安全参数 bdTicketGuardClientData 生成失败,请重新获取后重试", "");
38860
38730
  }
38861
- task.logger.info(`[douyinPublish] decision值: ${JSON.stringify(decision)}, needsVerification(decision): ${needsVerification(decision)}`);
38862
- if (needsVerification(decision)) {
38863
- const details = [
38864
- publishResult.status_msg,
38865
- decision?.verify_title,
38866
- decision?.verify_desc
38867
- ].filter(Boolean).join(" ");
38868
- const message = `图文发布失败,原因:${details}${task.debug ? ` ${http.proxyInfo}` : ""}`;
38869
- const safeDecision = safeSerialize(decision) ?? {};
38870
- const mockData = {
38871
- state: types_TaskState.FAILED,
38872
- error: message,
38873
- result: {
38874
- ...safeDecision,
38875
- data: decision,
38876
- uploadedImgList: JSON.stringify(publishData.item.common.images)
38877
- }
38878
- };
38879
- await updateTaskState?.(mockData);
38880
- return {
38881
- code: 0,
38882
- data: mockData,
38883
- message: "操作成功"
38884
- };
38731
+ } catch (error) {
38732
+ task.logger.error(`[douyinPublish] 生成 bdTicketGuardClientData 失败: ${error}`);
38733
+ return utils_response(414, "安全参数 bdTicketGuardClientData 生成异常,请重新获取后重试", "");
38734
+ }
38735
+ task.logger.info("[douyinPublish] bdTicketGuardClientData 生成成功");
38736
+ const publishQuery = {
38737
+ ...publishParams,
38738
+ a_bogus: ""
38739
+ };
38740
+ const queryString = new URLSearchParams(publishQuery).toString();
38741
+ let aBogus;
38742
+ try {
38743
+ aBogus = mock_getABogus(`https://creator.douyin.com/web/api/media/aweme/create_v2/?${queryString}`, publishData, userAgent);
38744
+ if (!aBogus || aBogus.length < 10) {
38745
+ task.logger.error(`[douyinPublish] a_bogus 生成异常,长度过短: ${aBogus}`);
38746
+ return utils_response(414, "安全参数 a_bogus 生成失败,请重试", "");
38885
38747
  }
38886
- reportLogger({
38887
- token: params.huiwenToken || "",
38888
- enverionment: task.enverionment || "development",
38889
- postId: params.articleId,
38890
- eip: proxyHttp.proxyInfo,
38891
- proxyIp: params.localIP,
38892
- accountId: params.accountId,
38893
- uid: params.uid,
38894
- platform: "douyin",
38895
- publishParams: publishData
38896
- });
38897
- task.logger.info(`[douyinPublish] 发布结果 ${JSON.stringify(publishResult)}`);
38898
- const isSuccess = 0 === publishResult.status_code;
38899
- const message = `图文发布${isSuccess ? "成功" : `失败,原因:${publishResult.status_msg} ${decision?.verify_title} ${decision?.verify_desc}`}${task.debug ? ` ${http.proxyInfo}` : ""}`;
38900
- const data = isSuccess ? publishResult.item_id || "" : "";
38901
- if (!isSuccess) {
38902
- const safeDecision = safeSerialize(decision) ?? {};
38748
+ } catch (error) {
38749
+ task.logger.error(`[douyinPublish] 生成 a_bogus 失败: ${error}`);
38750
+ return utils_response(414, "安全参数 a_bogus 生成异常,请重试", "");
38751
+ }
38752
+ publishQuery.a_bogus = aBogus;
38753
+ const publishQueryParams = new URLSearchParams(publishQuery).toString();
38754
+ let csrfToken;
38755
+ try {
38756
+ csrfToken = mock_generateCsrfTokenAdvanced({
38757
+ cookies: params.cookies,
38758
+ url: "https://creator.douyin.com/web/api/media/aweme/create_v2/",
38759
+ method: "POST",
38760
+ userAgent
38761
+ });
38762
+ if (!csrfToken || csrfToken.length < 10) {
38763
+ task.logger.error(`[douyinPublish] csrfToken 生成异常,长度过短: ${csrfToken}`);
38764
+ return utils_response(414, "安全参数 csrfToken 生成失败,请重试", "");
38765
+ }
38766
+ task.logger.info(`[douyinPublish] csrfToken 生成成功: ${csrfToken.substring(0, 20)}...`);
38767
+ } catch (error) {
38768
+ task.logger.error(`[douyinPublish] 生成 csrfToken 失败: ${error}`);
38769
+ return utils_response(414, "安全参数 csrfToken 生成异常,请重试", "");
38770
+ }
38771
+ let sessionDtrait;
38772
+ try {
38773
+ sessionDtrait = mock_generateDtrait("/web/api/media/aweme/create_v2/");
38774
+ task.logger.info(`[douyinPublish] sessionDtrait 生成成功: ${sessionDtrait || "(空)"}`);
38775
+ } catch (error) {
38776
+ task.logger.error(`[douyinPublish] 生成 sessionDtrait 失败: ${error}`);
38777
+ return utils_response(414, "安全参数 sessionDtrait 生成异常,请重试", "");
38778
+ }
38779
+ task.logger.info(`[douyinPublish] headers: ${JSON.stringify({
38780
+ ...headers,
38781
+ Referer: "https://creator.douyin.com/creator-micro/content/post/image?default-tab=3&enter_from=publish_page&media_type=image&type=new",
38782
+ "Content-Type": "application/json",
38783
+ Accept: "application/json, text/plain, */*",
38784
+ "bd-ticket-guard-client-data": bdTicketGuardClientData["headers_bd_ticket_guard_client_data"],
38785
+ "bd-ticket-guard-ree-public-key": bdTicketGuardClientData["headers_bd_ticket_guard_ree_public_key"],
38786
+ "bd-ticket-guard-version": "2",
38787
+ "bd-ticket-guard-web-sign-type": "1",
38788
+ "bd-ticket-guard-web-version": "2",
38789
+ "x-secsdk-csrf-token": csrfToken,
38790
+ "x-tt-session-dtrait": sessionDtrait || ""
38791
+ })}`);
38792
+ task.logger.info(`[douyinPublish] url: https://creator.douyin.com/web/api/media/aweme/create_v2/?${publishQueryParams}`);
38793
+ let publishResult;
38794
+ try {
38795
+ publishResult = await proxyHttp.api({
38796
+ method: "post",
38797
+ url: `https://creator.douyin.com/web/api/media/aweme/create_v2/?${publishQueryParams}`,
38798
+ data: publishData,
38799
+ defaultErrorMsg: "发布异常,请稍后重试。",
38800
+ headers: {
38801
+ ...headers,
38802
+ Referer: "https://creator.douyin.com/creator-micro/content/post/image?default-tab=3&enter_from=publish_page&media_type=image&type=new",
38803
+ "Content-Type": "application/json",
38804
+ Accept: "application/json, text/plain, */*",
38805
+ "bd-ticket-guard-client-data": bdTicketGuardClientData["headers_bd_ticket_guard_client_data"],
38806
+ "bd-ticket-guard-ree-public-key": bdTicketGuardClientData["headers_bd_ticket_guard_ree_public_key"],
38807
+ "bd-ticket-guard-version": "2",
38808
+ "bd-ticket-guard-web-sign-type": "1",
38809
+ "bd-ticket-guard-web-version": "2",
38810
+ "x-secsdk-csrf-token": csrfToken,
38811
+ "x-tt-session-dtrait": sessionDtrait || ""
38812
+ }
38813
+ }, {
38814
+ timeout: 60000,
38815
+ retries: 3,
38816
+ retryDelay: 2000
38817
+ });
38818
+ } catch (error) {
38819
+ const handledError = Http.handleApiError(error);
38820
+ const isProxyOrNetworkError = [
38821
+ 599,
38822
+ 500,
38823
+ 502,
38824
+ 503,
38825
+ 504
38826
+ ].includes(handledError.code);
38827
+ if (isProxyOrNetworkError) {
38828
+ const isProxyRequest = handledError.extra?.isProxyRequest === true;
38829
+ const errorType = 599 === handledError.code || isProxyRequest ? "代理错误" : "网络错误";
38830
+ const message = `图文发布失败,${errorType}:${handledError.message}${task.debug ? ` ${http.proxyInfo}` : ""}`;
38831
+ task.logger.error(`[douyinPublish] ${errorType},直接返回: ${message}`, stringifyError(handledError));
38903
38832
  await updateTaskState?.({
38904
38833
  state: types_TaskState.FAILED,
38905
- error: message,
38906
- result: {
38907
- ...safeDecision,
38908
- data: safeDecision,
38909
- uploadedImgList: JSON.stringify(publishData.item.common.images)
38910
- }
38834
+ error: message
38911
38835
  });
38912
38836
  return {
38913
38837
  code: 414,
38914
- data: safeDecision,
38838
+ data: "",
38915
38839
  message
38916
38840
  };
38917
38841
  }
38918
- await updateTaskState?.({
38919
- state: types_TaskState.SUCCESS,
38842
+ throw error;
38843
+ }
38844
+ task.logger.info(`[douyinPublish] decision值: ${JSON.stringify(decision)}, needsVerification(decision): ${needsVerification(decision)}`);
38845
+ if (needsVerification(decision)) {
38846
+ const details = [
38847
+ publishResult.status_msg,
38848
+ decision?.verify_title,
38849
+ decision?.verify_desc
38850
+ ].filter(Boolean).join(" ");
38851
+ const message = `图文发布失败,原因:${details}${task.debug ? ` ${http.proxyInfo}` : ""}`;
38852
+ let decisionObj = {};
38853
+ if (decision) decisionObj = decision;
38854
+ const mockData = {
38855
+ state: types_TaskState.FAILED,
38856
+ error: message,
38920
38857
  result: {
38921
- response: data
38858
+ ...decisionObj,
38859
+ data: decision,
38860
+ uploadedImgList: JSON.stringify(publishData.item.common.images)
38922
38861
  }
38923
- });
38924
- return utils_response(isSuccess ? 0 : 414, message, data);
38925
- } catch (error) {
38926
- const handledError = Http.handleApiError(error);
38927
- const errorMsg = handledError.message || "发布失败";
38928
- const errorCode = handledError.code || 500;
38929
- task.logger.error(`[douyinPublish] 发布流程异常 (步骤: ${currentStep}): ${errorMsg}`, stringifyError(error), handledError.extra);
38862
+ };
38863
+ await updateTaskState?.(mockData);
38864
+ return {
38865
+ code: 0,
38866
+ data: mockData,
38867
+ message: "操作成功"
38868
+ };
38869
+ }
38870
+ reportLogger({
38871
+ token: params.huiwenToken || "",
38872
+ enverionment: task.enverionment || "development",
38873
+ postId: params.articleId,
38874
+ eip: proxyHttp.proxyInfo,
38875
+ proxyIp: params.localIP,
38876
+ accountId: params.accountId,
38877
+ uid: params.uid,
38878
+ platform: "douyin",
38879
+ publishParams: publishData
38880
+ });
38881
+ task.logger.info(`[douyinPublish] 发布结果 ${JSON.stringify(publishResult)}`);
38882
+ const isSuccess = 0 === publishResult.status_code;
38883
+ const message = `图文发布${isSuccess ? "成功" : `失败,原因:${publishResult.status_msg} ${decision?.verify_title} ${decision?.verify_desc}`}${task.debug ? ` ${http.proxyInfo}` : ""}`;
38884
+ const data = isSuccess ? publishResult.item_id || "" : "";
38885
+ if (!isSuccess) {
38886
+ let decisionObj = {};
38887
+ if (decision) decisionObj = decision;
38930
38888
  await updateTaskState?.({
38931
38889
  state: types_TaskState.FAILED,
38932
- error: `${currentStep}失败: ${errorMsg}`
38890
+ error: message,
38891
+ result: {
38892
+ ...decisionObj,
38893
+ data: decision,
38894
+ uploadedImgList: JSON.stringify(publishData.item.common.images)
38895
+ }
38933
38896
  });
38934
- return utils_response(errorCode, errorMsg, "");
38897
+ return {
38898
+ code: 414,
38899
+ data,
38900
+ message
38901
+ };
38935
38902
  }
38903
+ await updateTaskState?.({
38904
+ state: types_TaskState.SUCCESS,
38905
+ result: {
38906
+ response: data
38907
+ }
38908
+ });
38909
+ return utils_response(isSuccess ? 0 : 414, message, data);
38936
38910
  };
38937
38911
  const douyinPublish_rpa_rpaAction = async (task, params)=>{
38938
38912
  const commonCookies = {
@@ -40458,241 +40432,6 @@ var __webpack_exports__ = {};
40458
40432
  };
40459
40433
  return success(bjhData, "百家号平台数据获取成功!");
40460
40434
  }
40461
- async function getDouyinData(_task, params) {
40462
- try {
40463
- const sessionidCookie = params.cookies.find((it)=>"sessionid" === it.name)?.value;
40464
- if (!sessionidCookie) return types_errorResponse("抖音账号数据异常,请重新绑定账号后重试。", 414);
40465
- const csrfToken = params.cookies.find((it)=>"passport_csrf_token" === it.name)?.value || "";
40466
- const headers = {
40467
- cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
40468
- referer: "https://creator.douyin.com/creator-micro/home",
40469
- origin: "https://creator.douyin.com",
40470
- "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",
40471
- ...csrfToken ? {
40472
- "x-secsdk-csrf-token": csrfToken
40473
- } : {}
40474
- };
40475
- const args = [
40476
- {
40477
- headers
40478
- },
40479
- _task.logger,
40480
- params.proxyLoc,
40481
- params.localIP,
40482
- params.accountId
40483
- ];
40484
- const http = new Http(...args);
40485
- const toNum = (val)=>{
40486
- if (null == val) return 0;
40487
- const n = Number.parseInt(String(val).replace(/[+,]/g, ""), 10);
40488
- return Number.isNaN(n) ? 0 : n;
40489
- };
40490
- const userProfileP = http.api({
40491
- method: "get",
40492
- url: "https://www.douyin.com/aweme/v1/web/user/profile/self/",
40493
- params: {
40494
- device_platform: "webapp",
40495
- aid: "6383",
40496
- channel: "channel_pc_web",
40497
- pc_client_type: "1",
40498
- version_code: "170400",
40499
- version_name: "17.4.0",
40500
- cookie_enabled: "true",
40501
- platform: "PC"
40502
- }
40503
- }, {
40504
- retries: 3,
40505
- retryDelay: 100,
40506
- timeout: 10000
40507
- }).catch((e)=>{
40508
- _task.logger.warn(`抖音用户信息获取失败: ${e instanceof Error ? e.message : String(e)}`);
40509
- return null;
40510
- });
40511
- const overviewP = http.api({
40512
- method: "get",
40513
- url: "https://creator.douyin.com/aweme/janus/creator/data/overview/all/",
40514
- params: {
40515
- last_days_type: 1,
40516
- aid: 2906,
40517
- app_name: "aweme_creator_platform",
40518
- device_platform: "web"
40519
- }
40520
- }, {
40521
- retries: 3,
40522
- retryDelay: 100,
40523
- timeout: 5000
40524
- }).catch((e)=>{
40525
- _task.logger.warn(`抖音近7日数据获取失败(可能未开通数据中心或被风控): ${e instanceof Error ? e.message : String(e)}`);
40526
- return null;
40527
- });
40528
- const [userProfile, overview] = await Promise.all([
40529
- userProfileP,
40530
- overviewP
40531
- ]);
40532
- let fansNum = 0;
40533
- let favedNum = 0;
40534
- let followingNum = 0;
40535
- if (userProfile?.status_code === 0 && userProfile.user) {
40536
- const user = userProfile.user;
40537
- fansNum = toNum(user.follower_count);
40538
- followingNum = toNum(user.following_count);
40539
- favedNum = toNum(user.total_favorited);
40540
- } else _task.logger.warn(`用户信息接口返回异常: status_code=${userProfile?.status_code}, msg=${userProfile?.status_msg}`);
40541
- const ov = overview?.data;
40542
- const douyinData = {
40543
- fansNum,
40544
- favedNum,
40545
- fansNumLastWeek: toNum(ov?.new_fans?.last_period_incr),
40546
- watchNumLastWeek: toNum(ov?.play?.last_period_incr),
40547
- likeNumLastWeek: toNum(ov?.digg?.last_period_incr),
40548
- commentNumLastWeek: toNum(ov?.comment?.last_period_incr),
40549
- shareNumLastWeek: toNum(ov?.share?.last_period_incr),
40550
- visitNumLastWeek: toNum(ov?.profile?.last_period_incr)
40551
- };
40552
- return success(douyinData, "抖音平台数据获取成功!");
40553
- } catch (error) {
40554
- if (error && "object" == typeof error && "code" in error && "message" in error) {
40555
- const err = error;
40556
- _task.logger.error(`抖音账号数据获取失败: ${err.message} (${err.code})`);
40557
- return types_errorResponse(err.message, err.code);
40558
- }
40559
- const errMsg = error instanceof Error ? error.message : String(error);
40560
- _task.logger.error(`抖音账号数据获取失败: ${errMsg}`);
40561
- return types_errorResponse(errMsg || "抖音账号数据获取失败");
40562
- }
40563
- }
40564
- async function getShipinhaoData(_task, params) {
40565
- try {
40566
- const sessionidCookie = params.cookies.find((it)=>"sessionid" === it.name)?.value;
40567
- if (!sessionidCookie) return types_errorResponse("视频号账号数据异常,请重新绑定账号后重试。", 414);
40568
- const uinCookie = params.cookies.find((it)=>"uin" === it.name || "wxuin" === it.name)?.value || "0000000000";
40569
- const deviceIdCookie = params.cookies.find((it)=>"device_id" === it.name || "finger_print_device_id" === it.name)?.value;
40570
- const aid = params.cookies.find((it)=>"_aid" === it.name)?.value || "9d3e0e9f-b842-498d-a273-4285d58df264";
40571
- const finderId = params.cookies.find((it)=>"_log_finder_id" === it.name || "finder_id" === it.name)?.value || "";
40572
- const headers = {
40573
- cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
40574
- referer: "https://channels.weixin.qq.com/platform",
40575
- origin: "https://channels.weixin.qq.com",
40576
- "content-type": "application/json",
40577
- "X-WECHAT-UIN": uinCookie,
40578
- ...deviceIdCookie ? {
40579
- "finger-print-device-id": deviceIdCookie
40580
- } : {}
40581
- };
40582
- const args = [
40583
- {
40584
- headers
40585
- },
40586
- _task.logger,
40587
- params.proxyLoc,
40588
- params.localIP,
40589
- params.accountId
40590
- ];
40591
- const http = new Http(...args);
40592
- const authData = await http.api({
40593
- method: "post",
40594
- url: "https://channels.weixin.qq.com/cgi-bin/mmfinderassistant-bin/auth/auth_data",
40595
- params: {
40596
- _aid: aid,
40597
- _rid: `${Date.now().toString(16)}-${Math.random().toString(36).substring(2, 9)}`,
40598
- _pageUrl: encodeURIComponent("https://channels.weixin.qq.com/platform")
40599
- },
40600
- data: {
40601
- timestamp: Date.now().toString(),
40602
- _log_finder_uin: "",
40603
- _log_finder_id: finderId,
40604
- rawKeyBuff: "",
40605
- pluginSessionId: null,
40606
- scene: 7,
40607
- reqScene: 7
40608
- }
40609
- }, {
40610
- retries: 3,
40611
- retryDelay: 100,
40612
- timeout: 5000
40613
- });
40614
- const AUTH_ERROR_CODES = [
40615
- 300333,
40616
- 300334,
40617
- 300330,
40618
- 300331,
40619
- 300332
40620
- ];
40621
- if (authData.errCode && AUTH_ERROR_CODES.includes(authData.errCode)) {
40622
- _task.logger.warn(`视频号登录已失效:${authData.errMsg} (${authData.errCode})`);
40623
- return types_errorResponse("视频号账号信息获取失败,请检查账号状态", 414);
40624
- }
40625
- if (authData.errCode) {
40626
- _task.logger.warn(`视频号账号API错误:${authData.errMsg} (${authData.errCode})`);
40627
- return types_errorResponse(`视频号账号信息获取失败:${authData.errMsg || "未知错误"}`, 414);
40628
- }
40629
- const finderUser = authData.data?.finderUser;
40630
- const now = new Date();
40631
- const yesterday = new Date(now.getFullYear(), now.getMonth(), now.getDate() - 2);
40632
- const startTs = Math.floor(yesterday.getTime() / 1000);
40633
- const endTs = startTs + 86400;
40634
- _task.logger.info(`视频号昨日数据范围 start: ${startTs} ~ end: ${endTs}`);
40635
- let fansNumYesterday = 0;
40636
- let playNumYesterday = 0;
40637
- let likeNumYesterday = 0;
40638
- let commentNumYesterday = 0;
40639
- try {
40640
- const statsData = await http.api({
40641
- method: "post",
40642
- url: "https://channels.weixin.qq.com/cgi-bin/mmfinderassistant-bin/statistic/new_post_total_data",
40643
- params: {
40644
- _aid: aid,
40645
- _rid: `${Date.now().toString(16)}-${Math.random().toString(36).substring(2, 9)}`,
40646
- _pageUrl: encodeURIComponent("https://channels.weixin.qq.com/platform")
40647
- },
40648
- data: {
40649
- startTs: startTs.toString(),
40650
- endTs: endTs.toString(),
40651
- interval: 3,
40652
- timestamp: Date.now().toString(),
40653
- _log_finder_uin: "",
40654
- _log_finder_id: finderId,
40655
- rawKeyBuff: "",
40656
- pluginSessionId: null,
40657
- scene: 7,
40658
- reqScene: 7
40659
- }
40660
- }, {
40661
- retries: 3,
40662
- retryDelay: 100,
40663
- timeout: 5000
40664
- });
40665
- if (!statsData.errCode && statsData.data?.totalData) {
40666
- const data = statsData.data.totalData;
40667
- fansNumYesterday = Number.parseInt(data.follow?.[1] || "0", 10) || 0;
40668
- playNumYesterday = Number.parseInt(data.browse?.[1] || "0", 10) || 0;
40669
- likeNumYesterday = Number.parseInt(data.like?.[1] || "0", 10) || 0;
40670
- commentNumYesterday = Number.parseInt(data.comment?.[1] || "0", 10) || 0;
40671
- }
40672
- } catch (error) {
40673
- const errMsg = error instanceof Error ? error.message : String(error);
40674
- _task.logger.warn(`视频号昨日数据获取失败(降级为null): ${errMsg}`);
40675
- }
40676
- const shipinhaoData = {
40677
- fansNum: finderUser?.fansCount || 0,
40678
- feedsCount: finderUser?.feedsCount || 0,
40679
- fansNumYesterday,
40680
- playNumYesterday,
40681
- likeNumYesterday,
40682
- commentNumYesterday
40683
- };
40684
- return success(shipinhaoData, "视频号平台数据获取成功!");
40685
- } catch (error) {
40686
- if (error && "object" == typeof error && "code" in error && "message" in error) {
40687
- const err = error;
40688
- _task.logger.error(`视频号账号数据获取失败: ${err.message} (${err.code})`);
40689
- return types_errorResponse(err.message, err.code);
40690
- }
40691
- const errMsg = error instanceof Error ? error.message : String(error);
40692
- _task.logger.error(`视频号账号数据获取失败: ${errMsg}`);
40693
- return types_errorResponse(errMsg || "视频号账号数据获取失败");
40694
- }
40695
- }
40696
40435
  async function getToutiaoData(_task, params) {
40697
40436
  const http = new Http({
40698
40437
  headers: {
@@ -40791,7 +40530,7 @@ var __webpack_exports__ = {};
40791
40530
  userInfoHtmlPromise,
40792
40531
  userSummaryHtmlPromise
40793
40532
  ]);
40794
- if (userInfoHtml.includes("请重新<a id='jumpUrl' href='/'>登录</a>")) return types_errorResponse("微信公众号数据获取失败,请检查账号状态", 414);
40533
+ if (userInfoHtml.includes("请重新<a id='jumpUrl' href='/'>登录</a>")) return types_errorResponse("Token已失效,请重新获取", 414);
40795
40534
  const userInfoJson = exportWxCgiData(userInfoHtml);
40796
40535
  const userSummaryJson = exportWxCgiData(userSummaryHtml);
40797
40536
  const wxData = {
@@ -40868,9 +40607,7 @@ var __webpack_exports__ = {};
40868
40607
  "toutiao",
40869
40608
  "xiaohongshu",
40870
40609
  "weixin",
40871
- "baijiahao",
40872
- "douyin",
40873
- "shipinhao"
40610
+ "baijiahao"
40874
40611
  ])
40875
40612
  });
40876
40613
  const SearchAccountInfo = async (_task, params)=>{
@@ -40884,10 +40621,6 @@ var __webpack_exports__ = {};
40884
40621
  return getWeixinData(_task, params);
40885
40622
  case "baijiahao":
40886
40623
  return getBaijiahaoData(_task, params);
40887
- case "douyin":
40888
- return getDouyinData(_task, params);
40889
- case "shipinhao":
40890
- return getShipinhaoData(_task, params);
40891
40624
  default:
40892
40625
  return success(null, "暂不支持该平台");
40893
40626
  }
@@ -40982,45 +40715,18 @@ var __webpack_exports__ = {};
40982
40715
  collectNum: classic_schemas_number(),
40983
40716
  shareNum: classic_schemas_number()
40984
40717
  });
40985
- const DouyinArticleSchema = BaseArticleSchema.extend({
40986
- playNum: classic_schemas_number(),
40987
- likeNum: classic_schemas_number(),
40988
- commentNum: classic_schemas_number(),
40989
- shareNum: classic_schemas_number(),
40990
- collectNum: classic_schemas_number(),
40991
- awemeId: classic_schemas_string(),
40992
- awemeType: classic_schemas_number(),
40993
- duration: classic_schemas_number().optional(),
40994
- status: classic_schemas_string(),
40995
- publicUrl: classic_schemas_string()
40996
- });
40997
- const ShipinhaoArticleSchema = BaseArticleSchema.extend({
40998
- readNum: classic_schemas_number(),
40999
- likeNum: classic_schemas_number(),
41000
- commentNum: classic_schemas_number(),
41001
- forwardNum: classic_schemas_number(),
41002
- favNum: classic_schemas_number(),
41003
- objectId: classic_schemas_string(),
41004
- postType: classic_schemas_string(),
41005
- postStatus: classic_schemas_number(),
41006
- effectiveTime: classic_schemas_number().optional()
41007
- });
41008
40718
  const FetchArticlesDataSchema = classic_schemas_object({
41009
40719
  articleCell: classic_schemas_array(schemas_union([
41010
40720
  ToutiaoArticleSchema,
41011
40721
  WeixinArticleSchema,
41012
40722
  BaijiahaoArticleSchema,
41013
- XiaohongshuArticleSchema,
41014
- DouyinArticleSchema,
41015
- ShipinhaoArticleSchema
40723
+ XiaohongshuArticleSchema
41016
40724
  ])).optional(),
41017
40725
  timerPublish: classic_schemas_array(schemas_union([
41018
40726
  ToutiaoArticleSchema,
41019
40727
  WeixinArticleSchema,
41020
40728
  BaijiahaoArticleSchema,
41021
- XiaohongshuArticleSchema,
41022
- DouyinArticleSchema,
41023
- ShipinhaoArticleSchema
40729
+ XiaohongshuArticleSchema
41024
40730
  ])).optional(),
41025
40731
  pagination: classic_schemas_object({
41026
40732
  total: classic_schemas_number().optional(),
@@ -41135,269 +40841,6 @@ var __webpack_exports__ = {};
41135
40841
  return searchPublishInfo_types_errorResponse(error instanceof Error ? error.message : "百家号文章数据获取失败");
41136
40842
  }
41137
40843
  }
41138
- async function handleDouyinData(_task, params) {
41139
- try {
41140
- const { cookies, pageSize = 12, status = 0, showOriginalData = false, onlySuccess = false } = params;
41141
- const pageNum = params.pageNum || 1;
41142
- const headers = {
41143
- cookie: cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
41144
- referer: "https://creator.douyin.com"
41145
- };
41146
- const args = [
41147
- {
41148
- headers
41149
- },
41150
- _task.logger,
41151
- params.proxyLoc,
41152
- params.localIP,
41153
- params.accountId
41154
- ];
41155
- const http = new Http(...args);
41156
- async function fetchWorks(cursor) {
41157
- return await http.api({
41158
- method: "get",
41159
- url: "https://creator.douyin.com/janus/douyin/creator/pc/work_list",
41160
- params: {
41161
- scene: "star_atlas",
41162
- device_platform: "android",
41163
- aid: 1128,
41164
- status,
41165
- count: pageSize,
41166
- max_cursor: cursor
41167
- }
41168
- }, {
41169
- retries: 3,
41170
- retryDelay: 100,
41171
- timeout: 5000
41172
- });
41173
- }
41174
- const isHasMore = (v)=>true === v || 1 === v;
41175
- const skipCount = (pageNum - 1) * pageSize;
41176
- const needCount = skipCount + pageSize;
41177
- const workListResponse = await fetchWorks(0);
41178
- if (!workListResponse || !Array.isArray(workListResponse.aweme_list)) return searchPublishInfo_types_errorResponse("抖音数据获取失败,请检查账号状态", 414);
41179
- const allWorks = [
41180
- ...workListResponse.aweme_list
41181
- ];
41182
- let hasMore = isHasMore(workListResponse.has_more);
41183
- let currentCursor = workListResponse.cursor ?? workListResponse.max_cursor ?? 0;
41184
- let guard = 0;
41185
- while(allWorks.length < needCount && hasMore && guard < 20){
41186
- const nextPageResponse = await fetchWorks(currentCursor);
41187
- if (!Array.isArray(nextPageResponse.aweme_list) || 0 === nextPageResponse.aweme_list.length) break;
41188
- allWorks.push(...nextPageResponse.aweme_list);
41189
- hasMore = isHasMore(nextPageResponse.has_more);
41190
- currentCursor = nextPageResponse.cursor ?? nextPageResponse.max_cursor ?? currentCursor;
41191
- guard++;
41192
- }
41193
- const finalWorks = allWorks.slice(skipCount, needCount);
41194
- const articleCell = finalWorks.map((item)=>{
41195
- const workDetailUrl = `https://creator.douyin.com/creator-micro/work-management/work-detail/${item.aweme_id}`;
41196
- const workPublicUrl = item.share_url || `https://www.douyin.com/video/${item.aweme_id}`;
41197
- let statusText;
41198
- statusText = item.status?.is_delete ? "deleted" : item.status?.is_private ? "private" : item.status?.in_reviewing ? "reviewing" : "public";
41199
- return {
41200
- title: item.desc || "无作品描述",
41201
- imageUrl: item.Cover?.url_list?.[0] || "",
41202
- createTime: item.create_time,
41203
- redirectUrl: workDetailUrl,
41204
- playNum: item.statistics?.play_count || 0,
41205
- likeNum: item.statistics?.digg_count || 0,
41206
- commentNum: item.statistics?.comment_count || 0,
41207
- shareNum: item.statistics?.share_count || 0,
41208
- collectNum: item.statistics?.collect_count || 0,
41209
- awemeId: item.aweme_id,
41210
- awemeType: item.aweme_type ?? 0,
41211
- duration: item.duration,
41212
- status: statusText,
41213
- publicUrl: workPublicUrl,
41214
- ...showOriginalData ? {
41215
- originalData: item
41216
- } : {}
41217
- };
41218
- });
41219
- return success({
41220
- articleCell,
41221
- ...onlySuccess ? {
41222
- pagination: {
41223
- total: workListResponse.total || allWorks.length,
41224
- nextPage: hasMore,
41225
- pageNum,
41226
- pageSize
41227
- }
41228
- } : null
41229
- }, "抖音数据获取成功");
41230
- } catch (error) {
41231
- return searchPublishInfo_types_errorResponse(error instanceof Error ? error.message : "抖音数据获取失败");
41232
- }
41233
- }
41234
- async function handleShipinhaoData(_task, params) {
41235
- try {
41236
- const { cookies, postType = "all", pageSize = 10, showOriginalData = false } = params;
41237
- const pageNum = params.pageNum || 1;
41238
- const aidCookie = cookies.find((it)=>"_aid" === it.name)?.value;
41239
- const aid = aidCookie || "9d3e0e9f-b842-498d-a273-4285d58df264";
41240
- const uinCookie = cookies.find((it)=>"uin" === it.name || "wxuin" === it.name)?.value || "0000000000";
41241
- const deviceIdCookie = cookies.find((it)=>"device_id" === it.name || "finger_print_device_id" === it.name)?.value;
41242
- const headers = {
41243
- cookie: cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
41244
- referer: "https://channels.weixin.qq.com",
41245
- origin: "https://channels.weixin.qq.com",
41246
- "content-type": "application/json",
41247
- "X-WECHAT-UIN": uinCookie,
41248
- ...deviceIdCookie ? {
41249
- "finger-print-device-id": deviceIdCookie
41250
- } : {}
41251
- };
41252
- const args = [
41253
- {
41254
- headers
41255
- },
41256
- _task.logger,
41257
- params.proxyLoc,
41258
- params.localIP,
41259
- params.accountId
41260
- ];
41261
- const http = new Http(...args);
41262
- const finderIdCookie = cookies.find((it)=>"_log_finder_id" === it.name || "finder_id" === it.name)?.value || "";
41263
- async function fetchPosts(currentPage, userpageType, pageUrl, rawKeyBuff = "") {
41264
- return await http.api({
41265
- method: "post",
41266
- url: "https://channels.weixin.qq.com/micro/content/cgi-bin/mmfinderassistant-bin/post/post_list",
41267
- params: {
41268
- _aid: aid,
41269
- _rid: `${Date.now().toString(16)}-${Math.random().toString(36).substring(2, 9)}`,
41270
- _pageUrl: encodeURIComponent(pageUrl)
41271
- },
41272
- data: {
41273
- pageSize,
41274
- currentPage,
41275
- userpageType,
41276
- stickyOrder: true,
41277
- timestamp: Date.now().toString(),
41278
- _log_finder_uin: "",
41279
- _log_finder_id: finderIdCookie,
41280
- rawKeyBuff,
41281
- pluginSessionId: null,
41282
- scene: 7,
41283
- reqScene: 7
41284
- }
41285
- }, {
41286
- retries: 3,
41287
- retryDelay: 100,
41288
- timeout: 5000
41289
- });
41290
- }
41291
- async function fetchAllPosts(userpageType, pageUrl) {
41292
- const allPosts = [];
41293
- let currentPage = 1;
41294
- let rawKeyBuff = "";
41295
- let continueFlag = true;
41296
- let totalCount = 0;
41297
- while(continueFlag){
41298
- const response = await fetchPosts(currentPage, userpageType, pageUrl, rawKeyBuff);
41299
- if (response.errCode && AUTH_ERROR_CODES.includes(response.errCode)) throw new Error(`AUTH_ERROR:${response.errMsg || "登录已失效"}`);
41300
- if (response.errCode) {
41301
- _task.logger.warn(`视频号API错误:${response.errMsg} (${response.errCode})`);
41302
- throw new Error(`视频号API错误:${response.errMsg} (${response.errCode})`);
41303
- }
41304
- if (1 === currentPage) totalCount = response.data?.totalCount ?? 0;
41305
- const posts = response.data?.list || response.posts || response.post_list || [];
41306
- allPosts.push(...posts);
41307
- continueFlag = response.data?.continueFlag ?? false;
41308
- rawKeyBuff = response.data?.lastBuff || "";
41309
- currentPage++;
41310
- if (currentPage > 100) {
41311
- _task.logger.warn("分页超过100页,停止请求");
41312
- break;
41313
- }
41314
- }
41315
- if (totalCount > 0 && allPosts.length !== totalCount) _task.logger.warn(`视频号分页可能不完整:期望${totalCount}条,实际${allPosts.length}条`);
41316
- return {
41317
- posts: allPosts,
41318
- totalCount
41319
- };
41320
- }
41321
- const mapPost = (item, forcePostType)=>{
41322
- let imageUrl = "";
41323
- if (item.desc?.media?.[0]?.thumbUrl) imageUrl = item.desc.media[0].thumbUrl;
41324
- else if (item.desc?.media?.[0]?.coverUrl) imageUrl = item.desc.media[0].coverUrl;
41325
- else if (item.cover?.url) imageUrl = item.cover.url;
41326
- else if (item.media_url) imageUrl = item.media_url;
41327
- const title = item.desc?.description || item.object_desc || "无标题";
41328
- return {
41329
- title,
41330
- imageUrl,
41331
- createTime: item.createTime || item.create_time,
41332
- redirectUrl: "https://channels.weixin.qq.com/platform",
41333
- readNum: item.readCount || item.read_count || 0,
41334
- likeNum: item.likeCount || item.like_count || 0,
41335
- commentNum: item.commentCount || item.comment_count || 0,
41336
- forwardNum: item.forwardCount || item.forward_count || 0,
41337
- favNum: item.favCount || item.fav_count || 0,
41338
- objectId: item.exportId || item.objectId || "",
41339
- postType: forcePostType,
41340
- postStatus: item.status || item.post_status || 0,
41341
- ...item.effectiveTime ? {
41342
- effectiveTime: item.effectiveTime
41343
- } : {},
41344
- ...showOriginalData ? {
41345
- originalData: item
41346
- } : {}
41347
- };
41348
- };
41349
- const allArticles = [];
41350
- const needVideo = "all" === postType || "video" === postType;
41351
- const needArticle = "all" === postType || "article" === postType;
41352
- const AUTH_ERROR_CODES = [
41353
- 300333,
41354
- 300334,
41355
- 300330,
41356
- 300331,
41357
- 300332
41358
- ];
41359
- let combinedTotal = 0;
41360
- if (needVideo) try {
41361
- const videoPageUrl = "https://channels.weixin.qq.com/micro/content/post/list";
41362
- const { posts, totalCount } = await fetchAllPosts(11, videoPageUrl);
41363
- const videoArticles = posts.filter((item)=>item.createTime || item.create_time).map((item)=>mapPost(item, "video"));
41364
- allArticles.push(...videoArticles);
41365
- combinedTotal += totalCount || videoArticles.length;
41366
- } catch (error) {
41367
- const errMsg = error instanceof Error ? error.message : String(error);
41368
- if (errMsg.startsWith("AUTH_ERROR:")) throw error;
41369
- _task.logger.warn(`获取视频号视频失败:${errMsg}`);
41370
- }
41371
- if (needArticle) try {
41372
- const articlePageUrl = "https://channels.weixin.qq.com/micro/content/post/finderNewLifePostList";
41373
- const { posts, totalCount } = await fetchAllPosts(10, articlePageUrl);
41374
- const articleArticles = posts.filter((item)=>item.createTime || item.create_time).map((item)=>mapPost(item, "article"));
41375
- allArticles.push(...articleArticles);
41376
- combinedTotal += totalCount || articleArticles.length;
41377
- } catch (error) {
41378
- const errMsg = error instanceof Error ? error.message : String(error);
41379
- if (errMsg.startsWith("AUTH_ERROR:")) throw error;
41380
- _task.logger.warn(`获取视频号图文失败:${errMsg}`);
41381
- }
41382
- allArticles.sort((a, b)=>b.createTime - a.createTime);
41383
- const total = allArticles.length;
41384
- const start = (pageNum - 1) * pageSize;
41385
- const pageItems = allArticles.slice(start, start + pageSize);
41386
- return success({
41387
- articleCell: pageItems,
41388
- pagination: {
41389
- total,
41390
- nextPage: start + pageSize < total,
41391
- pageNum,
41392
- pageSize
41393
- }
41394
- }, "视频号数据获取成功");
41395
- } catch (error) {
41396
- const errMsg = error instanceof Error ? error.message : String(error);
41397
- if (errMsg.startsWith("AUTH_ERROR:")) return searchPublishInfo_types_errorResponse("视频号数据获取失败,请检查账号状态", 414);
41398
- return searchPublishInfo_types_errorResponse(errMsg || "视频号数据获取失败");
41399
- }
41400
- }
41401
40844
  async function handleToutiaoData(_task, params) {
41402
40845
  try {
41403
40846
  const { cookies, pageNum = 1, pageSize = 10, showOriginalData = false, onlySuccess = false, containsArticle = false } = params;
@@ -41430,7 +40873,7 @@ var __webpack_exports__ = {};
41430
40873
  app_id: 1231
41431
40874
  }
41432
40875
  });
41433
- if (0 !== visitedUid.code) return searchPublishInfo_types_errorResponse("头条号数据获取失败,请检查账号状态", 414);
40876
+ if (0 !== visitedUid.code) return searchPublishInfo_types_errorResponse("头条号账号信息获取失败,请检查账号状态", 414);
41434
40877
  const articleInfo = await http.api({
41435
40878
  method: "get",
41436
40879
  url: "https://mp.toutiao.com/api/feed/mp_provider/v1/",
@@ -41539,7 +40982,7 @@ var __webpack_exports__ = {};
41539
40982
  const size = onlySuccess ? 10 : pageSize > 20 ? 20 : pageSize;
41540
40983
  let begin = (lastPage ?? pageNum) - 1;
41541
40984
  const rawArticlesInfo = await fetchArticles(begin * size, size, token);
41542
- if (rawArticlesInfo.includes("请重新<a id='jumpUrl' href='/'>登录</a>")) return searchPublishInfo_types_errorResponse("微信公众号数据获取失败,请检查账号状态", 414);
40985
+ if (rawArticlesInfo.includes("请重新<a id='jumpUrl' href='/'>登录</a>")) return searchPublishInfo_types_errorResponse("登陆已失效,请重新登陆!", 414);
41543
40986
  const articlesInfo = ParsePublishPage(rawArticlesInfo);
41544
40987
  let articleCell = [];
41545
40988
  if (!onlySuccess && pageSize > 20) {
@@ -41701,7 +41144,7 @@ var __webpack_exports__ = {};
41701
41144
  const a1Cookie = cookies.find((it)=>"a1" === it.name)?.value;
41702
41145
  if (!a1Cookie) return {
41703
41146
  code: 414,
41704
- message: "小红书数据获取失败,请检查账号状态",
41147
+ message: "账号数据异常",
41705
41148
  data: {}
41706
41149
  };
41707
41150
  if (onlySuccess && 10 !== pageSize) return {
@@ -41820,7 +41263,7 @@ var __webpack_exports__ = {};
41820
41263
  }, "小红书文章数据获取成功");
41821
41264
  }
41822
41265
  const FetchArticlesParamsSchema = ActionCommonParamsSchema.extend({
41823
- platform: classic_schemas_string().describe("社交平台:weixin, toutiao, baijiahao, xiaohongshu, douyin, shipinhao"),
41266
+ platform: classic_schemas_string().describe("社交平台:weixin, toutiao, baijiahao, xiaohongshu"),
41824
41267
  token: schemas_union([
41825
41268
  classic_schemas_string(),
41826
41269
  classic_schemas_number()
@@ -41832,14 +41275,7 @@ var __webpack_exports__ = {};
41832
41275
  showOriginalData: classic_schemas_boolean().optional().describe("是否展示原始数据,默认false"),
41833
41276
  cursor: classic_schemas_number().optional().describe("仅用于微信分页游标,默认为空"),
41834
41277
  lastPage: classic_schemas_number().optional(),
41835
- containsArticle: classic_schemas_boolean().optional().describe("是否包含文章内容,默认false"),
41836
- status: classic_schemas_number().optional().describe("抖音作品状态:0=全部"),
41837
- includeAccount: classic_schemas_boolean().optional().describe("是否包含账号数据,默认true"),
41838
- postType: classic_schemas_enum([
41839
- "video",
41840
- "article",
41841
- "all"
41842
- ]).optional().describe("视频号作品类型:video=视频, article=图文, all=全部")
41278
+ containsArticle: classic_schemas_boolean().optional().describe("是否包含文章内容,默认false")
41843
41279
  });
41844
41280
  const FetchArticles = async (_task, params)=>{
41845
41281
  const { platform } = params;
@@ -41852,10 +41288,6 @@ var __webpack_exports__ = {};
41852
41288
  return handleBaijiahaoData(_task, params);
41853
41289
  case "xiaohongshu":
41854
41290
  return handleXiaohongshuData(_task, params);
41855
- case "douyin":
41856
- return handleDouyinData(_task, params);
41857
- case "shipinhao":
41858
- return handleShipinhaoData(_task, params);
41859
41291
  default:
41860
41292
  return success({}, "暂不支持该平台");
41861
41293
  }
@@ -43259,11 +42691,6 @@ var __webpack_exports__ = {};
43259
42691
  this.concurrentLimit = config.concurrentLimit || 4;
43260
42692
  this.singleFileSize = config.singleFileSize || 10485760;
43261
42693
  this.http = config.http || new Http();
43262
- this.reqOptions = {
43263
- timeout: config.timeout ?? 60000,
43264
- retries: config.retries ?? 3,
43265
- retryDelay: config.retryDelay ?? 2000
43266
- };
43267
42694
  }
43268
42695
  calculateMd5(buffer) {
43269
42696
  const MAX_SIZE = 5242880;
@@ -43320,7 +42747,7 @@ var __webpack_exports__ = {};
43320
42747
  url: filePath,
43321
42748
  method: "get",
43322
42749
  responseType: "arraybuffer"
43323
- }, this.reqOptions);
42750
+ });
43324
42751
  return Buffer.from(resp);
43325
42752
  }
43326
42753
  return external_node_fs_default().promises.readFile(filePath);
@@ -43350,7 +42777,7 @@ var __webpack_exports__ = {};
43350
42777
  headers,
43351
42778
  data: requestBody,
43352
42779
  defaultErrorMsg: "获取UploadID失败"
43353
- }, this.reqOptions);
42780
+ });
43354
42781
  if (!resp?.UploadID) throw new Error(`获取 UploadID 失败: ${resp?.errMsg || "未知错误"}`);
43355
42782
  return resp.UploadID;
43356
42783
  }
@@ -43371,7 +42798,7 @@ var __webpack_exports__ = {};
43371
42798
  headers,
43372
42799
  data: chunk,
43373
42800
  defaultErrorMsg: `分片 ${partNumber} 上传失败`
43374
- }, this.reqOptions);
42801
+ });
43375
42802
  if (resp?.errCode !== void 0 && 0 !== resp.errCode) throw new Error(`分片 ${partNumber} 上传失败: ${resp.errMsg}`);
43376
42803
  if (onProgress) onProgress(chunk.length);
43377
42804
  return resp.ETag || "";
@@ -43395,7 +42822,7 @@ var __webpack_exports__ = {};
43395
42822
  headers,
43396
42823
  data: requestBody,
43397
42824
  defaultErrorMsg: "确认分片上传失败"
43398
- }, this.reqOptions);
42825
+ });
43399
42826
  if (resp?.ListPartsResult?.Part) return resp.ListPartsResult.Part.map((p)=>({
43400
42827
  PartNumber: parseInt(p.PartNumber),
43401
42828
  ETag: p.ETag
@@ -43421,7 +42848,7 @@ var __webpack_exports__ = {};
43421
42848
  headers,
43422
42849
  data: requestBody,
43423
42850
  defaultErrorMsg: "完成上传失败"
43424
- }, this.reqOptions);
42851
+ });
43425
42852
  if (!resp?.DownloadURL) throw new Error(`完成上传失败: ${resp?.errMsg || "未知错误"}`);
43426
42853
  return resp.DownloadURL;
43427
42854
  }
@@ -43772,9 +43199,7 @@ var __webpack_exports__ = {};
43772
43199
  task.logger.info("[shipinhaoPublish] 开始执行视频号发布 - Mock API 方式");
43773
43200
  const updateTaskState = task.taskStageStore?.update?.bind(task.taskStageStore, task.taskId || "");
43774
43201
  if (!params.extraParam.fingerPrintDeviceId || !params.extraParam.aId) return utils_response(400, "fingerPrintDeviceId和aId 不能为空", "");
43775
- let currentStep = "初始化";
43776
43202
  try {
43777
- currentStep = "解析认证信息";
43778
43203
  const cookieString = params.cookies.map((c)=>`${c.name}=${c.value}`).join("; ");
43779
43204
  const fingerPrintDeviceId = params.extraParam.fingerPrintDeviceId;
43780
43205
  const aId = params.extraParam.aId;
@@ -43795,10 +43220,8 @@ var __webpack_exports__ = {};
43795
43220
  headers
43796
43221
  });
43797
43222
  const proxyHttp = new Http(...args);
43798
- currentStep = "验证发布参数";
43799
43223
  if (!params.banners || 0 === params.banners.length) return utils_response(400, "至少需要一张图片", "");
43800
43224
  const images = params.banners.slice(0, 18).filter((img)=>"string" == typeof img);
43801
- currentStep = "获取用户信息";
43802
43225
  task.logger.info("[shipinhaoPublish] 获取用户信息...");
43803
43226
  console.log("cookieString", cookieString);
43804
43227
  const userInfo = await mock_getUserInfo(cookieString, http);
@@ -43809,7 +43232,6 @@ var __webpack_exports__ = {};
43809
43232
  }
43810
43233
  const finderUsername = userInfo.data.finderUser.finderUsername;
43811
43234
  console.log(finderUsername);
43812
- currentStep = "获取上传认证密钥";
43813
43235
  task.logger.info("[shipinhaoPublish] 获取上传认证密钥...");
43814
43236
  const authKeyResponse = await getUploadAuthKey(cookieString, finderUsername, http);
43815
43237
  if (0 !== authKeyResponse.errCode || !authKeyResponse.data?.authKey) return utils_response(authKeyResponse.errCode || 500, `获取上传认证参数失败: ${authKeyResponse.errMsg}`, "");
@@ -43817,12 +43239,10 @@ var __webpack_exports__ = {};
43817
43239
  const uin = authKeyResponse.data.uin;
43818
43240
  if (!uin) return utils_response(500, "获取用户 uin 失败", "");
43819
43241
  const taskId = String(generateUUID());
43820
- currentStep = "上传图片";
43821
43242
  task.logger.info(`[shipinhaoPublish] 开始上传 ${images.length} 张图片...`);
43822
43243
  const uploadedImages = [];
43823
43244
  for(let i = 0; i < images.length; i++){
43824
- currentStep = `上传图片 ${i + 1}/${images.length}`;
43825
- task.logger.info(`[shipinhaoPublish] ${currentStep}...`);
43245
+ task.logger.info(`[shipinhaoPublish] 上传图片 ${i + 1}/${images.length}...`);
43826
43246
  const uploadResult = await uploadImageComplete(images[i], taskId, finderUsername, uin, authKey, http);
43827
43247
  console.log(JSON.stringify(uploadResult));
43828
43248
  if (!uploadResult.DownloadURL) return utils_response(500, `图片上传失败: ${uploadResult.errMsg}`, "");
@@ -43839,7 +43259,6 @@ var __webpack_exports__ = {};
43839
43259
  urlCdnTaskId: ""
43840
43260
  });
43841
43261
  }
43842
- currentStep = "发布图文内容";
43843
43262
  task.logger.info("[shipinhaoPublish] 正在发布...");
43844
43263
  const topicNames = params.topic || void 0;
43845
43264
  const addressInfo = params.address ? {
@@ -43926,15 +43345,9 @@ var __webpack_exports__ = {};
43926
43345
  });
43927
43346
  return utils_response(resultCode || 500, errorMessage, "");
43928
43347
  } catch (error) {
43929
- const handledError = Http.handleApiError(error);
43930
- const errorMsg = handledError.message || "发布失败,请稍后重试";
43931
- const errorCode = handledError.code || 500;
43932
- task.logger.error(`[shipinhaoPublish] 发布流程异常: ${errorMsg}`, stringifyError(error), handledError.extra);
43933
- await updateTaskState?.({
43934
- state: types_TaskState.FAILED,
43935
- error: errorMsg
43936
- });
43937
- return utils_response(errorCode, errorMsg, "");
43348
+ const errorMsg = error instanceof Error ? error.message : "发布失败";
43349
+ task.logger.error(`[shipinhaoPublish] 发布异常: ${errorMsg}`);
43350
+ return utils_response(500, errorMsg, "");
43938
43351
  }
43939
43352
  };
43940
43353
  const shipinhaoPublish_rpa_rpaAction = async (task, params)=>{
@@ -50440,24 +49853,6 @@ var __webpack_exports__ = {};
50440
49853
  likeNumYesterday: classic_schemas_number().nullable(),
50441
49854
  commentNumYesterday: classic_schemas_number().nullable()
50442
49855
  });
50443
- const douyinConfigDataSchema = classic_schemas_object({
50444
- fansNum: classic_schemas_number(),
50445
- favedNum: classic_schemas_number(),
50446
- fansNumLastWeek: classic_schemas_number(),
50447
- watchNumLastWeek: classic_schemas_number(),
50448
- likeNumLastWeek: classic_schemas_number(),
50449
- commentNumLastWeek: classic_schemas_number(),
50450
- shareNumLastWeek: classic_schemas_number(),
50451
- visitNumLastWeek: classic_schemas_number()
50452
- });
50453
- const shipinhaoConfigDataSchema = classic_schemas_object({
50454
- fansNum: classic_schemas_number(),
50455
- feedsCount: classic_schemas_number(),
50456
- fansNumYesterday: classic_schemas_number().nullable(),
50457
- playNumYesterday: classic_schemas_number().nullable(),
50458
- likeNumYesterday: classic_schemas_number().nullable(),
50459
- commentNumYesterday: classic_schemas_number().nullable()
50460
- });
50461
49856
  const BetaFlag = "HuiwenCanary";
50462
49857
  class Action {
50463
49858
  constructor(task){
@@ -50746,5 +50141,4 @@ if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_targe
50746
50141
  value: true
50747
50142
  });
50748
50143
 
50749
- //# sourceMappingURL=bundle.js.map
50750
- //# debugId=aed90b90-6fd5-5e1b-ba81-6ede67b0dc32
50144
+ //# sourceMappingURL=bundle.js.map