@iflyrpa/actions 4.1.0-beta.6 → 4.1.1-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions/searchAccountInfo/index.d.ts +1 -1
- package/dist/actions/shipinhaoPublishVideo/videoValidator.d.ts +4 -2
- package/dist/actions/toutiaoPublish/index.d.ts +1 -1
- package/dist/bundle.js +153 -137
- package/dist/bundle.js.map +1 -1
- package/dist/index.js +153 -137
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +153 -137
- package/dist/index.mjs.map +1 -1
- package/dist/utils/feishuAlarm.d.ts +4 -1
- package/dist/utils/http.d.ts +16 -0
- package/dist/utils/shipinhao/utils.d.ts +10 -0
- package/package.json +2 -2
package/dist/index.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]="56541751-7175-5826-bba1-27edba330f54")}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.
|
|
4406
|
+
var package_namespaceObject = JSON.parse('{"i8":"4.1.1-beta.0"}');
|
|
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 {}
|
|
@@ -4679,6 +4685,19 @@ var __webpack_exports__ = {};
|
|
|
4679
4685
|
461,
|
|
4680
4686
|
471
|
|
4681
4687
|
]);
|
|
4688
|
+
function isLocalAddress(url) {
|
|
4689
|
+
let hostname;
|
|
4690
|
+
try {
|
|
4691
|
+
hostname = new URL(url).hostname.toLowerCase();
|
|
4692
|
+
} catch {
|
|
4693
|
+
return false;
|
|
4694
|
+
}
|
|
4695
|
+
if ("localhost" === hostname || "::1" === hostname || "[::1]" === hostname) return true;
|
|
4696
|
+
if (hostname.endsWith(".localhost") || hostname.endsWith(".local")) return true;
|
|
4697
|
+
if (/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(hostname)) return true;
|
|
4698
|
+
if ("0.0.0.0" === hostname) return true;
|
|
4699
|
+
return false;
|
|
4700
|
+
}
|
|
4682
4701
|
const HTTP_STATUS_MESSAGE = {
|
|
4683
4702
|
400: "请求参数错误,请检查参数格式是否正确!",
|
|
4684
4703
|
401: "登录状态已失效,请重新登录后重试!",
|
|
@@ -4715,7 +4734,14 @@ var __webpack_exports__ = {};
|
|
|
4715
4734
|
};
|
|
4716
4735
|
class Http {
|
|
4717
4736
|
static handleApiError(error) {
|
|
4718
|
-
if (error && "object" == typeof error && "code" in error && "message" in error)
|
|
4737
|
+
if (error && "object" == typeof error && "code" in error && "message" in error) {
|
|
4738
|
+
const resp = error;
|
|
4739
|
+
if ("string" != typeof resp.message || !resp.message.trim()) return {
|
|
4740
|
+
...resp,
|
|
4741
|
+
message: USER_MESSAGE.SYSTEM_ERROR
|
|
4742
|
+
};
|
|
4743
|
+
return resp;
|
|
4744
|
+
}
|
|
4719
4745
|
return {
|
|
4720
4746
|
code: 500,
|
|
4721
4747
|
message: USER_MESSAGE.SYSTEM_ERROR,
|
|
@@ -4853,21 +4879,51 @@ var __webpack_exports__ = {};
|
|
|
4853
4879
|
errorResponse.message = message;
|
|
4854
4880
|
}
|
|
4855
4881
|
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
|
-
});
|
|
4882
|
+
errorResponse.extra = {
|
|
4883
|
+
...errorResponse.extra,
|
|
4884
|
+
alarmStatus: error.response?.status,
|
|
4885
|
+
alarmErrorCode: error.code
|
|
4886
|
+
};
|
|
4868
4887
|
throw errorResponse;
|
|
4869
4888
|
});
|
|
4870
4889
|
}
|
|
4890
|
+
reportRequestFailure(config, error, attempts) {
|
|
4891
|
+
const status = error.extra?.alarmStatus;
|
|
4892
|
+
const axiosCode = error.extra?.alarmErrorCode;
|
|
4893
|
+
const method = (config.method || "get").toUpperCase();
|
|
4894
|
+
const baseURL = config.baseURL || this.apiClient.defaults.baseURL || "";
|
|
4895
|
+
const fullUrl = config.url ? /^https?:\/\//.test(config.url) ? config.url : `${baseURL.replace(/\/$/, "")}${config.url}` : baseURL;
|
|
4896
|
+
if (!fullUrl) {
|
|
4897
|
+
this.logger?.debug(`[告警跳过] 请求失败但无 URL,不上报: ${error.message}`);
|
|
4898
|
+
return;
|
|
4899
|
+
}
|
|
4900
|
+
if (isLocalAddress(fullUrl)) {
|
|
4901
|
+
this.logger?.debug(`[告警跳过] 本机地址不上报: ${fullUrl}`);
|
|
4902
|
+
return;
|
|
4903
|
+
}
|
|
4904
|
+
if (attempts < 3) {
|
|
4905
|
+
const isAuthExpired = 401 === status;
|
|
4906
|
+
const isTimeoutCanceled = "ERR_CANCELED" === axiosCode;
|
|
4907
|
+
if (isAuthExpired || isTimeoutCanceled) {
|
|
4908
|
+
this.logger?.debug(`[告警跳过] 低重试次数(${attempts})的常见错误不上报: status=${status}, code=${error.code}, axiosCode=${axiosCode}, url=${fullUrl}`);
|
|
4909
|
+
return;
|
|
4910
|
+
}
|
|
4911
|
+
}
|
|
4912
|
+
const rawMsg = "string" == typeof error.message && error.message.trim() ? error.message : "";
|
|
4913
|
+
const baseMsg = rawMsg || `请求失败(无错误文案,code=${error.code ?? "unknown"})`;
|
|
4914
|
+
const retriedSuffix = attempts > 0 ? `(已重试${attempts}次仍失败)` : "";
|
|
4915
|
+
reportFeishuAlarm({
|
|
4916
|
+
level: status && ALARM_STATUS.has(status) ? "alarm" : "warning",
|
|
4917
|
+
platform: "@iflyrpa/playwright",
|
|
4918
|
+
source: "http",
|
|
4919
|
+
stage: `${method} ${fullUrl}`,
|
|
4920
|
+
errorType: status ? `HTTP_${status}` : axiosCode || "NETWORK_ERROR",
|
|
4921
|
+
code: error.code,
|
|
4922
|
+
msg: `${baseMsg}${retriedSuffix}`,
|
|
4923
|
+
url: fullUrl,
|
|
4924
|
+
title: "RPA接口异常"
|
|
4925
|
+
});
|
|
4926
|
+
}
|
|
4871
4927
|
async api(config, options) {
|
|
4872
4928
|
const retries = options?.retries ?? 0;
|
|
4873
4929
|
const retryDelay = options?.retryDelay ?? 500;
|
|
@@ -4912,10 +4968,12 @@ var __webpack_exports__ = {};
|
|
|
4912
4968
|
].includes(handledError.code);
|
|
4913
4969
|
if (Rtimes < retries && isRetry) {
|
|
4914
4970
|
const url = config.url || "";
|
|
4915
|
-
|
|
4916
|
-
|
|
4971
|
+
const backoff = Math.min(retryDelay * 2 ** Rtimes, 5000);
|
|
4972
|
+
this.logger?.warn(`进入第${Rtimes + 1}次重试!错误码: ${handledError.code}, 等待: ${backoff}ms, 请求地址: ${url}`);
|
|
4973
|
+
await new Promise((resolve)=>setTimeout(resolve, backoff));
|
|
4917
4974
|
return sessionRt(Rtimes + 1);
|
|
4918
4975
|
}
|
|
4976
|
+
this.reportRequestFailure(config, handledError, Rtimes);
|
|
4919
4977
|
return Promise.reject(handledError);
|
|
4920
4978
|
}
|
|
4921
4979
|
};
|
|
@@ -6031,7 +6089,7 @@ var __webpack_exports__ = {};
|
|
|
6031
6089
|
const cidrv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
|
|
6032
6090
|
const regexes_base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
|
|
6033
6091
|
const regexes_base64url = /^[A-Za-z0-9_-]*$/;
|
|
6034
|
-
const
|
|
6092
|
+
const regexes_hostname = /^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/;
|
|
6035
6093
|
const e164 = /^\+(?:[0-9]){6,14}[0-9]$/;
|
|
6036
6094
|
const dateSource = "(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";
|
|
6037
6095
|
const regexes_date = /*@__PURE__*/ new RegExp(`^${dateSource}$`);
|
|
@@ -6627,7 +6685,7 @@ var __webpack_exports__ = {};
|
|
|
6627
6685
|
code: "invalid_format",
|
|
6628
6686
|
format: "url",
|
|
6629
6687
|
note: "Invalid hostname",
|
|
6630
|
-
pattern:
|
|
6688
|
+
pattern: regexes_hostname.source,
|
|
6631
6689
|
input: payload.value,
|
|
6632
6690
|
inst,
|
|
6633
6691
|
continue: !def.abort
|
|
@@ -9340,7 +9398,7 @@ var __webpack_exports__ = {};
|
|
|
9340
9398
|
".png"
|
|
9341
9399
|
].includes(ext)) throw {
|
|
9342
9400
|
code: 414,
|
|
9343
|
-
message:
|
|
9401
|
+
message: "图片格式不支持,百家号仅支持 jpg、png 格式,请转换后重试。",
|
|
9344
9402
|
data: ""
|
|
9345
9403
|
};
|
|
9346
9404
|
const image = await (0, share_namespaceObject.downloadImage)(url, external_node_path_default().join(tmpCachePath, fileName));
|
|
@@ -10023,7 +10081,8 @@ var __webpack_exports__ = {};
|
|
|
10023
10081
|
},
|
|
10024
10082
|
_task.logger,
|
|
10025
10083
|
params.proxyLoc,
|
|
10026
|
-
params.accountId
|
|
10084
|
+
params.accountId,
|
|
10085
|
+
"xiaohongshu"
|
|
10027
10086
|
];
|
|
10028
10087
|
const http = new Http(...args);
|
|
10029
10088
|
const fans = {
|
|
@@ -10037,8 +10096,8 @@ var __webpack_exports__ = {};
|
|
|
10037
10096
|
url: "https://creator.xiaohongshu.com/api/galaxy/creator/home/personal_info"
|
|
10038
10097
|
}, {
|
|
10039
10098
|
retries: 3,
|
|
10040
|
-
retryDelay:
|
|
10041
|
-
timeout:
|
|
10099
|
+
retryDelay: 300,
|
|
10100
|
+
timeout: 30000
|
|
10042
10101
|
});
|
|
10043
10102
|
fans.fans_count = Number(res.data.fans_count);
|
|
10044
10103
|
fans.digg_count = Number(res.data.faved_count);
|
|
@@ -11175,7 +11234,8 @@ var __webpack_exports__ = {};
|
|
|
11175
11234
|
},
|
|
11176
11235
|
_task.logger,
|
|
11177
11236
|
params.proxyLoc,
|
|
11178
|
-
params.accountId
|
|
11237
|
+
params.accountId,
|
|
11238
|
+
"xiaohongshu"
|
|
11179
11239
|
];
|
|
11180
11240
|
const http = new Http(...args);
|
|
11181
11241
|
http.addResponseInterceptor((response)=>{
|
|
@@ -11185,52 +11245,26 @@ var __webpack_exports__ = {};
|
|
|
11185
11245
|
data: response.data.data
|
|
11186
11246
|
};
|
|
11187
11247
|
});
|
|
11188
|
-
const loginBasePath = "/api/galaxy/
|
|
11248
|
+
const loginBasePath = "/api/galaxy/creator/home/personal_info";
|
|
11189
11249
|
const recordCookie = params.cookies.reduce((acc, cookie)=>{
|
|
11190
11250
|
if (cookie.name && cookie.value) acc[cookie.name] = cookie.value;
|
|
11191
11251
|
return acc;
|
|
11192
11252
|
}, {});
|
|
11193
|
-
let loginBaseXsHeader;
|
|
11194
|
-
try {
|
|
11195
|
-
loginBaseXsHeader = sessionCheck_xsEncrypt.signHeadersGet(loginBasePath, recordCookie, "xhs-pc-web", null);
|
|
11196
|
-
} catch (signError) {
|
|
11197
|
-
_task.logger?.error("[XhsSessionCheck] 签名生成失败 - 环境快照", {
|
|
11198
|
-
accountId: params.accountId,
|
|
11199
|
-
error: signError instanceof Error ? signError.message : String(signError),
|
|
11200
|
-
stack: _task.debug ? signError instanceof Error ? signError.stack : void 0 : void 0,
|
|
11201
|
-
hasA1: !!recordCookie.a1,
|
|
11202
|
-
env: {
|
|
11203
|
-
processType: process.type,
|
|
11204
|
-
memoryUsage: {
|
|
11205
|
-
heapUsed: `${Math.round(process.memoryUsage().heapUsed / 1024 / 1024)} MB`,
|
|
11206
|
-
heapTotal: `${Math.round(process.memoryUsage().heapTotal / 1024 / 1024)} MB`
|
|
11207
|
-
},
|
|
11208
|
-
hasProxy: !!params.proxyLoc,
|
|
11209
|
-
timeSinceLastLog: Date.now() - lastEnvLogTime
|
|
11210
|
-
}
|
|
11211
|
-
});
|
|
11212
|
-
return {
|
|
11213
|
-
code: 500,
|
|
11214
|
-
message: "账号签名生成失败,请稍后重试。",
|
|
11215
|
-
data: check
|
|
11216
|
-
};
|
|
11217
|
-
}
|
|
11218
11253
|
const baseInfoStart = Date.now();
|
|
11219
11254
|
const _baseInfo = http.api({
|
|
11220
11255
|
method: "get",
|
|
11221
11256
|
baseURL: "https://creator.xiaohongshu.com",
|
|
11222
|
-
url: loginBasePath
|
|
11223
|
-
headers: loginBaseXsHeader
|
|
11257
|
+
url: loginBasePath
|
|
11224
11258
|
}, {
|
|
11225
11259
|
retries: 3,
|
|
11226
|
-
retryDelay:
|
|
11227
|
-
timeout:
|
|
11260
|
+
retryDelay: 300,
|
|
11261
|
+
timeout: 30000
|
|
11228
11262
|
}).catch((e)=>{
|
|
11229
11263
|
const clientTimestamp = Date.now();
|
|
11230
11264
|
const serverDate = e?.extra?.serverDate;
|
|
11231
11265
|
const serverTimestamp = serverDate ? new Date(serverDate).getTime() : null;
|
|
11232
11266
|
const timeDriftMs = serverTimestamp ? clientTimestamp - serverTimestamp : null;
|
|
11233
|
-
_task.logger?.warn("[XhsSessionCheck] creator
|
|
11267
|
+
_task.logger?.warn("[XhsSessionCheck] creator personal_info 接口请求失败", {
|
|
11234
11268
|
accountId: params.accountId,
|
|
11235
11269
|
duration: Date.now() - baseInfoStart,
|
|
11236
11270
|
code: e?.code,
|
|
@@ -11248,7 +11282,31 @@ var __webpack_exports__ = {};
|
|
|
11248
11282
|
});
|
|
11249
11283
|
const webSessionPath = "/api/sns/web/unread_count";
|
|
11250
11284
|
const webSessionData = {};
|
|
11251
|
-
|
|
11285
|
+
let webSessionXsHeader;
|
|
11286
|
+
try {
|
|
11287
|
+
webSessionXsHeader = sessionCheck_xsEncrypt.signHeadersPost(webSessionPath, recordCookie, "xhs-pc-web", webSessionData);
|
|
11288
|
+
} catch (signError) {
|
|
11289
|
+
_task.logger?.error("[XhsSessionCheck] 签名生成失败 - 环境快照", {
|
|
11290
|
+
accountId: params.accountId,
|
|
11291
|
+
error: signError instanceof Error ? signError.message : String(signError),
|
|
11292
|
+
stack: _task.debug ? signError instanceof Error ? signError.stack : void 0 : void 0,
|
|
11293
|
+
hasA1: !!recordCookie.a1,
|
|
11294
|
+
env: {
|
|
11295
|
+
processType: process.type,
|
|
11296
|
+
memoryUsage: {
|
|
11297
|
+
heapUsed: `${Math.round(process.memoryUsage().heapUsed / 1024 / 1024)} MB`,
|
|
11298
|
+
heapTotal: `${Math.round(process.memoryUsage().heapTotal / 1024 / 1024)} MB`
|
|
11299
|
+
},
|
|
11300
|
+
hasProxy: !!params.proxyLoc,
|
|
11301
|
+
timeSinceLastLog: Date.now() - lastEnvLogTime
|
|
11302
|
+
}
|
|
11303
|
+
});
|
|
11304
|
+
return {
|
|
11305
|
+
code: 500,
|
|
11306
|
+
message: "账号签名生成失败,请稍后重试。",
|
|
11307
|
+
data: check
|
|
11308
|
+
};
|
|
11309
|
+
}
|
|
11252
11310
|
const _web_session = http.api({
|
|
11253
11311
|
method: "GET",
|
|
11254
11312
|
url: "https://edith.xiaohongshu.com/api/sns/web/unread_count",
|
|
@@ -11256,8 +11314,8 @@ var __webpack_exports__ = {};
|
|
|
11256
11314
|
headers: webSessionXsHeader
|
|
11257
11315
|
}, {
|
|
11258
11316
|
retries: 3,
|
|
11259
|
-
retryDelay:
|
|
11260
|
-
timeout:
|
|
11317
|
+
retryDelay: 300,
|
|
11318
|
+
timeout: 30000
|
|
11261
11319
|
});
|
|
11262
11320
|
const [baseInfo, web_session] = await Promise.all([
|
|
11263
11321
|
_baseInfo,
|
|
@@ -11349,6 +11407,10 @@ var __webpack_exports__ = {};
|
|
|
11349
11407
|
};
|
|
11350
11408
|
return (0, share_namespaceObject.success)(data, message);
|
|
11351
11409
|
};
|
|
11410
|
+
const extractEncFileKey = (downloadUrl)=>{
|
|
11411
|
+
if (!downloadUrl) return "";
|
|
11412
|
+
return downloadUrl.split("encfilekey=")[1]?.split("&")[0] || "";
|
|
11413
|
+
};
|
|
11352
11414
|
const rid = ()=>`${Math.floor(Date.now() / 1e3).toString(16)}-${[
|
|
11353
11415
|
...Array(8)
|
|
11354
11416
|
].map(()=>Math.floor(16 * Math.random()).toString(16)).join("")}`;
|
|
@@ -15508,7 +15570,8 @@ var __webpack_exports__ = {};
|
|
|
15508
15570
|
},
|
|
15509
15571
|
_task.logger,
|
|
15510
15572
|
params.proxyLoc,
|
|
15511
|
-
params.accountId
|
|
15573
|
+
params.accountId,
|
|
15574
|
+
"xiaohongshu"
|
|
15512
15575
|
];
|
|
15513
15576
|
const http = new Http(...args);
|
|
15514
15577
|
let unreadCount = {
|
|
@@ -15537,8 +15600,8 @@ var __webpack_exports__ = {};
|
|
|
15537
15600
|
headers: xsHeader
|
|
15538
15601
|
}, {
|
|
15539
15602
|
retries: 3,
|
|
15540
|
-
retryDelay:
|
|
15541
|
-
timeout:
|
|
15603
|
+
retryDelay: 300,
|
|
15604
|
+
timeout: 30000
|
|
15542
15605
|
});
|
|
15543
15606
|
const isSuccess = 0 === res.code;
|
|
15544
15607
|
if (isSuccess) unreadCount = res.data;
|
|
@@ -15951,7 +16014,8 @@ var __webpack_exports__ = {};
|
|
|
15951
16014
|
},
|
|
15952
16015
|
_task.logger,
|
|
15953
16016
|
params.proxyLoc,
|
|
15954
|
-
params.accountId
|
|
16017
|
+
params.accountId,
|
|
16018
|
+
"xiaohongshu"
|
|
15955
16019
|
];
|
|
15956
16020
|
const http = new Http(...args);
|
|
15957
16021
|
const xsEncrypt = new Xhshow();
|
|
@@ -15967,8 +16031,8 @@ var __webpack_exports__ = {};
|
|
|
15967
16031
|
url: "https://creator.xiaohongshu.com/api/galaxy/creator/home/personal_info"
|
|
15968
16032
|
}, {
|
|
15969
16033
|
retries: 3,
|
|
15970
|
-
retryDelay:
|
|
15971
|
-
timeout:
|
|
16034
|
+
retryDelay: 300,
|
|
16035
|
+
timeout: 30000
|
|
15972
16036
|
}),
|
|
15973
16037
|
http.api({
|
|
15974
16038
|
method: "get",
|
|
@@ -15977,8 +16041,8 @@ var __webpack_exports__ = {};
|
|
|
15977
16041
|
headers: sevenDataXsHeader
|
|
15978
16042
|
}, {
|
|
15979
16043
|
retries: 3,
|
|
15980
|
-
retryDelay:
|
|
15981
|
-
timeout:
|
|
16044
|
+
retryDelay: 300,
|
|
16045
|
+
timeout: 30000
|
|
15982
16046
|
})
|
|
15983
16047
|
]);
|
|
15984
16048
|
const xhsData = {
|
|
@@ -16885,9 +16949,10 @@ var __webpack_exports__ = {};
|
|
|
16885
16949
|
timeout: 3000
|
|
16886
16950
|
});
|
|
16887
16951
|
}
|
|
16952
|
+
const isPublished = (note)=>!note.schedule_post_time;
|
|
16888
16953
|
const articleInfo = await fetchArticles(pageNum, onlySuccess);
|
|
16889
16954
|
let hasNextpage = -1 !== articleInfo.data.page;
|
|
16890
|
-
const filtered = articleInfo.data.notes;
|
|
16955
|
+
const filtered = articleInfo.data.notes.filter(isPublished);
|
|
16891
16956
|
let currentPage = pageNum + 1;
|
|
16892
16957
|
const usedPages = new Set();
|
|
16893
16958
|
while(filtered.length < pageSize && hasNextpage){
|
|
@@ -16897,7 +16962,7 @@ var __webpack_exports__ = {};
|
|
|
16897
16962
|
}
|
|
16898
16963
|
const res = await fetchArticles(currentPage, onlySuccess);
|
|
16899
16964
|
usedPages.add(currentPage);
|
|
16900
|
-
const validItems = res.data.notes;
|
|
16965
|
+
const validItems = res.data.notes.filter(isPublished);
|
|
16901
16966
|
filtered.push(...validItems);
|
|
16902
16967
|
currentPage++;
|
|
16903
16968
|
hasNextpage = -1 !== res.data.page;
|
|
@@ -18840,7 +18905,7 @@ var __webpack_exports__ = {};
|
|
|
18840
18905
|
name: params.music.name,
|
|
18841
18906
|
artist: params.music.authorName,
|
|
18842
18907
|
mediaStreamingUrl: params.music.url,
|
|
18843
|
-
docType: params.music.raw.
|
|
18908
|
+
docType: 2 === params.music.raw.bgmSource ? 0 : 1
|
|
18844
18909
|
},
|
|
18845
18910
|
groupId: params.music.id,
|
|
18846
18911
|
hasBgm: 1,
|
|
@@ -19017,7 +19082,7 @@ var __webpack_exports__ = {};
|
|
|
19017
19082
|
const resultMsg = publishResult.data?.baseResp?.errmsg ?? publishResult.errMsg;
|
|
19018
19083
|
if (0 === resultCode) {
|
|
19019
19084
|
task.logger.info("[shipinhaoPublish] 发布成功");
|
|
19020
|
-
const publishId = uploadedImages[0]?.thumbUrl
|
|
19085
|
+
const publishId = extractEncFileKey(uploadedImages[0]?.thumbUrl);
|
|
19021
19086
|
await updateTaskState?.({
|
|
19022
19087
|
state: share_namespaceObject.TaskState.SUCCESS,
|
|
19023
19088
|
result: {
|
|
@@ -19912,8 +19977,7 @@ var __webpack_exports__ = {};
|
|
|
19912
19977
|
const partTimeout = tuning?.partTimeout ?? DEFAULT_TUNING.partTimeout;
|
|
19913
19978
|
const partRetries = tuning?.partRetries ?? DEFAULT_TUNING.partRetries;
|
|
19914
19979
|
const completeTimeout = tuning?.completeTimeout ?? DEFAULT_TUNING.completeTimeout;
|
|
19915
|
-
logger?.info(
|
|
19916
|
-
logger?.info(`上传超时策略: 单片 ${partTimeout / 1000}s(重试 ${partRetries} 次)、合并 ${completeTimeout / 1000}s`);
|
|
19980
|
+
logger?.info(`[shipinhaoPublishVideo] 开始上传: ${fileName} (${fileSize} B, filetype=${fileType})`);
|
|
19917
19981
|
const fileMd5 = await computeFileMd5(filePath);
|
|
19918
19982
|
const taskId = generateTaskId(fileName, fileSize, fileMd5);
|
|
19919
19983
|
const baseUrl = "https://finderassistancea.video.qq.com";
|
|
@@ -19924,7 +19988,7 @@ var __webpack_exports__ = {};
|
|
|
19924
19988
|
const chunkCount = Math.ceil(fileSize / CHUNK_SIZE);
|
|
19925
19989
|
const blockPartLength = [];
|
|
19926
19990
|
for(let i = 0; i < chunkCount; i++)blockPartLength.push(Math.min((i + 1) * CHUNK_SIZE, fileSize));
|
|
19927
|
-
logger?.info(
|
|
19991
|
+
logger?.info(`[shipinhaoPublishVideo] 视频分片: ${chunkCount} 片`);
|
|
19928
19992
|
const applyRes = await http.api({
|
|
19929
19993
|
method: "PUT",
|
|
19930
19994
|
url: `${baseUrl}/applyuploaddfs`,
|
|
@@ -19945,7 +20009,6 @@ var __webpack_exports__ = {};
|
|
|
19945
20009
|
let uploadId = applyRes.UploadID;
|
|
19946
20010
|
const uploadedParts = new Set();
|
|
19947
20011
|
if (applyRes.ListPartsResult) {
|
|
19948
|
-
logger?.info("检测到已上传分片,执行续传");
|
|
19949
20012
|
const parts = Array.isArray(applyRes.ListPartsResult.Part) ? applyRes.ListPartsResult.Part : applyRes.ListPartsResult.Part ? [
|
|
19950
20013
|
applyRes.ListPartsResult.Part
|
|
19951
20014
|
] : [];
|
|
@@ -19981,7 +20044,6 @@ var __webpack_exports__ = {};
|
|
|
19981
20044
|
PartNumber: partNumber,
|
|
19982
20045
|
ETag: existing.ETag
|
|
19983
20046
|
});
|
|
19984
|
-
logger?.info(`分片 ${partNumber}/${chunkCount} 已存在,跳过`);
|
|
19985
20047
|
continue;
|
|
19986
20048
|
}
|
|
19987
20049
|
}
|
|
@@ -20006,18 +20068,15 @@ var __webpack_exports__ = {};
|
|
|
20006
20068
|
retries: partRetries,
|
|
20007
20069
|
retryDelay: 2000
|
|
20008
20070
|
});
|
|
20009
|
-
|
|
20010
|
-
const throughput = Math.round(chunkSize / (partElapsed / 1000));
|
|
20071
|
+
Date.now();
|
|
20011
20072
|
partInfo.push({
|
|
20012
20073
|
PartNumber: partNumber,
|
|
20013
20074
|
ETag: `"${chunkMd5}"`
|
|
20014
20075
|
});
|
|
20015
|
-
logger?.info(`分片 ${partNumber}/${chunkCount} 完成 (${chunkSize} B, ${partElapsed}ms, ${Math.round(throughput / 1024)}KB/s)`);
|
|
20016
20076
|
}
|
|
20017
20077
|
} finally{
|
|
20018
20078
|
external_node_fs_default().closeSync(fd);
|
|
20019
20079
|
}
|
|
20020
|
-
logger?.info("合并分片...");
|
|
20021
20080
|
const completeRes = await http.api({
|
|
20022
20081
|
method: "POST",
|
|
20023
20082
|
url: `${baseUrl}/completepartuploaddfs?UploadID=${encodeURIComponent(uploadId)}`,
|
|
@@ -20035,7 +20094,7 @@ var __webpack_exports__ = {};
|
|
|
20035
20094
|
retryDelay: 3000
|
|
20036
20095
|
});
|
|
20037
20096
|
if (!completeRes.DownloadURL) throw new Error("合并分片失败: " + JSON.stringify(completeRes));
|
|
20038
|
-
logger?.info(
|
|
20097
|
+
logger?.info(`[shipinhaoPublishVideo] ${fileName} 上传成功`);
|
|
20039
20098
|
return {
|
|
20040
20099
|
downloadUrl: completeRes.DownloadURL,
|
|
20041
20100
|
md5: fileMd5,
|
|
@@ -20353,6 +20412,7 @@ var __webpack_exports__ = {};
|
|
|
20353
20412
|
"avc3"
|
|
20354
20413
|
];
|
|
20355
20414
|
const MIN_TITLE_LENGTH = 6;
|
|
20415
|
+
const MAX_TITLE_LENGTH = 16;
|
|
20356
20416
|
function formatFileSize(bytes) {
|
|
20357
20417
|
if (bytes < 1048576) return `${(bytes / 1024).toFixed(2)} KB`;
|
|
20358
20418
|
if (bytes < 1073741824) return `${(bytes / 1024 / 1024).toFixed(2)} MB`;
|
|
@@ -20379,10 +20439,11 @@ var __webpack_exports__ = {};
|
|
|
20379
20439
|
function validateShipinhaoTitle(title) {
|
|
20380
20440
|
if (void 0 === title) return null;
|
|
20381
20441
|
const trimmed = title.trim();
|
|
20442
|
+
if ("" === trimmed) return null;
|
|
20382
20443
|
const length = [
|
|
20383
20444
|
...trimmed
|
|
20384
20445
|
].length;
|
|
20385
|
-
if (length < MIN_TITLE_LENGTH) return
|
|
20446
|
+
if (length < MIN_TITLE_LENGTH || length > MAX_TITLE_LENGTH) return `视频号标题需要在 ${MIN_TITLE_LENGTH}-${MAX_TITLE_LENGTH} 个字符之间,当前 ${length} 个字符,请调整后重试。`;
|
|
20386
20447
|
return null;
|
|
20387
20448
|
}
|
|
20388
20449
|
const POST_CREATE_PAGE_URL = "https://channels.weixin.qq.com/micro/content/post/create";
|
|
@@ -20427,7 +20488,6 @@ var __webpack_exports__ = {};
|
|
|
20427
20488
|
};
|
|
20428
20489
|
}
|
|
20429
20490
|
async function getTraceKey(auth, client, http, logger) {
|
|
20430
|
-
logger.info("[getTraceKey] 开始获取 traceKey...");
|
|
20431
20491
|
const res = await http.api({
|
|
20432
20492
|
method: "POST",
|
|
20433
20493
|
url: `${MICRO_CONTENT_BASE}/post/get-finder-post-trace-key`,
|
|
@@ -20442,11 +20502,9 @@ var __webpack_exports__ = {};
|
|
|
20442
20502
|
logger.error("[getTraceKey] 获取失败:", JSON.stringify(res));
|
|
20443
20503
|
throw new Error(`获取 traceKey 失败: ${JSON.stringify(res)}`);
|
|
20444
20504
|
}
|
|
20445
|
-
logger.info(`[getTraceKey] 获取成功: ${res.data.traceKey}`);
|
|
20446
20505
|
return res.data.traceKey;
|
|
20447
20506
|
}
|
|
20448
20507
|
async function getObjectTagKey(auth, client, http, logger) {
|
|
20449
|
-
logger.info("[getObjectTagKey] 获取内容声明 tagKey...");
|
|
20450
20508
|
try {
|
|
20451
20509
|
const res = await http.api({
|
|
20452
20510
|
method: "POST",
|
|
@@ -20462,7 +20520,6 @@ var __webpack_exports__ = {};
|
|
|
20462
20520
|
logger.warn(`[getObjectTagKey] 未取到 tagKey: ${JSON.stringify(res)}`);
|
|
20463
20521
|
return null;
|
|
20464
20522
|
}
|
|
20465
|
-
logger.info(`[getObjectTagKey] tagKey: ${res.data.tagKey}`);
|
|
20466
20523
|
return res.data.tagKey;
|
|
20467
20524
|
} catch (error) {
|
|
20468
20525
|
logger.warn(`[getObjectTagKey] 获取 tagKey 异常: ${stringifyError(error)}`);
|
|
@@ -20471,7 +20528,6 @@ var __webpack_exports__ = {};
|
|
|
20471
20528
|
}
|
|
20472
20529
|
async function submitAndPollTranscode(opts) {
|
|
20473
20530
|
const { videoUrl, videoMeta, traceKey, uploadStartTime, uploadEndTime, finderUsername, client, http, logger } = opts;
|
|
20474
|
-
logger.info("[submitAndPollTranscode] 开始提交转码任务...");
|
|
20475
20531
|
const finderUrl = videoUrl.includes("wxapp.tc.qq.com") ? `https://finder.video.qq.com${videoUrl.split("qq.com")[1]}` : videoUrl;
|
|
20476
20532
|
logger.info(`[submitAndPollTranscode] 视频尺寸: ${videoMeta.width}x${videoMeta.height}, 时长: ${videoMeta.duration}s`);
|
|
20477
20533
|
const submitRes = await http.api({
|
|
@@ -20510,12 +20566,10 @@ var __webpack_exports__ = {};
|
|
|
20510
20566
|
throw new Error(`提交转码失败: ${JSON.stringify(submitRes)}`);
|
|
20511
20567
|
}
|
|
20512
20568
|
const { clipKey, draftId } = submitRes.data;
|
|
20513
|
-
logger.info(`[submitAndPollTranscode] 转码任务已提交,clipKey: ${clipKey}, draftId: ${draftId}`);
|
|
20514
20569
|
const pollInterval = 5000;
|
|
20515
20570
|
const pollBudget = Math.min(1800000, 300000 + 1000 * Math.ceil(1.5 * videoMeta.duration));
|
|
20516
20571
|
const maxPolls = Math.ceil(pollBudget / pollInterval);
|
|
20517
20572
|
let pollCount = 0;
|
|
20518
|
-
logger.info(`[submitAndPollTranscode] 开始轮询转码结果,最多 ${maxPolls} 次(${Math.round(pollBudget / 1000)}s),间隔 ${pollInterval / 1000}s`);
|
|
20519
20573
|
while(pollCount < maxPolls){
|
|
20520
20574
|
await sleep(pollInterval);
|
|
20521
20575
|
pollCount++;
|
|
@@ -20539,14 +20593,12 @@ var __webpack_exports__ = {};
|
|
|
20539
20593
|
throw new Error(`转码轮询失败 (poll ${pollCount}): ${JSON.stringify(pollRes)}`);
|
|
20540
20594
|
}
|
|
20541
20595
|
const { flag, url, width, height, duration, md5, fileSize } = pollRes.data || {};
|
|
20542
|
-
logger.info(`[submitAndPollTranscode] 轮询第 ${pollCount} 次,flag=${flag}`);
|
|
20543
20596
|
if (1 === flag) {
|
|
20544
20597
|
if (!url || !width || !height || !duration || !md5 || !fileSize) {
|
|
20545
20598
|
logger.error("[submitAndPollTranscode] 转码完成但返回数据不完整:", JSON.stringify(pollRes.data));
|
|
20546
20599
|
throw new Error(`转码完成但返回数据不完整: ${JSON.stringify(pollRes.data)}`);
|
|
20547
20600
|
}
|
|
20548
20601
|
logger.info(`[submitAndPollTranscode] 转码完成! 用时: ${pollCount * pollInterval / 1000}s`);
|
|
20549
|
-
logger.info(`[submitAndPollTranscode] 视频信息: ${width}x${height}, 时长: ${duration}s, 大小: ${fileSize}`);
|
|
20550
20602
|
return {
|
|
20551
20603
|
clipKey,
|
|
20552
20604
|
url,
|
|
@@ -20557,7 +20609,7 @@ var __webpack_exports__ = {};
|
|
|
20557
20609
|
fileSize
|
|
20558
20610
|
};
|
|
20559
20611
|
}
|
|
20560
|
-
if (2 === flag)
|
|
20612
|
+
if (2 === flag) ;
|
|
20561
20613
|
else {
|
|
20562
20614
|
logger.error(`[submitAndPollTranscode] 转码失败,未知 flag=${flag}:`, JSON.stringify(pollRes.data));
|
|
20563
20615
|
throw new Error(`转码失败,未知 flag=${flag}: ${JSON.stringify(pollRes.data)}`);
|
|
@@ -20568,16 +20620,11 @@ var __webpack_exports__ = {};
|
|
|
20568
20620
|
}
|
|
20569
20621
|
async function publishVideo(opts) {
|
|
20570
20622
|
const { params, auth, client, clipResult, videoUpload, coverUpload, verticalCoverUpload, videoMeta, traceKey, tagKey, uploadStartTime, uploadEndTime, proxyHttp, logger } = opts;
|
|
20571
|
-
logger.info("[publishVideo] 开始构建发布请求...");
|
|
20572
20623
|
const toFinderUrl = (url)=>url.includes("wxapp.tc.qq.com") ? `https://finder.video.qq.com${url.split("qq.com")[1]}` : url;
|
|
20573
20624
|
const thumbFinderUrl = toFinderUrl(coverUpload.downloadUrl);
|
|
20574
20625
|
const coverFinderUrl = toFinderUrl(verticalCoverUpload.downloadUrl);
|
|
20575
20626
|
const md5sumUuid = external_node_crypto_default().randomUUID();
|
|
20576
20627
|
const description = params.description;
|
|
20577
|
-
logger.info("[publishVideo] 发布参数:");
|
|
20578
|
-
logger.info(` - 短标题: ${params.title || "(无)"}`);
|
|
20579
|
-
logger.info(` - 描述: ${description.substring(0, 50)}${description.length > 50 ? "..." : ""}`);
|
|
20580
|
-
logger.info(` - 定时发布: ${params.scheduledTime ? new Date(1000 * params.scheduledTime).toLocaleString() : "立即发布"}`);
|
|
20581
20628
|
const objectDesc = {
|
|
20582
20629
|
mpTitle: "",
|
|
20583
20630
|
description,
|
|
@@ -20651,7 +20698,6 @@ var __webpack_exports__ = {};
|
|
|
20651
20698
|
};
|
|
20652
20699
|
if (params.scheduledTime) publishData.effectiveTime = params.scheduledTime;
|
|
20653
20700
|
if (params.tagInfo && tagKey) publishData.tagInfo = buildTagInfo(params.tagInfo, tagKey);
|
|
20654
|
-
logger.info("[publishVideo] 开始发布视频,全部参数:" + JSON.stringify(publishData));
|
|
20655
20701
|
const publishRes = await proxyHttp.api({
|
|
20656
20702
|
method: "POST",
|
|
20657
20703
|
url: `${MICRO_CONTENT_BASE}/post/post_create`,
|
|
@@ -20659,7 +20705,7 @@ var __webpack_exports__ = {};
|
|
|
20659
20705
|
data: publishData,
|
|
20660
20706
|
defaultErrorMsg: "发布视频失败"
|
|
20661
20707
|
});
|
|
20662
|
-
logger.info(`[publishVideo]
|
|
20708
|
+
logger.info(`[publishVideo] 发布结果: errCode=${publishRes.errCode}, baseResp.errcode=${publishRes.data?.baseResp?.errcode}`);
|
|
20663
20709
|
return publishRes;
|
|
20664
20710
|
}
|
|
20665
20711
|
function sleep(ms) {
|
|
@@ -20673,11 +20719,9 @@ var __webpack_exports__ = {};
|
|
|
20673
20719
|
return savePath;
|
|
20674
20720
|
}
|
|
20675
20721
|
const shipinhaoPublishVideo_mock_mockAction = async (task, params)=>{
|
|
20676
|
-
task.logger.info("[shipinhaoPublishVideo] 开始执行视频号视频发布 - Mock API 方式");
|
|
20677
20722
|
const updateTaskState = task.taskStageStore?.update?.bind(task.taskStageStore, task.taskId || "");
|
|
20678
20723
|
let currentStep = "初始化";
|
|
20679
20724
|
try {
|
|
20680
|
-
task.logger.info(`[shipinhaoPublishVideo] 发布方式: ${params.scheduledTime ? `定时 ${new Date(1000 * params.scheduledTime).toLocaleString()}` : "立即发布"}`);
|
|
20681
20725
|
currentStep = "解析认证信息";
|
|
20682
20726
|
const cookieString = params.cookies.map((c)=>`${c.name}=${c.value}`).join("; ");
|
|
20683
20727
|
const http = new Http({
|
|
@@ -20689,11 +20733,8 @@ var __webpack_exports__ = {};
|
|
|
20689
20733
|
if (!params.videoPath) return (0, share_namespaceObject.response)(414, "视频文件路径不能为空", "");
|
|
20690
20734
|
if (!params.coverPath) return (0, share_namespaceObject.response)(414, "横屏封面图片路径不能为空", "");
|
|
20691
20735
|
currentStep = "获取上传认证";
|
|
20692
|
-
task.logger.info("[shipinhaoPublishVideo] 获取上传认证...");
|
|
20693
20736
|
const auth = await getShipinhaoUploadAuth(cookieString, http);
|
|
20694
20737
|
const client = resolveClientContext(params, auth.uin);
|
|
20695
|
-
if (!client.aId) task.logger.warn("[shipinhaoPublishVideo] extraParam.aId 缺失,query 将不带 _aid");
|
|
20696
|
-
if (!client.fingerPrintDeviceId) task.logger.warn("[shipinhaoPublishVideo] extraParam.fingerPrintDeviceId 缺失,请求将不带 finger-print-device-id");
|
|
20697
20738
|
const publishHeaders = buildPublishHeaders(cookieString, client);
|
|
20698
20739
|
const microHttp = new Http({
|
|
20699
20740
|
headers: publishHeaders
|
|
@@ -20709,25 +20750,20 @@ var __webpack_exports__ = {};
|
|
|
20709
20750
|
];
|
|
20710
20751
|
const proxyHttp = new Http(...args);
|
|
20711
20752
|
currentStep = "组装视频元数据";
|
|
20712
|
-
task.logger.info("[shipinhaoPublishVideo] 组装视频元数据...");
|
|
20713
20753
|
const videoMeta = buildVideoMetaFromParams(params.videoPath, params.videoMetadata);
|
|
20714
20754
|
task.logger.info(`[shipinhaoPublishVideo] 视频: ${videoMeta.width}×${videoMeta.height}, ${videoMeta.duration.toFixed(2)}s, ${(videoMeta.fileSize / 1024 / 1024).toFixed(2)}MB, codec=${videoMeta.codec || "unknown"}`);
|
|
20715
|
-
if (!videoMeta.codec) task.logger.warn("[shipinhaoPublishVideo] 未能读取视频编码格式,跳过 H.264 预检,交由服务端判断");
|
|
20716
20755
|
currentStep = "校验视频限制";
|
|
20717
20756
|
const validationError = validateShipinhaoVideo(params.videoPath, videoMeta);
|
|
20718
20757
|
if (validationError) {
|
|
20719
|
-
task.logger.error(`[shipinhaoPublishVideo] 视频校验未通过: ${validationError}`);
|
|
20720
20758
|
await updateTaskState?.({
|
|
20721
20759
|
state: share_namespaceObject.TaskState.FAILED,
|
|
20722
20760
|
error: validationError
|
|
20723
20761
|
});
|
|
20724
20762
|
return (0, share_namespaceObject.response)(414, validationError, "");
|
|
20725
20763
|
}
|
|
20726
|
-
task.logger.info("[shipinhaoPublishVideo] 视频校验通过");
|
|
20727
20764
|
currentStep = "校验标题";
|
|
20728
20765
|
const titleError = validateShipinhaoTitle(params.title);
|
|
20729
20766
|
if (titleError) {
|
|
20730
|
-
task.logger.error(`[shipinhaoPublishVideo] 标题校验未通过: ${titleError}`);
|
|
20731
20767
|
await updateTaskState?.({
|
|
20732
20768
|
state: share_namespaceObject.TaskState.FAILED,
|
|
20733
20769
|
error: titleError
|
|
@@ -20735,7 +20771,6 @@ var __webpack_exports__ = {};
|
|
|
20735
20771
|
return (0, share_namespaceObject.response)(414, titleError, "");
|
|
20736
20772
|
}
|
|
20737
20773
|
currentStep = "获取 traceKey";
|
|
20738
|
-
task.logger.info("[shipinhaoPublishVideo] 获取 traceKey...");
|
|
20739
20774
|
const traceKey = await getTraceKey(auth, client, microHttp, task.logger);
|
|
20740
20775
|
let tagKey = null;
|
|
20741
20776
|
if (params.tagInfo) {
|
|
@@ -20743,11 +20778,7 @@ var __webpack_exports__ = {};
|
|
|
20743
20778
|
tagKey = await getObjectTagKey(auth, client, microHttp, task.logger);
|
|
20744
20779
|
}
|
|
20745
20780
|
const uploadStartTime = Math.floor(Date.now() / 1000);
|
|
20746
|
-
task.logger.info(`[shipinhaoPublishVideo] 上传开始时间: ${uploadStartTime}`);
|
|
20747
20781
|
currentStep = "上传视频";
|
|
20748
|
-
task.logger.info("[shipinhaoPublishVideo] 上传视频...");
|
|
20749
|
-
task.logger.info(`[shipinhaoPublishVideo] 视频路径: ${params.videoPath}`);
|
|
20750
|
-
task.logger.info(`[shipinhaoPublishVideo] 视频文件类型: ${auth.videoFileType}`);
|
|
20751
20782
|
const videoUpload = await uploader_uploadFile({
|
|
20752
20783
|
filePath: params.videoPath,
|
|
20753
20784
|
fileType: auth.videoFileType,
|
|
@@ -20756,12 +20787,10 @@ var __webpack_exports__ = {};
|
|
|
20756
20787
|
http,
|
|
20757
20788
|
logger: task.logger
|
|
20758
20789
|
});
|
|
20759
|
-
task.logger.info("[shipinhaoPublishVideo] 视频上传完成");
|
|
20760
20790
|
const uploadEndTime = Math.floor(Date.now() / 1000);
|
|
20761
|
-
task.logger.info(`[shipinhaoPublishVideo]
|
|
20791
|
+
task.logger.info(`[shipinhaoPublishVideo] 耗时: ${uploadEndTime - uploadStartTime}s`);
|
|
20762
20792
|
currentStep = "上传横屏封面";
|
|
20763
20793
|
const localCoverPath = await resolveLocalCoverPath(params.coverPath, "横屏封面", task.getTmpPath(), task.logger);
|
|
20764
|
-
task.logger.info("[shipinhaoPublishVideo] 上传横屏封面...");
|
|
20765
20794
|
const coverUpload = await uploader_uploadFile({
|
|
20766
20795
|
filePath: localCoverPath,
|
|
20767
20796
|
fileType: auth.pictureFileType,
|
|
@@ -20770,12 +20799,10 @@ var __webpack_exports__ = {};
|
|
|
20770
20799
|
http,
|
|
20771
20800
|
logger: task.logger
|
|
20772
20801
|
});
|
|
20773
|
-
task.logger.info("[shipinhaoPublishVideo] 横屏封面上传完成");
|
|
20774
20802
|
let verticalCoverUpload = coverUpload;
|
|
20775
20803
|
if (params.verticalCoverPath) {
|
|
20776
20804
|
currentStep = "上传竖屏封面";
|
|
20777
20805
|
const localVerticalPath = await resolveLocalCoverPath(params.verticalCoverPath, "竖屏封面", task.getTmpPath(), task.logger);
|
|
20778
|
-
task.logger.info("[shipinhaoPublishVideo] 上传竖屏封面");
|
|
20779
20806
|
verticalCoverUpload = await uploader_uploadFile({
|
|
20780
20807
|
filePath: localVerticalPath,
|
|
20781
20808
|
fileType: auth.pictureFileType,
|
|
@@ -20784,10 +20811,8 @@ var __webpack_exports__ = {};
|
|
|
20784
20811
|
http,
|
|
20785
20812
|
logger: task.logger
|
|
20786
20813
|
});
|
|
20787
|
-
|
|
20788
|
-
} else task.logger.info("[shipinhaoPublishVideo] 未传竖屏封面,复用横屏封面");
|
|
20814
|
+
}
|
|
20789
20815
|
currentStep = "提交转码";
|
|
20790
|
-
task.logger.info("[shipinhaoPublishVideo] 提交转码...");
|
|
20791
20816
|
const clipResult = await submitAndPollTranscode({
|
|
20792
20817
|
videoUrl: videoUpload.downloadUrl,
|
|
20793
20818
|
videoMeta,
|
|
@@ -20800,8 +20825,6 @@ var __webpack_exports__ = {};
|
|
|
20800
20825
|
logger: task.logger
|
|
20801
20826
|
});
|
|
20802
20827
|
currentStep = "发布视频";
|
|
20803
|
-
task.logger.info("[shipinhaoPublishVideo] 发布视频...");
|
|
20804
|
-
task.logger.info(`[shipinhaoPublishVideo] clipKey: ${clipResult.clipKey}`);
|
|
20805
20828
|
let publishResult;
|
|
20806
20829
|
try {
|
|
20807
20830
|
publishResult = await publishVideo({
|
|
@@ -20826,7 +20849,6 @@ var __webpack_exports__ = {};
|
|
|
20826
20849
|
const classified = classifyPublishError(handledError);
|
|
20827
20850
|
if (classified) {
|
|
20828
20851
|
const message = `${classified.userMessage}${task.debug ? ` ${http.proxyInfo}` : ""}`;
|
|
20829
|
-
task.logger.error(`[shipinhaoPublishVideo] ${classified.category},直接返回: ${handledError.message} (code=${handledError.code})`, stringifyError(handledError));
|
|
20830
20852
|
await updateTaskState?.({
|
|
20831
20853
|
state: share_namespaceObject.TaskState.FAILED,
|
|
20832
20854
|
error: message
|
|
@@ -20843,11 +20865,8 @@ var __webpack_exports__ = {};
|
|
|
20843
20865
|
const resultCode = publishResult.data?.baseResp?.errcode ?? publishResult.errCode;
|
|
20844
20866
|
const resultMsg = publishResult.data?.baseResp?.errmsg ?? (0 === resultCode ? "发布成功" : `发布失败(errCode=${resultCode})`);
|
|
20845
20867
|
if (0 === resultCode) {
|
|
20846
|
-
|
|
20847
|
-
task.logger.
|
|
20848
|
-
task.logger.info(`[shipinhaoPublishVideo] 视频URL: ${clipResult.url}`);
|
|
20849
|
-
task.logger.info(`[shipinhaoPublishVideo] 横屏封面URL: ${coverUpload.downloadUrl}`);
|
|
20850
|
-
task.logger.info(`[shipinhaoPublishVideo] 竖屏封面URL: ${verticalCoverUpload.downloadUrl}`);
|
|
20868
|
+
const publishId = extractEncFileKey(verticalCoverUpload.downloadUrl);
|
|
20869
|
+
if (!publishId) task.logger.error(`[shipinhaoPublishVideo] 封面 DownloadURL 中未解析到 encfilekey,关联 id 为空: ${verticalCoverUpload.downloadUrl}`);
|
|
20851
20870
|
await updateTaskState?.({
|
|
20852
20871
|
state: share_namespaceObject.TaskState.SUCCESS,
|
|
20853
20872
|
result: {
|
|
@@ -20877,8 +20896,7 @@ var __webpack_exports__ = {};
|
|
|
20877
20896
|
},
|
|
20878
20897
|
platform: "shipinhao"
|
|
20879
20898
|
});
|
|
20880
|
-
|
|
20881
|
-
return (0, share_namespaceObject.response)(0, "发布成功", clipResult.clipKey);
|
|
20899
|
+
return (0, share_namespaceObject.response)(0, "发布成功", publishId);
|
|
20882
20900
|
}
|
|
20883
20901
|
let errorMessage = resultMsg;
|
|
20884
20902
|
if (-11224 === resultCode) errorMessage = "视频号管理员完成实名且绑定手机号后才可以发表";
|
|
@@ -20890,18 +20908,16 @@ var __webpack_exports__ = {};
|
|
|
20890
20908
|
state: share_namespaceObject.TaskState.FAILED,
|
|
20891
20909
|
error: errorMessage
|
|
20892
20910
|
});
|
|
20893
|
-
return (0, share_namespaceObject.response)(
|
|
20911
|
+
return (0, share_namespaceObject.response)(414, errorMessage, "");
|
|
20894
20912
|
} catch (error) {
|
|
20895
20913
|
const handledError = Http.handleApiError(error);
|
|
20896
20914
|
const errorMsg = handledError.message || "发布失败,请稍后重试";
|
|
20897
|
-
const errorCode = handledError.code || 414;
|
|
20898
20915
|
task.logger.error(`[shipinhaoPublishVideo] 发布流程异常 [${currentStep}]: ${errorMsg}`, stringifyError(error), handledError.extra);
|
|
20899
|
-
task.logger.error(`[shipinhaoPublishVideo] 错误码: ${errorCode}, 当前步骤: ${currentStep}`);
|
|
20900
20916
|
await updateTaskState?.({
|
|
20901
20917
|
state: share_namespaceObject.TaskState.FAILED,
|
|
20902
20918
|
error: errorMsg
|
|
20903
20919
|
});
|
|
20904
|
-
return (0, share_namespaceObject.response)(
|
|
20920
|
+
return (0, share_namespaceObject.response)(414, errorMsg, "");
|
|
20905
20921
|
}
|
|
20906
20922
|
};
|
|
20907
20923
|
const shipinhaoPublishVideo_rpa_rpaAction = async (task, params)=>{
|
|
@@ -27473,4 +27489,4 @@ if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_targe
|
|
|
27473
27489
|
});
|
|
27474
27490
|
|
|
27475
27491
|
//# sourceMappingURL=index.js.map
|
|
27476
|
-
//# debugId=
|
|
27492
|
+
//# debugId=56541751-7175-5826-bba1-27edba330f54
|