@iflyrpa/actions 4.0.5 → 4.0.6-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bundle.js CHANGED
@@ -12474,6 +12474,8 @@ var __webpack_exports__ = {};
12474
12474
  bjhConfigDataSchema: ()=>bjhConfigDataSchema,
12475
12475
  Action: ()=>Action,
12476
12476
  ProxyAgent: ()=>ProxyAgent,
12477
+ douyinConfigDataSchema: ()=>douyinConfigDataSchema,
12478
+ shipinhaoConfigDataSchema: ()=>shipinhaoConfigDataSchema,
12477
12479
  version: ()=>package_namespaceObject_0.i8
12478
12480
  });
12479
12481
  var common_utils_namespaceObject = {};
@@ -12488,9 +12490,7 @@ var __webpack_exports__ = {};
12488
12490
  var package_namespaceObject = {
12489
12491
  i8: "0.1.2"
12490
12492
  };
12491
- var package_namespaceObject_0 = {
12492
- i8: "4.0.5"
12493
- };
12493
+ var package_namespaceObject_0 = JSON.parse('{"i8":"4.0.6-beta.0"}');
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,11 +27270,12 @@ 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
- errorResponse.message = errorResponse.message ? errorResponse.message : _message;
27277
+ if (error.code && !error.response?.data) errorResponse.message = _message || errorResponse.message;
27278
+ else errorResponse.message = errorResponse.message ? errorResponse.message : _message;
27278
27279
  if ("canceled" === errorResponse.message) {
27279
27280
  const message = errorResponse.extra?.isProxyRequest ? "代理连接建立超时,请更换区域或稍后重试!" : "网络请求超时,请稍后重试!";
27280
27281
  errorResponse.message = message;
@@ -38513,400 +38514,421 @@ var __webpack_exports__ = {};
38513
38514
  }
38514
38515
  return randomString;
38515
38516
  }
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
+ }
38516
38525
  const mock_mockAction = async (task, params)=>{
38517
38526
  const updateTaskState = task.taskStageStore?.update?.bind(task.taskStageStore, task.taskId || "");
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 参数缺失或不完整", "");
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: ""
38581
- },
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: "{}"
38527
+ if (!params.extraParam || !params.extraParam["security-sdk/s_sdk_sign_data_key/web_protect"] || !params.extraParam["security-sdk/s_sdk_server_cert_key"] || !params.extraParam["security-sdk/s_sdk_crypt_sdk"]) return 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
+ }
38592
38606
  }
38593
- }
38594
- };
38595
- const args = [
38596
- {
38607
+ };
38608
+ const args = [
38609
+ {
38610
+ headers
38611
+ },
38612
+ task.logger,
38613
+ "",
38614
+ "",
38615
+ params.accountId,
38616
+ "douyin"
38617
+ ];
38618
+ const http = new Http({
38597
38619
  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
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;
38659
+ }
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 ? 500 : responseData.status_code;
38664
+ if (4 === responseData.status_code) task.logger.warn(`[douyinPublish] 抖音服务器错误 status_code: 4,映射为 500 触发重试。原始响应: ${JSON.stringify(responseData)}`);
38665
+ return {
38666
+ code: errorCode,
38667
+ message: responseData.status_msg || "文章发布异常,请稍后重试。",
38668
+ data: responseData
38624
38669
  };
38625
38670
  }
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);
38626
38683
  }
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
- })));
38635
- }
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;
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}`);
38646
38707
  }
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
- };
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 解析失败,请重新获取后重试", "");
38657
38718
  }
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
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 缺失,请重新获取后重试", "");
38667
38725
  }
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 不完整,请重新获取后重试", "");
38726
+ } catch (error) {
38727
+ task.logger.error(`[douyinPublish] 解析 certificate 失败: ${error}`);
38728
+ return utils_response(414, "安全参数 certificate 解析失败,请重新获取后重试", "");
38677
38729
  }
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;
38730
+ const ree_public_key = webProtectData.client_cert.replace("pub.", "");
38731
+ let bdTicketGuardClientData;
38732
+ try {
38733
+ bdTicketGuardClientData = getBdV2({
38734
+ ticket,
38735
+ ts_sign: ts_sign,
38736
+ ec_privateKey: ec_privateKey,
38737
+ certificate: certificate,
38738
+ bd_ticket_guard_ree_public_key: ree_public_key
38739
+ });
38740
+ if (!bdTicketGuardClientData || !bdTicketGuardClientData["headers_bd_ticket_guard_client_data"]) {
38741
+ task.logger.error(`[douyinPublish] bdTicketGuardClientData 生成失败或不完整: ${JSON.stringify(bdTicketGuardClientData)}`);
38742
+ return utils_response(414, "安全参数 bdTicketGuardClientData 生成失败,请重新获取后重试", "");
38743
+ }
38744
+ } catch (error) {
38745
+ task.logger.error(`[douyinPublish] 生成 bdTicketGuardClientData 失败: ${error}`);
38746
+ return utils_response(414, "安全参数 bdTicketGuardClientData 生成异常,请重新获取后重试", "");
38691
38747
  }
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 缺失,请重新获取后重试", "");
38748
+ task.logger.info("[douyinPublish] bdTicketGuardClientData 生成成功");
38749
+ const publishQuery = {
38750
+ ...publishParams,
38751
+ a_bogus: ""
38752
+ };
38753
+ const queryString = new URLSearchParams(publishQuery).toString();
38754
+ let aBogus;
38755
+ try {
38756
+ aBogus = mock_getABogus(`https://creator.douyin.com/web/api/media/aweme/create_v2/?${queryString}`, publishData, userAgent);
38757
+ if (!aBogus || aBogus.length < 10) {
38758
+ task.logger.error(`[douyinPublish] a_bogus 生成异常,长度过短: ${aBogus}`);
38759
+ return utils_response(414, "安全参数 a_bogus 生成失败,请重试", "");
38760
+ }
38761
+ } catch (error) {
38762
+ task.logger.error(`[douyinPublish] 生成 a_bogus 失败: ${error}`);
38763
+ return utils_response(414, "安全参数 a_bogus 生成异常,请重试", "");
38701
38764
  }
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 缺失,请重新获取后重试", "");
38765
+ publishQuery.a_bogus = aBogus;
38766
+ const publishQueryParams = new URLSearchParams(publishQuery).toString();
38767
+ let csrfToken;
38768
+ try {
38769
+ csrfToken = mock_generateCsrfTokenAdvanced({
38770
+ cookies: params.cookies,
38771
+ url: "https://creator.douyin.com/web/api/media/aweme/create_v2/",
38772
+ method: "POST",
38773
+ userAgent
38774
+ });
38775
+ if (!csrfToken || csrfToken.length < 10) {
38776
+ task.logger.error(`[douyinPublish] csrfToken 生成异常,长度过短: ${csrfToken}`);
38777
+ return utils_response(414, "安全参数 csrfToken 生成失败,请重试", "");
38778
+ }
38779
+ task.logger.info(`[douyinPublish] csrfToken 生成成功: ${csrfToken.substring(0, 20)}...`);
38780
+ } catch (error) {
38781
+ task.logger.error(`[douyinPublish] 生成 csrfToken 失败: ${error}`);
38782
+ return utils_response(414, "安全参数 csrfToken 生成异常,请重试", "");
38712
38783
  }
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 生成失败,请重新获取后重试", "");
38784
+ let sessionDtrait;
38785
+ try {
38786
+ sessionDtrait = mock_generateDtrait("/web/api/media/aweme/create_v2/");
38787
+ task.logger.info(`[douyinPublish] sessionDtrait 生成成功: ${sessionDtrait || "(空)"}`);
38788
+ } catch (error) {
38789
+ task.logger.error(`[douyinPublish] 生成 sessionDtrait 失败: ${error}`);
38790
+ return utils_response(414, "安全参数 sessionDtrait 生成异常,请重试", "");
38730
38791
  }
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 生成失败,请重试", "");
38792
+ task.logger.info(`[douyinPublish] headers: ${JSON.stringify({
38793
+ ...headers,
38794
+ Referer: "https://creator.douyin.com/creator-micro/content/post/image?default-tab=3&enter_from=publish_page&media_type=image&type=new",
38795
+ "Content-Type": "application/json",
38796
+ Accept: "application/json, text/plain, */*",
38797
+ "bd-ticket-guard-client-data": bdTicketGuardClientData["headers_bd_ticket_guard_client_data"],
38798
+ "bd-ticket-guard-ree-public-key": bdTicketGuardClientData["headers_bd_ticket_guard_ree_public_key"],
38799
+ "bd-ticket-guard-version": "2",
38800
+ "bd-ticket-guard-web-sign-type": "1",
38801
+ "bd-ticket-guard-web-version": "2",
38802
+ "x-secsdk-csrf-token": csrfToken,
38803
+ "x-tt-session-dtrait": sessionDtrait || ""
38804
+ })}`);
38805
+ task.logger.info(`[douyinPublish] url: https://creator.douyin.com/web/api/media/aweme/create_v2/?${publishQueryParams}`);
38806
+ let publishResult;
38807
+ try {
38808
+ publishResult = await proxyHttp.api({
38809
+ method: "post",
38810
+ url: `https://creator.douyin.com/web/api/media/aweme/create_v2/?${publishQueryParams}`,
38811
+ data: publishData,
38812
+ defaultErrorMsg: "发布异常,请稍后重试。",
38813
+ headers: {
38814
+ ...headers,
38815
+ Referer: "https://creator.douyin.com/creator-micro/content/post/image?default-tab=3&enter_from=publish_page&media_type=image&type=new",
38816
+ "Content-Type": "application/json",
38817
+ Accept: "application/json, text/plain, */*",
38818
+ "bd-ticket-guard-client-data": bdTicketGuardClientData["headers_bd_ticket_guard_client_data"],
38819
+ "bd-ticket-guard-ree-public-key": bdTicketGuardClientData["headers_bd_ticket_guard_ree_public_key"],
38820
+ "bd-ticket-guard-version": "2",
38821
+ "bd-ticket-guard-web-sign-type": "1",
38822
+ "bd-ticket-guard-web-version": "2",
38823
+ "x-secsdk-csrf-token": csrfToken,
38824
+ "x-tt-session-dtrait": sessionDtrait || ""
38825
+ }
38826
+ }, {
38827
+ timeout: 60000,
38828
+ retries: 3,
38829
+ retryDelay: 2000
38830
+ });
38831
+ } catch (error) {
38832
+ const handledError = Http.handleApiError(error);
38833
+ const isProxyOrNetworkError = [
38834
+ 599,
38835
+ 500,
38836
+ 502,
38837
+ 503,
38838
+ 504
38839
+ ].includes(handledError.code);
38840
+ if (isProxyOrNetworkError) {
38841
+ const isProxyRequest = handledError.extra?.isProxyRequest === true;
38842
+ const errorType = 599 === handledError.code || isProxyRequest ? "代理错误" : "网络错误";
38843
+ const message = `图文发布失败,${errorType}:${handledError.message}${task.debug ? ` ${http.proxyInfo}` : ""}`;
38844
+ task.logger.error(`[douyinPublish] ${errorType},直接返回: ${message}`, stringifyError(handledError));
38845
+ await updateTaskState?.({
38846
+ state: types_TaskState.FAILED,
38847
+ error: message
38848
+ });
38849
+ return {
38850
+ code: 414,
38851
+ data: "",
38852
+ message
38853
+ };
38854
+ }
38855
+ throw error;
38747
38856
  }
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 生成失败,请重试", "");
38857
+ task.logger.info(`[douyinPublish] decision值: ${JSON.stringify(decision)}, needsVerification(decision): ${needsVerification(decision)}`);
38858
+ if (needsVerification(decision)) {
38859
+ const details = [
38860
+ publishResult.status_msg,
38861
+ decision?.verify_title,
38862
+ decision?.verify_desc
38863
+ ].filter(Boolean).join(" ");
38864
+ const message = `图文发布失败,原因:${details}${task.debug ? ` ${http.proxyInfo}` : ""}`;
38865
+ const safeDecision = safeSerialize(decision) ?? {};
38866
+ const mockData = {
38867
+ state: types_TaskState.FAILED,
38868
+ error: message,
38869
+ result: {
38870
+ ...safeDecision,
38871
+ data: decision,
38872
+ uploadedImgList: JSON.stringify(publishData.item.common.images)
38873
+ }
38874
+ };
38875
+ await updateTaskState?.(mockData);
38876
+ return {
38877
+ code: 0,
38878
+ data: mockData,
38879
+ message: "操作成功"
38880
+ };
38765
38881
  }
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));
38882
+ reportLogger({
38883
+ token: params.huiwenToken || "",
38884
+ enverionment: task.enverionment || "development",
38885
+ postId: params.articleId,
38886
+ eip: proxyHttp.proxyInfo,
38887
+ proxyIp: params.localIP,
38888
+ accountId: params.accountId,
38889
+ uid: params.uid,
38890
+ platform: "douyin",
38891
+ publishParams: publishData
38892
+ });
38893
+ task.logger.info(`[douyinPublish] 发布结果 ${JSON.stringify(publishResult)}`);
38894
+ const isSuccess = 0 === publishResult.status_code;
38895
+ const message = `图文发布${isSuccess ? "成功" : `失败,原因:${publishResult.status_msg} ${decision?.verify_title} ${decision?.verify_desc}`}${task.debug ? ` ${http.proxyInfo}` : ""}`;
38896
+ const data = isSuccess ? publishResult.item_id || "" : "";
38897
+ if (!isSuccess) {
38898
+ const safeDecision = safeSerialize(decision) ?? {};
38832
38899
  await updateTaskState?.({
38833
38900
  state: types_TaskState.FAILED,
38834
- error: message
38901
+ error: message,
38902
+ result: {
38903
+ ...safeDecision,
38904
+ data: safeDecision,
38905
+ uploadedImgList: JSON.stringify(publishData.item.common.images)
38906
+ }
38835
38907
  });
38836
38908
  return {
38837
38909
  code: 414,
38838
- data: "",
38910
+ data: safeDecision,
38839
38911
  message
38840
38912
  };
38841
38913
  }
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,
38914
+ await updateTaskState?.({
38915
+ state: types_TaskState.SUCCESS,
38857
38916
  result: {
38858
- ...decisionObj,
38859
- data: decision,
38860
- uploadedImgList: JSON.stringify(publishData.item.common.images)
38917
+ response: data
38861
38918
  }
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;
38919
+ });
38920
+ return utils_response(isSuccess ? 0 : 414, message, data);
38921
+ } catch (error) {
38922
+ const handledError = Http.handleApiError(error);
38923
+ const errorMsg = handledError.message || "发布失败";
38924
+ const errorCode = handledError.code || 500;
38925
+ task.logger.error(`[douyinPublish] 发布流程异常 (步骤: ${currentStep}): ${errorMsg}`, stringifyError(error), handledError.extra);
38888
38926
  await updateTaskState?.({
38889
38927
  state: types_TaskState.FAILED,
38890
- error: message,
38891
- result: {
38892
- ...decisionObj,
38893
- data: decision,
38894
- uploadedImgList: JSON.stringify(publishData.item.common.images)
38895
- }
38928
+ error: `${currentStep}失败: ${errorMsg}`
38896
38929
  });
38897
- return {
38898
- code: 414,
38899
- data,
38900
- message
38901
- };
38930
+ return utils_response(errorCode, errorMsg, "");
38902
38931
  }
38903
- await updateTaskState?.({
38904
- state: types_TaskState.SUCCESS,
38905
- result: {
38906
- response: data
38907
- }
38908
- });
38909
- return utils_response(isSuccess ? 0 : 414, message, data);
38910
38932
  };
38911
38933
  const douyinPublish_rpa_rpaAction = async (task, params)=>{
38912
38934
  const commonCookies = {
@@ -40432,6 +40454,241 @@ var __webpack_exports__ = {};
40432
40454
  };
40433
40455
  return success(bjhData, "百家号平台数据获取成功!");
40434
40456
  }
40457
+ async function getDouyinData(_task, params) {
40458
+ try {
40459
+ const sessionidCookie = params.cookies.find((it)=>"sessionid" === it.name)?.value;
40460
+ if (!sessionidCookie) return types_errorResponse("抖音账号数据异常,请重新绑定账号后重试。", 414);
40461
+ const csrfToken = params.cookies.find((it)=>"passport_csrf_token" === it.name)?.value || "";
40462
+ const headers = {
40463
+ cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
40464
+ referer: "https://creator.douyin.com/creator-micro/home",
40465
+ origin: "https://creator.douyin.com",
40466
+ "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",
40467
+ ...csrfToken ? {
40468
+ "x-secsdk-csrf-token": csrfToken
40469
+ } : {}
40470
+ };
40471
+ const args = [
40472
+ {
40473
+ headers
40474
+ },
40475
+ _task.logger,
40476
+ params.proxyLoc,
40477
+ params.localIP,
40478
+ params.accountId
40479
+ ];
40480
+ const http = new Http(...args);
40481
+ const toNum = (val)=>{
40482
+ if (null == val) return 0;
40483
+ const n = Number.parseInt(String(val).replace(/[+,]/g, ""), 10);
40484
+ return Number.isNaN(n) ? 0 : n;
40485
+ };
40486
+ const userProfileP = http.api({
40487
+ method: "get",
40488
+ url: "https://www.douyin.com/aweme/v1/web/user/profile/self/",
40489
+ params: {
40490
+ device_platform: "webapp",
40491
+ aid: "6383",
40492
+ channel: "channel_pc_web",
40493
+ pc_client_type: "1",
40494
+ version_code: "170400",
40495
+ version_name: "17.4.0",
40496
+ cookie_enabled: "true",
40497
+ platform: "PC"
40498
+ }
40499
+ }, {
40500
+ retries: 3,
40501
+ retryDelay: 100,
40502
+ timeout: 10000
40503
+ }).catch((e)=>{
40504
+ _task.logger.warn(`抖音用户信息获取失败: ${e instanceof Error ? e.message : String(e)}`);
40505
+ return null;
40506
+ });
40507
+ const overviewP = http.api({
40508
+ method: "get",
40509
+ url: "https://creator.douyin.com/aweme/janus/creator/data/overview/all/",
40510
+ params: {
40511
+ last_days_type: 1,
40512
+ aid: 2906,
40513
+ app_name: "aweme_creator_platform",
40514
+ device_platform: "web"
40515
+ }
40516
+ }, {
40517
+ retries: 3,
40518
+ retryDelay: 100,
40519
+ timeout: 5000
40520
+ }).catch((e)=>{
40521
+ _task.logger.warn(`抖音近7日数据获取失败(可能未开通数据中心或被风控): ${e instanceof Error ? e.message : String(e)}`);
40522
+ return null;
40523
+ });
40524
+ const [userProfile, overview] = await Promise.all([
40525
+ userProfileP,
40526
+ overviewP
40527
+ ]);
40528
+ let fansNum = 0;
40529
+ let favedNum = 0;
40530
+ let followingNum = 0;
40531
+ if (userProfile?.status_code === 0 && userProfile.user) {
40532
+ const user = userProfile.user;
40533
+ fansNum = toNum(user.follower_count);
40534
+ followingNum = toNum(user.following_count);
40535
+ favedNum = toNum(user.total_favorited);
40536
+ } else _task.logger.warn(`用户信息接口返回异常: status_code=${userProfile?.status_code}, msg=${userProfile?.status_msg}`);
40537
+ const ov = overview?.data;
40538
+ const douyinData = {
40539
+ fansNum,
40540
+ favedNum,
40541
+ fansNumLastWeek: toNum(ov?.new_fans?.last_period_incr),
40542
+ watchNumLastWeek: toNum(ov?.play?.last_period_incr),
40543
+ likeNumLastWeek: toNum(ov?.digg?.last_period_incr),
40544
+ commentNumLastWeek: toNum(ov?.comment?.last_period_incr),
40545
+ shareNumLastWeek: toNum(ov?.share?.last_period_incr),
40546
+ visitNumLastWeek: toNum(ov?.profile?.last_period_incr)
40547
+ };
40548
+ return success(douyinData, "抖音平台数据获取成功!");
40549
+ } catch (error) {
40550
+ if (error && "object" == typeof error && "code" in error && "message" in error) {
40551
+ const err = error;
40552
+ _task.logger.error(`抖音账号数据获取失败: ${err.message} (${err.code})`);
40553
+ return types_errorResponse(err.message, err.code);
40554
+ }
40555
+ const errMsg = error instanceof Error ? error.message : String(error);
40556
+ _task.logger.error(`抖音账号数据获取失败: ${errMsg}`);
40557
+ return types_errorResponse(errMsg || "抖音账号数据获取失败");
40558
+ }
40559
+ }
40560
+ async function getShipinhaoData(_task, params) {
40561
+ try {
40562
+ const sessionidCookie = params.cookies.find((it)=>"sessionid" === it.name)?.value;
40563
+ if (!sessionidCookie) return types_errorResponse("视频号账号数据异常,请重新绑定账号后重试。", 414);
40564
+ const uinCookie = params.cookies.find((it)=>"uin" === it.name || "wxuin" === it.name)?.value || "0000000000";
40565
+ const deviceIdCookie = params.cookies.find((it)=>"device_id" === it.name || "finger_print_device_id" === it.name)?.value;
40566
+ const aid = params.cookies.find((it)=>"_aid" === it.name)?.value || "9d3e0e9f-b842-498d-a273-4285d58df264";
40567
+ const finderId = params.cookies.find((it)=>"_log_finder_id" === it.name || "finder_id" === it.name)?.value || "";
40568
+ const headers = {
40569
+ cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
40570
+ referer: "https://channels.weixin.qq.com/platform",
40571
+ origin: "https://channels.weixin.qq.com",
40572
+ "content-type": "application/json",
40573
+ "X-WECHAT-UIN": uinCookie,
40574
+ ...deviceIdCookie ? {
40575
+ "finger-print-device-id": deviceIdCookie
40576
+ } : {}
40577
+ };
40578
+ const args = [
40579
+ {
40580
+ headers
40581
+ },
40582
+ _task.logger,
40583
+ params.proxyLoc,
40584
+ params.localIP,
40585
+ params.accountId
40586
+ ];
40587
+ const http = new Http(...args);
40588
+ const authData = await http.api({
40589
+ method: "post",
40590
+ url: "https://channels.weixin.qq.com/cgi-bin/mmfinderassistant-bin/auth/auth_data",
40591
+ params: {
40592
+ _aid: aid,
40593
+ _rid: `${Date.now().toString(16)}-${Math.random().toString(36).substring(2, 9)}`,
40594
+ _pageUrl: encodeURIComponent("https://channels.weixin.qq.com/platform")
40595
+ },
40596
+ data: {
40597
+ timestamp: Date.now().toString(),
40598
+ _log_finder_uin: "",
40599
+ _log_finder_id: finderId,
40600
+ rawKeyBuff: "",
40601
+ pluginSessionId: null,
40602
+ scene: 7,
40603
+ reqScene: 7
40604
+ }
40605
+ }, {
40606
+ retries: 3,
40607
+ retryDelay: 100,
40608
+ timeout: 5000
40609
+ });
40610
+ const AUTH_ERROR_CODES = [
40611
+ 300333,
40612
+ 300334,
40613
+ 300330,
40614
+ 300331,
40615
+ 300332
40616
+ ];
40617
+ if (authData.errCode && AUTH_ERROR_CODES.includes(authData.errCode)) {
40618
+ _task.logger.warn(`视频号登录已失效:${authData.errMsg} (${authData.errCode})`);
40619
+ return types_errorResponse("视频号账号信息获取失败,请检查账号状态", 414);
40620
+ }
40621
+ if (authData.errCode) {
40622
+ _task.logger.warn(`视频号账号API错误:${authData.errMsg} (${authData.errCode})`);
40623
+ return types_errorResponse(`视频号账号信息获取失败:${authData.errMsg || "未知错误"}`, 414);
40624
+ }
40625
+ const finderUser = authData.data?.finderUser;
40626
+ const now = new Date();
40627
+ const yesterday = new Date(now.getFullYear(), now.getMonth(), now.getDate() - 2);
40628
+ const startTs = Math.floor(yesterday.getTime() / 1000);
40629
+ const endTs = startTs + 86400;
40630
+ _task.logger.info(`视频号昨日数据范围 start: ${startTs} ~ end: ${endTs}`);
40631
+ let fansNumYesterday = 0;
40632
+ let playNumYesterday = 0;
40633
+ let likeNumYesterday = 0;
40634
+ let commentNumYesterday = 0;
40635
+ try {
40636
+ const statsData = await http.api({
40637
+ method: "post",
40638
+ url: "https://channels.weixin.qq.com/cgi-bin/mmfinderassistant-bin/statistic/new_post_total_data",
40639
+ params: {
40640
+ _aid: aid,
40641
+ _rid: `${Date.now().toString(16)}-${Math.random().toString(36).substring(2, 9)}`,
40642
+ _pageUrl: encodeURIComponent("https://channels.weixin.qq.com/platform")
40643
+ },
40644
+ data: {
40645
+ startTs: startTs.toString(),
40646
+ endTs: endTs.toString(),
40647
+ interval: 3,
40648
+ timestamp: Date.now().toString(),
40649
+ _log_finder_uin: "",
40650
+ _log_finder_id: finderId,
40651
+ rawKeyBuff: "",
40652
+ pluginSessionId: null,
40653
+ scene: 7,
40654
+ reqScene: 7
40655
+ }
40656
+ }, {
40657
+ retries: 3,
40658
+ retryDelay: 100,
40659
+ timeout: 5000
40660
+ });
40661
+ if (!statsData.errCode && statsData.data?.totalData) {
40662
+ const data = statsData.data.totalData;
40663
+ fansNumYesterday = Number.parseInt(data.follow?.[1] || "0", 10) || 0;
40664
+ playNumYesterday = Number.parseInt(data.browse?.[1] || "0", 10) || 0;
40665
+ likeNumYesterday = Number.parseInt(data.like?.[1] || "0", 10) || 0;
40666
+ commentNumYesterday = Number.parseInt(data.comment?.[1] || "0", 10) || 0;
40667
+ }
40668
+ } catch (error) {
40669
+ const errMsg = error instanceof Error ? error.message : String(error);
40670
+ _task.logger.warn(`视频号昨日数据获取失败(降级为null): ${errMsg}`);
40671
+ }
40672
+ const shipinhaoData = {
40673
+ fansNum: finderUser?.fansCount || 0,
40674
+ feedsCount: finderUser?.feedsCount || 0,
40675
+ fansNumYesterday,
40676
+ playNumYesterday,
40677
+ likeNumYesterday,
40678
+ commentNumYesterday
40679
+ };
40680
+ return success(shipinhaoData, "视频号平台数据获取成功!");
40681
+ } catch (error) {
40682
+ if (error && "object" == typeof error && "code" in error && "message" in error) {
40683
+ const err = error;
40684
+ _task.logger.error(`视频号账号数据获取失败: ${err.message} (${err.code})`);
40685
+ return types_errorResponse(err.message, err.code);
40686
+ }
40687
+ const errMsg = error instanceof Error ? error.message : String(error);
40688
+ _task.logger.error(`视频号账号数据获取失败: ${errMsg}`);
40689
+ return types_errorResponse(errMsg || "视频号账号数据获取失败");
40690
+ }
40691
+ }
40435
40692
  async function getToutiaoData(_task, params) {
40436
40693
  const http = new Http({
40437
40694
  headers: {
@@ -40530,7 +40787,7 @@ var __webpack_exports__ = {};
40530
40787
  userInfoHtmlPromise,
40531
40788
  userSummaryHtmlPromise
40532
40789
  ]);
40533
- if (userInfoHtml.includes("请重新<a id='jumpUrl' href='/'>登录</a>")) return types_errorResponse("Token已失效,请重新获取", 414);
40790
+ if (userInfoHtml.includes("请重新<a id='jumpUrl' href='/'>登录</a>")) return types_errorResponse("微信公众号数据获取失败,请检查账号状态", 414);
40534
40791
  const userInfoJson = exportWxCgiData(userInfoHtml);
40535
40792
  const userSummaryJson = exportWxCgiData(userSummaryHtml);
40536
40793
  const wxData = {
@@ -40607,7 +40864,9 @@ var __webpack_exports__ = {};
40607
40864
  "toutiao",
40608
40865
  "xiaohongshu",
40609
40866
  "weixin",
40610
- "baijiahao"
40867
+ "baijiahao",
40868
+ "douyin",
40869
+ "shipinhao"
40611
40870
  ])
40612
40871
  });
40613
40872
  const SearchAccountInfo = async (_task, params)=>{
@@ -40621,6 +40880,10 @@ var __webpack_exports__ = {};
40621
40880
  return getWeixinData(_task, params);
40622
40881
  case "baijiahao":
40623
40882
  return getBaijiahaoData(_task, params);
40883
+ case "douyin":
40884
+ return getDouyinData(_task, params);
40885
+ case "shipinhao":
40886
+ return getShipinhaoData(_task, params);
40624
40887
  default:
40625
40888
  return success(null, "暂不支持该平台");
40626
40889
  }
@@ -40715,18 +40978,45 @@ var __webpack_exports__ = {};
40715
40978
  collectNum: classic_schemas_number(),
40716
40979
  shareNum: classic_schemas_number()
40717
40980
  });
40981
+ const DouyinArticleSchema = BaseArticleSchema.extend({
40982
+ playNum: classic_schemas_number(),
40983
+ likeNum: classic_schemas_number(),
40984
+ commentNum: classic_schemas_number(),
40985
+ shareNum: classic_schemas_number(),
40986
+ collectNum: classic_schemas_number(),
40987
+ awemeId: classic_schemas_string(),
40988
+ awemeType: classic_schemas_number(),
40989
+ duration: classic_schemas_number().optional(),
40990
+ status: classic_schemas_string(),
40991
+ publicUrl: classic_schemas_string()
40992
+ });
40993
+ const ShipinhaoArticleSchema = BaseArticleSchema.extend({
40994
+ readNum: classic_schemas_number(),
40995
+ likeNum: classic_schemas_number(),
40996
+ commentNum: classic_schemas_number(),
40997
+ forwardNum: classic_schemas_number(),
40998
+ favNum: classic_schemas_number(),
40999
+ objectId: classic_schemas_string(),
41000
+ postType: classic_schemas_string(),
41001
+ postStatus: classic_schemas_number(),
41002
+ effectiveTime: classic_schemas_number().optional()
41003
+ });
40718
41004
  const FetchArticlesDataSchema = classic_schemas_object({
40719
41005
  articleCell: classic_schemas_array(schemas_union([
40720
41006
  ToutiaoArticleSchema,
40721
41007
  WeixinArticleSchema,
40722
41008
  BaijiahaoArticleSchema,
40723
- XiaohongshuArticleSchema
41009
+ XiaohongshuArticleSchema,
41010
+ DouyinArticleSchema,
41011
+ ShipinhaoArticleSchema
40724
41012
  ])).optional(),
40725
41013
  timerPublish: classic_schemas_array(schemas_union([
40726
41014
  ToutiaoArticleSchema,
40727
41015
  WeixinArticleSchema,
40728
41016
  BaijiahaoArticleSchema,
40729
- XiaohongshuArticleSchema
41017
+ XiaohongshuArticleSchema,
41018
+ DouyinArticleSchema,
41019
+ ShipinhaoArticleSchema
40730
41020
  ])).optional(),
40731
41021
  pagination: classic_schemas_object({
40732
41022
  total: classic_schemas_number().optional(),
@@ -40841,6 +41131,269 @@ var __webpack_exports__ = {};
40841
41131
  return searchPublishInfo_types_errorResponse(error instanceof Error ? error.message : "百家号文章数据获取失败");
40842
41132
  }
40843
41133
  }
41134
+ async function handleDouyinData(_task, params) {
41135
+ try {
41136
+ const { cookies, pageSize = 12, status = 0, showOriginalData = false, onlySuccess = false } = params;
41137
+ const pageNum = params.pageNum || 1;
41138
+ const headers = {
41139
+ cookie: cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
41140
+ referer: "https://creator.douyin.com"
41141
+ };
41142
+ const args = [
41143
+ {
41144
+ headers
41145
+ },
41146
+ _task.logger,
41147
+ params.proxyLoc,
41148
+ params.localIP,
41149
+ params.accountId
41150
+ ];
41151
+ const http = new Http(...args);
41152
+ async function fetchWorks(cursor) {
41153
+ return await http.api({
41154
+ method: "get",
41155
+ url: "https://creator.douyin.com/janus/douyin/creator/pc/work_list",
41156
+ params: {
41157
+ scene: "star_atlas",
41158
+ device_platform: "android",
41159
+ aid: 1128,
41160
+ status,
41161
+ count: pageSize,
41162
+ max_cursor: cursor
41163
+ }
41164
+ }, {
41165
+ retries: 3,
41166
+ retryDelay: 100,
41167
+ timeout: 5000
41168
+ });
41169
+ }
41170
+ const isHasMore = (v)=>true === v || 1 === v;
41171
+ const skipCount = (pageNum - 1) * pageSize;
41172
+ const needCount = skipCount + pageSize;
41173
+ const workListResponse = await fetchWorks(0);
41174
+ if (!workListResponse || !Array.isArray(workListResponse.aweme_list)) return searchPublishInfo_types_errorResponse("抖音数据获取失败,请检查账号状态", 414);
41175
+ const allWorks = [
41176
+ ...workListResponse.aweme_list
41177
+ ];
41178
+ let hasMore = isHasMore(workListResponse.has_more);
41179
+ let currentCursor = workListResponse.cursor ?? workListResponse.max_cursor ?? 0;
41180
+ let guard = 0;
41181
+ while(allWorks.length < needCount && hasMore && guard < 20){
41182
+ const nextPageResponse = await fetchWorks(currentCursor);
41183
+ if (!Array.isArray(nextPageResponse.aweme_list) || 0 === nextPageResponse.aweme_list.length) break;
41184
+ allWorks.push(...nextPageResponse.aweme_list);
41185
+ hasMore = isHasMore(nextPageResponse.has_more);
41186
+ currentCursor = nextPageResponse.cursor ?? nextPageResponse.max_cursor ?? currentCursor;
41187
+ guard++;
41188
+ }
41189
+ const finalWorks = allWorks.slice(skipCount, needCount);
41190
+ const articleCell = finalWorks.map((item)=>{
41191
+ const workDetailUrl = `https://creator.douyin.com/creator-micro/work-management/work-detail/${item.aweme_id}`;
41192
+ const workPublicUrl = item.share_url || `https://www.douyin.com/video/${item.aweme_id}`;
41193
+ let statusText;
41194
+ statusText = item.status?.is_delete ? "deleted" : item.status?.is_private ? "private" : item.status?.in_reviewing ? "reviewing" : "public";
41195
+ return {
41196
+ title: item.desc || "无作品描述",
41197
+ imageUrl: item.Cover?.url_list?.[0] || "",
41198
+ createTime: item.create_time,
41199
+ redirectUrl: workDetailUrl,
41200
+ playNum: item.statistics?.play_count || 0,
41201
+ likeNum: item.statistics?.digg_count || 0,
41202
+ commentNum: item.statistics?.comment_count || 0,
41203
+ shareNum: item.statistics?.share_count || 0,
41204
+ collectNum: item.statistics?.collect_count || 0,
41205
+ awemeId: item.aweme_id,
41206
+ awemeType: item.aweme_type ?? 0,
41207
+ duration: item.duration,
41208
+ status: statusText,
41209
+ publicUrl: workPublicUrl,
41210
+ ...showOriginalData ? {
41211
+ originalData: item
41212
+ } : {}
41213
+ };
41214
+ });
41215
+ return success({
41216
+ articleCell,
41217
+ ...onlySuccess ? {
41218
+ pagination: {
41219
+ total: workListResponse.total || allWorks.length,
41220
+ nextPage: hasMore,
41221
+ pageNum,
41222
+ pageSize
41223
+ }
41224
+ } : null
41225
+ }, "抖音数据获取成功");
41226
+ } catch (error) {
41227
+ return searchPublishInfo_types_errorResponse(error instanceof Error ? error.message : "抖音数据获取失败");
41228
+ }
41229
+ }
41230
+ async function handleShipinhaoData(_task, params) {
41231
+ try {
41232
+ const { cookies, postType = "all", pageSize = 10, showOriginalData = false } = params;
41233
+ const pageNum = params.pageNum || 1;
41234
+ const aidCookie = cookies.find((it)=>"_aid" === it.name)?.value;
41235
+ const aid = aidCookie || "9d3e0e9f-b842-498d-a273-4285d58df264";
41236
+ const uinCookie = cookies.find((it)=>"uin" === it.name || "wxuin" === it.name)?.value || "0000000000";
41237
+ const deviceIdCookie = cookies.find((it)=>"device_id" === it.name || "finger_print_device_id" === it.name)?.value;
41238
+ const headers = {
41239
+ cookie: cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
41240
+ referer: "https://channels.weixin.qq.com",
41241
+ origin: "https://channels.weixin.qq.com",
41242
+ "content-type": "application/json",
41243
+ "X-WECHAT-UIN": uinCookie,
41244
+ ...deviceIdCookie ? {
41245
+ "finger-print-device-id": deviceIdCookie
41246
+ } : {}
41247
+ };
41248
+ const args = [
41249
+ {
41250
+ headers
41251
+ },
41252
+ _task.logger,
41253
+ params.proxyLoc,
41254
+ params.localIP,
41255
+ params.accountId
41256
+ ];
41257
+ const http = new Http(...args);
41258
+ const finderIdCookie = cookies.find((it)=>"_log_finder_id" === it.name || "finder_id" === it.name)?.value || "";
41259
+ async function fetchPosts(currentPage, userpageType, pageUrl, rawKeyBuff = "") {
41260
+ return await http.api({
41261
+ method: "post",
41262
+ url: "https://channels.weixin.qq.com/micro/content/cgi-bin/mmfinderassistant-bin/post/post_list",
41263
+ params: {
41264
+ _aid: aid,
41265
+ _rid: `${Date.now().toString(16)}-${Math.random().toString(36).substring(2, 9)}`,
41266
+ _pageUrl: encodeURIComponent(pageUrl)
41267
+ },
41268
+ data: {
41269
+ pageSize,
41270
+ currentPage,
41271
+ userpageType,
41272
+ stickyOrder: true,
41273
+ timestamp: Date.now().toString(),
41274
+ _log_finder_uin: "",
41275
+ _log_finder_id: finderIdCookie,
41276
+ rawKeyBuff,
41277
+ pluginSessionId: null,
41278
+ scene: 7,
41279
+ reqScene: 7
41280
+ }
41281
+ }, {
41282
+ retries: 3,
41283
+ retryDelay: 100,
41284
+ timeout: 5000
41285
+ });
41286
+ }
41287
+ async function fetchAllPosts(userpageType, pageUrl) {
41288
+ const allPosts = [];
41289
+ let currentPage = 1;
41290
+ let rawKeyBuff = "";
41291
+ let continueFlag = true;
41292
+ let totalCount = 0;
41293
+ while(continueFlag){
41294
+ const response = await fetchPosts(currentPage, userpageType, pageUrl, rawKeyBuff);
41295
+ if (response.errCode && AUTH_ERROR_CODES.includes(response.errCode)) throw new Error(`AUTH_ERROR:${response.errMsg || "登录已失效"}`);
41296
+ if (response.errCode) {
41297
+ _task.logger.warn(`视频号API错误:${response.errMsg} (${response.errCode})`);
41298
+ throw new Error(`视频号API错误:${response.errMsg} (${response.errCode})`);
41299
+ }
41300
+ if (1 === currentPage) totalCount = response.data?.totalCount ?? 0;
41301
+ const posts = response.data?.list || response.posts || response.post_list || [];
41302
+ allPosts.push(...posts);
41303
+ continueFlag = response.data?.continueFlag ?? false;
41304
+ rawKeyBuff = response.data?.lastBuff || "";
41305
+ currentPage++;
41306
+ if (currentPage > 100) {
41307
+ _task.logger.warn("分页超过100页,停止请求");
41308
+ break;
41309
+ }
41310
+ }
41311
+ if (totalCount > 0 && allPosts.length !== totalCount) _task.logger.warn(`视频号分页可能不完整:期望${totalCount}条,实际${allPosts.length}条`);
41312
+ return {
41313
+ posts: allPosts,
41314
+ totalCount
41315
+ };
41316
+ }
41317
+ const mapPost = (item, forcePostType)=>{
41318
+ let imageUrl = "";
41319
+ if (item.desc?.media?.[0]?.thumbUrl) imageUrl = item.desc.media[0].thumbUrl;
41320
+ else if (item.desc?.media?.[0]?.coverUrl) imageUrl = item.desc.media[0].coverUrl;
41321
+ else if (item.cover?.url) imageUrl = item.cover.url;
41322
+ else if (item.media_url) imageUrl = item.media_url;
41323
+ const title = item.desc?.description || item.object_desc || "无标题";
41324
+ return {
41325
+ title,
41326
+ imageUrl,
41327
+ createTime: item.createTime || item.create_time,
41328
+ redirectUrl: "https://channels.weixin.qq.com/platform",
41329
+ readNum: item.readCount || item.read_count || 0,
41330
+ likeNum: item.likeCount || item.like_count || 0,
41331
+ commentNum: item.commentCount || item.comment_count || 0,
41332
+ forwardNum: item.forwardCount || item.forward_count || 0,
41333
+ favNum: item.favCount || item.fav_count || 0,
41334
+ objectId: item.exportId || item.objectId || "",
41335
+ postType: forcePostType,
41336
+ postStatus: item.status || item.post_status || 0,
41337
+ ...item.effectiveTime ? {
41338
+ effectiveTime: item.effectiveTime
41339
+ } : {},
41340
+ ...showOriginalData ? {
41341
+ originalData: item
41342
+ } : {}
41343
+ };
41344
+ };
41345
+ const allArticles = [];
41346
+ const needVideo = "all" === postType || "video" === postType;
41347
+ const needArticle = "all" === postType || "article" === postType;
41348
+ const AUTH_ERROR_CODES = [
41349
+ 300333,
41350
+ 300334,
41351
+ 300330,
41352
+ 300331,
41353
+ 300332
41354
+ ];
41355
+ let combinedTotal = 0;
41356
+ if (needVideo) try {
41357
+ const videoPageUrl = "https://channels.weixin.qq.com/micro/content/post/list";
41358
+ const { posts, totalCount } = await fetchAllPosts(11, videoPageUrl);
41359
+ const videoArticles = posts.filter((item)=>item.createTime || item.create_time).map((item)=>mapPost(item, "video"));
41360
+ allArticles.push(...videoArticles);
41361
+ combinedTotal += totalCount || videoArticles.length;
41362
+ } catch (error) {
41363
+ const errMsg = error instanceof Error ? error.message : String(error);
41364
+ if (errMsg.startsWith("AUTH_ERROR:")) throw error;
41365
+ _task.logger.warn(`获取视频号视频失败:${errMsg}`);
41366
+ }
41367
+ if (needArticle) try {
41368
+ const articlePageUrl = "https://channels.weixin.qq.com/micro/content/post/finderNewLifePostList";
41369
+ const { posts, totalCount } = await fetchAllPosts(10, articlePageUrl);
41370
+ const articleArticles = posts.filter((item)=>item.createTime || item.create_time).map((item)=>mapPost(item, "article"));
41371
+ allArticles.push(...articleArticles);
41372
+ combinedTotal += totalCount || articleArticles.length;
41373
+ } catch (error) {
41374
+ const errMsg = error instanceof Error ? error.message : String(error);
41375
+ if (errMsg.startsWith("AUTH_ERROR:")) throw error;
41376
+ _task.logger.warn(`获取视频号图文失败:${errMsg}`);
41377
+ }
41378
+ allArticles.sort((a, b)=>b.createTime - a.createTime);
41379
+ const total = allArticles.length;
41380
+ const start = (pageNum - 1) * pageSize;
41381
+ const pageItems = allArticles.slice(start, start + pageSize);
41382
+ return success({
41383
+ articleCell: pageItems,
41384
+ pagination: {
41385
+ total,
41386
+ nextPage: start + pageSize < total,
41387
+ pageNum,
41388
+ pageSize
41389
+ }
41390
+ }, "视频号数据获取成功");
41391
+ } catch (error) {
41392
+ const errMsg = error instanceof Error ? error.message : String(error);
41393
+ if (errMsg.startsWith("AUTH_ERROR:")) return searchPublishInfo_types_errorResponse("视频号数据获取失败,请检查账号状态", 414);
41394
+ return searchPublishInfo_types_errorResponse(errMsg || "视频号数据获取失败");
41395
+ }
41396
+ }
40844
41397
  async function handleToutiaoData(_task, params) {
40845
41398
  try {
40846
41399
  const { cookies, pageNum = 1, pageSize = 10, showOriginalData = false, onlySuccess = false, containsArticle = false } = params;
@@ -40873,7 +41426,7 @@ var __webpack_exports__ = {};
40873
41426
  app_id: 1231
40874
41427
  }
40875
41428
  });
40876
- if (0 !== visitedUid.code) return searchPublishInfo_types_errorResponse("头条号账号信息获取失败,请检查账号状态", 414);
41429
+ if (0 !== visitedUid.code) return searchPublishInfo_types_errorResponse("头条号数据获取失败,请检查账号状态", 414);
40877
41430
  const articleInfo = await http.api({
40878
41431
  method: "get",
40879
41432
  url: "https://mp.toutiao.com/api/feed/mp_provider/v1/",
@@ -40982,7 +41535,7 @@ var __webpack_exports__ = {};
40982
41535
  const size = onlySuccess ? 10 : pageSize > 20 ? 20 : pageSize;
40983
41536
  let begin = (lastPage ?? pageNum) - 1;
40984
41537
  const rawArticlesInfo = await fetchArticles(begin * size, size, token);
40985
- if (rawArticlesInfo.includes("请重新<a id='jumpUrl' href='/'>登录</a>")) return searchPublishInfo_types_errorResponse("登陆已失效,请重新登陆!", 414);
41538
+ if (rawArticlesInfo.includes("请重新<a id='jumpUrl' href='/'>登录</a>")) return searchPublishInfo_types_errorResponse("微信公众号数据获取失败,请检查账号状态", 414);
40986
41539
  const articlesInfo = ParsePublishPage(rawArticlesInfo);
40987
41540
  let articleCell = [];
40988
41541
  if (!onlySuccess && pageSize > 20) {
@@ -41144,7 +41697,7 @@ var __webpack_exports__ = {};
41144
41697
  const a1Cookie = cookies.find((it)=>"a1" === it.name)?.value;
41145
41698
  if (!a1Cookie) return {
41146
41699
  code: 414,
41147
- message: "账号数据异常",
41700
+ message: "小红书数据获取失败,请检查账号状态",
41148
41701
  data: {}
41149
41702
  };
41150
41703
  if (onlySuccess && 10 !== pageSize) return {
@@ -41263,7 +41816,7 @@ var __webpack_exports__ = {};
41263
41816
  }, "小红书文章数据获取成功");
41264
41817
  }
41265
41818
  const FetchArticlesParamsSchema = ActionCommonParamsSchema.extend({
41266
- platform: classic_schemas_string().describe("社交平台:weixin, toutiao, baijiahao, xiaohongshu"),
41819
+ platform: classic_schemas_string().describe("社交平台:weixin, toutiao, baijiahao, xiaohongshu, douyin, shipinhao"),
41267
41820
  token: schemas_union([
41268
41821
  classic_schemas_string(),
41269
41822
  classic_schemas_number()
@@ -41275,7 +41828,14 @@ var __webpack_exports__ = {};
41275
41828
  showOriginalData: classic_schemas_boolean().optional().describe("是否展示原始数据,默认false"),
41276
41829
  cursor: classic_schemas_number().optional().describe("仅用于微信分页游标,默认为空"),
41277
41830
  lastPage: classic_schemas_number().optional(),
41278
- containsArticle: classic_schemas_boolean().optional().describe("是否包含文章内容,默认false")
41831
+ containsArticle: classic_schemas_boolean().optional().describe("是否包含文章内容,默认false"),
41832
+ status: classic_schemas_number().optional().describe("抖音作品状态:0=全部"),
41833
+ includeAccount: classic_schemas_boolean().optional().describe("是否包含账号数据,默认true"),
41834
+ postType: classic_schemas_enum([
41835
+ "video",
41836
+ "article",
41837
+ "all"
41838
+ ]).optional().describe("视频号作品类型:video=视频, article=图文, all=全部")
41279
41839
  });
41280
41840
  const FetchArticles = async (_task, params)=>{
41281
41841
  const { platform } = params;
@@ -41288,6 +41848,10 @@ var __webpack_exports__ = {};
41288
41848
  return handleBaijiahaoData(_task, params);
41289
41849
  case "xiaohongshu":
41290
41850
  return handleXiaohongshuData(_task, params);
41851
+ case "douyin":
41852
+ return handleDouyinData(_task, params);
41853
+ case "shipinhao":
41854
+ return handleShipinhaoData(_task, params);
41291
41855
  default:
41292
41856
  return success({}, "暂不支持该平台");
41293
41857
  }
@@ -42691,6 +43255,11 @@ var __webpack_exports__ = {};
42691
43255
  this.concurrentLimit = config.concurrentLimit || 4;
42692
43256
  this.singleFileSize = config.singleFileSize || 10485760;
42693
43257
  this.http = config.http || new Http();
43258
+ this.reqOptions = {
43259
+ timeout: config.timeout ?? 60000,
43260
+ retries: config.retries ?? 3,
43261
+ retryDelay: config.retryDelay ?? 2000
43262
+ };
42694
43263
  }
42695
43264
  calculateMd5(buffer) {
42696
43265
  const MAX_SIZE = 5242880;
@@ -42747,7 +43316,7 @@ var __webpack_exports__ = {};
42747
43316
  url: filePath,
42748
43317
  method: "get",
42749
43318
  responseType: "arraybuffer"
42750
- });
43319
+ }, this.reqOptions);
42751
43320
  return Buffer.from(resp);
42752
43321
  }
42753
43322
  return external_node_fs_default().promises.readFile(filePath);
@@ -42777,7 +43346,7 @@ var __webpack_exports__ = {};
42777
43346
  headers,
42778
43347
  data: requestBody,
42779
43348
  defaultErrorMsg: "获取UploadID失败"
42780
- });
43349
+ }, this.reqOptions);
42781
43350
  if (!resp?.UploadID) throw new Error(`获取 UploadID 失败: ${resp?.errMsg || "未知错误"}`);
42782
43351
  return resp.UploadID;
42783
43352
  }
@@ -42798,7 +43367,7 @@ var __webpack_exports__ = {};
42798
43367
  headers,
42799
43368
  data: chunk,
42800
43369
  defaultErrorMsg: `分片 ${partNumber} 上传失败`
42801
- });
43370
+ }, this.reqOptions);
42802
43371
  if (resp?.errCode !== void 0 && 0 !== resp.errCode) throw new Error(`分片 ${partNumber} 上传失败: ${resp.errMsg}`);
42803
43372
  if (onProgress) onProgress(chunk.length);
42804
43373
  return resp.ETag || "";
@@ -42822,7 +43391,7 @@ var __webpack_exports__ = {};
42822
43391
  headers,
42823
43392
  data: requestBody,
42824
43393
  defaultErrorMsg: "确认分片上传失败"
42825
- });
43394
+ }, this.reqOptions);
42826
43395
  if (resp?.ListPartsResult?.Part) return resp.ListPartsResult.Part.map((p)=>({
42827
43396
  PartNumber: parseInt(p.PartNumber),
42828
43397
  ETag: p.ETag
@@ -42848,7 +43417,7 @@ var __webpack_exports__ = {};
42848
43417
  headers,
42849
43418
  data: requestBody,
42850
43419
  defaultErrorMsg: "完成上传失败"
42851
- });
43420
+ }, this.reqOptions);
42852
43421
  if (!resp?.DownloadURL) throw new Error(`完成上传失败: ${resp?.errMsg || "未知错误"}`);
42853
43422
  return resp.DownloadURL;
42854
43423
  }
@@ -43199,7 +43768,9 @@ var __webpack_exports__ = {};
43199
43768
  task.logger.info("[shipinhaoPublish] 开始执行视频号发布 - Mock API 方式");
43200
43769
  const updateTaskState = task.taskStageStore?.update?.bind(task.taskStageStore, task.taskId || "");
43201
43770
  if (!params.extraParam.fingerPrintDeviceId || !params.extraParam.aId) return utils_response(400, "fingerPrintDeviceId和aId 不能为空", "");
43771
+ let currentStep = "初始化";
43202
43772
  try {
43773
+ currentStep = "解析认证信息";
43203
43774
  const cookieString = params.cookies.map((c)=>`${c.name}=${c.value}`).join("; ");
43204
43775
  const fingerPrintDeviceId = params.extraParam.fingerPrintDeviceId;
43205
43776
  const aId = params.extraParam.aId;
@@ -43220,8 +43791,10 @@ var __webpack_exports__ = {};
43220
43791
  headers
43221
43792
  });
43222
43793
  const proxyHttp = new Http(...args);
43794
+ currentStep = "验证发布参数";
43223
43795
  if (!params.banners || 0 === params.banners.length) return utils_response(400, "至少需要一张图片", "");
43224
43796
  const images = params.banners.slice(0, 18).filter((img)=>"string" == typeof img);
43797
+ currentStep = "获取用户信息";
43225
43798
  task.logger.info("[shipinhaoPublish] 获取用户信息...");
43226
43799
  console.log("cookieString", cookieString);
43227
43800
  const userInfo = await mock_getUserInfo(cookieString, http);
@@ -43232,6 +43805,7 @@ var __webpack_exports__ = {};
43232
43805
  }
43233
43806
  const finderUsername = userInfo.data.finderUser.finderUsername;
43234
43807
  console.log(finderUsername);
43808
+ currentStep = "获取上传认证密钥";
43235
43809
  task.logger.info("[shipinhaoPublish] 获取上传认证密钥...");
43236
43810
  const authKeyResponse = await getUploadAuthKey(cookieString, finderUsername, http);
43237
43811
  if (0 !== authKeyResponse.errCode || !authKeyResponse.data?.authKey) return utils_response(authKeyResponse.errCode || 500, `获取上传认证参数失败: ${authKeyResponse.errMsg}`, "");
@@ -43239,10 +43813,12 @@ var __webpack_exports__ = {};
43239
43813
  const uin = authKeyResponse.data.uin;
43240
43814
  if (!uin) return utils_response(500, "获取用户 uin 失败", "");
43241
43815
  const taskId = String(generateUUID());
43816
+ currentStep = "上传图片";
43242
43817
  task.logger.info(`[shipinhaoPublish] 开始上传 ${images.length} 张图片...`);
43243
43818
  const uploadedImages = [];
43244
43819
  for(let i = 0; i < images.length; i++){
43245
- task.logger.info(`[shipinhaoPublish] 上传图片 ${i + 1}/${images.length}...`);
43820
+ currentStep = `上传图片 ${i + 1}/${images.length}`;
43821
+ task.logger.info(`[shipinhaoPublish] ${currentStep}...`);
43246
43822
  const uploadResult = await uploadImageComplete(images[i], taskId, finderUsername, uin, authKey, http);
43247
43823
  console.log(JSON.stringify(uploadResult));
43248
43824
  if (!uploadResult.DownloadURL) return utils_response(500, `图片上传失败: ${uploadResult.errMsg}`, "");
@@ -43259,6 +43835,7 @@ var __webpack_exports__ = {};
43259
43835
  urlCdnTaskId: ""
43260
43836
  });
43261
43837
  }
43838
+ currentStep = "发布图文内容";
43262
43839
  task.logger.info("[shipinhaoPublish] 正在发布...");
43263
43840
  const topicNames = params.topic || void 0;
43264
43841
  const addressInfo = params.address ? {
@@ -43345,9 +43922,15 @@ var __webpack_exports__ = {};
43345
43922
  });
43346
43923
  return utils_response(resultCode || 500, errorMessage, "");
43347
43924
  } catch (error) {
43348
- const errorMsg = error instanceof Error ? error.message : "发布失败";
43349
- task.logger.error(`[shipinhaoPublish] 发布异常: ${errorMsg}`);
43350
- return utils_response(500, errorMsg, "");
43925
+ const handledError = Http.handleApiError(error);
43926
+ const errorMsg = handledError.message || "发布失败,请稍后重试";
43927
+ const errorCode = handledError.code || 500;
43928
+ task.logger.error(`[shipinhaoPublish] 发布流程异常: ${errorMsg}`, stringifyError(error), handledError.extra);
43929
+ await updateTaskState?.({
43930
+ state: types_TaskState.FAILED,
43931
+ error: errorMsg
43932
+ });
43933
+ return utils_response(errorCode, errorMsg, "");
43351
43934
  }
43352
43935
  };
43353
43936
  const shipinhaoPublish_rpa_rpaAction = async (task, params)=>{
@@ -47862,8 +48445,8 @@ var __webpack_exports__ = {};
47862
48445
  params: fetchCoverParams
47863
48446
  }, {
47864
48447
  retries: 3,
47865
- retryDelay: 20,
47866
- timeout: 3000
48448
+ retryDelay: 500,
48449
+ timeout: 30000
47867
48450
  });
47868
48451
  for (const item of batchCoverIdInfo?.data?.uploadTempPermits ?? [])for (const fileId of item.fileIds)uploadInfos.push({
47869
48452
  bucket: item.bucket || "",
@@ -47882,8 +48465,8 @@ var __webpack_exports__ = {};
47882
48465
  params: fetchCoverParams
47883
48466
  }, {
47884
48467
  retries: 3,
47885
- retryDelay: 20,
47886
- timeout: 3000
48468
+ retryDelay: 500,
48469
+ timeout: 30000
47887
48470
  });
47888
48471
  for (const item of coverIdInfo?.data?.uploadTempPermits ?? [])for (const fileId of item.fileIds)uploadInfos.push({
47889
48472
  bucket: item.bucket || "",
@@ -47944,7 +48527,9 @@ var __webpack_exports__ = {};
47944
48527
  headers: {
47945
48528
  "x-cos-security-token": ossToken
47946
48529
  },
47947
- defaultErrorMsg: "图片上传异常,请稍后重试发布。"
48530
+ defaultErrorMsg: "图片上传异常,请稍后重试。"
48531
+ }, {
48532
+ timeout: 60000
47948
48533
  });
47949
48534
  return {
47950
48535
  ossFileId,
@@ -47954,6 +48539,8 @@ var __webpack_exports__ = {};
47954
48539
  originSize
47955
48540
  };
47956
48541
  } catch (error) {
48542
+ const e = Http.handleApiError(error);
48543
+ task.logger.warn(`[xhs upload] 第${attempt + 1}次失败 index=${index} bucket=${ossBucketIndex} domain=${ossDomain} fileId=${ossFileId} code=${e.code} msg=${e.message} data=${stringifyError(e.data)}`);
47957
48544
  attempt++;
47958
48545
  }
47959
48546
  }
@@ -48933,8 +49520,8 @@ var __webpack_exports__ = {};
48933
49520
  params: fetchCoverParams
48934
49521
  }, {
48935
49522
  retries: 3,
48936
- retryDelay: 20,
48937
- timeout: 3000
49523
+ retryDelay: 500,
49524
+ timeout: 8000
48938
49525
  });
48939
49526
  for (const item of batchCoverIdInfo?.data?.uploadTempPermits ?? [])for (const fileId of item?.fileIds ?? [])uploadInfos.push({
48940
49527
  bucket: item.bucket || "",
@@ -48953,8 +49540,8 @@ var __webpack_exports__ = {};
48953
49540
  params: fetchCoverParams
48954
49541
  }, {
48955
49542
  retries: 3,
48956
- retryDelay: 20,
48957
- timeout: 3000
49543
+ retryDelay: 500,
49544
+ timeout: 8000
48958
49545
  });
48959
49546
  for (const item of coverIdInfo?.data?.uploadTempPermits ?? [])for (const fileId of item?.fileIds ?? [])uploadInfos.push({
48960
49547
  bucket: item.bucket || "",
@@ -48999,6 +49586,8 @@ var __webpack_exports__ = {};
48999
49586
  "x-cos-security-token": ossToken
49000
49587
  },
49001
49588
  defaultErrorMsg: "图片上传异常,请稍后重试发布。"
49589
+ }, {
49590
+ timeout: 60000
49002
49591
  });
49003
49592
  return {
49004
49593
  ossFileId,
@@ -49853,6 +50442,24 @@ var __webpack_exports__ = {};
49853
50442
  likeNumYesterday: classic_schemas_number().nullable(),
49854
50443
  commentNumYesterday: classic_schemas_number().nullable()
49855
50444
  });
50445
+ const douyinConfigDataSchema = classic_schemas_object({
50446
+ fansNum: classic_schemas_number(),
50447
+ favedNum: classic_schemas_number(),
50448
+ fansNumLastWeek: classic_schemas_number(),
50449
+ watchNumLastWeek: classic_schemas_number(),
50450
+ likeNumLastWeek: classic_schemas_number(),
50451
+ commentNumLastWeek: classic_schemas_number(),
50452
+ shareNumLastWeek: classic_schemas_number(),
50453
+ visitNumLastWeek: classic_schemas_number()
50454
+ });
50455
+ const shipinhaoConfigDataSchema = classic_schemas_object({
50456
+ fansNum: classic_schemas_number(),
50457
+ feedsCount: classic_schemas_number(),
50458
+ fansNumYesterday: classic_schemas_number().nullable(),
50459
+ playNumYesterday: classic_schemas_number().nullable(),
50460
+ likeNumYesterday: classic_schemas_number().nullable(),
50461
+ commentNumYesterday: classic_schemas_number().nullable()
50462
+ });
49856
50463
  const BetaFlag = "HuiwenCanary";
49857
50464
  class Action {
49858
50465
  constructor(task){