@iflyrpa/actions 1.2.11-beta.2 → 1.2.11-beta.3
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/baijiahaoPublish/index.d.ts +5 -0
- package/dist/actions/getBaijiaohaoConfig/index.d.ts +13 -0
- package/dist/actions/searchToutiaoLocation/index.d.ts +7 -0
- package/dist/actions/searchToutiaoUserID/index.d.ts +7 -0
- package/dist/actions/toutiaoPublish/index.d.ts +15 -0
- package/dist/bundle.js +175 -41
- package/dist/bundle.js.map +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.js +175 -41
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +175 -41
- package/dist/index.mjs.map +1 -1
- package/dist/types.d.ts +14 -0
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1475,13 +1475,15 @@ const mockAction = async (task, params)=>{
|
|
|
1475
1475
|
is_checked: 1
|
|
1476
1476
|
}
|
|
1477
1477
|
] : [],
|
|
1478
|
-
...
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
}
|
|
1483
|
-
] : []
|
|
1478
|
+
...params.settingInfo.baijiahaoPublishConf?.map((item)=>({
|
|
1479
|
+
id: item.confName,
|
|
1480
|
+
is_checked: item.isChecked ? 1 : 0
|
|
1481
|
+
})) || []
|
|
1484
1482
|
];
|
|
1483
|
+
if (isAi && !activity_list.some((item)=>'aigc_bjh_status' in item)) activity_list.push({
|
|
1484
|
+
id: 'aigc_bjh_status',
|
|
1485
|
+
is_checked: 1
|
|
1486
|
+
});
|
|
1485
1487
|
const publishData = {
|
|
1486
1488
|
title: params.settingInfo.baijiahaoTitle,
|
|
1487
1489
|
content,
|
|
@@ -1497,6 +1499,7 @@ const mockAction = async (task, params)=>{
|
|
|
1497
1499
|
usingImgFilter: "false",
|
|
1498
1500
|
source: "upload",
|
|
1499
1501
|
cover_source: "upload",
|
|
1502
|
+
event2news: params.settingInfo?.baijiahaoEvent2News ? 2 : 0,
|
|
1500
1503
|
activity_list
|
|
1501
1504
|
};
|
|
1502
1505
|
params.settingInfo.timer && (publishData['timer_time'] = params.settingInfo.timer);
|
|
@@ -1604,12 +1607,17 @@ const rpaAction = async (task, params)=>{
|
|
|
1604
1607
|
await abstractFormItem.click();
|
|
1605
1608
|
await abstractFormItem.fill(params.settingInfo.baijiahaoAbstract);
|
|
1606
1609
|
const isAi = params.settingInfo.baijiahaoIsAi.includes("isAi");
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1610
|
+
const settingFormItem = page.locator(".bjh-edit-wrap-set .cheetah-form-item").nth(5);
|
|
1611
|
+
if (isAi) await settingFormItem.locator("label.cheetah-checkbox-wrapper").filter({
|
|
1612
|
+
hasText: "AI创作声明"
|
|
1613
|
+
}).click();
|
|
1614
|
+
if (params.settingInfo.baijiahaoPublishConf) for (const item of params.settingInfo.baijiahaoPublishConf){
|
|
1615
|
+
const _settingFormItem = settingFormItem.locator("label.cheetah-checkbox-wrapper").locator(`span.${item.confName}`);
|
|
1616
|
+
if (await _settingFormItem.isChecked() !== item.isChecked) await _settingFormItem.click();
|
|
1617
|
+
await page.waitForTimeout(200);
|
|
1612
1618
|
}
|
|
1619
|
+
const enent2NewsBtn = page.locator("input#event2news");
|
|
1620
|
+
if (await enent2NewsBtn.isVisible() && params.settingInfo.baijiahaoEvent2News) await enent2NewsBtn.click();
|
|
1613
1621
|
if (params.settingInfo.baijiahaoActivity.length > 0 && params.settingInfo.baijiahaoSelectActivityCache.length > 0) {
|
|
1614
1622
|
const activity = params.settingInfo.baijiahaoActivity.filter((it)=>params.settingInfo.baijiahaoSelectActivityCache.includes(it.id));
|
|
1615
1623
|
if (activity.length > 0) {
|
|
@@ -1704,6 +1712,7 @@ const rpaAction = async (task, params)=>{
|
|
|
1704
1712
|
hasText: /^发布/
|
|
1705
1713
|
}).locator("button").click();
|
|
1706
1714
|
});
|
|
1715
|
+
await page.waitForTimeout(200000);
|
|
1707
1716
|
await page.close();
|
|
1708
1717
|
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(articleId, articleId ? "发布成功" : message);
|
|
1709
1718
|
};
|
|
@@ -1790,6 +1799,28 @@ const getToutiaoConfig = async (_task, params)=>{
|
|
|
1790
1799
|
userRights
|
|
1791
1800
|
});
|
|
1792
1801
|
};
|
|
1802
|
+
const getBaijiahaoConfig = async (_task, params)=>{
|
|
1803
|
+
const cookies = params.cookies ?? [];
|
|
1804
|
+
const http = new Http({
|
|
1805
|
+
headers: {
|
|
1806
|
+
cookie: cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
1807
|
+
token: params.token
|
|
1808
|
+
}
|
|
1809
|
+
});
|
|
1810
|
+
const res = await http.api({
|
|
1811
|
+
method: "get",
|
|
1812
|
+
url: "https://baijiahao.baidu.com/pcui/article/edit",
|
|
1813
|
+
params: {
|
|
1814
|
+
type: "news"
|
|
1815
|
+
}
|
|
1816
|
+
});
|
|
1817
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(res?.data?.article.activity_list.map((_item)=>({
|
|
1818
|
+
id: _item.id,
|
|
1819
|
+
name: _item.name,
|
|
1820
|
+
detail: _item.detail,
|
|
1821
|
+
is_enable: _item.is_enable
|
|
1822
|
+
})) ?? [], "获取头条发布配置项成功");
|
|
1823
|
+
};
|
|
1793
1824
|
const searchToutiaoTopicList = async (_task, params)=>{
|
|
1794
1825
|
const http = new Http({
|
|
1795
1826
|
headers: {
|
|
@@ -1812,6 +1843,72 @@ const searchToutiaoTopicList = async (_task, params)=>{
|
|
|
1812
1843
|
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)([]);
|
|
1813
1844
|
}
|
|
1814
1845
|
};
|
|
1846
|
+
const searchToutiaoLocation = async (_task, params)=>{
|
|
1847
|
+
const http = new Http({
|
|
1848
|
+
headers: {
|
|
1849
|
+
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
1850
|
+
referer: "https://mp.toutiao.com/profile_v4/graphic/publish",
|
|
1851
|
+
biz: 1231
|
|
1852
|
+
}
|
|
1853
|
+
});
|
|
1854
|
+
try {
|
|
1855
|
+
const res = await http.api({
|
|
1856
|
+
method: "post",
|
|
1857
|
+
url: "https://mp.toutiao.com/poi/api/searchplace",
|
|
1858
|
+
data: {
|
|
1859
|
+
appid: 1231,
|
|
1860
|
+
device: 2,
|
|
1861
|
+
keywords: params.placeName,
|
|
1862
|
+
language: "zh-CN",
|
|
1863
|
+
location: "-1,-1",
|
|
1864
|
+
offset: 20,
|
|
1865
|
+
page: 1,
|
|
1866
|
+
region: "CN",
|
|
1867
|
+
scenario: "TIPS",
|
|
1868
|
+
timestamp: Math.floor(Date.now() / 1000)
|
|
1869
|
+
}
|
|
1870
|
+
});
|
|
1871
|
+
if (200 === res.code) return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(res.data.poi.map((item)=>({
|
|
1872
|
+
position: item.name,
|
|
1873
|
+
city: item.city,
|
|
1874
|
+
longitude: item.longitude,
|
|
1875
|
+
latitude: item.latitude,
|
|
1876
|
+
type_code: item.type_code,
|
|
1877
|
+
poi_id: item.id
|
|
1878
|
+
})));
|
|
1879
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)([]);
|
|
1880
|
+
} catch (error) {
|
|
1881
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)([]);
|
|
1882
|
+
}
|
|
1883
|
+
};
|
|
1884
|
+
const searchToutiaoUserInfo = async (_task, params)=>{
|
|
1885
|
+
const http = new Http({
|
|
1886
|
+
headers: {
|
|
1887
|
+
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
1888
|
+
referer: "https://mp.toutiao.com/profile_v4/graphic/publish"
|
|
1889
|
+
}
|
|
1890
|
+
});
|
|
1891
|
+
try {
|
|
1892
|
+
const res = await http.api({
|
|
1893
|
+
method: "get",
|
|
1894
|
+
url: "https://mp.toutiao.com/ugc/publish/post/v1/suggest/",
|
|
1895
|
+
params: {
|
|
1896
|
+
words: params.UserName,
|
|
1897
|
+
language: "zh",
|
|
1898
|
+
app_name: "toutiao_mp"
|
|
1899
|
+
}
|
|
1900
|
+
});
|
|
1901
|
+
if (0 === res.err_no) return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(res.data.suggest.map((item)=>({
|
|
1902
|
+
user_id: item.user.info.user_id,
|
|
1903
|
+
name: item.user.info.name,
|
|
1904
|
+
avatar_url: item.user.info.avatar_url,
|
|
1905
|
+
followers_count: item.user.relation_count.followers_count
|
|
1906
|
+
})), '搜索成功');
|
|
1907
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)([]);
|
|
1908
|
+
} catch (error) {
|
|
1909
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)([]);
|
|
1910
|
+
}
|
|
1911
|
+
};
|
|
1815
1912
|
const searchXiaohongshuLocation = async (_task, params)=>{
|
|
1816
1913
|
const http = new Http({
|
|
1817
1914
|
headers: {
|
|
@@ -1899,7 +1996,7 @@ const get3101DetailError = (errorList, message, saveType)=>{
|
|
|
1899
1996
|
return error || ("draft" === saveType ? "文章同步异常,请稍后重试。" : "文章发布异常,请稍后重试。");
|
|
1900
1997
|
};
|
|
1901
1998
|
const mock_mockAction = async (task, params)=>{
|
|
1902
|
-
const { toutiaoSingleCover, toutiaoMultCover, toutiaoCoverType, toutiaoOriginal } = params.settingInfo;
|
|
1999
|
+
const { toutiaoSingleCover, toutiaoMultCover, toutiaoCoverType, toutiaoOriginal, toutiaoExclusive, toutiaoClaim } = params.settingInfo;
|
|
1903
2000
|
const tmpCachePath = task.getTmpPath();
|
|
1904
2001
|
const http = new Http({
|
|
1905
2002
|
headers: {
|
|
@@ -1955,23 +2052,27 @@ const mock_mockAction = async (task, params)=>{
|
|
|
1955
2052
|
toutiaoSingleCover
|
|
1956
2053
|
] : "multiple" === toutiaoCoverType ? toutiaoMultCover : [];
|
|
1957
2054
|
const coverRes = await uploadImages(coverUrl);
|
|
1958
|
-
const isSingleTitle = "single" === params.settingInfo.toutiaoTitleType;
|
|
1959
2055
|
const location = params.settingInfo.toutiaoLocation;
|
|
1960
2056
|
const topics = params.settingInfo.toutiaoTopic || [];
|
|
1961
|
-
const multiTitleData = params.settingInfo.subTitles.map((title)=>({
|
|
1962
|
-
id: "0",
|
|
1963
|
-
visibility_level: 0,
|
|
1964
|
-
source: "author",
|
|
1965
|
-
old_source: "author",
|
|
1966
|
-
text: title,
|
|
1967
|
-
version: "author",
|
|
1968
|
-
ai_title: ""
|
|
1969
|
-
}));
|
|
1970
2057
|
const topicContent = topics.map((topic)=>`<p><a class="tteditor-forum" data-name="${topic.word}" data-id="${topic.id}" data-concern-id="${topic.id}">#${topic.word}#</a ></p >`).join("");
|
|
2058
|
+
let sourceData = {
|
|
2059
|
+
source_type: toutiaoClaim ? toutiaoClaim.type : 5
|
|
2060
|
+
};
|
|
2061
|
+
if (toutiaoClaim && 1 === toutiaoClaim.type) {
|
|
2062
|
+
if (!toutiaoClaim?.source_author_uid) return {
|
|
2063
|
+
code: 500,
|
|
2064
|
+
message: "请填写作者ID",
|
|
2065
|
+
data: ""
|
|
2066
|
+
};
|
|
2067
|
+
sourceData = {
|
|
2068
|
+
...sourceData,
|
|
2069
|
+
source_author_uid: toutiaoClaim.source_author_uid,
|
|
2070
|
+
time_format: toutiaoClaim.time_format,
|
|
2071
|
+
position: toutiaoClaim.position
|
|
2072
|
+
};
|
|
2073
|
+
}
|
|
1971
2074
|
const extraData = {
|
|
1972
2075
|
content_word_cnt: params.settingInfo.cntWord,
|
|
1973
|
-
is_multi_title: isSingleTitle ? 0 : 1,
|
|
1974
|
-
sub_titles: isSingleTitle ? [] : multiTitleData,
|
|
1975
2076
|
gd_ext: {
|
|
1976
2077
|
entrance: "",
|
|
1977
2078
|
from_page: "publisher_mp",
|
|
@@ -1980,12 +2081,7 @@ const mock_mockAction = async (task, params)=>{
|
|
|
1980
2081
|
is_message: 0
|
|
1981
2082
|
},
|
|
1982
2083
|
tuwen_wtt_trans_flag: "0",
|
|
1983
|
-
info_source:
|
|
1984
|
-
source_type: 5,
|
|
1985
|
-
source_link: "",
|
|
1986
|
-
time_format: "",
|
|
1987
|
-
position: {}
|
|
1988
|
-
},
|
|
2084
|
+
info_source: sourceData,
|
|
1989
2085
|
...location ? {
|
|
1990
2086
|
city: location.label,
|
|
1991
2087
|
city_code: location.value
|
|
@@ -2032,8 +2128,7 @@ const mock_mockAction = async (task, params)=>{
|
|
|
2032
2128
|
}
|
|
2033
2129
|
}))),
|
|
2034
2130
|
article_ad_type: getAddTypeValue(params.settingInfo.toutiaoAd),
|
|
2035
|
-
|
|
2036
|
-
claim_exclusive: toutiaoOriginal.includes("exclusive") ? 1 : 0
|
|
2131
|
+
claim_exclusive: toutiaoExclusive ? toutiaoExclusive : toutiaoOriginal.includes("exclusive") ? 1 : 0
|
|
2037
2132
|
};
|
|
2038
2133
|
const msToken = params.cookies.find((it)=>"msToken" === it.name)?.value;
|
|
2039
2134
|
let publishOption = {};
|
|
@@ -2202,11 +2297,38 @@ const rpa_rpaAction = async (task, params)=>{
|
|
|
2202
2297
|
}).locator("xpath=..");
|
|
2203
2298
|
const isAdOptionVisible = await adContainer.isVisible();
|
|
2204
2299
|
if (isAdOptionVisible) await adContainer.locator(`label.byte-radio:has(input[value="${getAddTypeValue(params.settingInfo.toutiaoAd)}"])`).click();
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2300
|
+
const exclusiveContainer = page.locator(".form-container .edit-cell .edit-label").filter({
|
|
2301
|
+
hasText: "声明首发"
|
|
2302
|
+
}).locator("xpath=..");
|
|
2303
|
+
if (params.settingInfo.toutiaoOriginal.includes("exclusive") || params.settingInfo.toutiaoExclusive) exclusiveContainer.locator(".exclusive .exclusive-checkbox-wraper .byte-checkbox").check();
|
|
2304
|
+
else exclusiveContainer.locator(".exclusive .exclusive-checkbox-wraper .byte-checkbox").uncheck();
|
|
2305
|
+
let claim = params.settingInfo.toutiaoClaim ? params.settingInfo.toutiaoClaim.type : 5;
|
|
2306
|
+
switch(claim){
|
|
2307
|
+
case 3:
|
|
2308
|
+
await page.locator(".source-wrap .byte-checkbox", {
|
|
2309
|
+
hasText: "引用AI"
|
|
2310
|
+
}).locator(".byte-checkbox-mask").check();
|
|
2311
|
+
break;
|
|
2312
|
+
case 4:
|
|
2313
|
+
await page.locator(".source-wrap .byte-checkbox", {
|
|
2314
|
+
hasText: "取材网络"
|
|
2315
|
+
}).locator(".byte-checkbox-mask").check();
|
|
2316
|
+
break;
|
|
2317
|
+
case 5:
|
|
2318
|
+
await page.locator(".source-wrap .byte-checkbox", {
|
|
2319
|
+
hasText: "个人观点,仅供参考"
|
|
2320
|
+
}).locator(".byte-checkbox-mask").check();
|
|
2321
|
+
break;
|
|
2322
|
+
case 6:
|
|
2323
|
+
await page.locator(".source-wrap .byte-checkbox", {
|
|
2324
|
+
hasText: "虚构演绎,故事经历"
|
|
2325
|
+
}).locator(".byte-checkbox-mask").check();
|
|
2326
|
+
break;
|
|
2327
|
+
default:
|
|
2328
|
+
await page.locator(".source-wrap .byte-checkbox", {
|
|
2329
|
+
hasText: "个人观点,仅供参考"
|
|
2330
|
+
}).locator(".byte-checkbox-mask").check();
|
|
2331
|
+
break;
|
|
2210
2332
|
}
|
|
2211
2333
|
const articleId = await new Promise(async (resolve)=>{
|
|
2212
2334
|
const handleResponse = async (response)=>{
|
|
@@ -2218,7 +2340,7 @@ const rpa_rpaAction = async (task, params)=>{
|
|
|
2218
2340
|
}
|
|
2219
2341
|
};
|
|
2220
2342
|
page.on("response", handleResponse);
|
|
2221
|
-
if (params.settingInfo.timer) {
|
|
2343
|
+
if (params.settingInfo.timer && "publish" == params.saveType) {
|
|
2222
2344
|
await page.locator(".publish-footer button").filter({
|
|
2223
2345
|
hasText: "定时发布"
|
|
2224
2346
|
}).click();
|
|
@@ -2264,7 +2386,7 @@ const rpa_rpaAction = async (task, params)=>{
|
|
|
2264
2386
|
}).click();
|
|
2265
2387
|
}
|
|
2266
2388
|
await page.close();
|
|
2267
|
-
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(articleId);
|
|
2389
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(articleId, "publish" === params.saveType ? "发布成功" : "保存草稿成功");
|
|
2268
2390
|
};
|
|
2269
2391
|
const COVER_TYPE = {
|
|
2270
2392
|
no: 1,
|
|
@@ -3050,7 +3172,7 @@ const weixinPublish_mock_mockAction = async (task, params)=>{
|
|
|
3050
3172
|
f: "json",
|
|
3051
3173
|
ajax: 1,
|
|
3052
3174
|
is_release_publish_page: params.masssend ? 0 : 1,
|
|
3053
|
-
send_time: 0,
|
|
3175
|
+
send_time: params.settingInfo.timer ? params.settingInfo.timer : 0,
|
|
3054
3176
|
random: Math.random().toString()
|
|
3055
3177
|
})
|
|
3056
3178
|
});
|
|
@@ -3204,6 +3326,9 @@ const weixinPublish_mock_mockAction = async (task, params)=>{
|
|
|
3204
3326
|
t: "ajax-response",
|
|
3205
3327
|
token: params.token,
|
|
3206
3328
|
lang: "zh_CN",
|
|
3329
|
+
...params.settingInfo.timer ? {
|
|
3330
|
+
action: "time_send"
|
|
3331
|
+
} : {},
|
|
3207
3332
|
...params.masssend ? {} : {
|
|
3208
3333
|
is_release_publish_page: 1
|
|
3209
3334
|
}
|
|
@@ -4353,7 +4478,7 @@ const xiaohongshuPublish = async (task, params)=>{
|
|
|
4353
4478
|
if ("mockApi" === params.actionType) return xiaohongshuPublish_mock_mockAction(task, params);
|
|
4354
4479
|
return executeAction(xiaohongshuPublish_mock_mockAction, xiaohongshuPublish_rpa_rpaAction)(task, params);
|
|
4355
4480
|
};
|
|
4356
|
-
var package_namespaceObject = JSON.parse('{"i8":"1.2.11-beta.
|
|
4481
|
+
var package_namespaceObject = JSON.parse('{"i8":"1.2.11-beta.2"}');
|
|
4357
4482
|
class Action {
|
|
4358
4483
|
constructor(task){
|
|
4359
4484
|
this.task = task;
|
|
@@ -4389,9 +4514,18 @@ class Action {
|
|
|
4389
4514
|
BjhFansExport(params) {
|
|
4390
4515
|
return this.bindTask(BjhFansExport, params);
|
|
4391
4516
|
}
|
|
4517
|
+
searchToutiaoUserID(params) {
|
|
4518
|
+
return this.bindTask(searchToutiaoUserInfo, params);
|
|
4519
|
+
}
|
|
4520
|
+
searchToutiaoLocation(params) {
|
|
4521
|
+
return this.bindTask(searchToutiaoLocation, params);
|
|
4522
|
+
}
|
|
4392
4523
|
getToutiaoConfig(params) {
|
|
4393
4524
|
return this.bindTask(getToutiaoConfig, params);
|
|
4394
4525
|
}
|
|
4526
|
+
getBaijiahaoConfig(params) {
|
|
4527
|
+
return this.bindTask(getBaijiahaoConfig, params);
|
|
4528
|
+
}
|
|
4395
4529
|
baijiahaoPublish(params) {
|
|
4396
4530
|
return this.bindTask(baijiahaoPublish, params);
|
|
4397
4531
|
}
|