@iflyrpa/actions 1.2.6-beta.0 → 1.2.6-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -648,6 +648,36 @@ const searchXiaohongshuLocation = async (_task, params)=>{
648
648
  return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)([]);
649
649
  }
650
650
  };
651
+ const searchXiaohongshuTopicList = async (_task, params)=>{
652
+ const http = new Http({
653
+ headers: {
654
+ cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
655
+ referer: "https://creator.xiaohongshu.com",
656
+ origin: "https://creator.xiaohongshu.com"
657
+ }
658
+ });
659
+ try {
660
+ const result = await http.api({
661
+ method: "post",
662
+ url: "https://edith.xiaohongshu.com/web_api/sns/v1/search/topic",
663
+ data: {
664
+ keyword: params.searchValue,
665
+ suggest_topic_request: {
666
+ title: "",
667
+ desc: `#${params.searchValue}`
668
+ },
669
+ page: {
670
+ page_size: 20,
671
+ page: 1
672
+ }
673
+ },
674
+ defaultErrorMsg: "话题搜索异常,请稍后重试。"
675
+ });
676
+ return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(0 === result.code ? result.data.topic_info_dtos : [], '获取话题成功');
677
+ } catch (error) {
678
+ return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)([]);
679
+ }
680
+ };
651
681
  const mock_errnoMap = {
652
682
  20004020: "图片上传异常,请重新绑定账号后同步。",
653
683
  7115: "正文图片和封面图片推荐jpg、png格式。",
@@ -856,6 +886,10 @@ const rpa_rpaAction = async (task, params)=>{
856
886
  });
857
887
  } else await route.continue();
858
888
  });
889
+ PopupListener(page, '.byte-modal.publish-exclusive-modal .title', "激励", '.byte-modal-close-icon', {
890
+ checkInterval: 1000,
891
+ stopAfterClick: false
892
+ });
859
893
  const titleInstance = page.locator(".publish-editor-title-wrapper .publish-editor-title textarea");
860
894
  await titleInstance.click();
861
895
  await titleInstance.fill(params.title);
@@ -1128,7 +1162,10 @@ const weixinPublish_mock_errnoMap = {
1128
1162
  153201: "不支持发布审核中或转码中的视频",
1129
1163
  200007: "登陆失败,请重新登陆账户后重试。",
1130
1164
  64703: "摘要超出120字长度限制,请修改摘要后重试。",
1131
- "-4": "不支持发布审核中或转码中的视频"
1165
+ "-4": "不支持发布审核中或转码中的视频",
1166
+ "-2": "不支持发布审核中或转码中的视频",
1167
+ 770001: "不支持发布审核中或转码中的视频",
1168
+ 200074: "系统繁忙,请稍后重试!"
1132
1169
  };
1133
1170
  const ignoreErrno = [
1134
1171
  154019
@@ -2492,7 +2529,8 @@ class XsEncrypt {
2492
2529
  }
2493
2530
  }
2494
2531
  const xiaohongshuPublish_mock_errnoMap = {
2495
- 903: "账户已登出,需重新登陆重试!"
2532
+ 903: "账户已登出,需重新登陆重试!",
2533
+ 902: "登录已过期,请重新登录!"
2496
2534
  };
2497
2535
  const xsEncrypt = new XsEncrypt();
2498
2536
  const xiaohongshuPublish_mock_mockAction = async (task, params)=>{
@@ -2562,13 +2600,34 @@ const xiaohongshuPublish_mock_mockAction = async (task, params)=>{
2562
2600
  };
2563
2601
  };
2564
2602
  const coverInfos = await Promise.all(params.banners.map((it, idx)=>uploadFile(it, idx)));
2603
+ if (params.topic && params.topic.length > 0) await Promise.all(params.topic.map(async (topic)=>{
2604
+ if (!topic["id"]) {
2605
+ const topicData = {
2606
+ topic_names: topic["name"]
2607
+ };
2608
+ const topicDataStr = xsEncrypt.dumps(topicData);
2609
+ const publishXt = Date.now().toString();
2610
+ const publishXs = await xsEncrypt.encryptXs(`/web_api/sns/capa/postgw/topic/batch_customized${topicDataStr}`, a1Cookie, publishXt);
2611
+ let createTopic = await http.api({
2612
+ method: "POST",
2613
+ url: "https://edith.xiaohongshu.com/web_api/sns/capa/postgw/topic/batch_customized",
2614
+ headers: {
2615
+ "x-s": publishXs,
2616
+ "x-t": publishXt
2617
+ },
2618
+ data: topicData,
2619
+ defaultErrorMsg: "话题创建异常,请稍后重试。"
2620
+ });
2621
+ Object.assign(topic, createTopic.data.topic_infos[0]);
2622
+ }
2623
+ }));
2565
2624
  const publishData = {
2566
2625
  common: {
2567
2626
  ats: [],
2568
2627
  biz_relations: [],
2569
2628
  desc: params?.content,
2570
2629
  goods_info: {},
2571
- hash_tag: [],
2630
+ hash_tag: params.topic || [],
2572
2631
  note_id: "",
2573
2632
  source: JSON.stringify({
2574
2633
  type: "web",
@@ -2686,6 +2745,7 @@ const xiaohongshuPublish_rpa_rpaAction = async (task, params)=>{
2686
2745
  '/api/galaxy/v2/creator/activity_center/list',
2687
2746
  '/web_api/sns/v5/creator/topic/template/list',
2688
2747
  '/web_api/sns/v5/creator/file/encryption',
2748
+ '/web_api/sns/capa/postgw/topic/batch_customized',
2689
2749
  '/web_api/sns/v2/note'
2690
2750
  ];
2691
2751
  await page.route('**', async (route, request)=>{
@@ -2707,11 +2767,11 @@ const xiaohongshuPublish_rpa_rpaAction = async (task, params)=>{
2707
2767
  });
2708
2768
  return;
2709
2769
  }
2710
- const isNoteRequest = urlObj.pathname.includes(interceptUrls[4]);
2770
+ const isNoteRequest = urlObj.pathname.includes(interceptUrls[5]);
2711
2771
  const xs = await (isNoteRequest ? (async ()=>{
2712
2772
  const publishData = JSON.parse(request.postData() || "");
2713
2773
  const publishDataStr = rpa_xsEncrypt.dumps(publishData);
2714
- return rpa_xsEncrypt.encryptXs(interceptUrls[4] + publishDataStr, a1Cookie, xt);
2774
+ return rpa_xsEncrypt.encryptXs(interceptUrls[5] + publishDataStr, a1Cookie, xt);
2715
2775
  })() : rpa_xsEncrypt.encryptXs(fetchCoverUrl, a1Cookie, xt));
2716
2776
  const newHeaders = {
2717
2777
  ...request.headers(),
@@ -2765,7 +2825,7 @@ const xiaohongshuPublish_rpa_rpaAction = async (task, params)=>{
2765
2825
  data: page.url()
2766
2826
  };
2767
2827
  }
2768
- await page.locator("#content-area .menu-container .publish-video a").click();
2828
+ await page.locator("#content-area .menu-container .publish-video .btn").click();
2769
2829
  await page.locator('.creator-container .header .creator-tab:not([style*="-9999px"]) .title').filter({
2770
2830
  hasText: /^上传图文$/
2771
2831
  }).click();
@@ -2782,7 +2842,15 @@ const xiaohongshuPublish_rpa_rpaAction = async (task, params)=>{
2782
2842
  await titleInstance.fill(params.title);
2783
2843
  const descInstance = page.locator(".editor-container #quillEditor .ql-editor");
2784
2844
  await descInstance.click();
2785
- await descInstance.fill(params.content);
2845
+ await descInstance.pressSequentially(params.content.replace(/#.*?\[.*?]\#/g, ""));
2846
+ if (params.topic && params.topic.length > 0) for (const it of params.topic){
2847
+ await descInstance.pressSequentially(`#${it["name"]}`);
2848
+ await page.locator('.ql-mention-loading').waitFor({
2849
+ state: 'detached'
2850
+ });
2851
+ await page.waitForTimeout(1000);
2852
+ await page.locator('#quill-mention-item-0 .item-view-num').click();
2853
+ }
2786
2854
  const container = page.locator(".creator-container .content .scroll-content");
2787
2855
  await container.focus();
2788
2856
  await page.mouse.wheel(0, 500);
@@ -2791,8 +2859,8 @@ const xiaohongshuPublish_rpa_rpaAction = async (task, params)=>{
2791
2859
  }), params.address.name);
2792
2860
  if (params.selfDeclaration) {
2793
2861
  await page.locator(".media-settings .flexbox").filter({
2794
- hasText: "自主声明"
2795
- }).locator(".d-select-wrapper").click();
2862
+ hasText: "内容类型声明"
2863
+ }).locator(".d-select-placeholder").click();
2796
2864
  const poperInstance = await getPoperInstance();
2797
2865
  const selfDeclarationInstance = poperInstance.locator(".d-options .d-option");
2798
2866
  if ("fictional-rendition" === params.selfDeclaration.type) await selfDeclarationInstance.filter({
@@ -2868,9 +2936,7 @@ const xiaohongshuPublish = async (task, params)=>{
2868
2936
  if ("mockApi" === params.actionType) return xiaohongshuPublish_mock_mockAction(task, params);
2869
2937
  return executeAction(xiaohongshuPublish_mock_mockAction, xiaohongshuPublish_rpa_rpaAction)(task, params);
2870
2938
  };
2871
- var package_namespaceObject = {
2872
- i8: "1.2.5"
2873
- };
2939
+ var package_namespaceObject = JSON.parse('{"i8":"1.2.6-beta.1"}');
2874
2940
  class Action {
2875
2941
  constructor(task){
2876
2942
  this.task = task;
@@ -2905,6 +2971,9 @@ class Action {
2905
2971
  xiaohongshuPublish(params) {
2906
2972
  return this.bindTask(xiaohongshuPublish, params);
2907
2973
  }
2974
+ searchXiaohongshuTopicList(params) {
2975
+ return this.bindTask(searchXiaohongshuTopicList, params);
2976
+ }
2908
2977
  searchXiaohongshuLocation(params) {
2909
2978
  return this.bindTask(searchXiaohongshuLocation, params);
2910
2979
  }