@iflyrpa/actions 4.1.0-beta.6 → 4.1.0
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/searchAccountInfo/index.d.ts +1 -1
- package/dist/actions/shipinhaoPublishVideo/videoValidator.d.ts +4 -2
- package/dist/bundle.js +116 -105
- package/dist/bundle.js.map +1 -1
- package/dist/index.js +116 -105
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +116 -105
- package/dist/index.mjs.map +1 -1
- package/dist/utils/feishuAlarm.d.ts +4 -1
- package/dist/utils/http.d.ts +16 -0
- package/dist/utils/shipinhao/utils.d.ts +10 -0
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="309d0c4f-ece2-5152-b000-0390cb565a64")}catch(e){}}();
|
|
3
3
|
import * as __WEBPACK_EXTERNAL_MODULE_crypto__ from "crypto";
|
|
4
4
|
import * as __WEBPACK_EXTERNAL_MODULE_fs__ from "fs";
|
|
5
5
|
import * as __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_package_json_58ae5f06__ from "@iflyrpa/share/package.json";
|
|
@@ -4352,7 +4352,9 @@ function __webpack_require__(moduleId) {
|
|
|
4352
4352
|
return module;
|
|
4353
4353
|
};
|
|
4354
4354
|
})();
|
|
4355
|
-
var package_namespaceObject =
|
|
4355
|
+
var package_namespaceObject = {
|
|
4356
|
+
i8: "4.1.0"
|
|
4357
|
+
};
|
|
4356
4358
|
const USER_MESSAGE = {
|
|
4357
4359
|
PROXY_UNAVAILABLE: "代理暂时不可用,请稍后重试或使用本地IP",
|
|
4358
4360
|
NETWORK_ERROR: "网络异常,请稍后重试",
|
|
@@ -4386,6 +4388,11 @@ function classifyPublishError(handledError) {
|
|
|
4386
4388
|
const RPA_ERROR_WEBHOOK_URL = "https://open.xfchat.iflytek.com/open-apis/bot/v2/hook/d202c0dc-5af5-40bc-83ed-abc677caa4a5";
|
|
4387
4389
|
const ALARM_THROTTLE_MS = 60000;
|
|
4388
4390
|
const lastSentAt = new Map();
|
|
4391
|
+
const THROTTLE_MAP_MAX_KEYS = 500;
|
|
4392
|
+
const pruneThrottleMap = (now)=>{
|
|
4393
|
+
if (lastSentAt.size < THROTTLE_MAP_MAX_KEYS) return;
|
|
4394
|
+
for (const [key, at] of lastSentAt)if (now - at >= ALARM_THROTTLE_MS) lastSentAt.delete(key);
|
|
4395
|
+
};
|
|
4389
4396
|
const postFeishuWebhook = (webhookUrl, payload)=>__WEBPACK_EXTERNAL_MODULE_axios__["default"].post(webhookUrl, payload, {
|
|
4390
4397
|
headers: {
|
|
4391
4398
|
"Content-Type": "application/json"
|
|
@@ -4463,10 +4470,11 @@ const buildFeishuPostMessage = (report)=>{
|
|
|
4463
4470
|
};
|
|
4464
4471
|
const reportFeishuAlarm = (report)=>{
|
|
4465
4472
|
try {
|
|
4466
|
-
const key = `${report.platform}|${report.source}|${report.errorType}|${report.code ?? ""}`;
|
|
4473
|
+
const key = `${report.platform}|${report.source}|${report.stage}|${report.errorType}|${report.code ?? ""}`;
|
|
4467
4474
|
const now = Date.now();
|
|
4468
4475
|
const last = lastSentAt.get(key);
|
|
4469
4476
|
if (last && now - last < ALARM_THROTTLE_MS) return;
|
|
4477
|
+
pruneThrottleMap(now);
|
|
4470
4478
|
lastSentAt.set(key, now);
|
|
4471
4479
|
postFeishuWebhook(RPA_ERROR_WEBHOOK_URL, buildFeishuPostMessage(report)).catch(()=>{});
|
|
4472
4480
|
} catch {}
|
|
@@ -4612,6 +4620,19 @@ const ALARM_STATUS = new Set([
|
|
|
4612
4620
|
461,
|
|
4613
4621
|
471
|
|
4614
4622
|
]);
|
|
4623
|
+
function isLocalAddress(url) {
|
|
4624
|
+
let hostname;
|
|
4625
|
+
try {
|
|
4626
|
+
hostname = new URL(url).hostname.toLowerCase();
|
|
4627
|
+
} catch {
|
|
4628
|
+
return false;
|
|
4629
|
+
}
|
|
4630
|
+
if ("localhost" === hostname || "::1" === hostname || "[::1]" === hostname) return true;
|
|
4631
|
+
if (hostname.endsWith(".localhost") || hostname.endsWith(".local")) return true;
|
|
4632
|
+
if (/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(hostname)) return true;
|
|
4633
|
+
if ("0.0.0.0" === hostname) return true;
|
|
4634
|
+
return false;
|
|
4635
|
+
}
|
|
4615
4636
|
const HTTP_STATUS_MESSAGE = {
|
|
4616
4637
|
400: "请求参数错误,请检查参数格式是否正确!",
|
|
4617
4638
|
401: "登录状态已失效,请重新登录后重试!",
|
|
@@ -4648,7 +4669,14 @@ const HTTP_STATUS_MESSAGE = {
|
|
|
4648
4669
|
};
|
|
4649
4670
|
class Http {
|
|
4650
4671
|
static handleApiError(error) {
|
|
4651
|
-
if (error && "object" == typeof error && "code" in error && "message" in error)
|
|
4672
|
+
if (error && "object" == typeof error && "code" in error && "message" in error) {
|
|
4673
|
+
const resp = error;
|
|
4674
|
+
if ("string" != typeof resp.message || !resp.message.trim()) return {
|
|
4675
|
+
...resp,
|
|
4676
|
+
message: USER_MESSAGE.SYSTEM_ERROR
|
|
4677
|
+
};
|
|
4678
|
+
return resp;
|
|
4679
|
+
}
|
|
4652
4680
|
return {
|
|
4653
4681
|
code: 500,
|
|
4654
4682
|
message: USER_MESSAGE.SYSTEM_ERROR,
|
|
@@ -4786,21 +4814,43 @@ class Http {
|
|
|
4786
4814
|
errorResponse.message = message;
|
|
4787
4815
|
}
|
|
4788
4816
|
if (error.message.includes("Proxy connection ended")) errorResponse.message = "所在区域代理连接超时,请更换区域或稍后重试!";
|
|
4789
|
-
|
|
4790
|
-
|
|
4791
|
-
|
|
4792
|
-
|
|
4793
|
-
|
|
4794
|
-
stage: `${(error.config?.method || "get").toUpperCase()} ${error.config?.url || "-"}`,
|
|
4795
|
-
errorType: status ? `HTTP_${status}` : error.code || "NETWORK_ERROR",
|
|
4796
|
-
code: errorResponse.code,
|
|
4797
|
-
msg: errorResponse.message,
|
|
4798
|
-
url: error.config?.url,
|
|
4799
|
-
title: "RPA接口异常"
|
|
4800
|
-
});
|
|
4817
|
+
errorResponse.extra = {
|
|
4818
|
+
...errorResponse.extra,
|
|
4819
|
+
alarmStatus: error.response?.status,
|
|
4820
|
+
alarmErrorCode: error.code
|
|
4821
|
+
};
|
|
4801
4822
|
throw errorResponse;
|
|
4802
4823
|
});
|
|
4803
4824
|
}
|
|
4825
|
+
reportRequestFailure(config, error, attempts) {
|
|
4826
|
+
const status = error.extra?.alarmStatus;
|
|
4827
|
+
const axiosCode = error.extra?.alarmErrorCode;
|
|
4828
|
+
const method = (config.method || "get").toUpperCase();
|
|
4829
|
+
const baseURL = config.baseURL || this.apiClient.defaults.baseURL || "";
|
|
4830
|
+
const fullUrl = config.url ? /^https?:\/\//.test(config.url) ? config.url : `${baseURL.replace(/\/$/, "")}${config.url}` : baseURL;
|
|
4831
|
+
if (!fullUrl) {
|
|
4832
|
+
this.logger?.debug(`[告警跳过] 请求失败但无 URL,不上报: ${error.message}`);
|
|
4833
|
+
return;
|
|
4834
|
+
}
|
|
4835
|
+
if (isLocalAddress(fullUrl)) {
|
|
4836
|
+
this.logger?.debug(`[告警跳过] 本机地址不上报: ${fullUrl}`);
|
|
4837
|
+
return;
|
|
4838
|
+
}
|
|
4839
|
+
const rawMsg = "string" == typeof error.message && error.message.trim() ? error.message : "";
|
|
4840
|
+
const baseMsg = rawMsg || `请求失败(无错误文案,code=${error.code ?? "unknown"})`;
|
|
4841
|
+
const retriedSuffix = attempts > 0 ? `(已重试${attempts}次仍失败)` : "";
|
|
4842
|
+
reportFeishuAlarm({
|
|
4843
|
+
level: status && ALARM_STATUS.has(status) ? "alarm" : "warning",
|
|
4844
|
+
platform: "@iflyrpa/playwright",
|
|
4845
|
+
source: "http",
|
|
4846
|
+
stage: `${method} ${fullUrl}`,
|
|
4847
|
+
errorType: status ? `HTTP_${status}` : axiosCode || "NETWORK_ERROR",
|
|
4848
|
+
code: error.code,
|
|
4849
|
+
msg: `${baseMsg}${retriedSuffix}`,
|
|
4850
|
+
url: fullUrl,
|
|
4851
|
+
title: "RPA接口异常"
|
|
4852
|
+
});
|
|
4853
|
+
}
|
|
4804
4854
|
async api(config, options) {
|
|
4805
4855
|
const retries = options?.retries ?? 0;
|
|
4806
4856
|
const retryDelay = options?.retryDelay ?? 500;
|
|
@@ -4845,10 +4895,12 @@ class Http {
|
|
|
4845
4895
|
].includes(handledError.code);
|
|
4846
4896
|
if (Rtimes < retries && isRetry) {
|
|
4847
4897
|
const url = config.url || "";
|
|
4848
|
-
|
|
4849
|
-
|
|
4898
|
+
const backoff = Math.min(retryDelay * 2 ** Rtimes, 5000);
|
|
4899
|
+
this.logger?.warn(`进入第${Rtimes + 1}次重试!错误码: ${handledError.code}, 等待: ${backoff}ms, 请求地址: ${url}`);
|
|
4900
|
+
await new Promise((resolve)=>setTimeout(resolve, backoff));
|
|
4850
4901
|
return sessionRt(Rtimes + 1);
|
|
4851
4902
|
}
|
|
4903
|
+
this.reportRequestFailure(config, handledError, Rtimes);
|
|
4852
4904
|
return Promise.reject(handledError);
|
|
4853
4905
|
}
|
|
4854
4906
|
};
|
|
@@ -5962,7 +6014,7 @@ const cidrv4 = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-
|
|
|
5962
6014
|
const cidrv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
|
|
5963
6015
|
const regexes_base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
|
|
5964
6016
|
const regexes_base64url = /^[A-Za-z0-9_-]*$/;
|
|
5965
|
-
const
|
|
6017
|
+
const regexes_hostname = /^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/;
|
|
5966
6018
|
const e164 = /^\+(?:[0-9]){6,14}[0-9]$/;
|
|
5967
6019
|
const dateSource = "(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";
|
|
5968
6020
|
const regexes_date = /*@__PURE__*/ new RegExp(`^${dateSource}$`);
|
|
@@ -6558,7 +6610,7 @@ const $ZodURL = /*@__PURE__*/ $constructor("$ZodURL", (inst, def)=>{
|
|
|
6558
6610
|
code: "invalid_format",
|
|
6559
6611
|
format: "url",
|
|
6560
6612
|
note: "Invalid hostname",
|
|
6561
|
-
pattern:
|
|
6613
|
+
pattern: regexes_hostname.source,
|
|
6562
6614
|
input: payload.value,
|
|
6563
6615
|
inst,
|
|
6564
6616
|
continue: !def.abort
|
|
@@ -9269,7 +9321,7 @@ const mockAction = async (task, params)=>{
|
|
|
9269
9321
|
".png"
|
|
9270
9322
|
].includes(ext)) throw {
|
|
9271
9323
|
code: 414,
|
|
9272
|
-
message:
|
|
9324
|
+
message: "图片格式不支持,百家号仅支持 jpg、png 格式,请转换后重试。",
|
|
9273
9325
|
data: ""
|
|
9274
9326
|
};
|
|
9275
9327
|
const image = await (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.downloadImage)(url, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(tmpCachePath, fileName));
|
|
@@ -9950,7 +10002,8 @@ const XhsFansExport = async (_task, params)=>{
|
|
|
9950
10002
|
},
|
|
9951
10003
|
_task.logger,
|
|
9952
10004
|
params.proxyLoc,
|
|
9953
|
-
params.accountId
|
|
10005
|
+
params.accountId,
|
|
10006
|
+
"xiaohongshu"
|
|
9954
10007
|
];
|
|
9955
10008
|
const http = new Http(...args);
|
|
9956
10009
|
const fans = {
|
|
@@ -9964,8 +10017,8 @@ const XhsFansExport = async (_task, params)=>{
|
|
|
9964
10017
|
url: "https://creator.xiaohongshu.com/api/galaxy/creator/home/personal_info"
|
|
9965
10018
|
}, {
|
|
9966
10019
|
retries: 3,
|
|
9967
|
-
retryDelay:
|
|
9968
|
-
timeout:
|
|
10020
|
+
retryDelay: 300,
|
|
10021
|
+
timeout: 30000
|
|
9969
10022
|
});
|
|
9970
10023
|
fans.fans_count = Number(res.data.fans_count);
|
|
9971
10024
|
fans.digg_count = Number(res.data.faved_count);
|
|
@@ -11102,7 +11155,8 @@ const XhsSessionCheck = async (_task, params)=>{
|
|
|
11102
11155
|
},
|
|
11103
11156
|
_task.logger,
|
|
11104
11157
|
params.proxyLoc,
|
|
11105
|
-
params.accountId
|
|
11158
|
+
params.accountId,
|
|
11159
|
+
"xiaohongshu"
|
|
11106
11160
|
];
|
|
11107
11161
|
const http = new Http(...args);
|
|
11108
11162
|
http.addResponseInterceptor((response)=>{
|
|
@@ -11150,8 +11204,8 @@ const XhsSessionCheck = async (_task, params)=>{
|
|
|
11150
11204
|
headers: loginBaseXsHeader
|
|
11151
11205
|
}, {
|
|
11152
11206
|
retries: 3,
|
|
11153
|
-
retryDelay:
|
|
11154
|
-
timeout:
|
|
11207
|
+
retryDelay: 300,
|
|
11208
|
+
timeout: 30000
|
|
11155
11209
|
}).catch((e)=>{
|
|
11156
11210
|
const clientTimestamp = Date.now();
|
|
11157
11211
|
const serverDate = e?.extra?.serverDate;
|
|
@@ -11183,8 +11237,8 @@ const XhsSessionCheck = async (_task, params)=>{
|
|
|
11183
11237
|
headers: webSessionXsHeader
|
|
11184
11238
|
}, {
|
|
11185
11239
|
retries: 3,
|
|
11186
|
-
retryDelay:
|
|
11187
|
-
timeout:
|
|
11240
|
+
retryDelay: 300,
|
|
11241
|
+
timeout: 30000
|
|
11188
11242
|
});
|
|
11189
11243
|
const [baseInfo, web_session] = await Promise.all([
|
|
11190
11244
|
_baseInfo,
|
|
@@ -11276,6 +11330,10 @@ const ShipinhaoSessionCheck = async (_task, params)=>{
|
|
|
11276
11330
|
};
|
|
11277
11331
|
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(data, message);
|
|
11278
11332
|
};
|
|
11333
|
+
const extractEncFileKey = (downloadUrl)=>{
|
|
11334
|
+
if (!downloadUrl) return "";
|
|
11335
|
+
return downloadUrl.split("encfilekey=")[1]?.split("&")[0] || "";
|
|
11336
|
+
};
|
|
11279
11337
|
const rid = ()=>`${Math.floor(Date.now() / 1e3).toString(16)}-${[
|
|
11280
11338
|
...Array(8)
|
|
11281
11339
|
].map(()=>Math.floor(16 * Math.random()).toString(16)).join("")}`;
|
|
@@ -15430,7 +15488,8 @@ const getXhsUnreadCount = async (_task, params)=>{
|
|
|
15430
15488
|
},
|
|
15431
15489
|
_task.logger,
|
|
15432
15490
|
params.proxyLoc,
|
|
15433
|
-
params.accountId
|
|
15491
|
+
params.accountId,
|
|
15492
|
+
"xiaohongshu"
|
|
15434
15493
|
];
|
|
15435
15494
|
const http = new Http(...args);
|
|
15436
15495
|
let unreadCount = {
|
|
@@ -15459,8 +15518,8 @@ const getXhsUnreadCount = async (_task, params)=>{
|
|
|
15459
15518
|
headers: xsHeader
|
|
15460
15519
|
}, {
|
|
15461
15520
|
retries: 3,
|
|
15462
|
-
retryDelay:
|
|
15463
|
-
timeout:
|
|
15521
|
+
retryDelay: 300,
|
|
15522
|
+
timeout: 30000
|
|
15464
15523
|
});
|
|
15465
15524
|
const isSuccess = 0 === res.code;
|
|
15466
15525
|
if (isSuccess) unreadCount = res.data;
|
|
@@ -15871,7 +15930,8 @@ async function getXiaohongshuData(_task, params) {
|
|
|
15871
15930
|
},
|
|
15872
15931
|
_task.logger,
|
|
15873
15932
|
params.proxyLoc,
|
|
15874
|
-
params.accountId
|
|
15933
|
+
params.accountId,
|
|
15934
|
+
"xiaohongshu"
|
|
15875
15935
|
];
|
|
15876
15936
|
const http = new Http(...args);
|
|
15877
15937
|
const xsEncrypt = new Xhshow();
|
|
@@ -15887,8 +15947,8 @@ async function getXiaohongshuData(_task, params) {
|
|
|
15887
15947
|
url: "https://creator.xiaohongshu.com/api/galaxy/creator/home/personal_info"
|
|
15888
15948
|
}, {
|
|
15889
15949
|
retries: 3,
|
|
15890
|
-
retryDelay:
|
|
15891
|
-
timeout:
|
|
15950
|
+
retryDelay: 300,
|
|
15951
|
+
timeout: 30000
|
|
15892
15952
|
}),
|
|
15893
15953
|
http.api({
|
|
15894
15954
|
method: "get",
|
|
@@ -15897,8 +15957,8 @@ async function getXiaohongshuData(_task, params) {
|
|
|
15897
15957
|
headers: sevenDataXsHeader
|
|
15898
15958
|
}, {
|
|
15899
15959
|
retries: 3,
|
|
15900
|
-
retryDelay:
|
|
15901
|
-
timeout:
|
|
15960
|
+
retryDelay: 300,
|
|
15961
|
+
timeout: 30000
|
|
15902
15962
|
})
|
|
15903
15963
|
]);
|
|
15904
15964
|
const xhsData = {
|
|
@@ -18758,7 +18818,7 @@ async function publishDynamic(cookies, uin, fingerPrintDeviceId, aId, proxyHttp,
|
|
|
18758
18818
|
name: params.music.name,
|
|
18759
18819
|
artist: params.music.authorName,
|
|
18760
18820
|
mediaStreamingUrl: params.music.url,
|
|
18761
|
-
docType: params.music.raw.
|
|
18821
|
+
docType: 2 === params.music.raw.bgmSource ? 0 : 1
|
|
18762
18822
|
},
|
|
18763
18823
|
groupId: params.music.id,
|
|
18764
18824
|
hasBgm: 1,
|
|
@@ -18935,7 +18995,7 @@ const shipinhaoPublish_mock_mockAction = async (task, params)=>{
|
|
|
18935
18995
|
const resultMsg = publishResult.data?.baseResp?.errmsg ?? publishResult.errMsg;
|
|
18936
18996
|
if (0 === resultCode) {
|
|
18937
18997
|
task.logger.info("[shipinhaoPublish] 发布成功");
|
|
18938
|
-
const publishId = uploadedImages[0]?.thumbUrl
|
|
18998
|
+
const publishId = extractEncFileKey(uploadedImages[0]?.thumbUrl);
|
|
18939
18999
|
await updateTaskState?.({
|
|
18940
19000
|
state: __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.TaskState.SUCCESS,
|
|
18941
19001
|
result: {
|
|
@@ -19830,8 +19890,7 @@ async function uploader_uploadFile(opts) {
|
|
|
19830
19890
|
const partTimeout = tuning?.partTimeout ?? DEFAULT_TUNING.partTimeout;
|
|
19831
19891
|
const partRetries = tuning?.partRetries ?? DEFAULT_TUNING.partRetries;
|
|
19832
19892
|
const completeTimeout = tuning?.completeTimeout ?? DEFAULT_TUNING.completeTimeout;
|
|
19833
|
-
logger?.info(
|
|
19834
|
-
logger?.info(`上传超时策略: 单片 ${partTimeout / 1000}s(重试 ${partRetries} 次)、合并 ${completeTimeout / 1000}s`);
|
|
19893
|
+
logger?.info(`[shipinhaoPublishVideo] 开始上传: ${fileName} (${fileSize} B, filetype=${fileType})`);
|
|
19835
19894
|
const fileMd5 = await computeFileMd5(filePath);
|
|
19836
19895
|
const taskId = generateTaskId(fileName, fileSize, fileMd5);
|
|
19837
19896
|
const baseUrl = "https://finderassistancea.video.qq.com";
|
|
@@ -19842,7 +19901,7 @@ async function uploader_uploadFile(opts) {
|
|
|
19842
19901
|
const chunkCount = Math.ceil(fileSize / CHUNK_SIZE);
|
|
19843
19902
|
const blockPartLength = [];
|
|
19844
19903
|
for(let i = 0; i < chunkCount; i++)blockPartLength.push(Math.min((i + 1) * CHUNK_SIZE, fileSize));
|
|
19845
|
-
logger?.info(
|
|
19904
|
+
logger?.info(`[shipinhaoPublishVideo] 视频分片: ${chunkCount} 片`);
|
|
19846
19905
|
const applyRes = await http.api({
|
|
19847
19906
|
method: "PUT",
|
|
19848
19907
|
url: `${baseUrl}/applyuploaddfs`,
|
|
@@ -19863,7 +19922,6 @@ async function uploader_uploadFile(opts) {
|
|
|
19863
19922
|
let uploadId = applyRes.UploadID;
|
|
19864
19923
|
const uploadedParts = new Set();
|
|
19865
19924
|
if (applyRes.ListPartsResult) {
|
|
19866
|
-
logger?.info("检测到已上传分片,执行续传");
|
|
19867
19925
|
const parts = Array.isArray(applyRes.ListPartsResult.Part) ? applyRes.ListPartsResult.Part : applyRes.ListPartsResult.Part ? [
|
|
19868
19926
|
applyRes.ListPartsResult.Part
|
|
19869
19927
|
] : [];
|
|
@@ -19899,7 +19957,6 @@ async function uploader_uploadFile(opts) {
|
|
|
19899
19957
|
PartNumber: partNumber,
|
|
19900
19958
|
ETag: existing.ETag
|
|
19901
19959
|
});
|
|
19902
|
-
logger?.info(`分片 ${partNumber}/${chunkCount} 已存在,跳过`);
|
|
19903
19960
|
continue;
|
|
19904
19961
|
}
|
|
19905
19962
|
}
|
|
@@ -19924,18 +19981,15 @@ async function uploader_uploadFile(opts) {
|
|
|
19924
19981
|
retries: partRetries,
|
|
19925
19982
|
retryDelay: 2000
|
|
19926
19983
|
});
|
|
19927
|
-
|
|
19928
|
-
const throughput = Math.round(chunkSize / (partElapsed / 1000));
|
|
19984
|
+
Date.now();
|
|
19929
19985
|
partInfo.push({
|
|
19930
19986
|
PartNumber: partNumber,
|
|
19931
19987
|
ETag: `"${chunkMd5}"`
|
|
19932
19988
|
});
|
|
19933
|
-
logger?.info(`分片 ${partNumber}/${chunkCount} 完成 (${chunkSize} B, ${partElapsed}ms, ${Math.round(throughput / 1024)}KB/s)`);
|
|
19934
19989
|
}
|
|
19935
19990
|
} finally{
|
|
19936
19991
|
__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].closeSync(fd);
|
|
19937
19992
|
}
|
|
19938
|
-
logger?.info("合并分片...");
|
|
19939
19993
|
const completeRes = await http.api({
|
|
19940
19994
|
method: "POST",
|
|
19941
19995
|
url: `${baseUrl}/completepartuploaddfs?UploadID=${encodeURIComponent(uploadId)}`,
|
|
@@ -19953,7 +20007,7 @@ async function uploader_uploadFile(opts) {
|
|
|
19953
20007
|
retryDelay: 3000
|
|
19954
20008
|
});
|
|
19955
20009
|
if (!completeRes.DownloadURL) throw new Error("合并分片失败: " + JSON.stringify(completeRes));
|
|
19956
|
-
logger?.info(
|
|
20010
|
+
logger?.info(`[shipinhaoPublishVideo] ${fileName} 上传成功`);
|
|
19957
20011
|
return {
|
|
19958
20012
|
downloadUrl: completeRes.DownloadURL,
|
|
19959
20013
|
md5: fileMd5,
|
|
@@ -20271,6 +20325,7 @@ const ALLOWED_CODECS = [
|
|
|
20271
20325
|
"avc3"
|
|
20272
20326
|
];
|
|
20273
20327
|
const MIN_TITLE_LENGTH = 6;
|
|
20328
|
+
const MAX_TITLE_LENGTH = 16;
|
|
20274
20329
|
function formatFileSize(bytes) {
|
|
20275
20330
|
if (bytes < 1048576) return `${(bytes / 1024).toFixed(2)} KB`;
|
|
20276
20331
|
if (bytes < 1073741824) return `${(bytes / 1024 / 1024).toFixed(2)} MB`;
|
|
@@ -20297,10 +20352,11 @@ function validateShipinhaoVideo(filePath, meta) {
|
|
|
20297
20352
|
function validateShipinhaoTitle(title) {
|
|
20298
20353
|
if (void 0 === title) return null;
|
|
20299
20354
|
const trimmed = title.trim();
|
|
20355
|
+
if ("" === trimmed) return null;
|
|
20300
20356
|
const length = [
|
|
20301
20357
|
...trimmed
|
|
20302
20358
|
].length;
|
|
20303
|
-
if (length < MIN_TITLE_LENGTH) return
|
|
20359
|
+
if (length < MIN_TITLE_LENGTH || length > MAX_TITLE_LENGTH) return `视频号标题需要在 ${MIN_TITLE_LENGTH}-${MAX_TITLE_LENGTH} 个字符之间,当前 ${length} 个字符,请调整后重试。`;
|
|
20304
20360
|
return null;
|
|
20305
20361
|
}
|
|
20306
20362
|
const POST_CREATE_PAGE_URL = "https://channels.weixin.qq.com/micro/content/post/create";
|
|
@@ -20345,7 +20401,6 @@ function buildCommonBody(finderUsername) {
|
|
|
20345
20401
|
};
|
|
20346
20402
|
}
|
|
20347
20403
|
async function getTraceKey(auth, client, http, logger) {
|
|
20348
|
-
logger.info("[getTraceKey] 开始获取 traceKey...");
|
|
20349
20404
|
const res = await http.api({
|
|
20350
20405
|
method: "POST",
|
|
20351
20406
|
url: `${MICRO_CONTENT_BASE}/post/get-finder-post-trace-key`,
|
|
@@ -20360,11 +20415,9 @@ async function getTraceKey(auth, client, http, logger) {
|
|
|
20360
20415
|
logger.error("[getTraceKey] 获取失败:", JSON.stringify(res));
|
|
20361
20416
|
throw new Error(`获取 traceKey 失败: ${JSON.stringify(res)}`);
|
|
20362
20417
|
}
|
|
20363
|
-
logger.info(`[getTraceKey] 获取成功: ${res.data.traceKey}`);
|
|
20364
20418
|
return res.data.traceKey;
|
|
20365
20419
|
}
|
|
20366
20420
|
async function getObjectTagKey(auth, client, http, logger) {
|
|
20367
|
-
logger.info("[getObjectTagKey] 获取内容声明 tagKey...");
|
|
20368
20421
|
try {
|
|
20369
20422
|
const res = await http.api({
|
|
20370
20423
|
method: "POST",
|
|
@@ -20380,7 +20433,6 @@ async function getObjectTagKey(auth, client, http, logger) {
|
|
|
20380
20433
|
logger.warn(`[getObjectTagKey] 未取到 tagKey: ${JSON.stringify(res)}`);
|
|
20381
20434
|
return null;
|
|
20382
20435
|
}
|
|
20383
|
-
logger.info(`[getObjectTagKey] tagKey: ${res.data.tagKey}`);
|
|
20384
20436
|
return res.data.tagKey;
|
|
20385
20437
|
} catch (error) {
|
|
20386
20438
|
logger.warn(`[getObjectTagKey] 获取 tagKey 异常: ${stringifyError(error)}`);
|
|
@@ -20389,7 +20441,6 @@ async function getObjectTagKey(auth, client, http, logger) {
|
|
|
20389
20441
|
}
|
|
20390
20442
|
async function submitAndPollTranscode(opts) {
|
|
20391
20443
|
const { videoUrl, videoMeta, traceKey, uploadStartTime, uploadEndTime, finderUsername, client, http, logger } = opts;
|
|
20392
|
-
logger.info("[submitAndPollTranscode] 开始提交转码任务...");
|
|
20393
20444
|
const finderUrl = videoUrl.includes("wxapp.tc.qq.com") ? `https://finder.video.qq.com${videoUrl.split("qq.com")[1]}` : videoUrl;
|
|
20394
20445
|
logger.info(`[submitAndPollTranscode] 视频尺寸: ${videoMeta.width}x${videoMeta.height}, 时长: ${videoMeta.duration}s`);
|
|
20395
20446
|
const submitRes = await http.api({
|
|
@@ -20428,12 +20479,10 @@ async function submitAndPollTranscode(opts) {
|
|
|
20428
20479
|
throw new Error(`提交转码失败: ${JSON.stringify(submitRes)}`);
|
|
20429
20480
|
}
|
|
20430
20481
|
const { clipKey, draftId } = submitRes.data;
|
|
20431
|
-
logger.info(`[submitAndPollTranscode] 转码任务已提交,clipKey: ${clipKey}, draftId: ${draftId}`);
|
|
20432
20482
|
const pollInterval = 5000;
|
|
20433
20483
|
const pollBudget = Math.min(1800000, 300000 + 1000 * Math.ceil(1.5 * videoMeta.duration));
|
|
20434
20484
|
const maxPolls = Math.ceil(pollBudget / pollInterval);
|
|
20435
20485
|
let pollCount = 0;
|
|
20436
|
-
logger.info(`[submitAndPollTranscode] 开始轮询转码结果,最多 ${maxPolls} 次(${Math.round(pollBudget / 1000)}s),间隔 ${pollInterval / 1000}s`);
|
|
20437
20486
|
while(pollCount < maxPolls){
|
|
20438
20487
|
await sleep(pollInterval);
|
|
20439
20488
|
pollCount++;
|
|
@@ -20457,14 +20506,12 @@ async function submitAndPollTranscode(opts) {
|
|
|
20457
20506
|
throw new Error(`转码轮询失败 (poll ${pollCount}): ${JSON.stringify(pollRes)}`);
|
|
20458
20507
|
}
|
|
20459
20508
|
const { flag, url, width, height, duration, md5, fileSize } = pollRes.data || {};
|
|
20460
|
-
logger.info(`[submitAndPollTranscode] 轮询第 ${pollCount} 次,flag=${flag}`);
|
|
20461
20509
|
if (1 === flag) {
|
|
20462
20510
|
if (!url || !width || !height || !duration || !md5 || !fileSize) {
|
|
20463
20511
|
logger.error("[submitAndPollTranscode] 转码完成但返回数据不完整:", JSON.stringify(pollRes.data));
|
|
20464
20512
|
throw new Error(`转码完成但返回数据不完整: ${JSON.stringify(pollRes.data)}`);
|
|
20465
20513
|
}
|
|
20466
20514
|
logger.info(`[submitAndPollTranscode] 转码完成! 用时: ${pollCount * pollInterval / 1000}s`);
|
|
20467
|
-
logger.info(`[submitAndPollTranscode] 视频信息: ${width}x${height}, 时长: ${duration}s, 大小: ${fileSize}`);
|
|
20468
20515
|
return {
|
|
20469
20516
|
clipKey,
|
|
20470
20517
|
url,
|
|
@@ -20475,7 +20522,7 @@ async function submitAndPollTranscode(opts) {
|
|
|
20475
20522
|
fileSize
|
|
20476
20523
|
};
|
|
20477
20524
|
}
|
|
20478
|
-
if (2 === flag)
|
|
20525
|
+
if (2 === flag) ;
|
|
20479
20526
|
else {
|
|
20480
20527
|
logger.error(`[submitAndPollTranscode] 转码失败,未知 flag=${flag}:`, JSON.stringify(pollRes.data));
|
|
20481
20528
|
throw new Error(`转码失败,未知 flag=${flag}: ${JSON.stringify(pollRes.data)}`);
|
|
@@ -20486,16 +20533,11 @@ async function submitAndPollTranscode(opts) {
|
|
|
20486
20533
|
}
|
|
20487
20534
|
async function publishVideo(opts) {
|
|
20488
20535
|
const { params, auth, client, clipResult, videoUpload, coverUpload, verticalCoverUpload, videoMeta, traceKey, tagKey, uploadStartTime, uploadEndTime, proxyHttp, logger } = opts;
|
|
20489
|
-
logger.info("[publishVideo] 开始构建发布请求...");
|
|
20490
20536
|
const toFinderUrl = (url)=>url.includes("wxapp.tc.qq.com") ? `https://finder.video.qq.com${url.split("qq.com")[1]}` : url;
|
|
20491
20537
|
const thumbFinderUrl = toFinderUrl(coverUpload.downloadUrl);
|
|
20492
20538
|
const coverFinderUrl = toFinderUrl(verticalCoverUpload.downloadUrl);
|
|
20493
20539
|
const md5sumUuid = __WEBPACK_EXTERNAL_MODULE_node_crypto_9ba42079__["default"].randomUUID();
|
|
20494
20540
|
const description = params.description;
|
|
20495
|
-
logger.info("[publishVideo] 发布参数:");
|
|
20496
|
-
logger.info(` - 短标题: ${params.title || "(无)"}`);
|
|
20497
|
-
logger.info(` - 描述: ${description.substring(0, 50)}${description.length > 50 ? "..." : ""}`);
|
|
20498
|
-
logger.info(` - 定时发布: ${params.scheduledTime ? new Date(1000 * params.scheduledTime).toLocaleString() : "立即发布"}`);
|
|
20499
20541
|
const objectDesc = {
|
|
20500
20542
|
mpTitle: "",
|
|
20501
20543
|
description,
|
|
@@ -20569,7 +20611,6 @@ async function publishVideo(opts) {
|
|
|
20569
20611
|
};
|
|
20570
20612
|
if (params.scheduledTime) publishData.effectiveTime = params.scheduledTime;
|
|
20571
20613
|
if (params.tagInfo && tagKey) publishData.tagInfo = buildTagInfo(params.tagInfo, tagKey);
|
|
20572
|
-
logger.info("[publishVideo] 开始发布视频,全部参数:" + JSON.stringify(publishData));
|
|
20573
20614
|
const publishRes = await proxyHttp.api({
|
|
20574
20615
|
method: "POST",
|
|
20575
20616
|
url: `${MICRO_CONTENT_BASE}/post/post_create`,
|
|
@@ -20577,7 +20618,7 @@ async function publishVideo(opts) {
|
|
|
20577
20618
|
data: publishData,
|
|
20578
20619
|
defaultErrorMsg: "发布视频失败"
|
|
20579
20620
|
});
|
|
20580
|
-
logger.info(`[publishVideo]
|
|
20621
|
+
logger.info(`[publishVideo] 发布结果: errCode=${publishRes.errCode}, baseResp.errcode=${publishRes.data?.baseResp?.errcode}`);
|
|
20581
20622
|
return publishRes;
|
|
20582
20623
|
}
|
|
20583
20624
|
function sleep(ms) {
|
|
@@ -20591,11 +20632,9 @@ async function resolveLocalCoverPath(coverPath, label, tmpCachePath, logger) {
|
|
|
20591
20632
|
return savePath;
|
|
20592
20633
|
}
|
|
20593
20634
|
const shipinhaoPublishVideo_mock_mockAction = async (task, params)=>{
|
|
20594
|
-
task.logger.info("[shipinhaoPublishVideo] 开始执行视频号视频发布 - Mock API 方式");
|
|
20595
20635
|
const updateTaskState = task.taskStageStore?.update?.bind(task.taskStageStore, task.taskId || "");
|
|
20596
20636
|
let currentStep = "初始化";
|
|
20597
20637
|
try {
|
|
20598
|
-
task.logger.info(`[shipinhaoPublishVideo] 发布方式: ${params.scheduledTime ? `定时 ${new Date(1000 * params.scheduledTime).toLocaleString()}` : "立即发布"}`);
|
|
20599
20638
|
currentStep = "解析认证信息";
|
|
20600
20639
|
const cookieString = params.cookies.map((c)=>`${c.name}=${c.value}`).join("; ");
|
|
20601
20640
|
const http = new Http({
|
|
@@ -20607,11 +20646,8 @@ const shipinhaoPublishVideo_mock_mockAction = async (task, params)=>{
|
|
|
20607
20646
|
if (!params.videoPath) return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "视频文件路径不能为空", "");
|
|
20608
20647
|
if (!params.coverPath) return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "横屏封面图片路径不能为空", "");
|
|
20609
20648
|
currentStep = "获取上传认证";
|
|
20610
|
-
task.logger.info("[shipinhaoPublishVideo] 获取上传认证...");
|
|
20611
20649
|
const auth = await getShipinhaoUploadAuth(cookieString, http);
|
|
20612
20650
|
const client = resolveClientContext(params, auth.uin);
|
|
20613
|
-
if (!client.aId) task.logger.warn("[shipinhaoPublishVideo] extraParam.aId 缺失,query 将不带 _aid");
|
|
20614
|
-
if (!client.fingerPrintDeviceId) task.logger.warn("[shipinhaoPublishVideo] extraParam.fingerPrintDeviceId 缺失,请求将不带 finger-print-device-id");
|
|
20615
20651
|
const publishHeaders = buildPublishHeaders(cookieString, client);
|
|
20616
20652
|
const microHttp = new Http({
|
|
20617
20653
|
headers: publishHeaders
|
|
@@ -20627,25 +20663,20 @@ const shipinhaoPublishVideo_mock_mockAction = async (task, params)=>{
|
|
|
20627
20663
|
];
|
|
20628
20664
|
const proxyHttp = new Http(...args);
|
|
20629
20665
|
currentStep = "组装视频元数据";
|
|
20630
|
-
task.logger.info("[shipinhaoPublishVideo] 组装视频元数据...");
|
|
20631
20666
|
const videoMeta = buildVideoMetaFromParams(params.videoPath, params.videoMetadata);
|
|
20632
20667
|
task.logger.info(`[shipinhaoPublishVideo] 视频: ${videoMeta.width}×${videoMeta.height}, ${videoMeta.duration.toFixed(2)}s, ${(videoMeta.fileSize / 1024 / 1024).toFixed(2)}MB, codec=${videoMeta.codec || "unknown"}`);
|
|
20633
|
-
if (!videoMeta.codec) task.logger.warn("[shipinhaoPublishVideo] 未能读取视频编码格式,跳过 H.264 预检,交由服务端判断");
|
|
20634
20668
|
currentStep = "校验视频限制";
|
|
20635
20669
|
const validationError = validateShipinhaoVideo(params.videoPath, videoMeta);
|
|
20636
20670
|
if (validationError) {
|
|
20637
|
-
task.logger.error(`[shipinhaoPublishVideo] 视频校验未通过: ${validationError}`);
|
|
20638
20671
|
await updateTaskState?.({
|
|
20639
20672
|
state: __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.TaskState.FAILED,
|
|
20640
20673
|
error: validationError
|
|
20641
20674
|
});
|
|
20642
20675
|
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, validationError, "");
|
|
20643
20676
|
}
|
|
20644
|
-
task.logger.info("[shipinhaoPublishVideo] 视频校验通过");
|
|
20645
20677
|
currentStep = "校验标题";
|
|
20646
20678
|
const titleError = validateShipinhaoTitle(params.title);
|
|
20647
20679
|
if (titleError) {
|
|
20648
|
-
task.logger.error(`[shipinhaoPublishVideo] 标题校验未通过: ${titleError}`);
|
|
20649
20680
|
await updateTaskState?.({
|
|
20650
20681
|
state: __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.TaskState.FAILED,
|
|
20651
20682
|
error: titleError
|
|
@@ -20653,7 +20684,6 @@ const shipinhaoPublishVideo_mock_mockAction = async (task, params)=>{
|
|
|
20653
20684
|
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, titleError, "");
|
|
20654
20685
|
}
|
|
20655
20686
|
currentStep = "获取 traceKey";
|
|
20656
|
-
task.logger.info("[shipinhaoPublishVideo] 获取 traceKey...");
|
|
20657
20687
|
const traceKey = await getTraceKey(auth, client, microHttp, task.logger);
|
|
20658
20688
|
let tagKey = null;
|
|
20659
20689
|
if (params.tagInfo) {
|
|
@@ -20661,11 +20691,7 @@ const shipinhaoPublishVideo_mock_mockAction = async (task, params)=>{
|
|
|
20661
20691
|
tagKey = await getObjectTagKey(auth, client, microHttp, task.logger);
|
|
20662
20692
|
}
|
|
20663
20693
|
const uploadStartTime = Math.floor(Date.now() / 1000);
|
|
20664
|
-
task.logger.info(`[shipinhaoPublishVideo] 上传开始时间: ${uploadStartTime}`);
|
|
20665
20694
|
currentStep = "上传视频";
|
|
20666
|
-
task.logger.info("[shipinhaoPublishVideo] 上传视频...");
|
|
20667
|
-
task.logger.info(`[shipinhaoPublishVideo] 视频路径: ${params.videoPath}`);
|
|
20668
|
-
task.logger.info(`[shipinhaoPublishVideo] 视频文件类型: ${auth.videoFileType}`);
|
|
20669
20695
|
const videoUpload = await uploader_uploadFile({
|
|
20670
20696
|
filePath: params.videoPath,
|
|
20671
20697
|
fileType: auth.videoFileType,
|
|
@@ -20674,12 +20700,10 @@ const shipinhaoPublishVideo_mock_mockAction = async (task, params)=>{
|
|
|
20674
20700
|
http,
|
|
20675
20701
|
logger: task.logger
|
|
20676
20702
|
});
|
|
20677
|
-
task.logger.info("[shipinhaoPublishVideo] 视频上传完成");
|
|
20678
20703
|
const uploadEndTime = Math.floor(Date.now() / 1000);
|
|
20679
|
-
task.logger.info(`[shipinhaoPublishVideo]
|
|
20704
|
+
task.logger.info(`[shipinhaoPublishVideo] 耗时: ${uploadEndTime - uploadStartTime}s`);
|
|
20680
20705
|
currentStep = "上传横屏封面";
|
|
20681
20706
|
const localCoverPath = await resolveLocalCoverPath(params.coverPath, "横屏封面", task.getTmpPath(), task.logger);
|
|
20682
|
-
task.logger.info("[shipinhaoPublishVideo] 上传横屏封面...");
|
|
20683
20707
|
const coverUpload = await uploader_uploadFile({
|
|
20684
20708
|
filePath: localCoverPath,
|
|
20685
20709
|
fileType: auth.pictureFileType,
|
|
@@ -20688,12 +20712,10 @@ const shipinhaoPublishVideo_mock_mockAction = async (task, params)=>{
|
|
|
20688
20712
|
http,
|
|
20689
20713
|
logger: task.logger
|
|
20690
20714
|
});
|
|
20691
|
-
task.logger.info("[shipinhaoPublishVideo] 横屏封面上传完成");
|
|
20692
20715
|
let verticalCoverUpload = coverUpload;
|
|
20693
20716
|
if (params.verticalCoverPath) {
|
|
20694
20717
|
currentStep = "上传竖屏封面";
|
|
20695
20718
|
const localVerticalPath = await resolveLocalCoverPath(params.verticalCoverPath, "竖屏封面", task.getTmpPath(), task.logger);
|
|
20696
|
-
task.logger.info("[shipinhaoPublishVideo] 上传竖屏封面");
|
|
20697
20719
|
verticalCoverUpload = await uploader_uploadFile({
|
|
20698
20720
|
filePath: localVerticalPath,
|
|
20699
20721
|
fileType: auth.pictureFileType,
|
|
@@ -20702,10 +20724,8 @@ const shipinhaoPublishVideo_mock_mockAction = async (task, params)=>{
|
|
|
20702
20724
|
http,
|
|
20703
20725
|
logger: task.logger
|
|
20704
20726
|
});
|
|
20705
|
-
|
|
20706
|
-
} else task.logger.info("[shipinhaoPublishVideo] 未传竖屏封面,复用横屏封面");
|
|
20727
|
+
}
|
|
20707
20728
|
currentStep = "提交转码";
|
|
20708
|
-
task.logger.info("[shipinhaoPublishVideo] 提交转码...");
|
|
20709
20729
|
const clipResult = await submitAndPollTranscode({
|
|
20710
20730
|
videoUrl: videoUpload.downloadUrl,
|
|
20711
20731
|
videoMeta,
|
|
@@ -20718,8 +20738,6 @@ const shipinhaoPublishVideo_mock_mockAction = async (task, params)=>{
|
|
|
20718
20738
|
logger: task.logger
|
|
20719
20739
|
});
|
|
20720
20740
|
currentStep = "发布视频";
|
|
20721
|
-
task.logger.info("[shipinhaoPublishVideo] 发布视频...");
|
|
20722
|
-
task.logger.info(`[shipinhaoPublishVideo] clipKey: ${clipResult.clipKey}`);
|
|
20723
20741
|
let publishResult;
|
|
20724
20742
|
try {
|
|
20725
20743
|
publishResult = await publishVideo({
|
|
@@ -20744,7 +20762,6 @@ const shipinhaoPublishVideo_mock_mockAction = async (task, params)=>{
|
|
|
20744
20762
|
const classified = classifyPublishError(handledError);
|
|
20745
20763
|
if (classified) {
|
|
20746
20764
|
const message = `${classified.userMessage}${task.debug ? ` ${http.proxyInfo}` : ""}`;
|
|
20747
|
-
task.logger.error(`[shipinhaoPublishVideo] ${classified.category},直接返回: ${handledError.message} (code=${handledError.code})`, stringifyError(handledError));
|
|
20748
20765
|
await updateTaskState?.({
|
|
20749
20766
|
state: __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.TaskState.FAILED,
|
|
20750
20767
|
error: message
|
|
@@ -20761,11 +20778,8 @@ const shipinhaoPublishVideo_mock_mockAction = async (task, params)=>{
|
|
|
20761
20778
|
const resultCode = publishResult.data?.baseResp?.errcode ?? publishResult.errCode;
|
|
20762
20779
|
const resultMsg = publishResult.data?.baseResp?.errmsg ?? (0 === resultCode ? "发布成功" : `发布失败(errCode=${resultCode})`);
|
|
20763
20780
|
if (0 === resultCode) {
|
|
20764
|
-
|
|
20765
|
-
task.logger.
|
|
20766
|
-
task.logger.info(`[shipinhaoPublishVideo] 视频URL: ${clipResult.url}`);
|
|
20767
|
-
task.logger.info(`[shipinhaoPublishVideo] 横屏封面URL: ${coverUpload.downloadUrl}`);
|
|
20768
|
-
task.logger.info(`[shipinhaoPublishVideo] 竖屏封面URL: ${verticalCoverUpload.downloadUrl}`);
|
|
20781
|
+
const publishId = extractEncFileKey(verticalCoverUpload.downloadUrl);
|
|
20782
|
+
if (!publishId) task.logger.error(`[shipinhaoPublishVideo] 封面 DownloadURL 中未解析到 encfilekey,关联 id 为空: ${verticalCoverUpload.downloadUrl}`);
|
|
20769
20783
|
await updateTaskState?.({
|
|
20770
20784
|
state: __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.TaskState.SUCCESS,
|
|
20771
20785
|
result: {
|
|
@@ -20795,8 +20809,7 @@ const shipinhaoPublishVideo_mock_mockAction = async (task, params)=>{
|
|
|
20795
20809
|
},
|
|
20796
20810
|
platform: "shipinhao"
|
|
20797
20811
|
});
|
|
20798
|
-
|
|
20799
|
-
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(0, "发布成功", clipResult.clipKey);
|
|
20812
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(0, "发布成功", publishId);
|
|
20800
20813
|
}
|
|
20801
20814
|
let errorMessage = resultMsg;
|
|
20802
20815
|
if (-11224 === resultCode) errorMessage = "视频号管理员完成实名且绑定手机号后才可以发表";
|
|
@@ -20808,18 +20821,16 @@ const shipinhaoPublishVideo_mock_mockAction = async (task, params)=>{
|
|
|
20808
20821
|
state: __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.TaskState.FAILED,
|
|
20809
20822
|
error: errorMessage
|
|
20810
20823
|
});
|
|
20811
|
-
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(
|
|
20824
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, errorMessage, "");
|
|
20812
20825
|
} catch (error) {
|
|
20813
20826
|
const handledError = Http.handleApiError(error);
|
|
20814
20827
|
const errorMsg = handledError.message || "发布失败,请稍后重试";
|
|
20815
|
-
const errorCode = handledError.code || 414;
|
|
20816
20828
|
task.logger.error(`[shipinhaoPublishVideo] 发布流程异常 [${currentStep}]: ${errorMsg}`, stringifyError(error), handledError.extra);
|
|
20817
|
-
task.logger.error(`[shipinhaoPublishVideo] 错误码: ${errorCode}, 当前步骤: ${currentStep}`);
|
|
20818
20829
|
await updateTaskState?.({
|
|
20819
20830
|
state: __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.TaskState.FAILED,
|
|
20820
20831
|
error: errorMsg
|
|
20821
20832
|
});
|
|
20822
|
-
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(
|
|
20833
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, errorMsg, "");
|
|
20823
20834
|
}
|
|
20824
20835
|
};
|
|
20825
20836
|
const shipinhaoPublishVideo_rpa_rpaAction = async (task, params)=>{
|
|
@@ -27387,4 +27398,4 @@ var __webpack_exports__version = package_namespaceObject.i8;
|
|
|
27387
27398
|
export { Action, ActionCommonParamsSchema, BaijiahaoPublishParamsSchema, BetaFlag, CollectionDetailSchema, ConfigDataSchema, DouyinCheckVerifyQrCodeParamsSchema, DouyinCreateCommentReplyParamsSchema, DouyinGetCollectionParamsSchema, DouyinGetCommentListParamsSchema, DouyinGetCommentReplyListParamsSchema, DouyinGetHotParamsSchema, DouyinGetLocationParamsSchema, DouyinGetMusicByCategoryParamsSchema, DouyinGetMusicCategoryParamsSchema, DouyinGetMusicParamsSchema, DouyinGetTopicsParamsSchema, DouyinGetVerifyQrCodeParamsSchema, DouyinGetWorkListParamsSchema, DouyinPublishParamsSchema, FetchArticlesDataSchema, FetchArticlesParamsSchema, Http, ProxyAgent, SearchAccountInfoParamsSchema, SessionCheckResultSchema, ShipinhaoCheckLinkValidateParamsSchema, ShipinhaoGetLocationParamsSchema, ShipinhaoGetMsgParamsSchema, ShipinhaoPublishParamsSchema, ShipinhaoPublishVideoParamsSchema, ShipinhaoSendMsgParamsSchema, ToutiaoPublishParamsSchema, UnreadCountSchema, WeixinPublishParamsSchema, WxBjhSessionParamsSchema, XhsWebSearchParamsSchema, XiaohongshuPublishParamsSchema, bjhConfigDataSchema, douyinConfigDataSchema, getFileState, reportLogger, rpaAction_Server_Mock, shipinhaoConfigDataSchema, ttConfigDataSchema, wxConfigDataSchema, xhsConfigDataSchema, __webpack_exports__version as version };
|
|
27388
27399
|
|
|
27389
27400
|
//# sourceMappingURL=index.mjs.map
|
|
27390
|
-
//# debugId=
|
|
27401
|
+
//# debugId=309d0c4f-ece2-5152-b000-0390cb565a64
|