@iflyrpa/actions 1.1.18 → 1.1.19
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/toutiaoPublish/index.d.ts +1 -0
- package/dist/bundle.js +24 -24
- package/dist/bundle.js.map +1 -1
- package/dist/index.js +24 -24
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +24 -24
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/bundle.js
CHANGED
|
@@ -12887,7 +12887,7 @@ var __webpack_exports__ = {};
|
|
|
12887
12887
|
addResponseInterceptor(findError) {
|
|
12888
12888
|
this.apiClient.interceptors.response.use((response)=>{
|
|
12889
12889
|
const error = findError(response);
|
|
12890
|
-
return error ? Promise.reject(error) : response
|
|
12890
|
+
return error ? Promise.reject(error) : response;
|
|
12891
12891
|
}, (error)=>{
|
|
12892
12892
|
const errorResponse = {
|
|
12893
12893
|
code: error.response?.status || 500,
|
|
@@ -12987,13 +12987,17 @@ var __webpack_exports__ = {};
|
|
|
12987
12987
|
message: "所有操作均失败",
|
|
12988
12988
|
data: null
|
|
12989
12989
|
};
|
|
12990
|
-
for
|
|
12991
|
-
const
|
|
12992
|
-
|
|
12993
|
-
|
|
12994
|
-
|
|
12995
|
-
|
|
12996
|
-
|
|
12990
|
+
for(let index = 0; index < actions.length; index++){
|
|
12991
|
+
const action = actions[index];
|
|
12992
|
+
try {
|
|
12993
|
+
const currentResult = await action(task, params);
|
|
12994
|
+
if (0 === currentResult.code) return currentResult;
|
|
12995
|
+
task.logger.error(currentResult.message, currentResult.data);
|
|
12996
|
+
result = currentResult;
|
|
12997
|
+
} catch (error) {
|
|
12998
|
+
result = Http.handleApiError(error);
|
|
12999
|
+
if (index !== actions.length - 1) task.logger.error(result.message, result.data);
|
|
13000
|
+
}
|
|
12997
13001
|
}
|
|
12998
13002
|
return result;
|
|
12999
13003
|
};
|
|
@@ -13147,31 +13151,29 @@ var __webpack_exports__ = {};
|
|
|
13147
13151
|
url: "https://baijiahao.baidu.com/builder/app/appinfo",
|
|
13148
13152
|
defaultErrorMsg: "创建草稿失败,请稍后重试。"
|
|
13149
13153
|
});
|
|
13150
|
-
const appId = appIdInfo.user.app_id;
|
|
13154
|
+
const appId = appIdInfo.data.user.app_id;
|
|
13151
13155
|
const uploadImages = async (_images)=>{
|
|
13152
13156
|
const images = _images.filter((url)=>!!url && "" !== url.trim());
|
|
13153
|
-
|
|
13157
|
+
return await Promise.all(images.map(async (url)=>{
|
|
13154
13158
|
const fileName = getFilenameFromUrl(url);
|
|
13155
|
-
|
|
13156
|
-
}));
|
|
13157
|
-
const orgList = await Promise.all(localImages.map(async (image)=>{
|
|
13159
|
+
const image = await downloadImage(url, external_node_path_default().join(tmpCachePath, fileName));
|
|
13158
13160
|
const formData = new (form_data_default())();
|
|
13161
|
+
formData.append("org_file_name", fileName);
|
|
13159
13162
|
formData.append("type", "image");
|
|
13163
|
+
formData.append("app_id", appId);
|
|
13160
13164
|
formData.append("is_waterlog", "1");
|
|
13161
13165
|
formData.append("save_material", "1");
|
|
13162
13166
|
formData.append("no_compress", "0");
|
|
13163
13167
|
formData.append("article_type", "news");
|
|
13164
|
-
formData.append("app_id", appId);
|
|
13165
13168
|
formData.append("media", external_node_fs_default().createReadStream(image));
|
|
13166
13169
|
const res = await http.api({
|
|
13167
13170
|
method: "post",
|
|
13168
|
-
url: "https://baijiahao.baidu.com/
|
|
13171
|
+
url: "https://baijiahao.baidu.com/materialui/picture/uploadProxy",
|
|
13169
13172
|
data: formData,
|
|
13170
13173
|
defaultErrorMsg: "draft" === params.saveType ? "图片上传异常,请稍后重试同步。" : "图片上传异常,请稍后重试发布。"
|
|
13171
13174
|
});
|
|
13172
13175
|
return res.ret;
|
|
13173
13176
|
}));
|
|
13174
|
-
return orgList;
|
|
13175
13177
|
};
|
|
13176
13178
|
const originContentImages = extractImgTag(params.content);
|
|
13177
13179
|
const targetContentImages = await uploadImages(originContentImages);
|
|
@@ -13535,6 +13537,7 @@ var __webpack_exports__ = {};
|
|
|
13535
13537
|
return error || ("draft" === saveType ? "文章同步异常,请稍后重试。" : "文章发布异常,请稍后重试。");
|
|
13536
13538
|
};
|
|
13537
13539
|
const mock_mockAction = async (task, params)=>{
|
|
13540
|
+
task.logger.info("开始头条 MockApi 发布");
|
|
13538
13541
|
const { toutiaoSingleCover, toutiaoMultCover, toutiaoCoverType, toutiaoOriginal } = params.settingInfo;
|
|
13539
13542
|
const tmpCachePath = task.getTmpPath();
|
|
13540
13543
|
const http = new Http({
|
|
@@ -13560,23 +13563,19 @@ var __webpack_exports__ = {};
|
|
|
13560
13563
|
url: "https://mp.toutiao.com/mp/agw/creator_center/user_info",
|
|
13561
13564
|
defaultErrorMsg: `头条号登录状态失效,请重新绑定账号后${"draft" === params.saveType ? "同步" : "发布"}。`
|
|
13562
13565
|
});
|
|
13563
|
-
const uploadImages = async (images)=>{
|
|
13564
|
-
const localImages = await Promise.all(images.map((url)=>{
|
|
13566
|
+
const uploadImages = async (images)=>await Promise.all(images.map(async (url)=>{
|
|
13565
13567
|
const fileName = getFilenameFromUrl(url);
|
|
13566
|
-
|
|
13567
|
-
}));
|
|
13568
|
-
return await Promise.all(localImages.map(async (image)=>{
|
|
13568
|
+
const image = await downloadImage(url, external_node_path_default().join(tmpCachePath, fileName));
|
|
13569
13569
|
const formData = new (form_data_default())();
|
|
13570
13570
|
formData.append("image", external_node_fs_default().createReadStream(image));
|
|
13571
13571
|
const response = await http.api({
|
|
13572
13572
|
method: "post",
|
|
13573
|
-
url: "https://mp.toutiao.com/spice/image?upload_source=
|
|
13573
|
+
url: "https://mp.toutiao.com/spice/image?upload_source=20020002&aid=1231&device_platform=web",
|
|
13574
13574
|
data: formData,
|
|
13575
13575
|
defaultErrorMsg: "draft" === params.saveType ? "图片上传异常,请稍后重试同步。" : "图片上传异常,请稍后重试发布。"
|
|
13576
13576
|
});
|
|
13577
13577
|
return response.data;
|
|
13578
13578
|
}));
|
|
13579
|
-
};
|
|
13580
13579
|
const originContentImages = extractImgTag(params.content);
|
|
13581
13580
|
const targetContentImages = await uploadImages(originContentImages);
|
|
13582
13581
|
const content = replaceImgSrc(params.content, (dom)=>{
|
|
@@ -13687,6 +13686,7 @@ var __webpack_exports__ = {};
|
|
|
13687
13686
|
return success(publishResult.data.pgc_id);
|
|
13688
13687
|
};
|
|
13689
13688
|
const rpa_rpaAction = async (task, params)=>{
|
|
13689
|
+
task.logger.info("开始头条 RPA 发布");
|
|
13690
13690
|
const tmpCachePath = task.getTmpPath();
|
|
13691
13691
|
const commonCookies = {
|
|
13692
13692
|
path: "/",
|
|
@@ -14885,7 +14885,7 @@ var __webpack_exports__ = {};
|
|
|
14885
14885
|
return executeAction(xiaohongshuPublish_mock_mockAction, xiaohongshuPublish_rpa_rpaAction)(task, params);
|
|
14886
14886
|
};
|
|
14887
14887
|
var package_namespaceObject = {
|
|
14888
|
-
i8: "1.1.
|
|
14888
|
+
i8: "1.1.18"
|
|
14889
14889
|
};
|
|
14890
14890
|
class Action {
|
|
14891
14891
|
constructor(task){
|