@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
|
@@ -38,9 +38,9 @@ export declare const SearchAccountInfoParamsSchema: z.ZodObject<{
|
|
|
38
38
|
token: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
39
39
|
platform: z.ZodEnum<{
|
|
40
40
|
baijiahao: "baijiahao";
|
|
41
|
+
xiaohongshu: "xiaohongshu";
|
|
41
42
|
douyin: "douyin";
|
|
42
43
|
toutiao: "toutiao";
|
|
43
|
-
xiaohongshu: "xiaohongshu";
|
|
44
44
|
weixin: "weixin";
|
|
45
45
|
shipinhao: "shipinhao";
|
|
46
46
|
}>;
|
package/dist/bundle.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*! For license information please see bundle.js.LICENSE.txt */
|
|
2
2
|
|
|
3
|
-
!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]="
|
|
3
|
+
!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]="51f3980f-4908-5c61-864e-675122bae629")}catch(e){}}();
|
|
4
4
|
var __webpack_modules__ = {
|
|
5
5
|
"../../node_modules/.pnpm/agent-base@7.1.4/node_modules/agent-base/dist/helpers.js": function(__unused_webpack_module, exports1, __webpack_require__) {
|
|
6
6
|
"use strict";
|
|
@@ -12493,7 +12493,7 @@ var __webpack_exports__ = {};
|
|
|
12493
12493
|
var package_namespaceObject = {
|
|
12494
12494
|
i8: "0.1.2"
|
|
12495
12495
|
};
|
|
12496
|
-
var package_namespaceObject_0 = JSON.parse('{"i8":"4.1.0-beta.
|
|
12496
|
+
var package_namespaceObject_0 = JSON.parse('{"i8":"4.1.0-beta.1"}');
|
|
12497
12497
|
const external_node_fs_namespaceObject = require("node:fs");
|
|
12498
12498
|
var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
|
|
12499
12499
|
const external_node_http_namespaceObject = require("node:http");
|
|
@@ -27073,6 +27073,11 @@ var __webpack_exports__ = {};
|
|
|
27073
27073
|
const RPA_ERROR_WEBHOOK_URL = "https://open.xfchat.iflytek.com/open-apis/bot/v2/hook/d202c0dc-5af5-40bc-83ed-abc677caa4a5";
|
|
27074
27074
|
const ALARM_THROTTLE_MS = 60000;
|
|
27075
27075
|
const lastSentAt = new Map();
|
|
27076
|
+
const THROTTLE_MAP_MAX_KEYS = 500;
|
|
27077
|
+
const pruneThrottleMap = (now)=>{
|
|
27078
|
+
if (lastSentAt.size < THROTTLE_MAP_MAX_KEYS) return;
|
|
27079
|
+
for (const [key, at] of lastSentAt)if (now - at >= ALARM_THROTTLE_MS) lastSentAt.delete(key);
|
|
27080
|
+
};
|
|
27076
27081
|
const postFeishuWebhook = (webhookUrl, payload)=>lib_axios.post(webhookUrl, payload, {
|
|
27077
27082
|
headers: {
|
|
27078
27083
|
"Content-Type": "application/json"
|
|
@@ -27150,10 +27155,11 @@ var __webpack_exports__ = {};
|
|
|
27150
27155
|
};
|
|
27151
27156
|
const reportFeishuAlarm = (report)=>{
|
|
27152
27157
|
try {
|
|
27153
|
-
const key = `${report.platform}|${report.source}|${report.errorType}|${report.code ?? ""}`;
|
|
27158
|
+
const key = `${report.platform}|${report.source}|${report.stage}|${report.errorType}|${report.code ?? ""}`;
|
|
27154
27159
|
const now = Date.now();
|
|
27155
27160
|
const last = lastSentAt.get(key);
|
|
27156
27161
|
if (last && now - last < ALARM_THROTTLE_MS) return;
|
|
27162
|
+
pruneThrottleMap(now);
|
|
27157
27163
|
lastSentAt.set(key, now);
|
|
27158
27164
|
postFeishuWebhook(RPA_ERROR_WEBHOOK_URL, buildFeishuPostMessage(report)).catch(()=>{});
|
|
27159
27165
|
} catch {}
|
|
@@ -27474,21 +27480,32 @@ var __webpack_exports__ = {};
|
|
|
27474
27480
|
errorResponse.message = message;
|
|
27475
27481
|
}
|
|
27476
27482
|
if (error.message.includes("Proxy connection ended")) errorResponse.message = "所在区域代理连接超时,请更换区域或稍后重试!";
|
|
27477
|
-
|
|
27478
|
-
|
|
27479
|
-
|
|
27480
|
-
|
|
27481
|
-
|
|
27482
|
-
stage: `${(error.config?.method || "get").toUpperCase()} ${error.config?.url || "-"}`,
|
|
27483
|
-
errorType: status ? `HTTP_${status}` : error.code || "NETWORK_ERROR",
|
|
27484
|
-
code: errorResponse.code,
|
|
27485
|
-
msg: errorResponse.message,
|
|
27486
|
-
url: error.config?.url,
|
|
27487
|
-
title: "RPA接口异常"
|
|
27488
|
-
});
|
|
27483
|
+
errorResponse.extra = {
|
|
27484
|
+
...errorResponse.extra,
|
|
27485
|
+
alarmStatus: error.response?.status,
|
|
27486
|
+
alarmErrorCode: error.code
|
|
27487
|
+
};
|
|
27489
27488
|
throw errorResponse;
|
|
27490
27489
|
});
|
|
27491
27490
|
}
|
|
27491
|
+
reportRequestFailure(config, error, attempts) {
|
|
27492
|
+
const status = error.extra?.alarmStatus;
|
|
27493
|
+
const axiosCode = error.extra?.alarmErrorCode;
|
|
27494
|
+
const method = (config.method || "get").toUpperCase();
|
|
27495
|
+
const url = config.url || "-";
|
|
27496
|
+
const retriedSuffix = attempts > 0 ? `(已重试${attempts}次仍失败)` : "";
|
|
27497
|
+
reportFeishuAlarm({
|
|
27498
|
+
level: status && ALARM_STATUS.has(status) ? "alarm" : "warning",
|
|
27499
|
+
platform: this.platform || "unknown",
|
|
27500
|
+
source: "http",
|
|
27501
|
+
stage: `${method} ${url}`,
|
|
27502
|
+
errorType: status ? `HTTP_${status}` : axiosCode || "NETWORK_ERROR",
|
|
27503
|
+
code: error.code,
|
|
27504
|
+
msg: `${error.message}${retriedSuffix}`,
|
|
27505
|
+
url: config.url,
|
|
27506
|
+
title: "RPA接口异常"
|
|
27507
|
+
});
|
|
27508
|
+
}
|
|
27492
27509
|
async api(config, options) {
|
|
27493
27510
|
const retries = options?.retries ?? 0;
|
|
27494
27511
|
const retryDelay = options?.retryDelay ?? 500;
|
|
@@ -27533,10 +27550,12 @@ var __webpack_exports__ = {};
|
|
|
27533
27550
|
].includes(handledError.code);
|
|
27534
27551
|
if (Rtimes < retries && isRetry) {
|
|
27535
27552
|
const url = config.url || "";
|
|
27536
|
-
|
|
27537
|
-
|
|
27553
|
+
const backoff = Math.min(retryDelay * 2 ** Rtimes, 5000);
|
|
27554
|
+
this.logger?.warn(`进入第${Rtimes + 1}次重试!错误码: ${handledError.code}, 等待: ${backoff}ms, 请求地址: ${url}`);
|
|
27555
|
+
await new Promise((resolve)=>setTimeout(resolve, backoff));
|
|
27538
27556
|
return sessionRt(Rtimes + 1);
|
|
27539
27557
|
}
|
|
27558
|
+
this.reportRequestFailure(config, handledError, Rtimes);
|
|
27540
27559
|
return Promise.reject(handledError);
|
|
27541
27560
|
}
|
|
27542
27561
|
};
|
|
@@ -33608,7 +33627,8 @@ var __webpack_exports__ = {};
|
|
|
33608
33627
|
},
|
|
33609
33628
|
_task.logger,
|
|
33610
33629
|
params.proxyLoc,
|
|
33611
|
-
params.accountId
|
|
33630
|
+
params.accountId,
|
|
33631
|
+
"xiaohongshu"
|
|
33612
33632
|
];
|
|
33613
33633
|
const http = new Http(...args);
|
|
33614
33634
|
const fans = {
|
|
@@ -33622,8 +33642,8 @@ var __webpack_exports__ = {};
|
|
|
33622
33642
|
url: "https://creator.xiaohongshu.com/api/galaxy/creator/home/personal_info"
|
|
33623
33643
|
}, {
|
|
33624
33644
|
retries: 3,
|
|
33625
|
-
retryDelay:
|
|
33626
|
-
timeout:
|
|
33645
|
+
retryDelay: 300,
|
|
33646
|
+
timeout: 30000
|
|
33627
33647
|
});
|
|
33628
33648
|
fans.fans_count = Number(res.data.fans_count);
|
|
33629
33649
|
fans.digg_count = Number(res.data.faved_count);
|
|
@@ -34760,7 +34780,8 @@ var __webpack_exports__ = {};
|
|
|
34760
34780
|
},
|
|
34761
34781
|
_task.logger,
|
|
34762
34782
|
params.proxyLoc,
|
|
34763
|
-
params.accountId
|
|
34783
|
+
params.accountId,
|
|
34784
|
+
"xiaohongshu"
|
|
34764
34785
|
];
|
|
34765
34786
|
const http = new Http(...args);
|
|
34766
34787
|
http.addResponseInterceptor((response)=>{
|
|
@@ -34808,8 +34829,8 @@ var __webpack_exports__ = {};
|
|
|
34808
34829
|
headers: loginBaseXsHeader
|
|
34809
34830
|
}, {
|
|
34810
34831
|
retries: 3,
|
|
34811
|
-
retryDelay:
|
|
34812
|
-
timeout:
|
|
34832
|
+
retryDelay: 300,
|
|
34833
|
+
timeout: 30000
|
|
34813
34834
|
}).catch((e)=>{
|
|
34814
34835
|
const clientTimestamp = Date.now();
|
|
34815
34836
|
const serverDate = e?.extra?.serverDate;
|
|
@@ -34841,8 +34862,8 @@ var __webpack_exports__ = {};
|
|
|
34841
34862
|
headers: webSessionXsHeader
|
|
34842
34863
|
}, {
|
|
34843
34864
|
retries: 3,
|
|
34844
|
-
retryDelay:
|
|
34845
|
-
timeout:
|
|
34865
|
+
retryDelay: 300,
|
|
34866
|
+
timeout: 30000
|
|
34846
34867
|
});
|
|
34847
34868
|
const [baseInfo, web_session] = await Promise.all([
|
|
34848
34869
|
_baseInfo,
|
|
@@ -34934,6 +34955,10 @@ var __webpack_exports__ = {};
|
|
|
34934
34955
|
};
|
|
34935
34956
|
return success(data, message);
|
|
34936
34957
|
};
|
|
34958
|
+
const extractEncFileKey = (downloadUrl)=>{
|
|
34959
|
+
if (!downloadUrl) return "";
|
|
34960
|
+
return downloadUrl.split("encfilekey=")[1]?.split("&")[0] || "";
|
|
34961
|
+
};
|
|
34937
34962
|
const rid = ()=>`${Math.floor(Date.now() / 1e3).toString(16)}-${[
|
|
34938
34963
|
...Array(8)
|
|
34939
34964
|
].map(()=>Math.floor(16 * Math.random()).toString(16)).join("")}`;
|
|
@@ -40579,7 +40604,8 @@ var __webpack_exports__ = {};
|
|
|
40579
40604
|
},
|
|
40580
40605
|
_task.logger,
|
|
40581
40606
|
params.proxyLoc,
|
|
40582
|
-
params.accountId
|
|
40607
|
+
params.accountId,
|
|
40608
|
+
"xiaohongshu"
|
|
40583
40609
|
];
|
|
40584
40610
|
const http = new Http(...args);
|
|
40585
40611
|
let unreadCount = {
|
|
@@ -40608,8 +40634,8 @@ var __webpack_exports__ = {};
|
|
|
40608
40634
|
headers: xsHeader
|
|
40609
40635
|
}, {
|
|
40610
40636
|
retries: 3,
|
|
40611
|
-
retryDelay:
|
|
40612
|
-
timeout:
|
|
40637
|
+
retryDelay: 300,
|
|
40638
|
+
timeout: 30000
|
|
40613
40639
|
});
|
|
40614
40640
|
const isSuccess = 0 === res.code;
|
|
40615
40641
|
if (isSuccess) unreadCount = res.data;
|
|
@@ -41022,7 +41048,8 @@ var __webpack_exports__ = {};
|
|
|
41022
41048
|
},
|
|
41023
41049
|
_task.logger,
|
|
41024
41050
|
params.proxyLoc,
|
|
41025
|
-
params.accountId
|
|
41051
|
+
params.accountId,
|
|
41052
|
+
"xiaohongshu"
|
|
41026
41053
|
];
|
|
41027
41054
|
const http = new Http(...args);
|
|
41028
41055
|
const xsEncrypt = new Xhshow();
|
|
@@ -41038,8 +41065,8 @@ var __webpack_exports__ = {};
|
|
|
41038
41065
|
url: "https://creator.xiaohongshu.com/api/galaxy/creator/home/personal_info"
|
|
41039
41066
|
}, {
|
|
41040
41067
|
retries: 3,
|
|
41041
|
-
retryDelay:
|
|
41042
|
-
timeout:
|
|
41068
|
+
retryDelay: 300,
|
|
41069
|
+
timeout: 30000
|
|
41043
41070
|
}),
|
|
41044
41071
|
http.api({
|
|
41045
41072
|
method: "get",
|
|
@@ -41048,8 +41075,8 @@ var __webpack_exports__ = {};
|
|
|
41048
41075
|
headers: sevenDataXsHeader
|
|
41049
41076
|
}, {
|
|
41050
41077
|
retries: 3,
|
|
41051
|
-
retryDelay:
|
|
41052
|
-
timeout:
|
|
41078
|
+
retryDelay: 300,
|
|
41079
|
+
timeout: 30000
|
|
41053
41080
|
})
|
|
41054
41081
|
]);
|
|
41055
41082
|
const xhsData = {
|
|
@@ -44088,7 +44115,7 @@ var __webpack_exports__ = {};
|
|
|
44088
44115
|
const resultMsg = publishResult.data?.baseResp?.errmsg ?? publishResult.errMsg;
|
|
44089
44116
|
if (0 === resultCode) {
|
|
44090
44117
|
task.logger.info("[shipinhaoPublish] 发布成功");
|
|
44091
|
-
const publishId = uploadedImages[0]?.thumbUrl
|
|
44118
|
+
const publishId = extractEncFileKey(uploadedImages[0]?.thumbUrl);
|
|
44092
44119
|
await updateTaskState?.({
|
|
44093
44120
|
state: types_TaskState.SUCCESS,
|
|
44094
44121
|
result: {
|
|
@@ -44983,8 +45010,7 @@ var __webpack_exports__ = {};
|
|
|
44983
45010
|
const partTimeout = tuning?.partTimeout ?? DEFAULT_TUNING.partTimeout;
|
|
44984
45011
|
const partRetries = tuning?.partRetries ?? DEFAULT_TUNING.partRetries;
|
|
44985
45012
|
const completeTimeout = tuning?.completeTimeout ?? DEFAULT_TUNING.completeTimeout;
|
|
44986
|
-
logger?.info(
|
|
44987
|
-
logger?.info(`上传超时策略: 单片 ${partTimeout / 1000}s(重试 ${partRetries} 次)、合并 ${completeTimeout / 1000}s`);
|
|
45013
|
+
logger?.info(`[shipinhaoPublishVideo] 开始上传: ${fileName} (${fileSize} B, filetype=${fileType})`);
|
|
44988
45014
|
const fileMd5 = await computeFileMd5(filePath);
|
|
44989
45015
|
const taskId = generateTaskId(fileName, fileSize, fileMd5);
|
|
44990
45016
|
const baseUrl = "https://finderassistancea.video.qq.com";
|
|
@@ -44995,7 +45021,7 @@ var __webpack_exports__ = {};
|
|
|
44995
45021
|
const chunkCount = Math.ceil(fileSize / CHUNK_SIZE);
|
|
44996
45022
|
const blockPartLength = [];
|
|
44997
45023
|
for(let i = 0; i < chunkCount; i++)blockPartLength.push(Math.min((i + 1) * CHUNK_SIZE, fileSize));
|
|
44998
|
-
logger?.info(
|
|
45024
|
+
logger?.info(`[shipinhaoPublishVideo] 视频分片: ${chunkCount} 片`);
|
|
44999
45025
|
const applyRes = await http.api({
|
|
45000
45026
|
method: "PUT",
|
|
45001
45027
|
url: `${baseUrl}/applyuploaddfs`,
|
|
@@ -45016,7 +45042,6 @@ var __webpack_exports__ = {};
|
|
|
45016
45042
|
let uploadId = applyRes.UploadID;
|
|
45017
45043
|
const uploadedParts = new Set();
|
|
45018
45044
|
if (applyRes.ListPartsResult) {
|
|
45019
|
-
logger?.info("检测到已上传分片,执行续传");
|
|
45020
45045
|
const parts = Array.isArray(applyRes.ListPartsResult.Part) ? applyRes.ListPartsResult.Part : applyRes.ListPartsResult.Part ? [
|
|
45021
45046
|
applyRes.ListPartsResult.Part
|
|
45022
45047
|
] : [];
|
|
@@ -45052,7 +45077,6 @@ var __webpack_exports__ = {};
|
|
|
45052
45077
|
PartNumber: partNumber,
|
|
45053
45078
|
ETag: existing.ETag
|
|
45054
45079
|
});
|
|
45055
|
-
logger?.info(`分片 ${partNumber}/${chunkCount} 已存在,跳过`);
|
|
45056
45080
|
continue;
|
|
45057
45081
|
}
|
|
45058
45082
|
}
|
|
@@ -45077,18 +45101,15 @@ var __webpack_exports__ = {};
|
|
|
45077
45101
|
retries: partRetries,
|
|
45078
45102
|
retryDelay: 2000
|
|
45079
45103
|
});
|
|
45080
|
-
|
|
45081
|
-
const throughput = Math.round(chunkSize / (partElapsed / 1000));
|
|
45104
|
+
Date.now();
|
|
45082
45105
|
partInfo.push({
|
|
45083
45106
|
PartNumber: partNumber,
|
|
45084
45107
|
ETag: `"${chunkMd5}"`
|
|
45085
45108
|
});
|
|
45086
|
-
logger?.info(`分片 ${partNumber}/${chunkCount} 完成 (${chunkSize} B, ${partElapsed}ms, ${Math.round(throughput / 1024)}KB/s)`);
|
|
45087
45109
|
}
|
|
45088
45110
|
} finally{
|
|
45089
45111
|
external_node_fs_default().closeSync(fd);
|
|
45090
45112
|
}
|
|
45091
|
-
logger?.info("合并分片...");
|
|
45092
45113
|
const completeRes = await http.api({
|
|
45093
45114
|
method: "POST",
|
|
45094
45115
|
url: `${baseUrl}/completepartuploaddfs?UploadID=${encodeURIComponent(uploadId)}`,
|
|
@@ -45106,7 +45127,7 @@ var __webpack_exports__ = {};
|
|
|
45106
45127
|
retryDelay: 3000
|
|
45107
45128
|
});
|
|
45108
45129
|
if (!completeRes.DownloadURL) throw new Error("合并分片失败: " + JSON.stringify(completeRes));
|
|
45109
|
-
logger?.info(
|
|
45130
|
+
logger?.info(`[shipinhaoPublishVideo] ${fileName} 上传成功`);
|
|
45110
45131
|
return {
|
|
45111
45132
|
downloadUrl: completeRes.DownloadURL,
|
|
45112
45133
|
md5: fileMd5,
|
|
@@ -45500,7 +45521,6 @@ var __webpack_exports__ = {};
|
|
|
45500
45521
|
};
|
|
45501
45522
|
}
|
|
45502
45523
|
async function getTraceKey(auth, client, http, logger) {
|
|
45503
|
-
logger.info("[getTraceKey] 开始获取 traceKey...");
|
|
45504
45524
|
const res = await http.api({
|
|
45505
45525
|
method: "POST",
|
|
45506
45526
|
url: `${MICRO_CONTENT_BASE}/post/get-finder-post-trace-key`,
|
|
@@ -45515,11 +45535,9 @@ var __webpack_exports__ = {};
|
|
|
45515
45535
|
logger.error("[getTraceKey] 获取失败:", JSON.stringify(res));
|
|
45516
45536
|
throw new Error(`获取 traceKey 失败: ${JSON.stringify(res)}`);
|
|
45517
45537
|
}
|
|
45518
|
-
logger.info(`[getTraceKey] 获取成功: ${res.data.traceKey}`);
|
|
45519
45538
|
return res.data.traceKey;
|
|
45520
45539
|
}
|
|
45521
45540
|
async function getObjectTagKey(auth, client, http, logger) {
|
|
45522
|
-
logger.info("[getObjectTagKey] 获取内容声明 tagKey...");
|
|
45523
45541
|
try {
|
|
45524
45542
|
const res = await http.api({
|
|
45525
45543
|
method: "POST",
|
|
@@ -45535,7 +45553,6 @@ var __webpack_exports__ = {};
|
|
|
45535
45553
|
logger.warn(`[getObjectTagKey] 未取到 tagKey: ${JSON.stringify(res)}`);
|
|
45536
45554
|
return null;
|
|
45537
45555
|
}
|
|
45538
|
-
logger.info(`[getObjectTagKey] tagKey: ${res.data.tagKey}`);
|
|
45539
45556
|
return res.data.tagKey;
|
|
45540
45557
|
} catch (error) {
|
|
45541
45558
|
logger.warn(`[getObjectTagKey] 获取 tagKey 异常: ${stringifyError(error)}`);
|
|
@@ -45544,7 +45561,6 @@ var __webpack_exports__ = {};
|
|
|
45544
45561
|
}
|
|
45545
45562
|
async function submitAndPollTranscode(opts) {
|
|
45546
45563
|
const { videoUrl, videoMeta, traceKey, uploadStartTime, uploadEndTime, finderUsername, client, http, logger } = opts;
|
|
45547
|
-
logger.info("[submitAndPollTranscode] 开始提交转码任务...");
|
|
45548
45564
|
const finderUrl = videoUrl.includes("wxapp.tc.qq.com") ? `https://finder.video.qq.com${videoUrl.split("qq.com")[1]}` : videoUrl;
|
|
45549
45565
|
logger.info(`[submitAndPollTranscode] 视频尺寸: ${videoMeta.width}x${videoMeta.height}, 时长: ${videoMeta.duration}s`);
|
|
45550
45566
|
const submitRes = await http.api({
|
|
@@ -45583,12 +45599,10 @@ var __webpack_exports__ = {};
|
|
|
45583
45599
|
throw new Error(`提交转码失败: ${JSON.stringify(submitRes)}`);
|
|
45584
45600
|
}
|
|
45585
45601
|
const { clipKey, draftId } = submitRes.data;
|
|
45586
|
-
logger.info(`[submitAndPollTranscode] 转码任务已提交,clipKey: ${clipKey}, draftId: ${draftId}`);
|
|
45587
45602
|
const pollInterval = 5000;
|
|
45588
45603
|
const pollBudget = Math.min(1800000, 300000 + 1000 * Math.ceil(1.5 * videoMeta.duration));
|
|
45589
45604
|
const maxPolls = Math.ceil(pollBudget / pollInterval);
|
|
45590
45605
|
let pollCount = 0;
|
|
45591
|
-
logger.info(`[submitAndPollTranscode] 开始轮询转码结果,最多 ${maxPolls} 次(${Math.round(pollBudget / 1000)}s),间隔 ${pollInterval / 1000}s`);
|
|
45592
45606
|
while(pollCount < maxPolls){
|
|
45593
45607
|
await mock_sleep(pollInterval);
|
|
45594
45608
|
pollCount++;
|
|
@@ -45612,14 +45626,12 @@ var __webpack_exports__ = {};
|
|
|
45612
45626
|
throw new Error(`转码轮询失败 (poll ${pollCount}): ${JSON.stringify(pollRes)}`);
|
|
45613
45627
|
}
|
|
45614
45628
|
const { flag, url, width, height, duration, md5, fileSize } = pollRes.data || {};
|
|
45615
|
-
logger.info(`[submitAndPollTranscode] 轮询第 ${pollCount} 次,flag=${flag}`);
|
|
45616
45629
|
if (1 === flag) {
|
|
45617
45630
|
if (!url || !width || !height || !duration || !md5 || !fileSize) {
|
|
45618
45631
|
logger.error("[submitAndPollTranscode] 转码完成但返回数据不完整:", JSON.stringify(pollRes.data));
|
|
45619
45632
|
throw new Error(`转码完成但返回数据不完整: ${JSON.stringify(pollRes.data)}`);
|
|
45620
45633
|
}
|
|
45621
45634
|
logger.info(`[submitAndPollTranscode] 转码完成! 用时: ${pollCount * pollInterval / 1000}s`);
|
|
45622
|
-
logger.info(`[submitAndPollTranscode] 视频信息: ${width}x${height}, 时长: ${duration}s, 大小: ${fileSize}`);
|
|
45623
45635
|
return {
|
|
45624
45636
|
clipKey,
|
|
45625
45637
|
url,
|
|
@@ -45630,7 +45642,7 @@ var __webpack_exports__ = {};
|
|
|
45630
45642
|
fileSize
|
|
45631
45643
|
};
|
|
45632
45644
|
}
|
|
45633
|
-
if (2 === flag)
|
|
45645
|
+
if (2 === flag) ;
|
|
45634
45646
|
else {
|
|
45635
45647
|
logger.error(`[submitAndPollTranscode] 转码失败,未知 flag=${flag}:`, JSON.stringify(pollRes.data));
|
|
45636
45648
|
throw new Error(`转码失败,未知 flag=${flag}: ${JSON.stringify(pollRes.data)}`);
|
|
@@ -45641,16 +45653,11 @@ var __webpack_exports__ = {};
|
|
|
45641
45653
|
}
|
|
45642
45654
|
async function publishVideo(opts) {
|
|
45643
45655
|
const { params, auth, client, clipResult, videoUpload, coverUpload, verticalCoverUpload, videoMeta, traceKey, tagKey, uploadStartTime, uploadEndTime, proxyHttp, logger } = opts;
|
|
45644
|
-
logger.info("[publishVideo] 开始构建发布请求...");
|
|
45645
45656
|
const toFinderUrl = (url)=>url.includes("wxapp.tc.qq.com") ? `https://finder.video.qq.com${url.split("qq.com")[1]}` : url;
|
|
45646
45657
|
const thumbFinderUrl = toFinderUrl(coverUpload.downloadUrl);
|
|
45647
45658
|
const coverFinderUrl = toFinderUrl(verticalCoverUpload.downloadUrl);
|
|
45648
45659
|
const md5sumUuid = external_node_crypto_default().randomUUID();
|
|
45649
45660
|
const description = params.description;
|
|
45650
|
-
logger.info("[publishVideo] 发布参数:");
|
|
45651
|
-
logger.info(` - 短标题: ${params.title || "(无)"}`);
|
|
45652
|
-
logger.info(` - 描述: ${description.substring(0, 50)}${description.length > 50 ? "..." : ""}`);
|
|
45653
|
-
logger.info(` - 定时发布: ${params.scheduledTime ? new Date(1000 * params.scheduledTime).toLocaleString() : "立即发布"}`);
|
|
45654
45661
|
const objectDesc = {
|
|
45655
45662
|
mpTitle: "",
|
|
45656
45663
|
description,
|
|
@@ -45724,7 +45731,6 @@ var __webpack_exports__ = {};
|
|
|
45724
45731
|
};
|
|
45725
45732
|
if (params.scheduledTime) publishData.effectiveTime = params.scheduledTime;
|
|
45726
45733
|
if (params.tagInfo && tagKey) publishData.tagInfo = buildTagInfo(params.tagInfo, tagKey);
|
|
45727
|
-
logger.info("[publishVideo] 开始发布视频,全部参数:" + JSON.stringify(publishData));
|
|
45728
45734
|
const publishRes = await proxyHttp.api({
|
|
45729
45735
|
method: "POST",
|
|
45730
45736
|
url: `${MICRO_CONTENT_BASE}/post/post_create`,
|
|
@@ -45732,7 +45738,7 @@ var __webpack_exports__ = {};
|
|
|
45732
45738
|
data: publishData,
|
|
45733
45739
|
defaultErrorMsg: "发布视频失败"
|
|
45734
45740
|
});
|
|
45735
|
-
logger.info(`[publishVideo]
|
|
45741
|
+
logger.info(`[publishVideo] 发布结果: errCode=${publishRes.errCode}, baseResp.errcode=${publishRes.data?.baseResp?.errcode}`);
|
|
45736
45742
|
return publishRes;
|
|
45737
45743
|
}
|
|
45738
45744
|
function mock_sleep(ms) {
|
|
@@ -45746,11 +45752,9 @@ var __webpack_exports__ = {};
|
|
|
45746
45752
|
return savePath;
|
|
45747
45753
|
}
|
|
45748
45754
|
const shipinhaoPublishVideo_mock_mockAction = async (task, params)=>{
|
|
45749
|
-
task.logger.info("[shipinhaoPublishVideo] 开始执行视频号视频发布 - Mock API 方式");
|
|
45750
45755
|
const updateTaskState = task.taskStageStore?.update?.bind(task.taskStageStore, task.taskId || "");
|
|
45751
45756
|
let currentStep = "初始化";
|
|
45752
45757
|
try {
|
|
45753
|
-
task.logger.info(`[shipinhaoPublishVideo] 发布方式: ${params.scheduledTime ? `定时 ${new Date(1000 * params.scheduledTime).toLocaleString()}` : "立即发布"}`);
|
|
45754
45758
|
currentStep = "解析认证信息";
|
|
45755
45759
|
const cookieString = params.cookies.map((c)=>`${c.name}=${c.value}`).join("; ");
|
|
45756
45760
|
const http = new Http({
|
|
@@ -45762,11 +45766,8 @@ var __webpack_exports__ = {};
|
|
|
45762
45766
|
if (!params.videoPath) return utils_response(414, "视频文件路径不能为空", "");
|
|
45763
45767
|
if (!params.coverPath) return utils_response(414, "横屏封面图片路径不能为空", "");
|
|
45764
45768
|
currentStep = "获取上传认证";
|
|
45765
|
-
task.logger.info("[shipinhaoPublishVideo] 获取上传认证...");
|
|
45766
45769
|
const auth = await getShipinhaoUploadAuth(cookieString, http);
|
|
45767
45770
|
const client = resolveClientContext(params, auth.uin);
|
|
45768
|
-
if (!client.aId) task.logger.warn("[shipinhaoPublishVideo] extraParam.aId 缺失,query 将不带 _aid");
|
|
45769
|
-
if (!client.fingerPrintDeviceId) task.logger.warn("[shipinhaoPublishVideo] extraParam.fingerPrintDeviceId 缺失,请求将不带 finger-print-device-id");
|
|
45770
45771
|
const publishHeaders = buildPublishHeaders(cookieString, client);
|
|
45771
45772
|
const microHttp = new Http({
|
|
45772
45773
|
headers: publishHeaders
|
|
@@ -45782,25 +45783,20 @@ var __webpack_exports__ = {};
|
|
|
45782
45783
|
];
|
|
45783
45784
|
const proxyHttp = new Http(...args);
|
|
45784
45785
|
currentStep = "组装视频元数据";
|
|
45785
|
-
task.logger.info("[shipinhaoPublishVideo] 组装视频元数据...");
|
|
45786
45786
|
const videoMeta = buildVideoMetaFromParams(params.videoPath, params.videoMetadata);
|
|
45787
45787
|
task.logger.info(`[shipinhaoPublishVideo] 视频: ${videoMeta.width}×${videoMeta.height}, ${videoMeta.duration.toFixed(2)}s, ${(videoMeta.fileSize / 1024 / 1024).toFixed(2)}MB, codec=${videoMeta.codec || "unknown"}`);
|
|
45788
|
-
if (!videoMeta.codec) task.logger.warn("[shipinhaoPublishVideo] 未能读取视频编码格式,跳过 H.264 预检,交由服务端判断");
|
|
45789
45788
|
currentStep = "校验视频限制";
|
|
45790
45789
|
const validationError = validateShipinhaoVideo(params.videoPath, videoMeta);
|
|
45791
45790
|
if (validationError) {
|
|
45792
|
-
task.logger.error(`[shipinhaoPublishVideo] 视频校验未通过: ${validationError}`);
|
|
45793
45791
|
await updateTaskState?.({
|
|
45794
45792
|
state: types_TaskState.FAILED,
|
|
45795
45793
|
error: validationError
|
|
45796
45794
|
});
|
|
45797
45795
|
return utils_response(414, validationError, "");
|
|
45798
45796
|
}
|
|
45799
|
-
task.logger.info("[shipinhaoPublishVideo] 视频校验通过");
|
|
45800
45797
|
currentStep = "校验标题";
|
|
45801
45798
|
const titleError = validateShipinhaoTitle(params.title);
|
|
45802
45799
|
if (titleError) {
|
|
45803
|
-
task.logger.error(`[shipinhaoPublishVideo] 标题校验未通过: ${titleError}`);
|
|
45804
45800
|
await updateTaskState?.({
|
|
45805
45801
|
state: types_TaskState.FAILED,
|
|
45806
45802
|
error: titleError
|
|
@@ -45808,7 +45804,6 @@ var __webpack_exports__ = {};
|
|
|
45808
45804
|
return utils_response(414, titleError, "");
|
|
45809
45805
|
}
|
|
45810
45806
|
currentStep = "获取 traceKey";
|
|
45811
|
-
task.logger.info("[shipinhaoPublishVideo] 获取 traceKey...");
|
|
45812
45807
|
const traceKey = await getTraceKey(auth, client, microHttp, task.logger);
|
|
45813
45808
|
let tagKey = null;
|
|
45814
45809
|
if (params.tagInfo) {
|
|
@@ -45816,11 +45811,7 @@ var __webpack_exports__ = {};
|
|
|
45816
45811
|
tagKey = await getObjectTagKey(auth, client, microHttp, task.logger);
|
|
45817
45812
|
}
|
|
45818
45813
|
const uploadStartTime = Math.floor(Date.now() / 1000);
|
|
45819
|
-
task.logger.info(`[shipinhaoPublishVideo] 上传开始时间: ${uploadStartTime}`);
|
|
45820
45814
|
currentStep = "上传视频";
|
|
45821
|
-
task.logger.info("[shipinhaoPublishVideo] 上传视频...");
|
|
45822
|
-
task.logger.info(`[shipinhaoPublishVideo] 视频路径: ${params.videoPath}`);
|
|
45823
|
-
task.logger.info(`[shipinhaoPublishVideo] 视频文件类型: ${auth.videoFileType}`);
|
|
45824
45815
|
const videoUpload = await uploader_uploadFile({
|
|
45825
45816
|
filePath: params.videoPath,
|
|
45826
45817
|
fileType: auth.videoFileType,
|
|
@@ -45829,12 +45820,10 @@ var __webpack_exports__ = {};
|
|
|
45829
45820
|
http,
|
|
45830
45821
|
logger: task.logger
|
|
45831
45822
|
});
|
|
45832
|
-
task.logger.info("[shipinhaoPublishVideo] 视频上传完成");
|
|
45833
45823
|
const uploadEndTime = Math.floor(Date.now() / 1000);
|
|
45834
|
-
task.logger.info(`[shipinhaoPublishVideo]
|
|
45824
|
+
task.logger.info(`[shipinhaoPublishVideo] 耗时: ${uploadEndTime - uploadStartTime}s`);
|
|
45835
45825
|
currentStep = "上传横屏封面";
|
|
45836
45826
|
const localCoverPath = await resolveLocalCoverPath(params.coverPath, "横屏封面", task.getTmpPath(), task.logger);
|
|
45837
|
-
task.logger.info("[shipinhaoPublishVideo] 上传横屏封面...");
|
|
45838
45827
|
const coverUpload = await uploader_uploadFile({
|
|
45839
45828
|
filePath: localCoverPath,
|
|
45840
45829
|
fileType: auth.pictureFileType,
|
|
@@ -45843,12 +45832,10 @@ var __webpack_exports__ = {};
|
|
|
45843
45832
|
http,
|
|
45844
45833
|
logger: task.logger
|
|
45845
45834
|
});
|
|
45846
|
-
task.logger.info("[shipinhaoPublishVideo] 横屏封面上传完成");
|
|
45847
45835
|
let verticalCoverUpload = coverUpload;
|
|
45848
45836
|
if (params.verticalCoverPath) {
|
|
45849
45837
|
currentStep = "上传竖屏封面";
|
|
45850
45838
|
const localVerticalPath = await resolveLocalCoverPath(params.verticalCoverPath, "竖屏封面", task.getTmpPath(), task.logger);
|
|
45851
|
-
task.logger.info("[shipinhaoPublishVideo] 上传竖屏封面");
|
|
45852
45839
|
verticalCoverUpload = await uploader_uploadFile({
|
|
45853
45840
|
filePath: localVerticalPath,
|
|
45854
45841
|
fileType: auth.pictureFileType,
|
|
@@ -45857,10 +45844,8 @@ var __webpack_exports__ = {};
|
|
|
45857
45844
|
http,
|
|
45858
45845
|
logger: task.logger
|
|
45859
45846
|
});
|
|
45860
|
-
|
|
45861
|
-
} else task.logger.info("[shipinhaoPublishVideo] 未传竖屏封面,复用横屏封面");
|
|
45847
|
+
}
|
|
45862
45848
|
currentStep = "提交转码";
|
|
45863
|
-
task.logger.info("[shipinhaoPublishVideo] 提交转码...");
|
|
45864
45849
|
const clipResult = await submitAndPollTranscode({
|
|
45865
45850
|
videoUrl: videoUpload.downloadUrl,
|
|
45866
45851
|
videoMeta,
|
|
@@ -45873,8 +45858,6 @@ var __webpack_exports__ = {};
|
|
|
45873
45858
|
logger: task.logger
|
|
45874
45859
|
});
|
|
45875
45860
|
currentStep = "发布视频";
|
|
45876
|
-
task.logger.info("[shipinhaoPublishVideo] 发布视频...");
|
|
45877
|
-
task.logger.info(`[shipinhaoPublishVideo] clipKey: ${clipResult.clipKey}`);
|
|
45878
45861
|
let publishResult;
|
|
45879
45862
|
try {
|
|
45880
45863
|
publishResult = await publishVideo({
|
|
@@ -45899,7 +45882,6 @@ var __webpack_exports__ = {};
|
|
|
45899
45882
|
const classified = classifyPublishError(handledError);
|
|
45900
45883
|
if (classified) {
|
|
45901
45884
|
const message = `${classified.userMessage}${task.debug ? ` ${http.proxyInfo}` : ""}`;
|
|
45902
|
-
task.logger.error(`[shipinhaoPublishVideo] ${classified.category},直接返回: ${handledError.message} (code=${handledError.code})`, stringifyError(handledError));
|
|
45903
45885
|
await updateTaskState?.({
|
|
45904
45886
|
state: types_TaskState.FAILED,
|
|
45905
45887
|
error: message
|
|
@@ -45916,11 +45898,8 @@ var __webpack_exports__ = {};
|
|
|
45916
45898
|
const resultCode = publishResult.data?.baseResp?.errcode ?? publishResult.errCode;
|
|
45917
45899
|
const resultMsg = publishResult.data?.baseResp?.errmsg ?? (0 === resultCode ? "发布成功" : `发布失败(errCode=${resultCode})`);
|
|
45918
45900
|
if (0 === resultCode) {
|
|
45919
|
-
|
|
45920
|
-
task.logger.
|
|
45921
|
-
task.logger.info(`[shipinhaoPublishVideo] 视频URL: ${clipResult.url}`);
|
|
45922
|
-
task.logger.info(`[shipinhaoPublishVideo] 横屏封面URL: ${coverUpload.downloadUrl}`);
|
|
45923
|
-
task.logger.info(`[shipinhaoPublishVideo] 竖屏封面URL: ${verticalCoverUpload.downloadUrl}`);
|
|
45901
|
+
const publishId = extractEncFileKey(coverUpload.downloadUrl);
|
|
45902
|
+
if (!publishId) task.logger.error(`[shipinhaoPublishVideo] 封面 DownloadURL 中未解析到 encfilekey,关联 id 为空: ${coverUpload.downloadUrl}`);
|
|
45924
45903
|
await updateTaskState?.({
|
|
45925
45904
|
state: types_TaskState.SUCCESS,
|
|
45926
45905
|
result: {
|
|
@@ -45950,8 +45929,7 @@ var __webpack_exports__ = {};
|
|
|
45950
45929
|
},
|
|
45951
45930
|
platform: "shipinhao"
|
|
45952
45931
|
});
|
|
45953
|
-
|
|
45954
|
-
return utils_response(0, "发布成功", clipResult.clipKey);
|
|
45932
|
+
return utils_response(0, "发布成功", publishId);
|
|
45955
45933
|
}
|
|
45956
45934
|
let errorMessage = resultMsg;
|
|
45957
45935
|
if (-11224 === resultCode) errorMessage = "视频号管理员完成实名且绑定手机号后才可以发表";
|
|
@@ -45963,18 +45941,16 @@ var __webpack_exports__ = {};
|
|
|
45963
45941
|
state: types_TaskState.FAILED,
|
|
45964
45942
|
error: errorMessage
|
|
45965
45943
|
});
|
|
45966
|
-
return utils_response(
|
|
45944
|
+
return utils_response(414, errorMessage, "");
|
|
45967
45945
|
} catch (error) {
|
|
45968
45946
|
const handledError = Http.handleApiError(error);
|
|
45969
45947
|
const errorMsg = handledError.message || "发布失败,请稍后重试";
|
|
45970
|
-
const errorCode = handledError.code || 414;
|
|
45971
45948
|
task.logger.error(`[shipinhaoPublishVideo] 发布流程异常 [${currentStep}]: ${errorMsg}`, stringifyError(error), handledError.extra);
|
|
45972
|
-
task.logger.error(`[shipinhaoPublishVideo] 错误码: ${errorCode}, 当前步骤: ${currentStep}`);
|
|
45973
45949
|
await updateTaskState?.({
|
|
45974
45950
|
state: types_TaskState.FAILED,
|
|
45975
45951
|
error: errorMsg
|
|
45976
45952
|
});
|
|
45977
|
-
return utils_response(
|
|
45953
|
+
return utils_response(414, errorMsg, "");
|
|
45978
45954
|
}
|
|
45979
45955
|
};
|
|
45980
45956
|
const shipinhaoPublishVideo_rpa_rpaAction = async (task, params)=>{
|
|
@@ -52546,4 +52522,4 @@ if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_targe
|
|
|
52546
52522
|
});
|
|
52547
52523
|
|
|
52548
52524
|
//# sourceMappingURL=bundle.js.map
|
|
52549
|
-
//# debugId=
|
|
52525
|
+
//# debugId=51f3980f-4908-5c61-864e-675122bae629
|