@iflyrpa/actions 4.1.0-beta.0 → 4.1.0-beta.1
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/bundle.js +75 -99
- package/dist/bundle.js.map +1 -1
- package/dist/index.js +75 -99
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +75 -99
- package/dist/index.mjs.map +1 -1
- package/dist/utils/feishuAlarm.d.ts +4 -1
- package/dist/utils/http.d.ts +5 -0
- package/dist/utils/shipinhao/utils.d.ts +10 -0
- package/package.json +1 -1
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]="d7b84b2c-f6d7-5874-b962-65e4fb23456c")}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,7 @@ function __webpack_require__(moduleId) {
|
|
|
4352
4352
|
return module;
|
|
4353
4353
|
};
|
|
4354
4354
|
})();
|
|
4355
|
-
var package_namespaceObject = JSON.parse('{"i8":"4.1.0-beta.
|
|
4355
|
+
var package_namespaceObject = JSON.parse('{"i8":"4.1.0-beta.1"}');
|
|
4356
4356
|
const USER_MESSAGE = {
|
|
4357
4357
|
PROXY_UNAVAILABLE: "代理暂时不可用,请稍后重试或使用本地IP",
|
|
4358
4358
|
NETWORK_ERROR: "网络异常,请稍后重试",
|
|
@@ -4386,6 +4386,11 @@ function classifyPublishError(handledError) {
|
|
|
4386
4386
|
const RPA_ERROR_WEBHOOK_URL = "https://open.xfchat.iflytek.com/open-apis/bot/v2/hook/d202c0dc-5af5-40bc-83ed-abc677caa4a5";
|
|
4387
4387
|
const ALARM_THROTTLE_MS = 60000;
|
|
4388
4388
|
const lastSentAt = new Map();
|
|
4389
|
+
const THROTTLE_MAP_MAX_KEYS = 500;
|
|
4390
|
+
const pruneThrottleMap = (now)=>{
|
|
4391
|
+
if (lastSentAt.size < THROTTLE_MAP_MAX_KEYS) return;
|
|
4392
|
+
for (const [key, at] of lastSentAt)if (now - at >= ALARM_THROTTLE_MS) lastSentAt.delete(key);
|
|
4393
|
+
};
|
|
4389
4394
|
const postFeishuWebhook = (webhookUrl, payload)=>__WEBPACK_EXTERNAL_MODULE_axios__["default"].post(webhookUrl, payload, {
|
|
4390
4395
|
headers: {
|
|
4391
4396
|
"Content-Type": "application/json"
|
|
@@ -4463,10 +4468,11 @@ const buildFeishuPostMessage = (report)=>{
|
|
|
4463
4468
|
};
|
|
4464
4469
|
const reportFeishuAlarm = (report)=>{
|
|
4465
4470
|
try {
|
|
4466
|
-
const key = `${report.platform}|${report.source}|${report.errorType}|${report.code ?? ""}`;
|
|
4471
|
+
const key = `${report.platform}|${report.source}|${report.stage}|${report.errorType}|${report.code ?? ""}`;
|
|
4467
4472
|
const now = Date.now();
|
|
4468
4473
|
const last = lastSentAt.get(key);
|
|
4469
4474
|
if (last && now - last < ALARM_THROTTLE_MS) return;
|
|
4475
|
+
pruneThrottleMap(now);
|
|
4470
4476
|
lastSentAt.set(key, now);
|
|
4471
4477
|
postFeishuWebhook(RPA_ERROR_WEBHOOK_URL, buildFeishuPostMessage(report)).catch(()=>{});
|
|
4472
4478
|
} catch {}
|
|
@@ -4786,21 +4792,32 @@ class Http {
|
|
|
4786
4792
|
errorResponse.message = message;
|
|
4787
4793
|
}
|
|
4788
4794
|
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
|
-
});
|
|
4795
|
+
errorResponse.extra = {
|
|
4796
|
+
...errorResponse.extra,
|
|
4797
|
+
alarmStatus: error.response?.status,
|
|
4798
|
+
alarmErrorCode: error.code
|
|
4799
|
+
};
|
|
4801
4800
|
throw errorResponse;
|
|
4802
4801
|
});
|
|
4803
4802
|
}
|
|
4803
|
+
reportRequestFailure(config, error, attempts) {
|
|
4804
|
+
const status = error.extra?.alarmStatus;
|
|
4805
|
+
const axiosCode = error.extra?.alarmErrorCode;
|
|
4806
|
+
const method = (config.method || "get").toUpperCase();
|
|
4807
|
+
const url = config.url || "-";
|
|
4808
|
+
const retriedSuffix = attempts > 0 ? `(已重试${attempts}次仍失败)` : "";
|
|
4809
|
+
reportFeishuAlarm({
|
|
4810
|
+
level: status && ALARM_STATUS.has(status) ? "alarm" : "warning",
|
|
4811
|
+
platform: this.platform || "unknown",
|
|
4812
|
+
source: "http",
|
|
4813
|
+
stage: `${method} ${url}`,
|
|
4814
|
+
errorType: status ? `HTTP_${status}` : axiosCode || "NETWORK_ERROR",
|
|
4815
|
+
code: error.code,
|
|
4816
|
+
msg: `${error.message}${retriedSuffix}`,
|
|
4817
|
+
url: config.url,
|
|
4818
|
+
title: "RPA接口异常"
|
|
4819
|
+
});
|
|
4820
|
+
}
|
|
4804
4821
|
async api(config, options) {
|
|
4805
4822
|
const retries = options?.retries ?? 0;
|
|
4806
4823
|
const retryDelay = options?.retryDelay ?? 500;
|
|
@@ -4845,10 +4862,12 @@ class Http {
|
|
|
4845
4862
|
].includes(handledError.code);
|
|
4846
4863
|
if (Rtimes < retries && isRetry) {
|
|
4847
4864
|
const url = config.url || "";
|
|
4848
|
-
|
|
4849
|
-
|
|
4865
|
+
const backoff = Math.min(retryDelay * 2 ** Rtimes, 5000);
|
|
4866
|
+
this.logger?.warn(`进入第${Rtimes + 1}次重试!错误码: ${handledError.code}, 等待: ${backoff}ms, 请求地址: ${url}`);
|
|
4867
|
+
await new Promise((resolve)=>setTimeout(resolve, backoff));
|
|
4850
4868
|
return sessionRt(Rtimes + 1);
|
|
4851
4869
|
}
|
|
4870
|
+
this.reportRequestFailure(config, handledError, Rtimes);
|
|
4852
4871
|
return Promise.reject(handledError);
|
|
4853
4872
|
}
|
|
4854
4873
|
};
|
|
@@ -9950,7 +9969,8 @@ const XhsFansExport = async (_task, params)=>{
|
|
|
9950
9969
|
},
|
|
9951
9970
|
_task.logger,
|
|
9952
9971
|
params.proxyLoc,
|
|
9953
|
-
params.accountId
|
|
9972
|
+
params.accountId,
|
|
9973
|
+
"xiaohongshu"
|
|
9954
9974
|
];
|
|
9955
9975
|
const http = new Http(...args);
|
|
9956
9976
|
const fans = {
|
|
@@ -9964,8 +9984,8 @@ const XhsFansExport = async (_task, params)=>{
|
|
|
9964
9984
|
url: "https://creator.xiaohongshu.com/api/galaxy/creator/home/personal_info"
|
|
9965
9985
|
}, {
|
|
9966
9986
|
retries: 3,
|
|
9967
|
-
retryDelay:
|
|
9968
|
-
timeout:
|
|
9987
|
+
retryDelay: 300,
|
|
9988
|
+
timeout: 30000
|
|
9969
9989
|
});
|
|
9970
9990
|
fans.fans_count = Number(res.data.fans_count);
|
|
9971
9991
|
fans.digg_count = Number(res.data.faved_count);
|
|
@@ -11102,7 +11122,8 @@ const XhsSessionCheck = async (_task, params)=>{
|
|
|
11102
11122
|
},
|
|
11103
11123
|
_task.logger,
|
|
11104
11124
|
params.proxyLoc,
|
|
11105
|
-
params.accountId
|
|
11125
|
+
params.accountId,
|
|
11126
|
+
"xiaohongshu"
|
|
11106
11127
|
];
|
|
11107
11128
|
const http = new Http(...args);
|
|
11108
11129
|
http.addResponseInterceptor((response)=>{
|
|
@@ -11150,8 +11171,8 @@ const XhsSessionCheck = async (_task, params)=>{
|
|
|
11150
11171
|
headers: loginBaseXsHeader
|
|
11151
11172
|
}, {
|
|
11152
11173
|
retries: 3,
|
|
11153
|
-
retryDelay:
|
|
11154
|
-
timeout:
|
|
11174
|
+
retryDelay: 300,
|
|
11175
|
+
timeout: 30000
|
|
11155
11176
|
}).catch((e)=>{
|
|
11156
11177
|
const clientTimestamp = Date.now();
|
|
11157
11178
|
const serverDate = e?.extra?.serverDate;
|
|
@@ -11183,8 +11204,8 @@ const XhsSessionCheck = async (_task, params)=>{
|
|
|
11183
11204
|
headers: webSessionXsHeader
|
|
11184
11205
|
}, {
|
|
11185
11206
|
retries: 3,
|
|
11186
|
-
retryDelay:
|
|
11187
|
-
timeout:
|
|
11207
|
+
retryDelay: 300,
|
|
11208
|
+
timeout: 30000
|
|
11188
11209
|
});
|
|
11189
11210
|
const [baseInfo, web_session] = await Promise.all([
|
|
11190
11211
|
_baseInfo,
|
|
@@ -11276,6 +11297,10 @@ const ShipinhaoSessionCheck = async (_task, params)=>{
|
|
|
11276
11297
|
};
|
|
11277
11298
|
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(data, message);
|
|
11278
11299
|
};
|
|
11300
|
+
const extractEncFileKey = (downloadUrl)=>{
|
|
11301
|
+
if (!downloadUrl) return "";
|
|
11302
|
+
return downloadUrl.split("encfilekey=")[1]?.split("&")[0] || "";
|
|
11303
|
+
};
|
|
11279
11304
|
const rid = ()=>`${Math.floor(Date.now() / 1e3).toString(16)}-${[
|
|
11280
11305
|
...Array(8)
|
|
11281
11306
|
].map(()=>Math.floor(16 * Math.random()).toString(16)).join("")}`;
|
|
@@ -15430,7 +15455,8 @@ const getXhsUnreadCount = async (_task, params)=>{
|
|
|
15430
15455
|
},
|
|
15431
15456
|
_task.logger,
|
|
15432
15457
|
params.proxyLoc,
|
|
15433
|
-
params.accountId
|
|
15458
|
+
params.accountId,
|
|
15459
|
+
"xiaohongshu"
|
|
15434
15460
|
];
|
|
15435
15461
|
const http = new Http(...args);
|
|
15436
15462
|
let unreadCount = {
|
|
@@ -15459,8 +15485,8 @@ const getXhsUnreadCount = async (_task, params)=>{
|
|
|
15459
15485
|
headers: xsHeader
|
|
15460
15486
|
}, {
|
|
15461
15487
|
retries: 3,
|
|
15462
|
-
retryDelay:
|
|
15463
|
-
timeout:
|
|
15488
|
+
retryDelay: 300,
|
|
15489
|
+
timeout: 30000
|
|
15464
15490
|
});
|
|
15465
15491
|
const isSuccess = 0 === res.code;
|
|
15466
15492
|
if (isSuccess) unreadCount = res.data;
|
|
@@ -15871,7 +15897,8 @@ async function getXiaohongshuData(_task, params) {
|
|
|
15871
15897
|
},
|
|
15872
15898
|
_task.logger,
|
|
15873
15899
|
params.proxyLoc,
|
|
15874
|
-
params.accountId
|
|
15900
|
+
params.accountId,
|
|
15901
|
+
"xiaohongshu"
|
|
15875
15902
|
];
|
|
15876
15903
|
const http = new Http(...args);
|
|
15877
15904
|
const xsEncrypt = new Xhshow();
|
|
@@ -15887,8 +15914,8 @@ async function getXiaohongshuData(_task, params) {
|
|
|
15887
15914
|
url: "https://creator.xiaohongshu.com/api/galaxy/creator/home/personal_info"
|
|
15888
15915
|
}, {
|
|
15889
15916
|
retries: 3,
|
|
15890
|
-
retryDelay:
|
|
15891
|
-
timeout:
|
|
15917
|
+
retryDelay: 300,
|
|
15918
|
+
timeout: 30000
|
|
15892
15919
|
}),
|
|
15893
15920
|
http.api({
|
|
15894
15921
|
method: "get",
|
|
@@ -15897,8 +15924,8 @@ async function getXiaohongshuData(_task, params) {
|
|
|
15897
15924
|
headers: sevenDataXsHeader
|
|
15898
15925
|
}, {
|
|
15899
15926
|
retries: 3,
|
|
15900
|
-
retryDelay:
|
|
15901
|
-
timeout:
|
|
15927
|
+
retryDelay: 300,
|
|
15928
|
+
timeout: 30000
|
|
15902
15929
|
})
|
|
15903
15930
|
]);
|
|
15904
15931
|
const xhsData = {
|
|
@@ -18935,7 +18962,7 @@ const shipinhaoPublish_mock_mockAction = async (task, params)=>{
|
|
|
18935
18962
|
const resultMsg = publishResult.data?.baseResp?.errmsg ?? publishResult.errMsg;
|
|
18936
18963
|
if (0 === resultCode) {
|
|
18937
18964
|
task.logger.info("[shipinhaoPublish] 发布成功");
|
|
18938
|
-
const publishId = uploadedImages[0]?.thumbUrl
|
|
18965
|
+
const publishId = extractEncFileKey(uploadedImages[0]?.thumbUrl);
|
|
18939
18966
|
await updateTaskState?.({
|
|
18940
18967
|
state: __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.TaskState.SUCCESS,
|
|
18941
18968
|
result: {
|
|
@@ -19830,8 +19857,7 @@ async function uploader_uploadFile(opts) {
|
|
|
19830
19857
|
const partTimeout = tuning?.partTimeout ?? DEFAULT_TUNING.partTimeout;
|
|
19831
19858
|
const partRetries = tuning?.partRetries ?? DEFAULT_TUNING.partRetries;
|
|
19832
19859
|
const completeTimeout = tuning?.completeTimeout ?? DEFAULT_TUNING.completeTimeout;
|
|
19833
|
-
logger?.info(
|
|
19834
|
-
logger?.info(`上传超时策略: 单片 ${partTimeout / 1000}s(重试 ${partRetries} 次)、合并 ${completeTimeout / 1000}s`);
|
|
19860
|
+
logger?.info(`[shipinhaoPublishVideo] 开始上传: ${fileName} (${fileSize} B, filetype=${fileType})`);
|
|
19835
19861
|
const fileMd5 = await computeFileMd5(filePath);
|
|
19836
19862
|
const taskId = generateTaskId(fileName, fileSize, fileMd5);
|
|
19837
19863
|
const baseUrl = "https://finderassistancea.video.qq.com";
|
|
@@ -19842,7 +19868,7 @@ async function uploader_uploadFile(opts) {
|
|
|
19842
19868
|
const chunkCount = Math.ceil(fileSize / CHUNK_SIZE);
|
|
19843
19869
|
const blockPartLength = [];
|
|
19844
19870
|
for(let i = 0; i < chunkCount; i++)blockPartLength.push(Math.min((i + 1) * CHUNK_SIZE, fileSize));
|
|
19845
|
-
logger?.info(
|
|
19871
|
+
logger?.info(`[shipinhaoPublishVideo] 视频分片: ${chunkCount} 片`);
|
|
19846
19872
|
const applyRes = await http.api({
|
|
19847
19873
|
method: "PUT",
|
|
19848
19874
|
url: `${baseUrl}/applyuploaddfs`,
|
|
@@ -19863,7 +19889,6 @@ async function uploader_uploadFile(opts) {
|
|
|
19863
19889
|
let uploadId = applyRes.UploadID;
|
|
19864
19890
|
const uploadedParts = new Set();
|
|
19865
19891
|
if (applyRes.ListPartsResult) {
|
|
19866
|
-
logger?.info("检测到已上传分片,执行续传");
|
|
19867
19892
|
const parts = Array.isArray(applyRes.ListPartsResult.Part) ? applyRes.ListPartsResult.Part : applyRes.ListPartsResult.Part ? [
|
|
19868
19893
|
applyRes.ListPartsResult.Part
|
|
19869
19894
|
] : [];
|
|
@@ -19899,7 +19924,6 @@ async function uploader_uploadFile(opts) {
|
|
|
19899
19924
|
PartNumber: partNumber,
|
|
19900
19925
|
ETag: existing.ETag
|
|
19901
19926
|
});
|
|
19902
|
-
logger?.info(`分片 ${partNumber}/${chunkCount} 已存在,跳过`);
|
|
19903
19927
|
continue;
|
|
19904
19928
|
}
|
|
19905
19929
|
}
|
|
@@ -19924,18 +19948,15 @@ async function uploader_uploadFile(opts) {
|
|
|
19924
19948
|
retries: partRetries,
|
|
19925
19949
|
retryDelay: 2000
|
|
19926
19950
|
});
|
|
19927
|
-
|
|
19928
|
-
const throughput = Math.round(chunkSize / (partElapsed / 1000));
|
|
19951
|
+
Date.now();
|
|
19929
19952
|
partInfo.push({
|
|
19930
19953
|
PartNumber: partNumber,
|
|
19931
19954
|
ETag: `"${chunkMd5}"`
|
|
19932
19955
|
});
|
|
19933
|
-
logger?.info(`分片 ${partNumber}/${chunkCount} 完成 (${chunkSize} B, ${partElapsed}ms, ${Math.round(throughput / 1024)}KB/s)`);
|
|
19934
19956
|
}
|
|
19935
19957
|
} finally{
|
|
19936
19958
|
__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].closeSync(fd);
|
|
19937
19959
|
}
|
|
19938
|
-
logger?.info("合并分片...");
|
|
19939
19960
|
const completeRes = await http.api({
|
|
19940
19961
|
method: "POST",
|
|
19941
19962
|
url: `${baseUrl}/completepartuploaddfs?UploadID=${encodeURIComponent(uploadId)}`,
|
|
@@ -19953,7 +19974,7 @@ async function uploader_uploadFile(opts) {
|
|
|
19953
19974
|
retryDelay: 3000
|
|
19954
19975
|
});
|
|
19955
19976
|
if (!completeRes.DownloadURL) throw new Error("合并分片失败: " + JSON.stringify(completeRes));
|
|
19956
|
-
logger?.info(
|
|
19977
|
+
logger?.info(`[shipinhaoPublishVideo] ${fileName} 上传成功`);
|
|
19957
19978
|
return {
|
|
19958
19979
|
downloadUrl: completeRes.DownloadURL,
|
|
19959
19980
|
md5: fileMd5,
|
|
@@ -20347,7 +20368,6 @@ function buildCommonBody(finderUsername) {
|
|
|
20347
20368
|
};
|
|
20348
20369
|
}
|
|
20349
20370
|
async function getTraceKey(auth, client, http, logger) {
|
|
20350
|
-
logger.info("[getTraceKey] 开始获取 traceKey...");
|
|
20351
20371
|
const res = await http.api({
|
|
20352
20372
|
method: "POST",
|
|
20353
20373
|
url: `${MICRO_CONTENT_BASE}/post/get-finder-post-trace-key`,
|
|
@@ -20362,11 +20382,9 @@ async function getTraceKey(auth, client, http, logger) {
|
|
|
20362
20382
|
logger.error("[getTraceKey] 获取失败:", JSON.stringify(res));
|
|
20363
20383
|
throw new Error(`获取 traceKey 失败: ${JSON.stringify(res)}`);
|
|
20364
20384
|
}
|
|
20365
|
-
logger.info(`[getTraceKey] 获取成功: ${res.data.traceKey}`);
|
|
20366
20385
|
return res.data.traceKey;
|
|
20367
20386
|
}
|
|
20368
20387
|
async function getObjectTagKey(auth, client, http, logger) {
|
|
20369
|
-
logger.info("[getObjectTagKey] 获取内容声明 tagKey...");
|
|
20370
20388
|
try {
|
|
20371
20389
|
const res = await http.api({
|
|
20372
20390
|
method: "POST",
|
|
@@ -20382,7 +20400,6 @@ async function getObjectTagKey(auth, client, http, logger) {
|
|
|
20382
20400
|
logger.warn(`[getObjectTagKey] 未取到 tagKey: ${JSON.stringify(res)}`);
|
|
20383
20401
|
return null;
|
|
20384
20402
|
}
|
|
20385
|
-
logger.info(`[getObjectTagKey] tagKey: ${res.data.tagKey}`);
|
|
20386
20403
|
return res.data.tagKey;
|
|
20387
20404
|
} catch (error) {
|
|
20388
20405
|
logger.warn(`[getObjectTagKey] 获取 tagKey 异常: ${stringifyError(error)}`);
|
|
@@ -20391,7 +20408,6 @@ async function getObjectTagKey(auth, client, http, logger) {
|
|
|
20391
20408
|
}
|
|
20392
20409
|
async function submitAndPollTranscode(opts) {
|
|
20393
20410
|
const { videoUrl, videoMeta, traceKey, uploadStartTime, uploadEndTime, finderUsername, client, http, logger } = opts;
|
|
20394
|
-
logger.info("[submitAndPollTranscode] 开始提交转码任务...");
|
|
20395
20411
|
const finderUrl = videoUrl.includes("wxapp.tc.qq.com") ? `https://finder.video.qq.com${videoUrl.split("qq.com")[1]}` : videoUrl;
|
|
20396
20412
|
logger.info(`[submitAndPollTranscode] 视频尺寸: ${videoMeta.width}x${videoMeta.height}, 时长: ${videoMeta.duration}s`);
|
|
20397
20413
|
const submitRes = await http.api({
|
|
@@ -20430,12 +20446,10 @@ async function submitAndPollTranscode(opts) {
|
|
|
20430
20446
|
throw new Error(`提交转码失败: ${JSON.stringify(submitRes)}`);
|
|
20431
20447
|
}
|
|
20432
20448
|
const { clipKey, draftId } = submitRes.data;
|
|
20433
|
-
logger.info(`[submitAndPollTranscode] 转码任务已提交,clipKey: ${clipKey}, draftId: ${draftId}`);
|
|
20434
20449
|
const pollInterval = 5000;
|
|
20435
20450
|
const pollBudget = Math.min(1800000, 300000 + 1000 * Math.ceil(1.5 * videoMeta.duration));
|
|
20436
20451
|
const maxPolls = Math.ceil(pollBudget / pollInterval);
|
|
20437
20452
|
let pollCount = 0;
|
|
20438
|
-
logger.info(`[submitAndPollTranscode] 开始轮询转码结果,最多 ${maxPolls} 次(${Math.round(pollBudget / 1000)}s),间隔 ${pollInterval / 1000}s`);
|
|
20439
20453
|
while(pollCount < maxPolls){
|
|
20440
20454
|
await sleep(pollInterval);
|
|
20441
20455
|
pollCount++;
|
|
@@ -20459,14 +20473,12 @@ async function submitAndPollTranscode(opts) {
|
|
|
20459
20473
|
throw new Error(`转码轮询失败 (poll ${pollCount}): ${JSON.stringify(pollRes)}`);
|
|
20460
20474
|
}
|
|
20461
20475
|
const { flag, url, width, height, duration, md5, fileSize } = pollRes.data || {};
|
|
20462
|
-
logger.info(`[submitAndPollTranscode] 轮询第 ${pollCount} 次,flag=${flag}`);
|
|
20463
20476
|
if (1 === flag) {
|
|
20464
20477
|
if (!url || !width || !height || !duration || !md5 || !fileSize) {
|
|
20465
20478
|
logger.error("[submitAndPollTranscode] 转码完成但返回数据不完整:", JSON.stringify(pollRes.data));
|
|
20466
20479
|
throw new Error(`转码完成但返回数据不完整: ${JSON.stringify(pollRes.data)}`);
|
|
20467
20480
|
}
|
|
20468
20481
|
logger.info(`[submitAndPollTranscode] 转码完成! 用时: ${pollCount * pollInterval / 1000}s`);
|
|
20469
|
-
logger.info(`[submitAndPollTranscode] 视频信息: ${width}x${height}, 时长: ${duration}s, 大小: ${fileSize}`);
|
|
20470
20482
|
return {
|
|
20471
20483
|
clipKey,
|
|
20472
20484
|
url,
|
|
@@ -20477,7 +20489,7 @@ async function submitAndPollTranscode(opts) {
|
|
|
20477
20489
|
fileSize
|
|
20478
20490
|
};
|
|
20479
20491
|
}
|
|
20480
|
-
if (2 === flag)
|
|
20492
|
+
if (2 === flag) ;
|
|
20481
20493
|
else {
|
|
20482
20494
|
logger.error(`[submitAndPollTranscode] 转码失败,未知 flag=${flag}:`, JSON.stringify(pollRes.data));
|
|
20483
20495
|
throw new Error(`转码失败,未知 flag=${flag}: ${JSON.stringify(pollRes.data)}`);
|
|
@@ -20488,16 +20500,11 @@ async function submitAndPollTranscode(opts) {
|
|
|
20488
20500
|
}
|
|
20489
20501
|
async function publishVideo(opts) {
|
|
20490
20502
|
const { params, auth, client, clipResult, videoUpload, coverUpload, verticalCoverUpload, videoMeta, traceKey, tagKey, uploadStartTime, uploadEndTime, proxyHttp, logger } = opts;
|
|
20491
|
-
logger.info("[publishVideo] 开始构建发布请求...");
|
|
20492
20503
|
const toFinderUrl = (url)=>url.includes("wxapp.tc.qq.com") ? `https://finder.video.qq.com${url.split("qq.com")[1]}` : url;
|
|
20493
20504
|
const thumbFinderUrl = toFinderUrl(coverUpload.downloadUrl);
|
|
20494
20505
|
const coverFinderUrl = toFinderUrl(verticalCoverUpload.downloadUrl);
|
|
20495
20506
|
const md5sumUuid = __WEBPACK_EXTERNAL_MODULE_node_crypto_9ba42079__["default"].randomUUID();
|
|
20496
20507
|
const description = params.description;
|
|
20497
|
-
logger.info("[publishVideo] 发布参数:");
|
|
20498
|
-
logger.info(` - 短标题: ${params.title || "(无)"}`);
|
|
20499
|
-
logger.info(` - 描述: ${description.substring(0, 50)}${description.length > 50 ? "..." : ""}`);
|
|
20500
|
-
logger.info(` - 定时发布: ${params.scheduledTime ? new Date(1000 * params.scheduledTime).toLocaleString() : "立即发布"}`);
|
|
20501
20508
|
const objectDesc = {
|
|
20502
20509
|
mpTitle: "",
|
|
20503
20510
|
description,
|
|
@@ -20571,7 +20578,6 @@ async function publishVideo(opts) {
|
|
|
20571
20578
|
};
|
|
20572
20579
|
if (params.scheduledTime) publishData.effectiveTime = params.scheduledTime;
|
|
20573
20580
|
if (params.tagInfo && tagKey) publishData.tagInfo = buildTagInfo(params.tagInfo, tagKey);
|
|
20574
|
-
logger.info("[publishVideo] 开始发布视频,全部参数:" + JSON.stringify(publishData));
|
|
20575
20581
|
const publishRes = await proxyHttp.api({
|
|
20576
20582
|
method: "POST",
|
|
20577
20583
|
url: `${MICRO_CONTENT_BASE}/post/post_create`,
|
|
@@ -20579,7 +20585,7 @@ async function publishVideo(opts) {
|
|
|
20579
20585
|
data: publishData,
|
|
20580
20586
|
defaultErrorMsg: "发布视频失败"
|
|
20581
20587
|
});
|
|
20582
|
-
logger.info(`[publishVideo]
|
|
20588
|
+
logger.info(`[publishVideo] 发布结果: errCode=${publishRes.errCode}, baseResp.errcode=${publishRes.data?.baseResp?.errcode}`);
|
|
20583
20589
|
return publishRes;
|
|
20584
20590
|
}
|
|
20585
20591
|
function sleep(ms) {
|
|
@@ -20593,11 +20599,9 @@ async function resolveLocalCoverPath(coverPath, label, tmpCachePath, logger) {
|
|
|
20593
20599
|
return savePath;
|
|
20594
20600
|
}
|
|
20595
20601
|
const shipinhaoPublishVideo_mock_mockAction = async (task, params)=>{
|
|
20596
|
-
task.logger.info("[shipinhaoPublishVideo] 开始执行视频号视频发布 - Mock API 方式");
|
|
20597
20602
|
const updateTaskState = task.taskStageStore?.update?.bind(task.taskStageStore, task.taskId || "");
|
|
20598
20603
|
let currentStep = "初始化";
|
|
20599
20604
|
try {
|
|
20600
|
-
task.logger.info(`[shipinhaoPublishVideo] 发布方式: ${params.scheduledTime ? `定时 ${new Date(1000 * params.scheduledTime).toLocaleString()}` : "立即发布"}`);
|
|
20601
20605
|
currentStep = "解析认证信息";
|
|
20602
20606
|
const cookieString = params.cookies.map((c)=>`${c.name}=${c.value}`).join("; ");
|
|
20603
20607
|
const http = new Http({
|
|
@@ -20609,11 +20613,8 @@ const shipinhaoPublishVideo_mock_mockAction = async (task, params)=>{
|
|
|
20609
20613
|
if (!params.videoPath) return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "视频文件路径不能为空", "");
|
|
20610
20614
|
if (!params.coverPath) return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "横屏封面图片路径不能为空", "");
|
|
20611
20615
|
currentStep = "获取上传认证";
|
|
20612
|
-
task.logger.info("[shipinhaoPublishVideo] 获取上传认证...");
|
|
20613
20616
|
const auth = await getShipinhaoUploadAuth(cookieString, http);
|
|
20614
20617
|
const client = resolveClientContext(params, auth.uin);
|
|
20615
|
-
if (!client.aId) task.logger.warn("[shipinhaoPublishVideo] extraParam.aId 缺失,query 将不带 _aid");
|
|
20616
|
-
if (!client.fingerPrintDeviceId) task.logger.warn("[shipinhaoPublishVideo] extraParam.fingerPrintDeviceId 缺失,请求将不带 finger-print-device-id");
|
|
20617
20618
|
const publishHeaders = buildPublishHeaders(cookieString, client);
|
|
20618
20619
|
const microHttp = new Http({
|
|
20619
20620
|
headers: publishHeaders
|
|
@@ -20629,25 +20630,20 @@ const shipinhaoPublishVideo_mock_mockAction = async (task, params)=>{
|
|
|
20629
20630
|
];
|
|
20630
20631
|
const proxyHttp = new Http(...args);
|
|
20631
20632
|
currentStep = "组装视频元数据";
|
|
20632
|
-
task.logger.info("[shipinhaoPublishVideo] 组装视频元数据...");
|
|
20633
20633
|
const videoMeta = buildVideoMetaFromParams(params.videoPath, params.videoMetadata);
|
|
20634
20634
|
task.logger.info(`[shipinhaoPublishVideo] 视频: ${videoMeta.width}×${videoMeta.height}, ${videoMeta.duration.toFixed(2)}s, ${(videoMeta.fileSize / 1024 / 1024).toFixed(2)}MB, codec=${videoMeta.codec || "unknown"}`);
|
|
20635
|
-
if (!videoMeta.codec) task.logger.warn("[shipinhaoPublishVideo] 未能读取视频编码格式,跳过 H.264 预检,交由服务端判断");
|
|
20636
20635
|
currentStep = "校验视频限制";
|
|
20637
20636
|
const validationError = validateShipinhaoVideo(params.videoPath, videoMeta);
|
|
20638
20637
|
if (validationError) {
|
|
20639
|
-
task.logger.error(`[shipinhaoPublishVideo] 视频校验未通过: ${validationError}`);
|
|
20640
20638
|
await updateTaskState?.({
|
|
20641
20639
|
state: __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.TaskState.FAILED,
|
|
20642
20640
|
error: validationError
|
|
20643
20641
|
});
|
|
20644
20642
|
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, validationError, "");
|
|
20645
20643
|
}
|
|
20646
|
-
task.logger.info("[shipinhaoPublishVideo] 视频校验通过");
|
|
20647
20644
|
currentStep = "校验标题";
|
|
20648
20645
|
const titleError = validateShipinhaoTitle(params.title);
|
|
20649
20646
|
if (titleError) {
|
|
20650
|
-
task.logger.error(`[shipinhaoPublishVideo] 标题校验未通过: ${titleError}`);
|
|
20651
20647
|
await updateTaskState?.({
|
|
20652
20648
|
state: __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.TaskState.FAILED,
|
|
20653
20649
|
error: titleError
|
|
@@ -20655,7 +20651,6 @@ const shipinhaoPublishVideo_mock_mockAction = async (task, params)=>{
|
|
|
20655
20651
|
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, titleError, "");
|
|
20656
20652
|
}
|
|
20657
20653
|
currentStep = "获取 traceKey";
|
|
20658
|
-
task.logger.info("[shipinhaoPublishVideo] 获取 traceKey...");
|
|
20659
20654
|
const traceKey = await getTraceKey(auth, client, microHttp, task.logger);
|
|
20660
20655
|
let tagKey = null;
|
|
20661
20656
|
if (params.tagInfo) {
|
|
@@ -20663,11 +20658,7 @@ const shipinhaoPublishVideo_mock_mockAction = async (task, params)=>{
|
|
|
20663
20658
|
tagKey = await getObjectTagKey(auth, client, microHttp, task.logger);
|
|
20664
20659
|
}
|
|
20665
20660
|
const uploadStartTime = Math.floor(Date.now() / 1000);
|
|
20666
|
-
task.logger.info(`[shipinhaoPublishVideo] 上传开始时间: ${uploadStartTime}`);
|
|
20667
20661
|
currentStep = "上传视频";
|
|
20668
|
-
task.logger.info("[shipinhaoPublishVideo] 上传视频...");
|
|
20669
|
-
task.logger.info(`[shipinhaoPublishVideo] 视频路径: ${params.videoPath}`);
|
|
20670
|
-
task.logger.info(`[shipinhaoPublishVideo] 视频文件类型: ${auth.videoFileType}`);
|
|
20671
20662
|
const videoUpload = await uploader_uploadFile({
|
|
20672
20663
|
filePath: params.videoPath,
|
|
20673
20664
|
fileType: auth.videoFileType,
|
|
@@ -20676,12 +20667,10 @@ const shipinhaoPublishVideo_mock_mockAction = async (task, params)=>{
|
|
|
20676
20667
|
http,
|
|
20677
20668
|
logger: task.logger
|
|
20678
20669
|
});
|
|
20679
|
-
task.logger.info("[shipinhaoPublishVideo] 视频上传完成");
|
|
20680
20670
|
const uploadEndTime = Math.floor(Date.now() / 1000);
|
|
20681
|
-
task.logger.info(`[shipinhaoPublishVideo]
|
|
20671
|
+
task.logger.info(`[shipinhaoPublishVideo] 耗时: ${uploadEndTime - uploadStartTime}s`);
|
|
20682
20672
|
currentStep = "上传横屏封面";
|
|
20683
20673
|
const localCoverPath = await resolveLocalCoverPath(params.coverPath, "横屏封面", task.getTmpPath(), task.logger);
|
|
20684
|
-
task.logger.info("[shipinhaoPublishVideo] 上传横屏封面...");
|
|
20685
20674
|
const coverUpload = await uploader_uploadFile({
|
|
20686
20675
|
filePath: localCoverPath,
|
|
20687
20676
|
fileType: auth.pictureFileType,
|
|
@@ -20690,12 +20679,10 @@ const shipinhaoPublishVideo_mock_mockAction = async (task, params)=>{
|
|
|
20690
20679
|
http,
|
|
20691
20680
|
logger: task.logger
|
|
20692
20681
|
});
|
|
20693
|
-
task.logger.info("[shipinhaoPublishVideo] 横屏封面上传完成");
|
|
20694
20682
|
let verticalCoverUpload = coverUpload;
|
|
20695
20683
|
if (params.verticalCoverPath) {
|
|
20696
20684
|
currentStep = "上传竖屏封面";
|
|
20697
20685
|
const localVerticalPath = await resolveLocalCoverPath(params.verticalCoverPath, "竖屏封面", task.getTmpPath(), task.logger);
|
|
20698
|
-
task.logger.info("[shipinhaoPublishVideo] 上传竖屏封面");
|
|
20699
20686
|
verticalCoverUpload = await uploader_uploadFile({
|
|
20700
20687
|
filePath: localVerticalPath,
|
|
20701
20688
|
fileType: auth.pictureFileType,
|
|
@@ -20704,10 +20691,8 @@ const shipinhaoPublishVideo_mock_mockAction = async (task, params)=>{
|
|
|
20704
20691
|
http,
|
|
20705
20692
|
logger: task.logger
|
|
20706
20693
|
});
|
|
20707
|
-
|
|
20708
|
-
} else task.logger.info("[shipinhaoPublishVideo] 未传竖屏封面,复用横屏封面");
|
|
20694
|
+
}
|
|
20709
20695
|
currentStep = "提交转码";
|
|
20710
|
-
task.logger.info("[shipinhaoPublishVideo] 提交转码...");
|
|
20711
20696
|
const clipResult = await submitAndPollTranscode({
|
|
20712
20697
|
videoUrl: videoUpload.downloadUrl,
|
|
20713
20698
|
videoMeta,
|
|
@@ -20720,8 +20705,6 @@ const shipinhaoPublishVideo_mock_mockAction = async (task, params)=>{
|
|
|
20720
20705
|
logger: task.logger
|
|
20721
20706
|
});
|
|
20722
20707
|
currentStep = "发布视频";
|
|
20723
|
-
task.logger.info("[shipinhaoPublishVideo] 发布视频...");
|
|
20724
|
-
task.logger.info(`[shipinhaoPublishVideo] clipKey: ${clipResult.clipKey}`);
|
|
20725
20708
|
let publishResult;
|
|
20726
20709
|
try {
|
|
20727
20710
|
publishResult = await publishVideo({
|
|
@@ -20746,7 +20729,6 @@ const shipinhaoPublishVideo_mock_mockAction = async (task, params)=>{
|
|
|
20746
20729
|
const classified = classifyPublishError(handledError);
|
|
20747
20730
|
if (classified) {
|
|
20748
20731
|
const message = `${classified.userMessage}${task.debug ? ` ${http.proxyInfo}` : ""}`;
|
|
20749
|
-
task.logger.error(`[shipinhaoPublishVideo] ${classified.category},直接返回: ${handledError.message} (code=${handledError.code})`, stringifyError(handledError));
|
|
20750
20732
|
await updateTaskState?.({
|
|
20751
20733
|
state: __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.TaskState.FAILED,
|
|
20752
20734
|
error: message
|
|
@@ -20763,11 +20745,8 @@ const shipinhaoPublishVideo_mock_mockAction = async (task, params)=>{
|
|
|
20763
20745
|
const resultCode = publishResult.data?.baseResp?.errcode ?? publishResult.errCode;
|
|
20764
20746
|
const resultMsg = publishResult.data?.baseResp?.errmsg ?? (0 === resultCode ? "发布成功" : `发布失败(errCode=${resultCode})`);
|
|
20765
20747
|
if (0 === resultCode) {
|
|
20766
|
-
|
|
20767
|
-
task.logger.
|
|
20768
|
-
task.logger.info(`[shipinhaoPublishVideo] 视频URL: ${clipResult.url}`);
|
|
20769
|
-
task.logger.info(`[shipinhaoPublishVideo] 横屏封面URL: ${coverUpload.downloadUrl}`);
|
|
20770
|
-
task.logger.info(`[shipinhaoPublishVideo] 竖屏封面URL: ${verticalCoverUpload.downloadUrl}`);
|
|
20748
|
+
const publishId = extractEncFileKey(coverUpload.downloadUrl);
|
|
20749
|
+
if (!publishId) task.logger.error(`[shipinhaoPublishVideo] 封面 DownloadURL 中未解析到 encfilekey,关联 id 为空: ${coverUpload.downloadUrl}`);
|
|
20771
20750
|
await updateTaskState?.({
|
|
20772
20751
|
state: __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.TaskState.SUCCESS,
|
|
20773
20752
|
result: {
|
|
@@ -20797,8 +20776,7 @@ const shipinhaoPublishVideo_mock_mockAction = async (task, params)=>{
|
|
|
20797
20776
|
},
|
|
20798
20777
|
platform: "shipinhao"
|
|
20799
20778
|
});
|
|
20800
|
-
|
|
20801
|
-
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(0, "发布成功", clipResult.clipKey);
|
|
20779
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(0, "发布成功", publishId);
|
|
20802
20780
|
}
|
|
20803
20781
|
let errorMessage = resultMsg;
|
|
20804
20782
|
if (-11224 === resultCode) errorMessage = "视频号管理员完成实名且绑定手机号后才可以发表";
|
|
@@ -20810,18 +20788,16 @@ const shipinhaoPublishVideo_mock_mockAction = async (task, params)=>{
|
|
|
20810
20788
|
state: __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.TaskState.FAILED,
|
|
20811
20789
|
error: errorMessage
|
|
20812
20790
|
});
|
|
20813
|
-
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(
|
|
20791
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, errorMessage, "");
|
|
20814
20792
|
} catch (error) {
|
|
20815
20793
|
const handledError = Http.handleApiError(error);
|
|
20816
20794
|
const errorMsg = handledError.message || "发布失败,请稍后重试";
|
|
20817
|
-
const errorCode = handledError.code || 414;
|
|
20818
20795
|
task.logger.error(`[shipinhaoPublishVideo] 发布流程异常 [${currentStep}]: ${errorMsg}`, stringifyError(error), handledError.extra);
|
|
20819
|
-
task.logger.error(`[shipinhaoPublishVideo] 错误码: ${errorCode}, 当前步骤: ${currentStep}`);
|
|
20820
20796
|
await updateTaskState?.({
|
|
20821
20797
|
state: __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.TaskState.FAILED,
|
|
20822
20798
|
error: errorMsg
|
|
20823
20799
|
});
|
|
20824
|
-
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(
|
|
20800
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, errorMsg, "");
|
|
20825
20801
|
}
|
|
20826
20802
|
};
|
|
20827
20803
|
const shipinhaoPublishVideo_rpa_rpaAction = async (task, params)=>{
|
|
@@ -27389,4 +27365,4 @@ var __webpack_exports__version = package_namespaceObject.i8;
|
|
|
27389
27365
|
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 };
|
|
27390
27366
|
|
|
27391
27367
|
//# sourceMappingURL=index.mjs.map
|
|
27392
|
-
//# debugId=
|
|
27368
|
+
//# debugId=d7b84b2c-f6d7-5874-b962-65e4fb23456c
|