@iflyrpa/actions 1.2.6 → 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/actions/searchXiaohongshuTopicList/index.d.ts +7 -0
- package/dist/actions/xiaohongshuPublish/index.d.ts +1 -0
- package/dist/bundle.js +78 -10
- package/dist/bundle.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +78 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +78 -10
- package/dist/index.mjs.map +1 -1
- package/dist/types.d.ts +6 -0
- package/package.json +1 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type CommonAction } from "@iflyrpa/share";
|
|
2
|
+
import type { ActiomCommonParams, Xiaohongshu } from "../../types";
|
|
3
|
+
export interface SearchXiaohongshuTopicListParams extends ActiomCommonParams {
|
|
4
|
+
searchValue: string;
|
|
5
|
+
}
|
|
6
|
+
export type PublishAction = CommonAction<SearchXiaohongshuTopicListParams, Xiaohongshu.Topic[]>;
|
|
7
|
+
export declare const searchXiaohongshuTopicList: PublishAction;
|
|
@@ -20,6 +20,7 @@ export interface XiaohongshuPublishParams extends ActiomCommonParams {
|
|
|
20
20
|
content: string;
|
|
21
21
|
address?: Xiaohongshu.Location;
|
|
22
22
|
selfDeclaration?: SelfDeclaration;
|
|
23
|
+
topic?: Xiaohongshu.Topic[];
|
|
23
24
|
visibleRange: "public" | "private";
|
|
24
25
|
isImmediatelyPublish?: boolean;
|
|
25
26
|
scheduledPublish?: string;
|
package/dist/bundle.js
CHANGED
|
@@ -13583,6 +13583,36 @@ var __webpack_exports__ = {};
|
|
|
13583
13583
|
return success([]);
|
|
13584
13584
|
}
|
|
13585
13585
|
};
|
|
13586
|
+
const searchXiaohongshuTopicList = async (_task, params)=>{
|
|
13587
|
+
const http = new Http({
|
|
13588
|
+
headers: {
|
|
13589
|
+
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
13590
|
+
referer: "https://creator.xiaohongshu.com",
|
|
13591
|
+
origin: "https://creator.xiaohongshu.com"
|
|
13592
|
+
}
|
|
13593
|
+
});
|
|
13594
|
+
try {
|
|
13595
|
+
const result = await http.api({
|
|
13596
|
+
method: "post",
|
|
13597
|
+
url: "https://edith.xiaohongshu.com/web_api/sns/v1/search/topic",
|
|
13598
|
+
data: {
|
|
13599
|
+
keyword: params.searchValue,
|
|
13600
|
+
suggest_topic_request: {
|
|
13601
|
+
title: "",
|
|
13602
|
+
desc: `#${params.searchValue}`
|
|
13603
|
+
},
|
|
13604
|
+
page: {
|
|
13605
|
+
page_size: 20,
|
|
13606
|
+
page: 1
|
|
13607
|
+
}
|
|
13608
|
+
},
|
|
13609
|
+
defaultErrorMsg: "话题搜索异常,请稍后重试。"
|
|
13610
|
+
});
|
|
13611
|
+
return success(0 === result.code ? result.data.topic_info_dtos : [], '获取话题成功');
|
|
13612
|
+
} catch (error) {
|
|
13613
|
+
return success([]);
|
|
13614
|
+
}
|
|
13615
|
+
};
|
|
13586
13616
|
const mock_errnoMap = {
|
|
13587
13617
|
20004020: "图片上传异常,请重新绑定账号后同步。",
|
|
13588
13618
|
7115: "正文图片和封面图片推荐jpg、png格式。",
|
|
@@ -13593,8 +13623,11 @@ var __webpack_exports__ = {};
|
|
|
13593
13623
|
"头条账号状态异常,资料审核未通过,请前往头条号查看。"
|
|
13594
13624
|
],
|
|
13595
13625
|
2007: "文章发布失败,声明原创要求正文字数不少于 300 字,请修改后重试。",
|
|
13626
|
+
2010: "无头条广告权限,请修改后重试。",
|
|
13627
|
+
3103: "今日头条号发布次数已达上限,请明天再试。",
|
|
13596
13628
|
1053: "正文图片和封面图片推荐jpg、png格式。",
|
|
13597
|
-
2005: "账号无【申明原创】权限,请关闭申明后重试。"
|
|
13629
|
+
2005: "账号无【申明原创】权限,请关闭申明后重试。",
|
|
13630
|
+
100004: "用户未登录或登陆已过期,请重新登陆后重试。"
|
|
13598
13631
|
};
|
|
13599
13632
|
const get3101DetailError = (errorList, message, saveType)=>{
|
|
13600
13633
|
let error = "";
|
|
@@ -15433,7 +15466,9 @@ var __webpack_exports__ = {};
|
|
|
15433
15466
|
}
|
|
15434
15467
|
}
|
|
15435
15468
|
const xiaohongshuPublish_mock_errnoMap = {
|
|
15436
|
-
|
|
15469
|
+
915: "所属C端账号手机号被修改,请重新登录",
|
|
15470
|
+
903: "账户已登出,需重新登陆重试!",
|
|
15471
|
+
902: "登录已过期,请重新登录!"
|
|
15437
15472
|
};
|
|
15438
15473
|
const xsEncrypt = new XsEncrypt();
|
|
15439
15474
|
const xiaohongshuPublish_mock_mockAction = async (task, params)=>{
|
|
@@ -15503,13 +15538,34 @@ var __webpack_exports__ = {};
|
|
|
15503
15538
|
};
|
|
15504
15539
|
};
|
|
15505
15540
|
const coverInfos = await Promise.all(params.banners.map((it, idx)=>uploadFile(it, idx)));
|
|
15541
|
+
if (params.topic && params.topic.length > 0) await Promise.all(params.topic.map(async (topic)=>{
|
|
15542
|
+
if (!topic["id"]) {
|
|
15543
|
+
const topicData = {
|
|
15544
|
+
topic_names: topic["name"]
|
|
15545
|
+
};
|
|
15546
|
+
const topicDataStr = xsEncrypt.dumps(topicData);
|
|
15547
|
+
const publishXt = Date.now().toString();
|
|
15548
|
+
const publishXs = await xsEncrypt.encryptXs(`/web_api/sns/capa/postgw/topic/batch_customized${topicDataStr}`, a1Cookie, publishXt);
|
|
15549
|
+
let createTopic = await http.api({
|
|
15550
|
+
method: "POST",
|
|
15551
|
+
url: "https://edith.xiaohongshu.com/web_api/sns/capa/postgw/topic/batch_customized",
|
|
15552
|
+
headers: {
|
|
15553
|
+
"x-s": publishXs,
|
|
15554
|
+
"x-t": publishXt
|
|
15555
|
+
},
|
|
15556
|
+
data: topicData,
|
|
15557
|
+
defaultErrorMsg: "话题创建异常,请稍后重试。"
|
|
15558
|
+
});
|
|
15559
|
+
Object.assign(topic, createTopic.data.topic_infos[0]);
|
|
15560
|
+
}
|
|
15561
|
+
}));
|
|
15506
15562
|
const publishData = {
|
|
15507
15563
|
common: {
|
|
15508
15564
|
ats: [],
|
|
15509
15565
|
biz_relations: [],
|
|
15510
15566
|
desc: params?.content,
|
|
15511
15567
|
goods_info: {},
|
|
15512
|
-
hash_tag: [],
|
|
15568
|
+
hash_tag: params.topic || [],
|
|
15513
15569
|
note_id: "",
|
|
15514
15570
|
source: JSON.stringify({
|
|
15515
15571
|
type: "web",
|
|
@@ -15627,6 +15683,7 @@ var __webpack_exports__ = {};
|
|
|
15627
15683
|
'/api/galaxy/v2/creator/activity_center/list',
|
|
15628
15684
|
'/web_api/sns/v5/creator/topic/template/list',
|
|
15629
15685
|
'/web_api/sns/v5/creator/file/encryption',
|
|
15686
|
+
'/web_api/sns/capa/postgw/topic/batch_customized',
|
|
15630
15687
|
'/web_api/sns/v2/note'
|
|
15631
15688
|
];
|
|
15632
15689
|
await page.route('**', async (route, request)=>{
|
|
@@ -15648,11 +15705,11 @@ var __webpack_exports__ = {};
|
|
|
15648
15705
|
});
|
|
15649
15706
|
return;
|
|
15650
15707
|
}
|
|
15651
|
-
const isNoteRequest = urlObj.pathname.includes(interceptUrls[
|
|
15708
|
+
const isNoteRequest = urlObj.pathname.includes(interceptUrls[5]);
|
|
15652
15709
|
const xs = await (isNoteRequest ? (async ()=>{
|
|
15653
15710
|
const publishData = JSON.parse(request.postData() || "");
|
|
15654
15711
|
const publishDataStr = rpa_xsEncrypt.dumps(publishData);
|
|
15655
|
-
return rpa_xsEncrypt.encryptXs(interceptUrls[
|
|
15712
|
+
return rpa_xsEncrypt.encryptXs(interceptUrls[5] + publishDataStr, a1Cookie, xt);
|
|
15656
15713
|
})() : rpa_xsEncrypt.encryptXs(fetchCoverUrl, a1Cookie, xt));
|
|
15657
15714
|
const newHeaders = {
|
|
15658
15715
|
...request.headers(),
|
|
@@ -15706,7 +15763,7 @@ var __webpack_exports__ = {};
|
|
|
15706
15763
|
data: page.url()
|
|
15707
15764
|
};
|
|
15708
15765
|
}
|
|
15709
|
-
await page.locator("#content-area .menu-container .publish-video
|
|
15766
|
+
await page.locator("#content-area .menu-container .publish-video .btn").click();
|
|
15710
15767
|
await page.locator('.creator-container .header .creator-tab:not([style*="-9999px"]) .title').filter({
|
|
15711
15768
|
hasText: /^上传图文$/
|
|
15712
15769
|
}).click();
|
|
@@ -15723,7 +15780,15 @@ var __webpack_exports__ = {};
|
|
|
15723
15780
|
await titleInstance.fill(params.title);
|
|
15724
15781
|
const descInstance = page.locator(".editor-container #quillEditor .ql-editor");
|
|
15725
15782
|
await descInstance.click();
|
|
15726
|
-
await descInstance.
|
|
15783
|
+
await descInstance.pressSequentially(params.content.replace(/#.*?\[.*?]\#/g, ""));
|
|
15784
|
+
if (params.topic && params.topic.length > 0) for (const it of params.topic){
|
|
15785
|
+
await descInstance.pressSequentially(`#${it["name"]}`);
|
|
15786
|
+
await page.locator('.ql-mention-loading').waitFor({
|
|
15787
|
+
state: 'detached'
|
|
15788
|
+
});
|
|
15789
|
+
await page.waitForTimeout(1000);
|
|
15790
|
+
await page.locator('#quill-mention-item-0 .item-view-num').click();
|
|
15791
|
+
}
|
|
15727
15792
|
const container = page.locator(".creator-container .content .scroll-content");
|
|
15728
15793
|
await container.focus();
|
|
15729
15794
|
await page.mouse.wheel(0, 500);
|
|
@@ -15732,8 +15797,8 @@ var __webpack_exports__ = {};
|
|
|
15732
15797
|
}), params.address.name);
|
|
15733
15798
|
if (params.selfDeclaration) {
|
|
15734
15799
|
await page.locator(".media-settings .flexbox").filter({
|
|
15735
|
-
hasText: "
|
|
15736
|
-
}).locator(".d-select-
|
|
15800
|
+
hasText: "内容类型声明"
|
|
15801
|
+
}).locator(".d-select-placeholder").click();
|
|
15737
15802
|
const poperInstance = await getPoperInstance();
|
|
15738
15803
|
const selfDeclarationInstance = poperInstance.locator(".d-options .d-option");
|
|
15739
15804
|
if ("fictional-rendition" === params.selfDeclaration.type) await selfDeclarationInstance.filter({
|
|
@@ -15810,7 +15875,7 @@ var __webpack_exports__ = {};
|
|
|
15810
15875
|
return executeAction(xiaohongshuPublish_mock_mockAction, xiaohongshuPublish_rpa_rpaAction)(task, params);
|
|
15811
15876
|
};
|
|
15812
15877
|
var package_namespaceObject = {
|
|
15813
|
-
i8: "1.2.
|
|
15878
|
+
i8: "1.2.7"
|
|
15814
15879
|
};
|
|
15815
15880
|
class Action {
|
|
15816
15881
|
constructor(task){
|
|
@@ -15847,6 +15912,9 @@ var __webpack_exports__ = {};
|
|
|
15847
15912
|
xiaohongshuPublish(params) {
|
|
15848
15913
|
return this.bindTask(xiaohongshuPublish, params);
|
|
15849
15914
|
}
|
|
15915
|
+
searchXiaohongshuTopicList(params) {
|
|
15916
|
+
return this.bindTask(searchXiaohongshuTopicList, params);
|
|
15917
|
+
}
|
|
15850
15918
|
searchXiaohongshuLocation(params) {
|
|
15851
15919
|
return this.bindTask(searchXiaohongshuLocation, params);
|
|
15852
15920
|
}
|