@iflyrpa/actions 4.0.4-beta.7 → 4.0.5

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