@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.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]="8315ee33-ea9b-5a8e-92af-cf3835f6ed70")}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.1"}');
|
|
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 {}
|
|
@@ -4853,21 +4859,32 @@ var __webpack_exports__ = {};
|
|
|
4853
4859
|
errorResponse.message = message;
|
|
4854
4860
|
}
|
|
4855
4861
|
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
|
-
});
|
|
4862
|
+
errorResponse.extra = {
|
|
4863
|
+
...errorResponse.extra,
|
|
4864
|
+
alarmStatus: error.response?.status,
|
|
4865
|
+
alarmErrorCode: error.code
|
|
4866
|
+
};
|
|
4868
4867
|
throw errorResponse;
|
|
4869
4868
|
});
|
|
4870
4869
|
}
|
|
4870
|
+
reportRequestFailure(config, error, attempts) {
|
|
4871
|
+
const status = error.extra?.alarmStatus;
|
|
4872
|
+
const axiosCode = error.extra?.alarmErrorCode;
|
|
4873
|
+
const method = (config.method || "get").toUpperCase();
|
|
4874
|
+
const url = config.url || "-";
|
|
4875
|
+
const retriedSuffix = attempts > 0 ? `(已重试${attempts}次仍失败)` : "";
|
|
4876
|
+
reportFeishuAlarm({
|
|
4877
|
+
level: status && ALARM_STATUS.has(status) ? "alarm" : "warning",
|
|
4878
|
+
platform: this.platform || "unknown",
|
|
4879
|
+
source: "http",
|
|
4880
|
+
stage: `${method} ${url}`,
|
|
4881
|
+
errorType: status ? `HTTP_${status}` : axiosCode || "NETWORK_ERROR",
|
|
4882
|
+
code: error.code,
|
|
4883
|
+
msg: `${error.message}${retriedSuffix}`,
|
|
4884
|
+
url: config.url,
|
|
4885
|
+
title: "RPA接口异常"
|
|
4886
|
+
});
|
|
4887
|
+
}
|
|
4871
4888
|
async api(config, options) {
|
|
4872
4889
|
const retries = options?.retries ?? 0;
|
|
4873
4890
|
const retryDelay = options?.retryDelay ?? 500;
|
|
@@ -4912,10 +4929,12 @@ var __webpack_exports__ = {};
|
|
|
4912
4929
|
].includes(handledError.code);
|
|
4913
4930
|
if (Rtimes < retries && isRetry) {
|
|
4914
4931
|
const url = config.url || "";
|
|
4915
|
-
|
|
4916
|
-
|
|
4932
|
+
const backoff = Math.min(retryDelay * 2 ** Rtimes, 5000);
|
|
4933
|
+
this.logger?.warn(`进入第${Rtimes + 1}次重试!错误码: ${handledError.code}, 等待: ${backoff}ms, 请求地址: ${url}`);
|
|
4934
|
+
await new Promise((resolve)=>setTimeout(resolve, backoff));
|
|
4917
4935
|
return sessionRt(Rtimes + 1);
|
|
4918
4936
|
}
|
|
4937
|
+
this.reportRequestFailure(config, handledError, Rtimes);
|
|
4919
4938
|
return Promise.reject(handledError);
|
|
4920
4939
|
}
|
|
4921
4940
|
};
|
|
@@ -10023,7 +10042,8 @@ var __webpack_exports__ = {};
|
|
|
10023
10042
|
},
|
|
10024
10043
|
_task.logger,
|
|
10025
10044
|
params.proxyLoc,
|
|
10026
|
-
params.accountId
|
|
10045
|
+
params.accountId,
|
|
10046
|
+
"xiaohongshu"
|
|
10027
10047
|
];
|
|
10028
10048
|
const http = new Http(...args);
|
|
10029
10049
|
const fans = {
|
|
@@ -10037,8 +10057,8 @@ var __webpack_exports__ = {};
|
|
|
10037
10057
|
url: "https://creator.xiaohongshu.com/api/galaxy/creator/home/personal_info"
|
|
10038
10058
|
}, {
|
|
10039
10059
|
retries: 3,
|
|
10040
|
-
retryDelay:
|
|
10041
|
-
timeout:
|
|
10060
|
+
retryDelay: 300,
|
|
10061
|
+
timeout: 30000
|
|
10042
10062
|
});
|
|
10043
10063
|
fans.fans_count = Number(res.data.fans_count);
|
|
10044
10064
|
fans.digg_count = Number(res.data.faved_count);
|
|
@@ -11175,7 +11195,8 @@ var __webpack_exports__ = {};
|
|
|
11175
11195
|
},
|
|
11176
11196
|
_task.logger,
|
|
11177
11197
|
params.proxyLoc,
|
|
11178
|
-
params.accountId
|
|
11198
|
+
params.accountId,
|
|
11199
|
+
"xiaohongshu"
|
|
11179
11200
|
];
|
|
11180
11201
|
const http = new Http(...args);
|
|
11181
11202
|
http.addResponseInterceptor((response)=>{
|
|
@@ -11223,8 +11244,8 @@ var __webpack_exports__ = {};
|
|
|
11223
11244
|
headers: loginBaseXsHeader
|
|
11224
11245
|
}, {
|
|
11225
11246
|
retries: 3,
|
|
11226
|
-
retryDelay:
|
|
11227
|
-
timeout:
|
|
11247
|
+
retryDelay: 300,
|
|
11248
|
+
timeout: 30000
|
|
11228
11249
|
}).catch((e)=>{
|
|
11229
11250
|
const clientTimestamp = Date.now();
|
|
11230
11251
|
const serverDate = e?.extra?.serverDate;
|
|
@@ -11256,8 +11277,8 @@ var __webpack_exports__ = {};
|
|
|
11256
11277
|
headers: webSessionXsHeader
|
|
11257
11278
|
}, {
|
|
11258
11279
|
retries: 3,
|
|
11259
|
-
retryDelay:
|
|
11260
|
-
timeout:
|
|
11280
|
+
retryDelay: 300,
|
|
11281
|
+
timeout: 30000
|
|
11261
11282
|
});
|
|
11262
11283
|
const [baseInfo, web_session] = await Promise.all([
|
|
11263
11284
|
_baseInfo,
|
|
@@ -11349,6 +11370,10 @@ var __webpack_exports__ = {};
|
|
|
11349
11370
|
};
|
|
11350
11371
|
return (0, share_namespaceObject.success)(data, message);
|
|
11351
11372
|
};
|
|
11373
|
+
const extractEncFileKey = (downloadUrl)=>{
|
|
11374
|
+
if (!downloadUrl) return "";
|
|
11375
|
+
return downloadUrl.split("encfilekey=")[1]?.split("&")[0] || "";
|
|
11376
|
+
};
|
|
11352
11377
|
const rid = ()=>`${Math.floor(Date.now() / 1e3).toString(16)}-${[
|
|
11353
11378
|
...Array(8)
|
|
11354
11379
|
].map(()=>Math.floor(16 * Math.random()).toString(16)).join("")}`;
|
|
@@ -15508,7 +15533,8 @@ var __webpack_exports__ = {};
|
|
|
15508
15533
|
},
|
|
15509
15534
|
_task.logger,
|
|
15510
15535
|
params.proxyLoc,
|
|
15511
|
-
params.accountId
|
|
15536
|
+
params.accountId,
|
|
15537
|
+
"xiaohongshu"
|
|
15512
15538
|
];
|
|
15513
15539
|
const http = new Http(...args);
|
|
15514
15540
|
let unreadCount = {
|
|
@@ -15537,8 +15563,8 @@ var __webpack_exports__ = {};
|
|
|
15537
15563
|
headers: xsHeader
|
|
15538
15564
|
}, {
|
|
15539
15565
|
retries: 3,
|
|
15540
|
-
retryDelay:
|
|
15541
|
-
timeout:
|
|
15566
|
+
retryDelay: 300,
|
|
15567
|
+
timeout: 30000
|
|
15542
15568
|
});
|
|
15543
15569
|
const isSuccess = 0 === res.code;
|
|
15544
15570
|
if (isSuccess) unreadCount = res.data;
|
|
@@ -15951,7 +15977,8 @@ var __webpack_exports__ = {};
|
|
|
15951
15977
|
},
|
|
15952
15978
|
_task.logger,
|
|
15953
15979
|
params.proxyLoc,
|
|
15954
|
-
params.accountId
|
|
15980
|
+
params.accountId,
|
|
15981
|
+
"xiaohongshu"
|
|
15955
15982
|
];
|
|
15956
15983
|
const http = new Http(...args);
|
|
15957
15984
|
const xsEncrypt = new Xhshow();
|
|
@@ -15967,8 +15994,8 @@ var __webpack_exports__ = {};
|
|
|
15967
15994
|
url: "https://creator.xiaohongshu.com/api/galaxy/creator/home/personal_info"
|
|
15968
15995
|
}, {
|
|
15969
15996
|
retries: 3,
|
|
15970
|
-
retryDelay:
|
|
15971
|
-
timeout:
|
|
15997
|
+
retryDelay: 300,
|
|
15998
|
+
timeout: 30000
|
|
15972
15999
|
}),
|
|
15973
16000
|
http.api({
|
|
15974
16001
|
method: "get",
|
|
@@ -15977,8 +16004,8 @@ var __webpack_exports__ = {};
|
|
|
15977
16004
|
headers: sevenDataXsHeader
|
|
15978
16005
|
}, {
|
|
15979
16006
|
retries: 3,
|
|
15980
|
-
retryDelay:
|
|
15981
|
-
timeout:
|
|
16007
|
+
retryDelay: 300,
|
|
16008
|
+
timeout: 30000
|
|
15982
16009
|
})
|
|
15983
16010
|
]);
|
|
15984
16011
|
const xhsData = {
|
|
@@ -19017,7 +19044,7 @@ var __webpack_exports__ = {};
|
|
|
19017
19044
|
const resultMsg = publishResult.data?.baseResp?.errmsg ?? publishResult.errMsg;
|
|
19018
19045
|
if (0 === resultCode) {
|
|
19019
19046
|
task.logger.info("[shipinhaoPublish] 发布成功");
|
|
19020
|
-
const publishId = uploadedImages[0]?.thumbUrl
|
|
19047
|
+
const publishId = extractEncFileKey(uploadedImages[0]?.thumbUrl);
|
|
19021
19048
|
await updateTaskState?.({
|
|
19022
19049
|
state: share_namespaceObject.TaskState.SUCCESS,
|
|
19023
19050
|
result: {
|
|
@@ -19912,8 +19939,7 @@ var __webpack_exports__ = {};
|
|
|
19912
19939
|
const partTimeout = tuning?.partTimeout ?? DEFAULT_TUNING.partTimeout;
|
|
19913
19940
|
const partRetries = tuning?.partRetries ?? DEFAULT_TUNING.partRetries;
|
|
19914
19941
|
const completeTimeout = tuning?.completeTimeout ?? DEFAULT_TUNING.completeTimeout;
|
|
19915
|
-
logger?.info(
|
|
19916
|
-
logger?.info(`上传超时策略: 单片 ${partTimeout / 1000}s(重试 ${partRetries} 次)、合并 ${completeTimeout / 1000}s`);
|
|
19942
|
+
logger?.info(`[shipinhaoPublishVideo] 开始上传: ${fileName} (${fileSize} B, filetype=${fileType})`);
|
|
19917
19943
|
const fileMd5 = await computeFileMd5(filePath);
|
|
19918
19944
|
const taskId = generateTaskId(fileName, fileSize, fileMd5);
|
|
19919
19945
|
const baseUrl = "https://finderassistancea.video.qq.com";
|
|
@@ -19924,7 +19950,7 @@ var __webpack_exports__ = {};
|
|
|
19924
19950
|
const chunkCount = Math.ceil(fileSize / CHUNK_SIZE);
|
|
19925
19951
|
const blockPartLength = [];
|
|
19926
19952
|
for(let i = 0; i < chunkCount; i++)blockPartLength.push(Math.min((i + 1) * CHUNK_SIZE, fileSize));
|
|
19927
|
-
logger?.info(
|
|
19953
|
+
logger?.info(`[shipinhaoPublishVideo] 视频分片: ${chunkCount} 片`);
|
|
19928
19954
|
const applyRes = await http.api({
|
|
19929
19955
|
method: "PUT",
|
|
19930
19956
|
url: `${baseUrl}/applyuploaddfs`,
|
|
@@ -19945,7 +19971,6 @@ var __webpack_exports__ = {};
|
|
|
19945
19971
|
let uploadId = applyRes.UploadID;
|
|
19946
19972
|
const uploadedParts = new Set();
|
|
19947
19973
|
if (applyRes.ListPartsResult) {
|
|
19948
|
-
logger?.info("检测到已上传分片,执行续传");
|
|
19949
19974
|
const parts = Array.isArray(applyRes.ListPartsResult.Part) ? applyRes.ListPartsResult.Part : applyRes.ListPartsResult.Part ? [
|
|
19950
19975
|
applyRes.ListPartsResult.Part
|
|
19951
19976
|
] : [];
|
|
@@ -19981,7 +20006,6 @@ var __webpack_exports__ = {};
|
|
|
19981
20006
|
PartNumber: partNumber,
|
|
19982
20007
|
ETag: existing.ETag
|
|
19983
20008
|
});
|
|
19984
|
-
logger?.info(`分片 ${partNumber}/${chunkCount} 已存在,跳过`);
|
|
19985
20009
|
continue;
|
|
19986
20010
|
}
|
|
19987
20011
|
}
|
|
@@ -20006,18 +20030,15 @@ var __webpack_exports__ = {};
|
|
|
20006
20030
|
retries: partRetries,
|
|
20007
20031
|
retryDelay: 2000
|
|
20008
20032
|
});
|
|
20009
|
-
|
|
20010
|
-
const throughput = Math.round(chunkSize / (partElapsed / 1000));
|
|
20033
|
+
Date.now();
|
|
20011
20034
|
partInfo.push({
|
|
20012
20035
|
PartNumber: partNumber,
|
|
20013
20036
|
ETag: `"${chunkMd5}"`
|
|
20014
20037
|
});
|
|
20015
|
-
logger?.info(`分片 ${partNumber}/${chunkCount} 完成 (${chunkSize} B, ${partElapsed}ms, ${Math.round(throughput / 1024)}KB/s)`);
|
|
20016
20038
|
}
|
|
20017
20039
|
} finally{
|
|
20018
20040
|
external_node_fs_default().closeSync(fd);
|
|
20019
20041
|
}
|
|
20020
|
-
logger?.info("合并分片...");
|
|
20021
20042
|
const completeRes = await http.api({
|
|
20022
20043
|
method: "POST",
|
|
20023
20044
|
url: `${baseUrl}/completepartuploaddfs?UploadID=${encodeURIComponent(uploadId)}`,
|
|
@@ -20035,7 +20056,7 @@ var __webpack_exports__ = {};
|
|
|
20035
20056
|
retryDelay: 3000
|
|
20036
20057
|
});
|
|
20037
20058
|
if (!completeRes.DownloadURL) throw new Error("合并分片失败: " + JSON.stringify(completeRes));
|
|
20038
|
-
logger?.info(
|
|
20059
|
+
logger?.info(`[shipinhaoPublishVideo] ${fileName} 上传成功`);
|
|
20039
20060
|
return {
|
|
20040
20061
|
downloadUrl: completeRes.DownloadURL,
|
|
20041
20062
|
md5: fileMd5,
|
|
@@ -20429,7 +20450,6 @@ var __webpack_exports__ = {};
|
|
|
20429
20450
|
};
|
|
20430
20451
|
}
|
|
20431
20452
|
async function getTraceKey(auth, client, http, logger) {
|
|
20432
|
-
logger.info("[getTraceKey] 开始获取 traceKey...");
|
|
20433
20453
|
const res = await http.api({
|
|
20434
20454
|
method: "POST",
|
|
20435
20455
|
url: `${MICRO_CONTENT_BASE}/post/get-finder-post-trace-key`,
|
|
@@ -20444,11 +20464,9 @@ var __webpack_exports__ = {};
|
|
|
20444
20464
|
logger.error("[getTraceKey] 获取失败:", JSON.stringify(res));
|
|
20445
20465
|
throw new Error(`获取 traceKey 失败: ${JSON.stringify(res)}`);
|
|
20446
20466
|
}
|
|
20447
|
-
logger.info(`[getTraceKey] 获取成功: ${res.data.traceKey}`);
|
|
20448
20467
|
return res.data.traceKey;
|
|
20449
20468
|
}
|
|
20450
20469
|
async function getObjectTagKey(auth, client, http, logger) {
|
|
20451
|
-
logger.info("[getObjectTagKey] 获取内容声明 tagKey...");
|
|
20452
20470
|
try {
|
|
20453
20471
|
const res = await http.api({
|
|
20454
20472
|
method: "POST",
|
|
@@ -20464,7 +20482,6 @@ var __webpack_exports__ = {};
|
|
|
20464
20482
|
logger.warn(`[getObjectTagKey] 未取到 tagKey: ${JSON.stringify(res)}`);
|
|
20465
20483
|
return null;
|
|
20466
20484
|
}
|
|
20467
|
-
logger.info(`[getObjectTagKey] tagKey: ${res.data.tagKey}`);
|
|
20468
20485
|
return res.data.tagKey;
|
|
20469
20486
|
} catch (error) {
|
|
20470
20487
|
logger.warn(`[getObjectTagKey] 获取 tagKey 异常: ${stringifyError(error)}`);
|
|
@@ -20473,7 +20490,6 @@ var __webpack_exports__ = {};
|
|
|
20473
20490
|
}
|
|
20474
20491
|
async function submitAndPollTranscode(opts) {
|
|
20475
20492
|
const { videoUrl, videoMeta, traceKey, uploadStartTime, uploadEndTime, finderUsername, client, http, logger } = opts;
|
|
20476
|
-
logger.info("[submitAndPollTranscode] 开始提交转码任务...");
|
|
20477
20493
|
const finderUrl = videoUrl.includes("wxapp.tc.qq.com") ? `https://finder.video.qq.com${videoUrl.split("qq.com")[1]}` : videoUrl;
|
|
20478
20494
|
logger.info(`[submitAndPollTranscode] 视频尺寸: ${videoMeta.width}x${videoMeta.height}, 时长: ${videoMeta.duration}s`);
|
|
20479
20495
|
const submitRes = await http.api({
|
|
@@ -20512,12 +20528,10 @@ var __webpack_exports__ = {};
|
|
|
20512
20528
|
throw new Error(`提交转码失败: ${JSON.stringify(submitRes)}`);
|
|
20513
20529
|
}
|
|
20514
20530
|
const { clipKey, draftId } = submitRes.data;
|
|
20515
|
-
logger.info(`[submitAndPollTranscode] 转码任务已提交,clipKey: ${clipKey}, draftId: ${draftId}`);
|
|
20516
20531
|
const pollInterval = 5000;
|
|
20517
20532
|
const pollBudget = Math.min(1800000, 300000 + 1000 * Math.ceil(1.5 * videoMeta.duration));
|
|
20518
20533
|
const maxPolls = Math.ceil(pollBudget / pollInterval);
|
|
20519
20534
|
let pollCount = 0;
|
|
20520
|
-
logger.info(`[submitAndPollTranscode] 开始轮询转码结果,最多 ${maxPolls} 次(${Math.round(pollBudget / 1000)}s),间隔 ${pollInterval / 1000}s`);
|
|
20521
20535
|
while(pollCount < maxPolls){
|
|
20522
20536
|
await sleep(pollInterval);
|
|
20523
20537
|
pollCount++;
|
|
@@ -20541,14 +20555,12 @@ var __webpack_exports__ = {};
|
|
|
20541
20555
|
throw new Error(`转码轮询失败 (poll ${pollCount}): ${JSON.stringify(pollRes)}`);
|
|
20542
20556
|
}
|
|
20543
20557
|
const { flag, url, width, height, duration, md5, fileSize } = pollRes.data || {};
|
|
20544
|
-
logger.info(`[submitAndPollTranscode] 轮询第 ${pollCount} 次,flag=${flag}`);
|
|
20545
20558
|
if (1 === flag) {
|
|
20546
20559
|
if (!url || !width || !height || !duration || !md5 || !fileSize) {
|
|
20547
20560
|
logger.error("[submitAndPollTranscode] 转码完成但返回数据不完整:", JSON.stringify(pollRes.data));
|
|
20548
20561
|
throw new Error(`转码完成但返回数据不完整: ${JSON.stringify(pollRes.data)}`);
|
|
20549
20562
|
}
|
|
20550
20563
|
logger.info(`[submitAndPollTranscode] 转码完成! 用时: ${pollCount * pollInterval / 1000}s`);
|
|
20551
|
-
logger.info(`[submitAndPollTranscode] 视频信息: ${width}x${height}, 时长: ${duration}s, 大小: ${fileSize}`);
|
|
20552
20564
|
return {
|
|
20553
20565
|
clipKey,
|
|
20554
20566
|
url,
|
|
@@ -20559,7 +20571,7 @@ var __webpack_exports__ = {};
|
|
|
20559
20571
|
fileSize
|
|
20560
20572
|
};
|
|
20561
20573
|
}
|
|
20562
|
-
if (2 === flag)
|
|
20574
|
+
if (2 === flag) ;
|
|
20563
20575
|
else {
|
|
20564
20576
|
logger.error(`[submitAndPollTranscode] 转码失败,未知 flag=${flag}:`, JSON.stringify(pollRes.data));
|
|
20565
20577
|
throw new Error(`转码失败,未知 flag=${flag}: ${JSON.stringify(pollRes.data)}`);
|
|
@@ -20570,16 +20582,11 @@ var __webpack_exports__ = {};
|
|
|
20570
20582
|
}
|
|
20571
20583
|
async function publishVideo(opts) {
|
|
20572
20584
|
const { params, auth, client, clipResult, videoUpload, coverUpload, verticalCoverUpload, videoMeta, traceKey, tagKey, uploadStartTime, uploadEndTime, proxyHttp, logger } = opts;
|
|
20573
|
-
logger.info("[publishVideo] 开始构建发布请求...");
|
|
20574
20585
|
const toFinderUrl = (url)=>url.includes("wxapp.tc.qq.com") ? `https://finder.video.qq.com${url.split("qq.com")[1]}` : url;
|
|
20575
20586
|
const thumbFinderUrl = toFinderUrl(coverUpload.downloadUrl);
|
|
20576
20587
|
const coverFinderUrl = toFinderUrl(verticalCoverUpload.downloadUrl);
|
|
20577
20588
|
const md5sumUuid = external_node_crypto_default().randomUUID();
|
|
20578
20589
|
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
20590
|
const objectDesc = {
|
|
20584
20591
|
mpTitle: "",
|
|
20585
20592
|
description,
|
|
@@ -20653,7 +20660,6 @@ var __webpack_exports__ = {};
|
|
|
20653
20660
|
};
|
|
20654
20661
|
if (params.scheduledTime) publishData.effectiveTime = params.scheduledTime;
|
|
20655
20662
|
if (params.tagInfo && tagKey) publishData.tagInfo = buildTagInfo(params.tagInfo, tagKey);
|
|
20656
|
-
logger.info("[publishVideo] 开始发布视频,全部参数:" + JSON.stringify(publishData));
|
|
20657
20663
|
const publishRes = await proxyHttp.api({
|
|
20658
20664
|
method: "POST",
|
|
20659
20665
|
url: `${MICRO_CONTENT_BASE}/post/post_create`,
|
|
@@ -20661,7 +20667,7 @@ var __webpack_exports__ = {};
|
|
|
20661
20667
|
data: publishData,
|
|
20662
20668
|
defaultErrorMsg: "发布视频失败"
|
|
20663
20669
|
});
|
|
20664
|
-
logger.info(`[publishVideo]
|
|
20670
|
+
logger.info(`[publishVideo] 发布结果: errCode=${publishRes.errCode}, baseResp.errcode=${publishRes.data?.baseResp?.errcode}`);
|
|
20665
20671
|
return publishRes;
|
|
20666
20672
|
}
|
|
20667
20673
|
function sleep(ms) {
|
|
@@ -20675,11 +20681,9 @@ var __webpack_exports__ = {};
|
|
|
20675
20681
|
return savePath;
|
|
20676
20682
|
}
|
|
20677
20683
|
const shipinhaoPublishVideo_mock_mockAction = async (task, params)=>{
|
|
20678
|
-
task.logger.info("[shipinhaoPublishVideo] 开始执行视频号视频发布 - Mock API 方式");
|
|
20679
20684
|
const updateTaskState = task.taskStageStore?.update?.bind(task.taskStageStore, task.taskId || "");
|
|
20680
20685
|
let currentStep = "初始化";
|
|
20681
20686
|
try {
|
|
20682
|
-
task.logger.info(`[shipinhaoPublishVideo] 发布方式: ${params.scheduledTime ? `定时 ${new Date(1000 * params.scheduledTime).toLocaleString()}` : "立即发布"}`);
|
|
20683
20687
|
currentStep = "解析认证信息";
|
|
20684
20688
|
const cookieString = params.cookies.map((c)=>`${c.name}=${c.value}`).join("; ");
|
|
20685
20689
|
const http = new Http({
|
|
@@ -20691,11 +20695,8 @@ var __webpack_exports__ = {};
|
|
|
20691
20695
|
if (!params.videoPath) return (0, share_namespaceObject.response)(414, "视频文件路径不能为空", "");
|
|
20692
20696
|
if (!params.coverPath) return (0, share_namespaceObject.response)(414, "横屏封面图片路径不能为空", "");
|
|
20693
20697
|
currentStep = "获取上传认证";
|
|
20694
|
-
task.logger.info("[shipinhaoPublishVideo] 获取上传认证...");
|
|
20695
20698
|
const auth = await getShipinhaoUploadAuth(cookieString, http);
|
|
20696
20699
|
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
20700
|
const publishHeaders = buildPublishHeaders(cookieString, client);
|
|
20700
20701
|
const microHttp = new Http({
|
|
20701
20702
|
headers: publishHeaders
|
|
@@ -20711,25 +20712,20 @@ var __webpack_exports__ = {};
|
|
|
20711
20712
|
];
|
|
20712
20713
|
const proxyHttp = new Http(...args);
|
|
20713
20714
|
currentStep = "组装视频元数据";
|
|
20714
|
-
task.logger.info("[shipinhaoPublishVideo] 组装视频元数据...");
|
|
20715
20715
|
const videoMeta = buildVideoMetaFromParams(params.videoPath, params.videoMetadata);
|
|
20716
20716
|
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
20717
|
currentStep = "校验视频限制";
|
|
20719
20718
|
const validationError = validateShipinhaoVideo(params.videoPath, videoMeta);
|
|
20720
20719
|
if (validationError) {
|
|
20721
|
-
task.logger.error(`[shipinhaoPublishVideo] 视频校验未通过: ${validationError}`);
|
|
20722
20720
|
await updateTaskState?.({
|
|
20723
20721
|
state: share_namespaceObject.TaskState.FAILED,
|
|
20724
20722
|
error: validationError
|
|
20725
20723
|
});
|
|
20726
20724
|
return (0, share_namespaceObject.response)(414, validationError, "");
|
|
20727
20725
|
}
|
|
20728
|
-
task.logger.info("[shipinhaoPublishVideo] 视频校验通过");
|
|
20729
20726
|
currentStep = "校验标题";
|
|
20730
20727
|
const titleError = validateShipinhaoTitle(params.title);
|
|
20731
20728
|
if (titleError) {
|
|
20732
|
-
task.logger.error(`[shipinhaoPublishVideo] 标题校验未通过: ${titleError}`);
|
|
20733
20729
|
await updateTaskState?.({
|
|
20734
20730
|
state: share_namespaceObject.TaskState.FAILED,
|
|
20735
20731
|
error: titleError
|
|
@@ -20737,7 +20733,6 @@ var __webpack_exports__ = {};
|
|
|
20737
20733
|
return (0, share_namespaceObject.response)(414, titleError, "");
|
|
20738
20734
|
}
|
|
20739
20735
|
currentStep = "获取 traceKey";
|
|
20740
|
-
task.logger.info("[shipinhaoPublishVideo] 获取 traceKey...");
|
|
20741
20736
|
const traceKey = await getTraceKey(auth, client, microHttp, task.logger);
|
|
20742
20737
|
let tagKey = null;
|
|
20743
20738
|
if (params.tagInfo) {
|
|
@@ -20745,11 +20740,7 @@ var __webpack_exports__ = {};
|
|
|
20745
20740
|
tagKey = await getObjectTagKey(auth, client, microHttp, task.logger);
|
|
20746
20741
|
}
|
|
20747
20742
|
const uploadStartTime = Math.floor(Date.now() / 1000);
|
|
20748
|
-
task.logger.info(`[shipinhaoPublishVideo] 上传开始时间: ${uploadStartTime}`);
|
|
20749
20743
|
currentStep = "上传视频";
|
|
20750
|
-
task.logger.info("[shipinhaoPublishVideo] 上传视频...");
|
|
20751
|
-
task.logger.info(`[shipinhaoPublishVideo] 视频路径: ${params.videoPath}`);
|
|
20752
|
-
task.logger.info(`[shipinhaoPublishVideo] 视频文件类型: ${auth.videoFileType}`);
|
|
20753
20744
|
const videoUpload = await uploader_uploadFile({
|
|
20754
20745
|
filePath: params.videoPath,
|
|
20755
20746
|
fileType: auth.videoFileType,
|
|
@@ -20758,12 +20749,10 @@ var __webpack_exports__ = {};
|
|
|
20758
20749
|
http,
|
|
20759
20750
|
logger: task.logger
|
|
20760
20751
|
});
|
|
20761
|
-
task.logger.info("[shipinhaoPublishVideo] 视频上传完成");
|
|
20762
20752
|
const uploadEndTime = Math.floor(Date.now() / 1000);
|
|
20763
|
-
task.logger.info(`[shipinhaoPublishVideo]
|
|
20753
|
+
task.logger.info(`[shipinhaoPublishVideo] 耗时: ${uploadEndTime - uploadStartTime}s`);
|
|
20764
20754
|
currentStep = "上传横屏封面";
|
|
20765
20755
|
const localCoverPath = await resolveLocalCoverPath(params.coverPath, "横屏封面", task.getTmpPath(), task.logger);
|
|
20766
|
-
task.logger.info("[shipinhaoPublishVideo] 上传横屏封面...");
|
|
20767
20756
|
const coverUpload = await uploader_uploadFile({
|
|
20768
20757
|
filePath: localCoverPath,
|
|
20769
20758
|
fileType: auth.pictureFileType,
|
|
@@ -20772,12 +20761,10 @@ var __webpack_exports__ = {};
|
|
|
20772
20761
|
http,
|
|
20773
20762
|
logger: task.logger
|
|
20774
20763
|
});
|
|
20775
|
-
task.logger.info("[shipinhaoPublishVideo] 横屏封面上传完成");
|
|
20776
20764
|
let verticalCoverUpload = coverUpload;
|
|
20777
20765
|
if (params.verticalCoverPath) {
|
|
20778
20766
|
currentStep = "上传竖屏封面";
|
|
20779
20767
|
const localVerticalPath = await resolveLocalCoverPath(params.verticalCoverPath, "竖屏封面", task.getTmpPath(), task.logger);
|
|
20780
|
-
task.logger.info("[shipinhaoPublishVideo] 上传竖屏封面");
|
|
20781
20768
|
verticalCoverUpload = await uploader_uploadFile({
|
|
20782
20769
|
filePath: localVerticalPath,
|
|
20783
20770
|
fileType: auth.pictureFileType,
|
|
@@ -20786,10 +20773,8 @@ var __webpack_exports__ = {};
|
|
|
20786
20773
|
http,
|
|
20787
20774
|
logger: task.logger
|
|
20788
20775
|
});
|
|
20789
|
-
|
|
20790
|
-
} else task.logger.info("[shipinhaoPublishVideo] 未传竖屏封面,复用横屏封面");
|
|
20776
|
+
}
|
|
20791
20777
|
currentStep = "提交转码";
|
|
20792
|
-
task.logger.info("[shipinhaoPublishVideo] 提交转码...");
|
|
20793
20778
|
const clipResult = await submitAndPollTranscode({
|
|
20794
20779
|
videoUrl: videoUpload.downloadUrl,
|
|
20795
20780
|
videoMeta,
|
|
@@ -20802,8 +20787,6 @@ var __webpack_exports__ = {};
|
|
|
20802
20787
|
logger: task.logger
|
|
20803
20788
|
});
|
|
20804
20789
|
currentStep = "发布视频";
|
|
20805
|
-
task.logger.info("[shipinhaoPublishVideo] 发布视频...");
|
|
20806
|
-
task.logger.info(`[shipinhaoPublishVideo] clipKey: ${clipResult.clipKey}`);
|
|
20807
20790
|
let publishResult;
|
|
20808
20791
|
try {
|
|
20809
20792
|
publishResult = await publishVideo({
|
|
@@ -20828,7 +20811,6 @@ var __webpack_exports__ = {};
|
|
|
20828
20811
|
const classified = classifyPublishError(handledError);
|
|
20829
20812
|
if (classified) {
|
|
20830
20813
|
const message = `${classified.userMessage}${task.debug ? ` ${http.proxyInfo}` : ""}`;
|
|
20831
|
-
task.logger.error(`[shipinhaoPublishVideo] ${classified.category},直接返回: ${handledError.message} (code=${handledError.code})`, stringifyError(handledError));
|
|
20832
20814
|
await updateTaskState?.({
|
|
20833
20815
|
state: share_namespaceObject.TaskState.FAILED,
|
|
20834
20816
|
error: message
|
|
@@ -20845,11 +20827,8 @@ var __webpack_exports__ = {};
|
|
|
20845
20827
|
const resultCode = publishResult.data?.baseResp?.errcode ?? publishResult.errCode;
|
|
20846
20828
|
const resultMsg = publishResult.data?.baseResp?.errmsg ?? (0 === resultCode ? "发布成功" : `发布失败(errCode=${resultCode})`);
|
|
20847
20829
|
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}`);
|
|
20830
|
+
const publishId = extractEncFileKey(coverUpload.downloadUrl);
|
|
20831
|
+
if (!publishId) task.logger.error(`[shipinhaoPublishVideo] 封面 DownloadURL 中未解析到 encfilekey,关联 id 为空: ${coverUpload.downloadUrl}`);
|
|
20853
20832
|
await updateTaskState?.({
|
|
20854
20833
|
state: share_namespaceObject.TaskState.SUCCESS,
|
|
20855
20834
|
result: {
|
|
@@ -20879,8 +20858,7 @@ var __webpack_exports__ = {};
|
|
|
20879
20858
|
},
|
|
20880
20859
|
platform: "shipinhao"
|
|
20881
20860
|
});
|
|
20882
|
-
|
|
20883
|
-
return (0, share_namespaceObject.response)(0, "发布成功", clipResult.clipKey);
|
|
20861
|
+
return (0, share_namespaceObject.response)(0, "发布成功", publishId);
|
|
20884
20862
|
}
|
|
20885
20863
|
let errorMessage = resultMsg;
|
|
20886
20864
|
if (-11224 === resultCode) errorMessage = "视频号管理员完成实名且绑定手机号后才可以发表";
|
|
@@ -20892,18 +20870,16 @@ var __webpack_exports__ = {};
|
|
|
20892
20870
|
state: share_namespaceObject.TaskState.FAILED,
|
|
20893
20871
|
error: errorMessage
|
|
20894
20872
|
});
|
|
20895
|
-
return (0, share_namespaceObject.response)(
|
|
20873
|
+
return (0, share_namespaceObject.response)(414, errorMessage, "");
|
|
20896
20874
|
} catch (error) {
|
|
20897
20875
|
const handledError = Http.handleApiError(error);
|
|
20898
20876
|
const errorMsg = handledError.message || "发布失败,请稍后重试";
|
|
20899
|
-
const errorCode = handledError.code || 414;
|
|
20900
20877
|
task.logger.error(`[shipinhaoPublishVideo] 发布流程异常 [${currentStep}]: ${errorMsg}`, stringifyError(error), handledError.extra);
|
|
20901
|
-
task.logger.error(`[shipinhaoPublishVideo] 错误码: ${errorCode}, 当前步骤: ${currentStep}`);
|
|
20902
20878
|
await updateTaskState?.({
|
|
20903
20879
|
state: share_namespaceObject.TaskState.FAILED,
|
|
20904
20880
|
error: errorMsg
|
|
20905
20881
|
});
|
|
20906
|
-
return (0, share_namespaceObject.response)(
|
|
20882
|
+
return (0, share_namespaceObject.response)(414, errorMsg, "");
|
|
20907
20883
|
}
|
|
20908
20884
|
};
|
|
20909
20885
|
const shipinhaoPublishVideo_rpa_rpaAction = async (task, params)=>{
|
|
@@ -27475,4 +27451,4 @@ if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_targe
|
|
|
27475
27451
|
});
|
|
27476
27452
|
|
|
27477
27453
|
//# sourceMappingURL=index.js.map
|
|
27478
|
-
//# debugId=
|
|
27454
|
+
//# debugId=8315ee33-ea9b-5a8e-92af-cf3835f6ed70
|