@iflyrpa/actions 1.2.7 → 1.2.8

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格式。",
@@ -2498,7 +2528,9 @@ class XsEncrypt {
2498
2528
  }
2499
2529
  }
2500
2530
  const xiaohongshuPublish_mock_errnoMap = {
2501
- 903: "账户已登出,需重新登陆重试!"
2531
+ 915: "所属C端账号手机号被修改,请重新登录",
2532
+ 903: "账户已登出,需重新登陆重试!",
2533
+ 902: "登录已过期,请重新登录!"
2502
2534
  };
2503
2535
  const xsEncrypt = new XsEncrypt();
2504
2536
  const xiaohongshuPublish_mock_mockAction = async (task, params)=>{
@@ -2568,13 +2600,34 @@ const xiaohongshuPublish_mock_mockAction = async (task, params)=>{
2568
2600
  };
2569
2601
  };
2570
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
+ }));
2571
2624
  const publishData = {
2572
2625
  common: {
2573
2626
  ats: [],
2574
2627
  biz_relations: [],
2575
2628
  desc: params?.content,
2576
2629
  goods_info: {},
2577
- hash_tag: [],
2630
+ hash_tag: params.topic || [],
2578
2631
  note_id: "",
2579
2632
  source: JSON.stringify({
2580
2633
  type: "web",
@@ -2692,6 +2745,7 @@ const xiaohongshuPublish_rpa_rpaAction = async (task, params)=>{
2692
2745
  '/api/galaxy/v2/creator/activity_center/list',
2693
2746
  '/web_api/sns/v5/creator/topic/template/list',
2694
2747
  '/web_api/sns/v5/creator/file/encryption',
2748
+ '/web_api/sns/capa/postgw/topic/batch_customized',
2695
2749
  '/web_api/sns/v2/note'
2696
2750
  ];
2697
2751
  await page.route('**', async (route, request)=>{
@@ -2713,11 +2767,11 @@ const xiaohongshuPublish_rpa_rpaAction = async (task, params)=>{
2713
2767
  });
2714
2768
  return;
2715
2769
  }
2716
- const isNoteRequest = urlObj.pathname.includes(interceptUrls[4]);
2770
+ const isNoteRequest = urlObj.pathname.includes(interceptUrls[5]);
2717
2771
  const xs = await (isNoteRequest ? (async ()=>{
2718
2772
  const publishData = JSON.parse(request.postData() || "");
2719
2773
  const publishDataStr = rpa_xsEncrypt.dumps(publishData);
2720
- return rpa_xsEncrypt.encryptXs(interceptUrls[4] + publishDataStr, a1Cookie, xt);
2774
+ return rpa_xsEncrypt.encryptXs(interceptUrls[5] + publishDataStr, a1Cookie, xt);
2721
2775
  })() : rpa_xsEncrypt.encryptXs(fetchCoverUrl, a1Cookie, xt));
2722
2776
  const newHeaders = {
2723
2777
  ...request.headers(),
@@ -2771,7 +2825,7 @@ const xiaohongshuPublish_rpa_rpaAction = async (task, params)=>{
2771
2825
  data: page.url()
2772
2826
  };
2773
2827
  }
2774
- await page.locator("#content-area .menu-container .publish-video a").click();
2828
+ await page.locator("#content-area .menu-container .publish-video .btn").click();
2775
2829
  await page.locator('.creator-container .header .creator-tab:not([style*="-9999px"]) .title').filter({
2776
2830
  hasText: /^上传图文$/
2777
2831
  }).click();
@@ -2788,7 +2842,15 @@ const xiaohongshuPublish_rpa_rpaAction = async (task, params)=>{
2788
2842
  await titleInstance.fill(params.title);
2789
2843
  const descInstance = page.locator(".editor-container #quillEditor .ql-editor");
2790
2844
  await descInstance.click();
2791
- 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
+ }
2792
2854
  const container = page.locator(".creator-container .content .scroll-content");
2793
2855
  await container.focus();
2794
2856
  await page.mouse.wheel(0, 500);
@@ -2797,8 +2859,8 @@ const xiaohongshuPublish_rpa_rpaAction = async (task, params)=>{
2797
2859
  }), params.address.name);
2798
2860
  if (params.selfDeclaration) {
2799
2861
  await page.locator(".media-settings .flexbox").filter({
2800
- hasText: "自主声明"
2801
- }).locator(".d-select-wrapper").click();
2862
+ hasText: "内容类型声明"
2863
+ }).locator(".d-select-placeholder").click();
2802
2864
  const poperInstance = await getPoperInstance();
2803
2865
  const selfDeclarationInstance = poperInstance.locator(".d-options .d-option");
2804
2866
  if ("fictional-rendition" === params.selfDeclaration.type) await selfDeclarationInstance.filter({
@@ -2875,7 +2937,7 @@ const xiaohongshuPublish = async (task, params)=>{
2875
2937
  return executeAction(xiaohongshuPublish_mock_mockAction, xiaohongshuPublish_rpa_rpaAction)(task, params);
2876
2938
  };
2877
2939
  var package_namespaceObject = {
2878
- i8: "1.2.6"
2940
+ i8: "1.2.7"
2879
2941
  };
2880
2942
  class Action {
2881
2943
  constructor(task){
@@ -2912,6 +2974,9 @@ class Action {
2912
2974
  xiaohongshuPublish(params) {
2913
2975
  return this.bindTask(xiaohongshuPublish, params);
2914
2976
  }
2977
+ searchXiaohongshuTopicList(params) {
2978
+ return this.bindTask(searchXiaohongshuTopicList, params);
2979
+ }
2915
2980
  searchXiaohongshuLocation(params) {
2916
2981
  return this.bindTask(searchXiaohongshuLocation, params);
2917
2982
  }