@iflyrpa/actions 4.1.0-beta.0 → 4.1.0-beta.2
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 +88 -104
- package/dist/bundle.js.map +1 -1
- package/dist/index.js +86 -100
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +86 -100
- 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 +2 -2
package/dist/index.js
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]="161e4c22-57ca-5b29-b12b-b647dd871406")}catch(e){}}();
|
|
3
3
|
var __webpack_modules__ = {
|
|
4
4
|
"./src/utils/XhsXsCommonEnc.js": function(module) {
|
|
5
5
|
var encrypt_lookup = [
|
|
@@ -4403,7 +4403,7 @@ var __webpack_exports__ = {};
|
|
|
4403
4403
|
});
|
|
4404
4404
|
const package_json_namespaceObject = require("@iflyrpa/share/package.json");
|
|
4405
4405
|
var package_json_default = /*#__PURE__*/ __webpack_require__.n(package_json_namespaceObject);
|
|
4406
|
-
var package_namespaceObject = JSON.parse('{"i8":"4.1.0-beta.
|
|
4406
|
+
var package_namespaceObject = JSON.parse('{"i8":"4.1.0-beta.2"}');
|
|
4407
4407
|
const share_namespaceObject = require("@iflyrpa/share");
|
|
4408
4408
|
const external_node_fs_namespaceObject = require("node:fs");
|
|
4409
4409
|
var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
|
|
@@ -4452,6 +4452,11 @@ var __webpack_exports__ = {};
|
|
|
4452
4452
|
const RPA_ERROR_WEBHOOK_URL = "https://open.xfchat.iflytek.com/open-apis/bot/v2/hook/d202c0dc-5af5-40bc-83ed-abc677caa4a5";
|
|
4453
4453
|
const ALARM_THROTTLE_MS = 60000;
|
|
4454
4454
|
const lastSentAt = new Map();
|
|
4455
|
+
const THROTTLE_MAP_MAX_KEYS = 500;
|
|
4456
|
+
const pruneThrottleMap = (now)=>{
|
|
4457
|
+
if (lastSentAt.size < THROTTLE_MAP_MAX_KEYS) return;
|
|
4458
|
+
for (const [key, at] of lastSentAt)if (now - at >= ALARM_THROTTLE_MS) lastSentAt.delete(key);
|
|
4459
|
+
};
|
|
4455
4460
|
const postFeishuWebhook = (webhookUrl, payload)=>external_axios_default().post(webhookUrl, payload, {
|
|
4456
4461
|
headers: {
|
|
4457
4462
|
"Content-Type": "application/json"
|
|
@@ -4529,10 +4534,11 @@ var __webpack_exports__ = {};
|
|
|
4529
4534
|
};
|
|
4530
4535
|
const reportFeishuAlarm = (report)=>{
|
|
4531
4536
|
try {
|
|
4532
|
-
const key = `${report.platform}|${report.source}|${report.errorType}|${report.code ?? ""}`;
|
|
4537
|
+
const key = `${report.platform}|${report.source}|${report.stage}|${report.errorType}|${report.code ?? ""}`;
|
|
4533
4538
|
const now = Date.now();
|
|
4534
4539
|
const last = lastSentAt.get(key);
|
|
4535
4540
|
if (last && now - last < ALARM_THROTTLE_MS) return;
|
|
4541
|
+
pruneThrottleMap(now);
|
|
4536
4542
|
lastSentAt.set(key, now);
|
|
4537
4543
|
postFeishuWebhook(RPA_ERROR_WEBHOOK_URL, buildFeishuPostMessage(report)).catch(()=>{});
|
|
4538
4544
|
} catch {}
|
|
@@ -4715,7 +4721,14 @@ var __webpack_exports__ = {};
|
|
|
4715
4721
|
};
|
|
4716
4722
|
class Http {
|
|
4717
4723
|
static handleApiError(error) {
|
|
4718
|
-
if (error && "object" == typeof error && "code" in error && "message" in error)
|
|
4724
|
+
if (error && "object" == typeof error && "code" in error && "message" in error) {
|
|
4725
|
+
const resp = error;
|
|
4726
|
+
if ("string" != typeof resp.message || !resp.message.trim()) return {
|
|
4727
|
+
...resp,
|
|
4728
|
+
message: USER_MESSAGE.SYSTEM_ERROR
|
|
4729
|
+
};
|
|
4730
|
+
return resp;
|
|
4731
|
+
}
|
|
4719
4732
|
return {
|
|
4720
4733
|
code: 500,
|
|
4721
4734
|
message: USER_MESSAGE.SYSTEM_ERROR,
|
|
@@ -4853,21 +4866,35 @@ var __webpack_exports__ = {};
|
|
|
4853
4866
|
errorResponse.message = message;
|
|
4854
4867
|
}
|
|
4855
4868
|
if (error.message.includes("Proxy connection ended")) errorResponse.message = "所在区域代理连接超时,请更换区域或稍后重试!";
|
|
4856
|
-
|
|
4857
|
-
|
|
4858
|
-
|
|
4859
|
-
|
|
4860
|
-
|
|
4861
|
-
stage: `${(error.config?.method || "get").toUpperCase()} ${error.config?.url || "-"}`,
|
|
4862
|
-
errorType: status ? `HTTP_${status}` : error.code || "NETWORK_ERROR",
|
|
4863
|
-
code: errorResponse.code,
|
|
4864
|
-
msg: errorResponse.message,
|
|
4865
|
-
url: error.config?.url,
|
|
4866
|
-
title: "RPA接口异常"
|
|
4867
|
-
});
|
|
4869
|
+
errorResponse.extra = {
|
|
4870
|
+
...errorResponse.extra,
|
|
4871
|
+
alarmStatus: error.response?.status,
|
|
4872
|
+
alarmErrorCode: error.code
|
|
4873
|
+
};
|
|
4868
4874
|
throw errorResponse;
|
|
4869
4875
|
});
|
|
4870
4876
|
}
|
|
4877
|
+
reportRequestFailure(config, error, attempts) {
|
|
4878
|
+
const status = error.extra?.alarmStatus;
|
|
4879
|
+
const axiosCode = error.extra?.alarmErrorCode;
|
|
4880
|
+
const method = (config.method || "get").toUpperCase();
|
|
4881
|
+
const baseURL = config.baseURL || this.apiClient.defaults.baseURL || "";
|
|
4882
|
+
const fullUrl = config.url ? /^https?:\/\//.test(config.url) ? config.url : `${baseURL.replace(/\/$/, "")}${config.url}` : baseURL || "-";
|
|
4883
|
+
const rawMsg = "string" == typeof error.message && error.message.trim() ? error.message : "";
|
|
4884
|
+
const baseMsg = rawMsg || `请求失败(无错误文案,code=${error.code ?? "unknown"})`;
|
|
4885
|
+
const retriedSuffix = attempts > 0 ? `(已重试${attempts}次仍失败)` : "";
|
|
4886
|
+
reportFeishuAlarm({
|
|
4887
|
+
level: status && ALARM_STATUS.has(status) ? "alarm" : "warning",
|
|
4888
|
+
platform: "@iflyrpa/playwright",
|
|
4889
|
+
source: "http",
|
|
4890
|
+
stage: `${method} ${fullUrl}`,
|
|
4891
|
+
errorType: status ? `HTTP_${status}` : axiosCode || "NETWORK_ERROR",
|
|
4892
|
+
code: error.code,
|
|
4893
|
+
msg: `${baseMsg}${retriedSuffix}`,
|
|
4894
|
+
url: "-" !== fullUrl ? fullUrl : void 0,
|
|
4895
|
+
title: "RPA接口异常"
|
|
4896
|
+
});
|
|
4897
|
+
}
|
|
4871
4898
|
async api(config, options) {
|
|
4872
4899
|
const retries = options?.retries ?? 0;
|
|
4873
4900
|
const retryDelay = options?.retryDelay ?? 500;
|
|
@@ -4912,10 +4939,12 @@ var __webpack_exports__ = {};
|
|
|
4912
4939
|
].includes(handledError.code);
|
|
4913
4940
|
if (Rtimes < retries && isRetry) {
|
|
4914
4941
|
const url = config.url || "";
|
|
4915
|
-
|
|
4916
|
-
|
|
4942
|
+
const backoff = Math.min(retryDelay * 2 ** Rtimes, 5000);
|
|
4943
|
+
this.logger?.warn(`进入第${Rtimes + 1}次重试!错误码: ${handledError.code}, 等待: ${backoff}ms, 请求地址: ${url}`);
|
|
4944
|
+
await new Promise((resolve)=>setTimeout(resolve, backoff));
|
|
4917
4945
|
return sessionRt(Rtimes + 1);
|
|
4918
4946
|
}
|
|
4947
|
+
this.reportRequestFailure(config, handledError, Rtimes);
|
|
4919
4948
|
return Promise.reject(handledError);
|
|
4920
4949
|
}
|
|
4921
4950
|
};
|
|
@@ -10023,7 +10052,8 @@ var __webpack_exports__ = {};
|
|
|
10023
10052
|
},
|
|
10024
10053
|
_task.logger,
|
|
10025
10054
|
params.proxyLoc,
|
|
10026
|
-
params.accountId
|
|
10055
|
+
params.accountId,
|
|
10056
|
+
"xiaohongshu"
|
|
10027
10057
|
];
|
|
10028
10058
|
const http = new Http(...args);
|
|
10029
10059
|
const fans = {
|
|
@@ -10037,8 +10067,8 @@ var __webpack_exports__ = {};
|
|
|
10037
10067
|
url: "https://creator.xiaohongshu.com/api/galaxy/creator/home/personal_info"
|
|
10038
10068
|
}, {
|
|
10039
10069
|
retries: 3,
|
|
10040
|
-
retryDelay:
|
|
10041
|
-
timeout:
|
|
10070
|
+
retryDelay: 300,
|
|
10071
|
+
timeout: 30000
|
|
10042
10072
|
});
|
|
10043
10073
|
fans.fans_count = Number(res.data.fans_count);
|
|
10044
10074
|
fans.digg_count = Number(res.data.faved_count);
|
|
@@ -11175,7 +11205,8 @@ var __webpack_exports__ = {};
|
|
|
11175
11205
|
},
|
|
11176
11206
|
_task.logger,
|
|
11177
11207
|
params.proxyLoc,
|
|
11178
|
-
params.accountId
|
|
11208
|
+
params.accountId,
|
|
11209
|
+
"xiaohongshu"
|
|
11179
11210
|
];
|
|
11180
11211
|
const http = new Http(...args);
|
|
11181
11212
|
http.addResponseInterceptor((response)=>{
|
|
@@ -11223,8 +11254,8 @@ var __webpack_exports__ = {};
|
|
|
11223
11254
|
headers: loginBaseXsHeader
|
|
11224
11255
|
}, {
|
|
11225
11256
|
retries: 3,
|
|
11226
|
-
retryDelay:
|
|
11227
|
-
timeout:
|
|
11257
|
+
retryDelay: 300,
|
|
11258
|
+
timeout: 30000
|
|
11228
11259
|
}).catch((e)=>{
|
|
11229
11260
|
const clientTimestamp = Date.now();
|
|
11230
11261
|
const serverDate = e?.extra?.serverDate;
|
|
@@ -11256,8 +11287,8 @@ var __webpack_exports__ = {};
|
|
|
11256
11287
|
headers: webSessionXsHeader
|
|
11257
11288
|
}, {
|
|
11258
11289
|
retries: 3,
|
|
11259
|
-
retryDelay:
|
|
11260
|
-
timeout:
|
|
11290
|
+
retryDelay: 300,
|
|
11291
|
+
timeout: 30000
|
|
11261
11292
|
});
|
|
11262
11293
|
const [baseInfo, web_session] = await Promise.all([
|
|
11263
11294
|
_baseInfo,
|
|
@@ -11349,6 +11380,10 @@ var __webpack_exports__ = {};
|
|
|
11349
11380
|
};
|
|
11350
11381
|
return (0, share_namespaceObject.success)(data, message);
|
|
11351
11382
|
};
|
|
11383
|
+
const extractEncFileKey = (downloadUrl)=>{
|
|
11384
|
+
if (!downloadUrl) return "";
|
|
11385
|
+
return downloadUrl.split("encfilekey=")[1]?.split("&")[0] || "";
|
|
11386
|
+
};
|
|
11352
11387
|
const rid = ()=>`${Math.floor(Date.now() / 1e3).toString(16)}-${[
|
|
11353
11388
|
...Array(8)
|
|
11354
11389
|
].map(()=>Math.floor(16 * Math.random()).toString(16)).join("")}`;
|
|
@@ -15508,7 +15543,8 @@ var __webpack_exports__ = {};
|
|
|
15508
15543
|
},
|
|
15509
15544
|
_task.logger,
|
|
15510
15545
|
params.proxyLoc,
|
|
15511
|
-
params.accountId
|
|
15546
|
+
params.accountId,
|
|
15547
|
+
"xiaohongshu"
|
|
15512
15548
|
];
|
|
15513
15549
|
const http = new Http(...args);
|
|
15514
15550
|
let unreadCount = {
|
|
@@ -15537,8 +15573,8 @@ var __webpack_exports__ = {};
|
|
|
15537
15573
|
headers: xsHeader
|
|
15538
15574
|
}, {
|
|
15539
15575
|
retries: 3,
|
|
15540
|
-
retryDelay:
|
|
15541
|
-
timeout:
|
|
15576
|
+
retryDelay: 300,
|
|
15577
|
+
timeout: 30000
|
|
15542
15578
|
});
|
|
15543
15579
|
const isSuccess = 0 === res.code;
|
|
15544
15580
|
if (isSuccess) unreadCount = res.data;
|
|
@@ -15951,7 +15987,8 @@ var __webpack_exports__ = {};
|
|
|
15951
15987
|
},
|
|
15952
15988
|
_task.logger,
|
|
15953
15989
|
params.proxyLoc,
|
|
15954
|
-
params.accountId
|
|
15990
|
+
params.accountId,
|
|
15991
|
+
"xiaohongshu"
|
|
15955
15992
|
];
|
|
15956
15993
|
const http = new Http(...args);
|
|
15957
15994
|
const xsEncrypt = new Xhshow();
|
|
@@ -15967,8 +16004,8 @@ var __webpack_exports__ = {};
|
|
|
15967
16004
|
url: "https://creator.xiaohongshu.com/api/galaxy/creator/home/personal_info"
|
|
15968
16005
|
}, {
|
|
15969
16006
|
retries: 3,
|
|
15970
|
-
retryDelay:
|
|
15971
|
-
timeout:
|
|
16007
|
+
retryDelay: 300,
|
|
16008
|
+
timeout: 30000
|
|
15972
16009
|
}),
|
|
15973
16010
|
http.api({
|
|
15974
16011
|
method: "get",
|
|
@@ -15977,8 +16014,8 @@ var __webpack_exports__ = {};
|
|
|
15977
16014
|
headers: sevenDataXsHeader
|
|
15978
16015
|
}, {
|
|
15979
16016
|
retries: 3,
|
|
15980
|
-
retryDelay:
|
|
15981
|
-
timeout:
|
|
16017
|
+
retryDelay: 300,
|
|
16018
|
+
timeout: 30000
|
|
15982
16019
|
})
|
|
15983
16020
|
]);
|
|
15984
16021
|
const xhsData = {
|
|
@@ -19017,7 +19054,7 @@ var __webpack_exports__ = {};
|
|
|
19017
19054
|
const resultMsg = publishResult.data?.baseResp?.errmsg ?? publishResult.errMsg;
|
|
19018
19055
|
if (0 === resultCode) {
|
|
19019
19056
|
task.logger.info("[shipinhaoPublish] 发布成功");
|
|
19020
|
-
const publishId = uploadedImages[0]?.thumbUrl
|
|
19057
|
+
const publishId = extractEncFileKey(uploadedImages[0]?.thumbUrl);
|
|
19021
19058
|
await updateTaskState?.({
|
|
19022
19059
|
state: share_namespaceObject.TaskState.SUCCESS,
|
|
19023
19060
|
result: {
|
|
@@ -19912,8 +19949,7 @@ var __webpack_exports__ = {};
|
|
|
19912
19949
|
const partTimeout = tuning?.partTimeout ?? DEFAULT_TUNING.partTimeout;
|
|
19913
19950
|
const partRetries = tuning?.partRetries ?? DEFAULT_TUNING.partRetries;
|
|
19914
19951
|
const completeTimeout = tuning?.completeTimeout ?? DEFAULT_TUNING.completeTimeout;
|
|
19915
|
-
logger?.info(
|
|
19916
|
-
logger?.info(`上传超时策略: 单片 ${partTimeout / 1000}s(重试 ${partRetries} 次)、合并 ${completeTimeout / 1000}s`);
|
|
19952
|
+
logger?.info(`[shipinhaoPublishVideo] 开始上传: ${fileName} (${fileSize} B, filetype=${fileType})`);
|
|
19917
19953
|
const fileMd5 = await computeFileMd5(filePath);
|
|
19918
19954
|
const taskId = generateTaskId(fileName, fileSize, fileMd5);
|
|
19919
19955
|
const baseUrl = "https://finderassistancea.video.qq.com";
|
|
@@ -19924,7 +19960,7 @@ var __webpack_exports__ = {};
|
|
|
19924
19960
|
const chunkCount = Math.ceil(fileSize / CHUNK_SIZE);
|
|
19925
19961
|
const blockPartLength = [];
|
|
19926
19962
|
for(let i = 0; i < chunkCount; i++)blockPartLength.push(Math.min((i + 1) * CHUNK_SIZE, fileSize));
|
|
19927
|
-
logger?.info(
|
|
19963
|
+
logger?.info(`[shipinhaoPublishVideo] 视频分片: ${chunkCount} 片`);
|
|
19928
19964
|
const applyRes = await http.api({
|
|
19929
19965
|
method: "PUT",
|
|
19930
19966
|
url: `${baseUrl}/applyuploaddfs`,
|
|
@@ -19945,7 +19981,6 @@ var __webpack_exports__ = {};
|
|
|
19945
19981
|
let uploadId = applyRes.UploadID;
|
|
19946
19982
|
const uploadedParts = new Set();
|
|
19947
19983
|
if (applyRes.ListPartsResult) {
|
|
19948
|
-
logger?.info("检测到已上传分片,执行续传");
|
|
19949
19984
|
const parts = Array.isArray(applyRes.ListPartsResult.Part) ? applyRes.ListPartsResult.Part : applyRes.ListPartsResult.Part ? [
|
|
19950
19985
|
applyRes.ListPartsResult.Part
|
|
19951
19986
|
] : [];
|
|
@@ -19981,7 +20016,6 @@ var __webpack_exports__ = {};
|
|
|
19981
20016
|
PartNumber: partNumber,
|
|
19982
20017
|
ETag: existing.ETag
|
|
19983
20018
|
});
|
|
19984
|
-
logger?.info(`分片 ${partNumber}/${chunkCount} 已存在,跳过`);
|
|
19985
20019
|
continue;
|
|
19986
20020
|
}
|
|
19987
20021
|
}
|
|
@@ -20006,18 +20040,15 @@ var __webpack_exports__ = {};
|
|
|
20006
20040
|
retries: partRetries,
|
|
20007
20041
|
retryDelay: 2000
|
|
20008
20042
|
});
|
|
20009
|
-
|
|
20010
|
-
const throughput = Math.round(chunkSize / (partElapsed / 1000));
|
|
20043
|
+
Date.now();
|
|
20011
20044
|
partInfo.push({
|
|
20012
20045
|
PartNumber: partNumber,
|
|
20013
20046
|
ETag: `"${chunkMd5}"`
|
|
20014
20047
|
});
|
|
20015
|
-
logger?.info(`分片 ${partNumber}/${chunkCount} 完成 (${chunkSize} B, ${partElapsed}ms, ${Math.round(throughput / 1024)}KB/s)`);
|
|
20016
20048
|
}
|
|
20017
20049
|
} finally{
|
|
20018
20050
|
external_node_fs_default().closeSync(fd);
|
|
20019
20051
|
}
|
|
20020
|
-
logger?.info("合并分片...");
|
|
20021
20052
|
const completeRes = await http.api({
|
|
20022
20053
|
method: "POST",
|
|
20023
20054
|
url: `${baseUrl}/completepartuploaddfs?UploadID=${encodeURIComponent(uploadId)}`,
|
|
@@ -20035,7 +20066,7 @@ var __webpack_exports__ = {};
|
|
|
20035
20066
|
retryDelay: 3000
|
|
20036
20067
|
});
|
|
20037
20068
|
if (!completeRes.DownloadURL) throw new Error("合并分片失败: " + JSON.stringify(completeRes));
|
|
20038
|
-
logger?.info(
|
|
20069
|
+
logger?.info(`[shipinhaoPublishVideo] ${fileName} 上传成功`);
|
|
20039
20070
|
return {
|
|
20040
20071
|
downloadUrl: completeRes.DownloadURL,
|
|
20041
20072
|
md5: fileMd5,
|
|
@@ -20429,7 +20460,6 @@ var __webpack_exports__ = {};
|
|
|
20429
20460
|
};
|
|
20430
20461
|
}
|
|
20431
20462
|
async function getTraceKey(auth, client, http, logger) {
|
|
20432
|
-
logger.info("[getTraceKey] 开始获取 traceKey...");
|
|
20433
20463
|
const res = await http.api({
|
|
20434
20464
|
method: "POST",
|
|
20435
20465
|
url: `${MICRO_CONTENT_BASE}/post/get-finder-post-trace-key`,
|
|
@@ -20444,11 +20474,9 @@ var __webpack_exports__ = {};
|
|
|
20444
20474
|
logger.error("[getTraceKey] 获取失败:", JSON.stringify(res));
|
|
20445
20475
|
throw new Error(`获取 traceKey 失败: ${JSON.stringify(res)}`);
|
|
20446
20476
|
}
|
|
20447
|
-
logger.info(`[getTraceKey] 获取成功: ${res.data.traceKey}`);
|
|
20448
20477
|
return res.data.traceKey;
|
|
20449
20478
|
}
|
|
20450
20479
|
async function getObjectTagKey(auth, client, http, logger) {
|
|
20451
|
-
logger.info("[getObjectTagKey] 获取内容声明 tagKey...");
|
|
20452
20480
|
try {
|
|
20453
20481
|
const res = await http.api({
|
|
20454
20482
|
method: "POST",
|
|
@@ -20464,7 +20492,6 @@ var __webpack_exports__ = {};
|
|
|
20464
20492
|
logger.warn(`[getObjectTagKey] 未取到 tagKey: ${JSON.stringify(res)}`);
|
|
20465
20493
|
return null;
|
|
20466
20494
|
}
|
|
20467
|
-
logger.info(`[getObjectTagKey] tagKey: ${res.data.tagKey}`);
|
|
20468
20495
|
return res.data.tagKey;
|
|
20469
20496
|
} catch (error) {
|
|
20470
20497
|
logger.warn(`[getObjectTagKey] 获取 tagKey 异常: ${stringifyError(error)}`);
|
|
@@ -20473,7 +20500,6 @@ var __webpack_exports__ = {};
|
|
|
20473
20500
|
}
|
|
20474
20501
|
async function submitAndPollTranscode(opts) {
|
|
20475
20502
|
const { videoUrl, videoMeta, traceKey, uploadStartTime, uploadEndTime, finderUsername, client, http, logger } = opts;
|
|
20476
|
-
logger.info("[submitAndPollTranscode] 开始提交转码任务...");
|
|
20477
20503
|
const finderUrl = videoUrl.includes("wxapp.tc.qq.com") ? `https://finder.video.qq.com${videoUrl.split("qq.com")[1]}` : videoUrl;
|
|
20478
20504
|
logger.info(`[submitAndPollTranscode] 视频尺寸: ${videoMeta.width}x${videoMeta.height}, 时长: ${videoMeta.duration}s`);
|
|
20479
20505
|
const submitRes = await http.api({
|
|
@@ -20512,12 +20538,10 @@ var __webpack_exports__ = {};
|
|
|
20512
20538
|
throw new Error(`提交转码失败: ${JSON.stringify(submitRes)}`);
|
|
20513
20539
|
}
|
|
20514
20540
|
const { clipKey, draftId } = submitRes.data;
|
|
20515
|
-
logger.info(`[submitAndPollTranscode] 转码任务已提交,clipKey: ${clipKey}, draftId: ${draftId}`);
|
|
20516
20541
|
const pollInterval = 5000;
|
|
20517
20542
|
const pollBudget = Math.min(1800000, 300000 + 1000 * Math.ceil(1.5 * videoMeta.duration));
|
|
20518
20543
|
const maxPolls = Math.ceil(pollBudget / pollInterval);
|
|
20519
20544
|
let pollCount = 0;
|
|
20520
|
-
logger.info(`[submitAndPollTranscode] 开始轮询转码结果,最多 ${maxPolls} 次(${Math.round(pollBudget / 1000)}s),间隔 ${pollInterval / 1000}s`);
|
|
20521
20545
|
while(pollCount < maxPolls){
|
|
20522
20546
|
await sleep(pollInterval);
|
|
20523
20547
|
pollCount++;
|
|
@@ -20541,14 +20565,12 @@ var __webpack_exports__ = {};
|
|
|
20541
20565
|
throw new Error(`转码轮询失败 (poll ${pollCount}): ${JSON.stringify(pollRes)}`);
|
|
20542
20566
|
}
|
|
20543
20567
|
const { flag, url, width, height, duration, md5, fileSize } = pollRes.data || {};
|
|
20544
|
-
logger.info(`[submitAndPollTranscode] 轮询第 ${pollCount} 次,flag=${flag}`);
|
|
20545
20568
|
if (1 === flag) {
|
|
20546
20569
|
if (!url || !width || !height || !duration || !md5 || !fileSize) {
|
|
20547
20570
|
logger.error("[submitAndPollTranscode] 转码完成但返回数据不完整:", JSON.stringify(pollRes.data));
|
|
20548
20571
|
throw new Error(`转码完成但返回数据不完整: ${JSON.stringify(pollRes.data)}`);
|
|
20549
20572
|
}
|
|
20550
20573
|
logger.info(`[submitAndPollTranscode] 转码完成! 用时: ${pollCount * pollInterval / 1000}s`);
|
|
20551
|
-
logger.info(`[submitAndPollTranscode] 视频信息: ${width}x${height}, 时长: ${duration}s, 大小: ${fileSize}`);
|
|
20552
20574
|
return {
|
|
20553
20575
|
clipKey,
|
|
20554
20576
|
url,
|
|
@@ -20559,7 +20581,7 @@ var __webpack_exports__ = {};
|
|
|
20559
20581
|
fileSize
|
|
20560
20582
|
};
|
|
20561
20583
|
}
|
|
20562
|
-
if (2 === flag)
|
|
20584
|
+
if (2 === flag) ;
|
|
20563
20585
|
else {
|
|
20564
20586
|
logger.error(`[submitAndPollTranscode] 转码失败,未知 flag=${flag}:`, JSON.stringify(pollRes.data));
|
|
20565
20587
|
throw new Error(`转码失败,未知 flag=${flag}: ${JSON.stringify(pollRes.data)}`);
|
|
@@ -20570,16 +20592,11 @@ var __webpack_exports__ = {};
|
|
|
20570
20592
|
}
|
|
20571
20593
|
async function publishVideo(opts) {
|
|
20572
20594
|
const { params, auth, client, clipResult, videoUpload, coverUpload, verticalCoverUpload, videoMeta, traceKey, tagKey, uploadStartTime, uploadEndTime, proxyHttp, logger } = opts;
|
|
20573
|
-
logger.info("[publishVideo] 开始构建发布请求...");
|
|
20574
20595
|
const toFinderUrl = (url)=>url.includes("wxapp.tc.qq.com") ? `https://finder.video.qq.com${url.split("qq.com")[1]}` : url;
|
|
20575
20596
|
const thumbFinderUrl = toFinderUrl(coverUpload.downloadUrl);
|
|
20576
20597
|
const coverFinderUrl = toFinderUrl(verticalCoverUpload.downloadUrl);
|
|
20577
20598
|
const md5sumUuid = external_node_crypto_default().randomUUID();
|
|
20578
20599
|
const description = params.description;
|
|
20579
|
-
logger.info("[publishVideo] 发布参数:");
|
|
20580
|
-
logger.info(` - 短标题: ${params.title || "(无)"}`);
|
|
20581
|
-
logger.info(` - 描述: ${description.substring(0, 50)}${description.length > 50 ? "..." : ""}`);
|
|
20582
|
-
logger.info(` - 定时发布: ${params.scheduledTime ? new Date(1000 * params.scheduledTime).toLocaleString() : "立即发布"}`);
|
|
20583
20600
|
const objectDesc = {
|
|
20584
20601
|
mpTitle: "",
|
|
20585
20602
|
description,
|
|
@@ -20653,7 +20670,6 @@ var __webpack_exports__ = {};
|
|
|
20653
20670
|
};
|
|
20654
20671
|
if (params.scheduledTime) publishData.effectiveTime = params.scheduledTime;
|
|
20655
20672
|
if (params.tagInfo && tagKey) publishData.tagInfo = buildTagInfo(params.tagInfo, tagKey);
|
|
20656
|
-
logger.info("[publishVideo] 开始发布视频,全部参数:" + JSON.stringify(publishData));
|
|
20657
20673
|
const publishRes = await proxyHttp.api({
|
|
20658
20674
|
method: "POST",
|
|
20659
20675
|
url: `${MICRO_CONTENT_BASE}/post/post_create`,
|
|
@@ -20661,7 +20677,7 @@ var __webpack_exports__ = {};
|
|
|
20661
20677
|
data: publishData,
|
|
20662
20678
|
defaultErrorMsg: "发布视频失败"
|
|
20663
20679
|
});
|
|
20664
|
-
logger.info(`[publishVideo]
|
|
20680
|
+
logger.info(`[publishVideo] 发布结果: errCode=${publishRes.errCode}, baseResp.errcode=${publishRes.data?.baseResp?.errcode}`);
|
|
20665
20681
|
return publishRes;
|
|
20666
20682
|
}
|
|
20667
20683
|
function sleep(ms) {
|
|
@@ -20675,11 +20691,9 @@ var __webpack_exports__ = {};
|
|
|
20675
20691
|
return savePath;
|
|
20676
20692
|
}
|
|
20677
20693
|
const shipinhaoPublishVideo_mock_mockAction = async (task, params)=>{
|
|
20678
|
-
task.logger.info("[shipinhaoPublishVideo] 开始执行视频号视频发布 - Mock API 方式");
|
|
20679
20694
|
const updateTaskState = task.taskStageStore?.update?.bind(task.taskStageStore, task.taskId || "");
|
|
20680
20695
|
let currentStep = "初始化";
|
|
20681
20696
|
try {
|
|
20682
|
-
task.logger.info(`[shipinhaoPublishVideo] 发布方式: ${params.scheduledTime ? `定时 ${new Date(1000 * params.scheduledTime).toLocaleString()}` : "立即发布"}`);
|
|
20683
20697
|
currentStep = "解析认证信息";
|
|
20684
20698
|
const cookieString = params.cookies.map((c)=>`${c.name}=${c.value}`).join("; ");
|
|
20685
20699
|
const http = new Http({
|
|
@@ -20691,11 +20705,8 @@ var __webpack_exports__ = {};
|
|
|
20691
20705
|
if (!params.videoPath) return (0, share_namespaceObject.response)(414, "视频文件路径不能为空", "");
|
|
20692
20706
|
if (!params.coverPath) return (0, share_namespaceObject.response)(414, "横屏封面图片路径不能为空", "");
|
|
20693
20707
|
currentStep = "获取上传认证";
|
|
20694
|
-
task.logger.info("[shipinhaoPublishVideo] 获取上传认证...");
|
|
20695
20708
|
const auth = await getShipinhaoUploadAuth(cookieString, http);
|
|
20696
20709
|
const client = resolveClientContext(params, auth.uin);
|
|
20697
|
-
if (!client.aId) task.logger.warn("[shipinhaoPublishVideo] extraParam.aId 缺失,query 将不带 _aid");
|
|
20698
|
-
if (!client.fingerPrintDeviceId) task.logger.warn("[shipinhaoPublishVideo] extraParam.fingerPrintDeviceId 缺失,请求将不带 finger-print-device-id");
|
|
20699
20710
|
const publishHeaders = buildPublishHeaders(cookieString, client);
|
|
20700
20711
|
const microHttp = new Http({
|
|
20701
20712
|
headers: publishHeaders
|
|
@@ -20711,25 +20722,20 @@ var __webpack_exports__ = {};
|
|
|
20711
20722
|
];
|
|
20712
20723
|
const proxyHttp = new Http(...args);
|
|
20713
20724
|
currentStep = "组装视频元数据";
|
|
20714
|
-
task.logger.info("[shipinhaoPublishVideo] 组装视频元数据...");
|
|
20715
20725
|
const videoMeta = buildVideoMetaFromParams(params.videoPath, params.videoMetadata);
|
|
20716
20726
|
task.logger.info(`[shipinhaoPublishVideo] 视频: ${videoMeta.width}×${videoMeta.height}, ${videoMeta.duration.toFixed(2)}s, ${(videoMeta.fileSize / 1024 / 1024).toFixed(2)}MB, codec=${videoMeta.codec || "unknown"}`);
|
|
20717
|
-
if (!videoMeta.codec) task.logger.warn("[shipinhaoPublishVideo] 未能读取视频编码格式,跳过 H.264 预检,交由服务端判断");
|
|
20718
20727
|
currentStep = "校验视频限制";
|
|
20719
20728
|
const validationError = validateShipinhaoVideo(params.videoPath, videoMeta);
|
|
20720
20729
|
if (validationError) {
|
|
20721
|
-
task.logger.error(`[shipinhaoPublishVideo] 视频校验未通过: ${validationError}`);
|
|
20722
20730
|
await updateTaskState?.({
|
|
20723
20731
|
state: share_namespaceObject.TaskState.FAILED,
|
|
20724
20732
|
error: validationError
|
|
20725
20733
|
});
|
|
20726
20734
|
return (0, share_namespaceObject.response)(414, validationError, "");
|
|
20727
20735
|
}
|
|
20728
|
-
task.logger.info("[shipinhaoPublishVideo] 视频校验通过");
|
|
20729
20736
|
currentStep = "校验标题";
|
|
20730
20737
|
const titleError = validateShipinhaoTitle(params.title);
|
|
20731
20738
|
if (titleError) {
|
|
20732
|
-
task.logger.error(`[shipinhaoPublishVideo] 标题校验未通过: ${titleError}`);
|
|
20733
20739
|
await updateTaskState?.({
|
|
20734
20740
|
state: share_namespaceObject.TaskState.FAILED,
|
|
20735
20741
|
error: titleError
|
|
@@ -20737,7 +20743,6 @@ var __webpack_exports__ = {};
|
|
|
20737
20743
|
return (0, share_namespaceObject.response)(414, titleError, "");
|
|
20738
20744
|
}
|
|
20739
20745
|
currentStep = "获取 traceKey";
|
|
20740
|
-
task.logger.info("[shipinhaoPublishVideo] 获取 traceKey...");
|
|
20741
20746
|
const traceKey = await getTraceKey(auth, client, microHttp, task.logger);
|
|
20742
20747
|
let tagKey = null;
|
|
20743
20748
|
if (params.tagInfo) {
|
|
@@ -20745,11 +20750,7 @@ var __webpack_exports__ = {};
|
|
|
20745
20750
|
tagKey = await getObjectTagKey(auth, client, microHttp, task.logger);
|
|
20746
20751
|
}
|
|
20747
20752
|
const uploadStartTime = Math.floor(Date.now() / 1000);
|
|
20748
|
-
task.logger.info(`[shipinhaoPublishVideo] 上传开始时间: ${uploadStartTime}`);
|
|
20749
20753
|
currentStep = "上传视频";
|
|
20750
|
-
task.logger.info("[shipinhaoPublishVideo] 上传视频...");
|
|
20751
|
-
task.logger.info(`[shipinhaoPublishVideo] 视频路径: ${params.videoPath}`);
|
|
20752
|
-
task.logger.info(`[shipinhaoPublishVideo] 视频文件类型: ${auth.videoFileType}`);
|
|
20753
20754
|
const videoUpload = await uploader_uploadFile({
|
|
20754
20755
|
filePath: params.videoPath,
|
|
20755
20756
|
fileType: auth.videoFileType,
|
|
@@ -20758,12 +20759,10 @@ var __webpack_exports__ = {};
|
|
|
20758
20759
|
http,
|
|
20759
20760
|
logger: task.logger
|
|
20760
20761
|
});
|
|
20761
|
-
task.logger.info("[shipinhaoPublishVideo] 视频上传完成");
|
|
20762
20762
|
const uploadEndTime = Math.floor(Date.now() / 1000);
|
|
20763
|
-
task.logger.info(`[shipinhaoPublishVideo]
|
|
20763
|
+
task.logger.info(`[shipinhaoPublishVideo] 耗时: ${uploadEndTime - uploadStartTime}s`);
|
|
20764
20764
|
currentStep = "上传横屏封面";
|
|
20765
20765
|
const localCoverPath = await resolveLocalCoverPath(params.coverPath, "横屏封面", task.getTmpPath(), task.logger);
|
|
20766
|
-
task.logger.info("[shipinhaoPublishVideo] 上传横屏封面...");
|
|
20767
20766
|
const coverUpload = await uploader_uploadFile({
|
|
20768
20767
|
filePath: localCoverPath,
|
|
20769
20768
|
fileType: auth.pictureFileType,
|
|
@@ -20772,12 +20771,10 @@ var __webpack_exports__ = {};
|
|
|
20772
20771
|
http,
|
|
20773
20772
|
logger: task.logger
|
|
20774
20773
|
});
|
|
20775
|
-
task.logger.info("[shipinhaoPublishVideo] 横屏封面上传完成");
|
|
20776
20774
|
let verticalCoverUpload = coverUpload;
|
|
20777
20775
|
if (params.verticalCoverPath) {
|
|
20778
20776
|
currentStep = "上传竖屏封面";
|
|
20779
20777
|
const localVerticalPath = await resolveLocalCoverPath(params.verticalCoverPath, "竖屏封面", task.getTmpPath(), task.logger);
|
|
20780
|
-
task.logger.info("[shipinhaoPublishVideo] 上传竖屏封面");
|
|
20781
20778
|
verticalCoverUpload = await uploader_uploadFile({
|
|
20782
20779
|
filePath: localVerticalPath,
|
|
20783
20780
|
fileType: auth.pictureFileType,
|
|
@@ -20786,10 +20783,8 @@ var __webpack_exports__ = {};
|
|
|
20786
20783
|
http,
|
|
20787
20784
|
logger: task.logger
|
|
20788
20785
|
});
|
|
20789
|
-
|
|
20790
|
-
} else task.logger.info("[shipinhaoPublishVideo] 未传竖屏封面,复用横屏封面");
|
|
20786
|
+
}
|
|
20791
20787
|
currentStep = "提交转码";
|
|
20792
|
-
task.logger.info("[shipinhaoPublishVideo] 提交转码...");
|
|
20793
20788
|
const clipResult = await submitAndPollTranscode({
|
|
20794
20789
|
videoUrl: videoUpload.downloadUrl,
|
|
20795
20790
|
videoMeta,
|
|
@@ -20802,8 +20797,6 @@ var __webpack_exports__ = {};
|
|
|
20802
20797
|
logger: task.logger
|
|
20803
20798
|
});
|
|
20804
20799
|
currentStep = "发布视频";
|
|
20805
|
-
task.logger.info("[shipinhaoPublishVideo] 发布视频...");
|
|
20806
|
-
task.logger.info(`[shipinhaoPublishVideo] clipKey: ${clipResult.clipKey}`);
|
|
20807
20800
|
let publishResult;
|
|
20808
20801
|
try {
|
|
20809
20802
|
publishResult = await publishVideo({
|
|
@@ -20828,7 +20821,6 @@ var __webpack_exports__ = {};
|
|
|
20828
20821
|
const classified = classifyPublishError(handledError);
|
|
20829
20822
|
if (classified) {
|
|
20830
20823
|
const message = `${classified.userMessage}${task.debug ? ` ${http.proxyInfo}` : ""}`;
|
|
20831
|
-
task.logger.error(`[shipinhaoPublishVideo] ${classified.category},直接返回: ${handledError.message} (code=${handledError.code})`, stringifyError(handledError));
|
|
20832
20824
|
await updateTaskState?.({
|
|
20833
20825
|
state: share_namespaceObject.TaskState.FAILED,
|
|
20834
20826
|
error: message
|
|
@@ -20845,11 +20837,8 @@ var __webpack_exports__ = {};
|
|
|
20845
20837
|
const resultCode = publishResult.data?.baseResp?.errcode ?? publishResult.errCode;
|
|
20846
20838
|
const resultMsg = publishResult.data?.baseResp?.errmsg ?? (0 === resultCode ? "发布成功" : `发布失败(errCode=${resultCode})`);
|
|
20847
20839
|
if (0 === resultCode) {
|
|
20848
|
-
|
|
20849
|
-
task.logger.
|
|
20850
|
-
task.logger.info(`[shipinhaoPublishVideo] 视频URL: ${clipResult.url}`);
|
|
20851
|
-
task.logger.info(`[shipinhaoPublishVideo] 横屏封面URL: ${coverUpload.downloadUrl}`);
|
|
20852
|
-
task.logger.info(`[shipinhaoPublishVideo] 竖屏封面URL: ${verticalCoverUpload.downloadUrl}`);
|
|
20840
|
+
const publishId = extractEncFileKey(verticalCoverUpload.downloadUrl);
|
|
20841
|
+
if (!publishId) task.logger.error(`[shipinhaoPublishVideo] 封面 DownloadURL 中未解析到 encfilekey,关联 id 为空: ${verticalCoverUpload.downloadUrl}`);
|
|
20853
20842
|
await updateTaskState?.({
|
|
20854
20843
|
state: share_namespaceObject.TaskState.SUCCESS,
|
|
20855
20844
|
result: {
|
|
@@ -20879,8 +20868,7 @@ var __webpack_exports__ = {};
|
|
|
20879
20868
|
},
|
|
20880
20869
|
platform: "shipinhao"
|
|
20881
20870
|
});
|
|
20882
|
-
|
|
20883
|
-
return (0, share_namespaceObject.response)(0, "发布成功", clipResult.clipKey);
|
|
20871
|
+
return (0, share_namespaceObject.response)(0, "发布成功", publishId);
|
|
20884
20872
|
}
|
|
20885
20873
|
let errorMessage = resultMsg;
|
|
20886
20874
|
if (-11224 === resultCode) errorMessage = "视频号管理员完成实名且绑定手机号后才可以发表";
|
|
@@ -20892,18 +20880,16 @@ var __webpack_exports__ = {};
|
|
|
20892
20880
|
state: share_namespaceObject.TaskState.FAILED,
|
|
20893
20881
|
error: errorMessage
|
|
20894
20882
|
});
|
|
20895
|
-
return (0, share_namespaceObject.response)(
|
|
20883
|
+
return (0, share_namespaceObject.response)(414, errorMessage, "");
|
|
20896
20884
|
} catch (error) {
|
|
20897
20885
|
const handledError = Http.handleApiError(error);
|
|
20898
20886
|
const errorMsg = handledError.message || "发布失败,请稍后重试";
|
|
20899
|
-
const errorCode = handledError.code || 414;
|
|
20900
20887
|
task.logger.error(`[shipinhaoPublishVideo] 发布流程异常 [${currentStep}]: ${errorMsg}`, stringifyError(error), handledError.extra);
|
|
20901
|
-
task.logger.error(`[shipinhaoPublishVideo] 错误码: ${errorCode}, 当前步骤: ${currentStep}`);
|
|
20902
20888
|
await updateTaskState?.({
|
|
20903
20889
|
state: share_namespaceObject.TaskState.FAILED,
|
|
20904
20890
|
error: errorMsg
|
|
20905
20891
|
});
|
|
20906
|
-
return (0, share_namespaceObject.response)(
|
|
20892
|
+
return (0, share_namespaceObject.response)(414, errorMsg, "");
|
|
20907
20893
|
}
|
|
20908
20894
|
};
|
|
20909
20895
|
const shipinhaoPublishVideo_rpa_rpaAction = async (task, params)=>{
|
|
@@ -27475,4 +27461,4 @@ if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_targe
|
|
|
27475
27461
|
});
|
|
27476
27462
|
|
|
27477
27463
|
//# sourceMappingURL=index.js.map
|
|
27478
|
-
//# debugId=
|
|
27464
|
+
//# debugId=161e4c22-57ca-5b29-b12b-b647dd871406
|