@iflyrpa/actions 4.1.0-beta.5 → 4.1.0-beta.6
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/shipinhaoPublishVideo/index.d.ts +45 -1
- package/dist/actions/shipinhaoPublishVideo/payload.d.ts +70 -0
- package/dist/actions/shipinhaoPublishVideo/uploader.d.ts +19 -0
- package/dist/actions/shipinhaoPublishVideo/videoMeta.d.ts +43 -5
- package/dist/bundle.js +799 -234
- package/dist/bundle.js.map +1 -1
- package/dist/index.js +797 -232
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +797 -232
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
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]="ed6f9fc8-db66-5df4-be7c-d5593224a8b2")}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.6"}');
|
|
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");
|
|
@@ -27492,7 +27492,7 @@ var __webpack_exports__ = {};
|
|
|
27492
27492
|
async api(config, options) {
|
|
27493
27493
|
const retries = options?.retries ?? 0;
|
|
27494
27494
|
const retryDelay = options?.retryDelay ?? 500;
|
|
27495
|
-
const reqTimeout = options?.timeout ??
|
|
27495
|
+
const reqTimeout = options?.timeout ?? 60000;
|
|
27496
27496
|
const externalSignal = options?.signal;
|
|
27497
27497
|
let agent;
|
|
27498
27498
|
const sessionRt = async (Rtimes)=>{
|
|
@@ -32227,6 +32227,14 @@ var __webpack_exports__ = {};
|
|
|
32227
32227
|
};
|
|
32228
32228
|
return new schemas_ZodObject(def);
|
|
32229
32229
|
}
|
|
32230
|
+
function looseObject(shape, params) {
|
|
32231
|
+
return new schemas_ZodObject({
|
|
32232
|
+
type: "object",
|
|
32233
|
+
shape,
|
|
32234
|
+
catchall: schemas_unknown(),
|
|
32235
|
+
...util_normalizeParams(params)
|
|
32236
|
+
});
|
|
32237
|
+
}
|
|
32230
32238
|
const schemas_ZodUnion = /*@__PURE__*/ core_$constructor("ZodUnion", (inst, def)=>{
|
|
32231
32239
|
schemas_$ZodUnion.init(inst, def);
|
|
32232
32240
|
schemas_ZodType.init(inst, def);
|
|
@@ -44872,13 +44880,111 @@ var __webpack_exports__ = {};
|
|
|
44872
44880
|
pictureFileType
|
|
44873
44881
|
};
|
|
44874
44882
|
}
|
|
44883
|
+
const MENTION_TEXT_SUFFIX = "\u0020";
|
|
44884
|
+
const MENTION_XML_SUFFIX = "\u2005";
|
|
44885
|
+
function payload_buildDescription(params) {
|
|
44886
|
+
let description = params.description || "";
|
|
44887
|
+
for (const topic of params.topics || [])description += `#${topic}`;
|
|
44888
|
+
for (const user of params.mentionedUsers || [])description += `@${user.nickname}${MENTION_TEXT_SUFFIX}`;
|
|
44889
|
+
return description;
|
|
44890
|
+
}
|
|
44891
|
+
function buildMentionedUser(mentionedUsers) {
|
|
44892
|
+
return (mentionedUsers || []).map((user)=>({
|
|
44893
|
+
nickname: `${user.nickname}${MENTION_TEXT_SUFFIX}`
|
|
44894
|
+
}));
|
|
44895
|
+
}
|
|
44896
|
+
function payload_buildTopicXml(params) {
|
|
44897
|
+
const values = [];
|
|
44898
|
+
let atIndex = null;
|
|
44899
|
+
if (params.description) values.push(`<![CDATA[${params.description}]]>`);
|
|
44900
|
+
for (const topic of params.topics || [])values.push(`<topic><![CDATA[#${topic}#]]></topic>`);
|
|
44901
|
+
for (const user of params.mentionedUsers || []){
|
|
44902
|
+
if (null === atIndex) atIndex = values.length;
|
|
44903
|
+
values.push(`<![CDATA[@${user.nickname}${MENTION_XML_SUFFIX}]]>`);
|
|
44904
|
+
}
|
|
44905
|
+
let xml = "<finder>";
|
|
44906
|
+
xml += "<version>1</version>";
|
|
44907
|
+
xml += `<valuecount>${values.length}</valuecount>`;
|
|
44908
|
+
xml += `<style><at>${atIndex ?? ""}</at></style>`;
|
|
44909
|
+
values.forEach((value, index)=>{
|
|
44910
|
+
xml += `<value${index}>${value}</value${index}>`;
|
|
44911
|
+
});
|
|
44912
|
+
xml += "</finder>";
|
|
44913
|
+
return xml;
|
|
44914
|
+
}
|
|
44915
|
+
function payload_buildLocation(location) {
|
|
44916
|
+
if (!location) return {
|
|
44917
|
+
latitude: 0,
|
|
44918
|
+
longitude: 0,
|
|
44919
|
+
city: "",
|
|
44920
|
+
poiName: "",
|
|
44921
|
+
address: "",
|
|
44922
|
+
poiClassifyId: ""
|
|
44923
|
+
};
|
|
44924
|
+
return {
|
|
44925
|
+
latitude: location.latitude,
|
|
44926
|
+
longitude: location.longitude,
|
|
44927
|
+
city: location.city,
|
|
44928
|
+
poiName: location.poiName || "",
|
|
44929
|
+
address: location.address || "",
|
|
44930
|
+
poiClassifyId: location.poiClassifyId || ""
|
|
44931
|
+
};
|
|
44932
|
+
}
|
|
44933
|
+
function buildTopic(params) {
|
|
44934
|
+
const topic = {
|
|
44935
|
+
finderTopicInfo: payload_buildTopicXml(params)
|
|
44936
|
+
};
|
|
44937
|
+
if (params.collection) {
|
|
44938
|
+
topic.collectionId = params.collection.collectionId;
|
|
44939
|
+
topic.collectionName = params.collection.collectionName;
|
|
44940
|
+
}
|
|
44941
|
+
return topic;
|
|
44942
|
+
}
|
|
44943
|
+
function buildEvent(event) {
|
|
44944
|
+
if (!event) return {};
|
|
44945
|
+
return {
|
|
44946
|
+
eventTopicId: event.eventTopicId,
|
|
44947
|
+
eventName: event.eventName,
|
|
44948
|
+
eventCreatorNickname: event.eventCreatorNickname || ""
|
|
44949
|
+
};
|
|
44950
|
+
}
|
|
44951
|
+
function buildExtReading(link) {
|
|
44952
|
+
if (!link) return {
|
|
44953
|
+
link: "",
|
|
44954
|
+
title: "",
|
|
44955
|
+
urlType: 1
|
|
44956
|
+
};
|
|
44957
|
+
return {
|
|
44958
|
+
link: link.link.replace(/[\s\u200b]/g, ""),
|
|
44959
|
+
title: link.title,
|
|
44960
|
+
urlType: link.urlType ?? 1
|
|
44961
|
+
};
|
|
44962
|
+
}
|
|
44963
|
+
function buildTagInfo(tagInfo, tagKey) {
|
|
44964
|
+
return {
|
|
44965
|
+
...tagInfo,
|
|
44966
|
+
tagKey
|
|
44967
|
+
};
|
|
44968
|
+
}
|
|
44875
44969
|
const CHUNK_SIZE = 8388608;
|
|
44970
|
+
const UPLOAD_STAGE_TIMEOUT = 180000;
|
|
44971
|
+
const DEFAULT_TUNING = {
|
|
44972
|
+
metaTimeout: UPLOAD_STAGE_TIMEOUT,
|
|
44973
|
+
partTimeout: UPLOAD_STAGE_TIMEOUT,
|
|
44974
|
+
partRetries: 3,
|
|
44975
|
+
completeTimeout: UPLOAD_STAGE_TIMEOUT
|
|
44976
|
+
};
|
|
44876
44977
|
async function uploader_uploadFile(opts) {
|
|
44877
|
-
const { filePath, fileType, uin, authKey, http, logger } = opts;
|
|
44978
|
+
const { filePath, fileType, uin, authKey, http, logger, tuning } = opts;
|
|
44878
44979
|
const stat = external_node_fs_default().statSync(filePath);
|
|
44879
44980
|
const fileSize = stat.size;
|
|
44880
44981
|
const fileName = filePath.split(/[\\/]/).pop() || "file";
|
|
44982
|
+
const metaTimeout = tuning?.metaTimeout ?? DEFAULT_TUNING.metaTimeout;
|
|
44983
|
+
const partTimeout = tuning?.partTimeout ?? DEFAULT_TUNING.partTimeout;
|
|
44984
|
+
const partRetries = tuning?.partRetries ?? DEFAULT_TUNING.partRetries;
|
|
44985
|
+
const completeTimeout = tuning?.completeTimeout ?? DEFAULT_TUNING.completeTimeout;
|
|
44881
44986
|
logger?.info(`开始上传: ${fileName} (${fileSize} B, filetype=${fileType})`);
|
|
44987
|
+
logger?.info(`上传超时策略: 单片 ${partTimeout / 1000}s(重试 ${partRetries} 次)、合并 ${completeTimeout / 1000}s`);
|
|
44882
44988
|
const fileMd5 = await computeFileMd5(filePath);
|
|
44883
44989
|
const taskId = generateTaskId(fileName, fileSize, fileMd5);
|
|
44884
44990
|
const baseUrl = "https://finderassistancea.video.qq.com";
|
|
@@ -44901,6 +45007,10 @@ var __webpack_exports__ = {};
|
|
|
44901
45007
|
BlockSum: chunkCount,
|
|
44902
45008
|
BlockPartLength: blockPartLength
|
|
44903
45009
|
}
|
|
45010
|
+
}, {
|
|
45011
|
+
timeout: metaTimeout,
|
|
45012
|
+
retries: 2,
|
|
45013
|
+
retryDelay: 2000
|
|
44904
45014
|
});
|
|
44905
45015
|
if (!applyRes.UploadID && !applyRes.ListPartsResult) throw new Error("申请 UploadID 失败: " + JSON.stringify(applyRes));
|
|
44906
45016
|
let uploadId = applyRes.UploadID;
|
|
@@ -44922,6 +45032,10 @@ var __webpack_exports__ = {};
|
|
|
44922
45032
|
BlockSum: chunkCount,
|
|
44923
45033
|
BlockPartLength: blockPartLength
|
|
44924
45034
|
}
|
|
45035
|
+
}, {
|
|
45036
|
+
timeout: metaTimeout,
|
|
45037
|
+
retries: 2,
|
|
45038
|
+
retryDelay: 2000
|
|
44925
45039
|
});
|
|
44926
45040
|
uploadId = retryRes.UploadID;
|
|
44927
45041
|
if (!uploadId) throw new Error("续传获取 UploadID 失败");
|
|
@@ -44948,6 +45062,7 @@ var __webpack_exports__ = {};
|
|
|
44948
45062
|
const chunk = Buffer.alloc(chunkSize);
|
|
44949
45063
|
external_node_fs_default().readSync(fd, chunk, 0, chunkSize, start);
|
|
44950
45064
|
const chunkMd5 = external_node_crypto_default().createHash("md5").update(chunk).digest("hex");
|
|
45065
|
+
const partStart = Date.now();
|
|
44951
45066
|
await http.api({
|
|
44952
45067
|
method: "PUT",
|
|
44953
45068
|
url: `${baseUrl}/uploadpartdfs?PartNumber=${partNumber}&UploadID=${encodeURIComponent(uploadId)}`,
|
|
@@ -44957,12 +45072,18 @@ var __webpack_exports__ = {};
|
|
|
44957
45072
|
"Content-MD5": chunkMd5
|
|
44958
45073
|
},
|
|
44959
45074
|
data: chunk
|
|
45075
|
+
}, {
|
|
45076
|
+
timeout: partTimeout,
|
|
45077
|
+
retries: partRetries,
|
|
45078
|
+
retryDelay: 2000
|
|
44960
45079
|
});
|
|
45080
|
+
const partElapsed = Date.now() - partStart;
|
|
45081
|
+
const throughput = Math.round(chunkSize / (partElapsed / 1000));
|
|
44961
45082
|
partInfo.push({
|
|
44962
45083
|
PartNumber: partNumber,
|
|
44963
45084
|
ETag: `"${chunkMd5}"`
|
|
44964
45085
|
});
|
|
44965
|
-
logger?.info(`分片 ${partNumber}/${chunkCount} 完成 (${chunkSize} B)`);
|
|
45086
|
+
logger?.info(`分片 ${partNumber}/${chunkCount} 完成 (${chunkSize} B, ${partElapsed}ms, ${Math.round(throughput / 1024)}KB/s)`);
|
|
44966
45087
|
}
|
|
44967
45088
|
} finally{
|
|
44968
45089
|
external_node_fs_default().closeSync(fd);
|
|
@@ -44979,9 +45100,13 @@ var __webpack_exports__ = {};
|
|
|
44979
45100
|
TransFlag: "0_0",
|
|
44980
45101
|
PartInfo: partInfo
|
|
44981
45102
|
}
|
|
45103
|
+
}, {
|
|
45104
|
+
timeout: completeTimeout,
|
|
45105
|
+
retries: 1,
|
|
45106
|
+
retryDelay: 3000
|
|
44982
45107
|
});
|
|
44983
45108
|
if (!completeRes.DownloadURL) throw new Error("合并分片失败: " + JSON.stringify(completeRes));
|
|
44984
|
-
logger?.info(
|
|
45109
|
+
logger?.info("上传成功");
|
|
44985
45110
|
return {
|
|
44986
45111
|
downloadUrl: completeRes.DownloadURL,
|
|
44987
45112
|
md5: fileMd5,
|
|
@@ -45001,85 +45126,233 @@ var __webpack_exports__ = {};
|
|
|
45001
45126
|
const input = `${fileName}-${fileSize}-${fileMd5}`;
|
|
45002
45127
|
return external_node_crypto_default().createHash("md5").update(input).digest("hex").slice(0, 32);
|
|
45003
45128
|
}
|
|
45129
|
+
const MAX_METADATA_BOX_SIZE = 268435456;
|
|
45130
|
+
function readBoxHeader(fd, offset, limit) {
|
|
45131
|
+
if (offset + 8 > limit) return null;
|
|
45132
|
+
const head = Buffer.alloc(16);
|
|
45133
|
+
const read = external_node_fs_default().readSync(fd, head, 0, 16, offset);
|
|
45134
|
+
if (read < 8) return null;
|
|
45135
|
+
let size = head.readUInt32BE(0);
|
|
45136
|
+
const type = head.toString("latin1", 4, 8);
|
|
45137
|
+
let headerSize = 8;
|
|
45138
|
+
if (1 === size) {
|
|
45139
|
+
if (read < 16) return null;
|
|
45140
|
+
size = head.readUInt32BE(8) * 2 ** 32 + head.readUInt32BE(12);
|
|
45141
|
+
headerSize = 16;
|
|
45142
|
+
} else if (0 === size) size = limit - offset;
|
|
45143
|
+
if (size < headerSize || offset + size > limit) return null;
|
|
45144
|
+
return {
|
|
45145
|
+
type,
|
|
45146
|
+
size,
|
|
45147
|
+
headerSize
|
|
45148
|
+
};
|
|
45149
|
+
}
|
|
45004
45150
|
function parseVideoMeta(filePath) {
|
|
45005
|
-
let
|
|
45151
|
+
let fd;
|
|
45152
|
+
let fileSize;
|
|
45006
45153
|
try {
|
|
45007
|
-
|
|
45154
|
+
fd = external_node_fs_default().openSync(filePath, "r");
|
|
45008
45155
|
} catch {
|
|
45009
45156
|
return null;
|
|
45010
45157
|
}
|
|
45011
|
-
|
|
45012
|
-
|
|
45013
|
-
|
|
45014
|
-
|
|
45015
|
-
|
|
45016
|
-
|
|
45017
|
-
|
|
45018
|
-
|
|
45019
|
-
|
|
45020
|
-
|
|
45021
|
-
|
|
45022
|
-
|
|
45023
|
-
|
|
45024
|
-
|
|
45025
|
-
|
|
45026
|
-
|
|
45027
|
-
|
|
45028
|
-
|
|
45029
|
-
|
|
45030
|
-
|
|
45031
|
-
|
|
45032
|
-
|
|
45033
|
-
|
|
45034
|
-
|
|
45035
|
-
|
|
45158
|
+
try {
|
|
45159
|
+
fileSize = external_node_fs_default().fstatSync(fd).size;
|
|
45160
|
+
const state = {
|
|
45161
|
+
movie: null,
|
|
45162
|
+
tracks: [],
|
|
45163
|
+
trexDefaults: new Map(),
|
|
45164
|
+
fragmentDurations: new Map(),
|
|
45165
|
+
trafTrackId: 0,
|
|
45166
|
+
trafDefaultSampleDuration: 0
|
|
45167
|
+
};
|
|
45168
|
+
let offset = 0;
|
|
45169
|
+
while(offset + 8 <= fileSize){
|
|
45170
|
+
const header = readBoxHeader(fd, offset, fileSize);
|
|
45171
|
+
if (!header) break;
|
|
45172
|
+
if ("moov" === header.type || "moof" === header.type) {
|
|
45173
|
+
const bodyLength = header.size - header.headerSize;
|
|
45174
|
+
if (bodyLength > 0 && bodyLength <= MAX_METADATA_BOX_SIZE) {
|
|
45175
|
+
const body = Buffer.alloc(bodyLength);
|
|
45176
|
+
const read = external_node_fs_default().readSync(fd, body, 0, bodyLength, offset + header.headerSize);
|
|
45177
|
+
state.trafTrackId = 0;
|
|
45178
|
+
state.trafDefaultSampleDuration = 0;
|
|
45179
|
+
walkBoxes(body.subarray(0, read), 0, read, state);
|
|
45180
|
+
}
|
|
45181
|
+
}
|
|
45182
|
+
offset += header.size;
|
|
45183
|
+
}
|
|
45184
|
+
const { movie, tracks } = state;
|
|
45185
|
+
const video = tracks.find((t)=>"vide" === t.handler) || tracks.find((t)=>t.width > 0 && t.height > 0);
|
|
45186
|
+
if (!video) return null;
|
|
45187
|
+
let { width, height } = video;
|
|
45188
|
+
if (90 === video.rotation || 270 === video.rotation) [width, height] = [
|
|
45189
|
+
height,
|
|
45190
|
+
width
|
|
45191
|
+
];
|
|
45192
|
+
return {
|
|
45193
|
+
width: Math.round(width),
|
|
45194
|
+
height: Math.round(height),
|
|
45195
|
+
duration: resolveDuration(movie, video, state.fragmentDurations),
|
|
45196
|
+
rotation: video.rotation,
|
|
45197
|
+
fileSize,
|
|
45198
|
+
codec: video.codec
|
|
45199
|
+
};
|
|
45200
|
+
} catch {
|
|
45201
|
+
return null;
|
|
45202
|
+
} finally{
|
|
45203
|
+
try {
|
|
45204
|
+
external_node_fs_default().closeSync(fd);
|
|
45205
|
+
} catch {}
|
|
45206
|
+
}
|
|
45207
|
+
}
|
|
45208
|
+
function walkBoxes(buf, start, end, state) {
|
|
45209
|
+
let off = start;
|
|
45210
|
+
while(off + 8 <= end){
|
|
45211
|
+
let size = buf.readUInt32BE(off);
|
|
45212
|
+
const type = buf.toString("latin1", off + 4, off + 8);
|
|
45213
|
+
let headerSize = 8;
|
|
45214
|
+
if (1 === size) {
|
|
45215
|
+
if (off + 16 > end) break;
|
|
45216
|
+
const hi = buf.readUInt32BE(off + 8);
|
|
45217
|
+
const lo = buf.readUInt32BE(off + 12);
|
|
45218
|
+
size = hi * 2 ** 32 + lo;
|
|
45219
|
+
headerSize = 16;
|
|
45220
|
+
} else if (0 === size) size = end - off;
|
|
45221
|
+
if (size < headerSize || off + size > end) break;
|
|
45222
|
+
const bodyStart = off + headerSize;
|
|
45223
|
+
const bodyEnd = off + size;
|
|
45224
|
+
switch(type){
|
|
45225
|
+
case "trak":
|
|
45226
|
+
case "mdia":
|
|
45227
|
+
case "minf":
|
|
45228
|
+
case "stbl":
|
|
45229
|
+
case "mvex":
|
|
45230
|
+
case "traf":
|
|
45231
|
+
walkBoxes(buf, bodyStart, bodyEnd, state);
|
|
45232
|
+
break;
|
|
45233
|
+
case "mvhd":
|
|
45234
|
+
state.movie = parseMvhd(buf, bodyStart, bodyEnd);
|
|
45235
|
+
break;
|
|
45236
|
+
case "tkhd":
|
|
45237
|
+
state.tracks.push({
|
|
45238
|
+
...parseTkhd(buf, bodyStart, bodyEnd),
|
|
45239
|
+
handler: null,
|
|
45240
|
+
codec: null,
|
|
45241
|
+
timescale: 0,
|
|
45242
|
+
mdhdDuration: 0,
|
|
45243
|
+
sttsDuration: 0
|
|
45244
|
+
});
|
|
45245
|
+
break;
|
|
45246
|
+
case "mdhd":
|
|
45247
|
+
{
|
|
45248
|
+
const mdhd = parseMvhd(buf, bodyStart, bodyEnd);
|
|
45249
|
+
if (mdhd && state.tracks.length) {
|
|
45250
|
+
const track = state.tracks[state.tracks.length - 1];
|
|
45251
|
+
track.timescale = mdhd.timescale;
|
|
45252
|
+
track.mdhdDuration = mdhd.duration;
|
|
45253
|
+
}
|
|
45036
45254
|
break;
|
|
45037
|
-
|
|
45038
|
-
|
|
45255
|
+
}
|
|
45256
|
+
case "hdlr":
|
|
45257
|
+
if (bodyEnd - bodyStart >= 12 && state.tracks.length) state.tracks[state.tracks.length - 1].handler = buf.toString("latin1", bodyStart + 8, bodyStart + 12);
|
|
45258
|
+
break;
|
|
45259
|
+
case "stsd":
|
|
45260
|
+
{
|
|
45261
|
+
const codec = parseStsdCodec(buf, bodyStart, bodyEnd);
|
|
45262
|
+
if (codec && state.tracks.length) state.tracks[state.tracks.length - 1].codec = codec;
|
|
45039
45263
|
break;
|
|
45040
|
-
|
|
45041
|
-
|
|
45042
|
-
|
|
45043
|
-
|
|
45044
|
-
|
|
45045
|
-
|
|
45264
|
+
}
|
|
45265
|
+
case "stts":
|
|
45266
|
+
if (state.tracks.length) state.tracks[state.tracks.length - 1].sttsDuration = parseSttsDuration(buf, bodyStart, bodyEnd);
|
|
45267
|
+
break;
|
|
45268
|
+
case "trex":
|
|
45269
|
+
if (bodyStart + 20 > bodyEnd) break;
|
|
45270
|
+
state.trexDefaults.set(buf.readUInt32BE(bodyStart + 4), buf.readUInt32BE(bodyStart + 12));
|
|
45271
|
+
break;
|
|
45272
|
+
case "tfhd":
|
|
45273
|
+
{
|
|
45274
|
+
const tfhd = parseTfhd(buf, bodyStart, bodyEnd);
|
|
45275
|
+
state.trafTrackId = tfhd.trackId;
|
|
45276
|
+
state.trafDefaultSampleDuration = tfhd.defaultSampleDuration || state.trexDefaults.get(tfhd.trackId) || 0;
|
|
45046
45277
|
break;
|
|
45047
|
-
|
|
45048
|
-
|
|
45049
|
-
|
|
45050
|
-
|
|
45051
|
-
|
|
45278
|
+
}
|
|
45279
|
+
case "trun":
|
|
45280
|
+
{
|
|
45281
|
+
const duration = parseTrunDuration(buf, bodyStart, bodyEnd, state.trafDefaultSampleDuration);
|
|
45282
|
+
state.fragmentDurations.set(state.trafTrackId, (state.fragmentDurations.get(state.trafTrackId) || 0) + duration);
|
|
45052
45283
|
break;
|
|
45053
|
-
|
|
45054
|
-
{
|
|
45055
|
-
const codec = parseStsdCodec(buf, bodyStart, bodyEnd);
|
|
45056
|
-
if (codec && tracks.length) tracks[tracks.length - 1].codec = codec;
|
|
45057
|
-
break;
|
|
45058
|
-
}
|
|
45059
|
-
}
|
|
45060
|
-
off += size;
|
|
45284
|
+
}
|
|
45061
45285
|
}
|
|
45062
|
-
|
|
45063
|
-
|
|
45064
|
-
|
|
45065
|
-
|
|
45066
|
-
|
|
45067
|
-
|
|
45068
|
-
|
|
45069
|
-
|
|
45070
|
-
|
|
45071
|
-
|
|
45072
|
-
|
|
45073
|
-
|
|
45074
|
-
|
|
45075
|
-
|
|
45076
|
-
|
|
45077
|
-
|
|
45078
|
-
|
|
45286
|
+
off += size;
|
|
45287
|
+
}
|
|
45288
|
+
}
|
|
45289
|
+
const UNKNOWN_DURATION_32 = 0xffffffff;
|
|
45290
|
+
function isUsableDuration(duration) {
|
|
45291
|
+
return duration > 0 && duration !== UNKNOWN_DURATION_32;
|
|
45292
|
+
}
|
|
45293
|
+
function resolveDuration(movie, video, fragmentDurations) {
|
|
45294
|
+
if (movie && movie.timescale && isUsableDuration(movie.duration)) return movie.duration / movie.timescale;
|
|
45295
|
+
if (video.timescale) {
|
|
45296
|
+
if (isUsableDuration(video.mdhdDuration)) return video.mdhdDuration / video.timescale;
|
|
45297
|
+
if (video.sttsDuration > 0) return video.sttsDuration / video.timescale;
|
|
45298
|
+
const fragment = fragmentDurations.get(video.trackId) ?? (1 === fragmentDurations.size ? [
|
|
45299
|
+
...fragmentDurations.values()
|
|
45300
|
+
][0] : 0);
|
|
45301
|
+
if (fragment > 0) return fragment / video.timescale;
|
|
45302
|
+
}
|
|
45303
|
+
return 0;
|
|
45304
|
+
}
|
|
45305
|
+
function parseSttsDuration(buf, start, end) {
|
|
45306
|
+
if (start + 8 > end) return 0;
|
|
45307
|
+
const entryCount = buf.readUInt32BE(start + 4);
|
|
45308
|
+
let total = 0;
|
|
45309
|
+
for(let i = 0; i < entryCount; i++){
|
|
45310
|
+
const off = start + 8 + 8 * i;
|
|
45311
|
+
if (off + 8 > end) break;
|
|
45312
|
+
total += buf.readUInt32BE(off) * buf.readUInt32BE(off + 4);
|
|
45313
|
+
}
|
|
45314
|
+
return total;
|
|
45315
|
+
}
|
|
45316
|
+
function parseTfhd(buf, start, end) {
|
|
45317
|
+
if (start + 8 > end) return {
|
|
45318
|
+
trackId: 0,
|
|
45319
|
+
defaultSampleDuration: 0
|
|
45320
|
+
};
|
|
45321
|
+
const flags = buf.readUIntBE(start + 1, 3);
|
|
45322
|
+
const trackId = buf.readUInt32BE(start + 4);
|
|
45323
|
+
let off = start + 8;
|
|
45324
|
+
if (0x000001 & flags) off += 8;
|
|
45325
|
+
if (0x000002 & flags) off += 4;
|
|
45326
|
+
if (0x000008 & flags && off + 4 <= end) return {
|
|
45327
|
+
trackId,
|
|
45328
|
+
defaultSampleDuration: buf.readUInt32BE(off)
|
|
45079
45329
|
};
|
|
45330
|
+
return {
|
|
45331
|
+
trackId,
|
|
45332
|
+
defaultSampleDuration: 0
|
|
45333
|
+
};
|
|
45334
|
+
}
|
|
45335
|
+
function parseTrunDuration(buf, start, end, defaultSampleDuration) {
|
|
45336
|
+
if (start + 8 > end) return 0;
|
|
45337
|
+
const flags = buf.readUIntBE(start + 1, 3);
|
|
45338
|
+
const sampleCount = buf.readUInt32BE(start + 4);
|
|
45339
|
+
let off = start + 8;
|
|
45340
|
+
if (0x000001 & flags) off += 4;
|
|
45341
|
+
if (0x000004 & flags) off += 4;
|
|
45342
|
+
const hasDuration = (0x000100 & flags) !== 0;
|
|
45343
|
+
if (!hasDuration) return sampleCount * defaultSampleDuration;
|
|
45344
|
+
const entrySize = 4 + ((0x000200 & flags) !== 0 ? 4 : 0) + ((0x000400 & flags) !== 0 ? 4 : 0) + ((0x000800 & flags) !== 0 ? 4 : 0);
|
|
45345
|
+
let total = 0;
|
|
45346
|
+
for(let i = 0; i < sampleCount; i++){
|
|
45347
|
+
const entryOff = off + i * entrySize;
|
|
45348
|
+
if (entryOff + 4 > end) break;
|
|
45349
|
+
total += buf.readUInt32BE(entryOff);
|
|
45350
|
+
}
|
|
45351
|
+
return total;
|
|
45080
45352
|
}
|
|
45081
45353
|
function parseStsdCodec(buf, start, end) {
|
|
45082
45354
|
if (start + 16 > end) return null;
|
|
45355
|
+
if (0 === buf.readUInt32BE(start + 4)) return null;
|
|
45083
45356
|
return buf.toString("latin1", start + 12, start + 16).toLowerCase();
|
|
45084
45357
|
}
|
|
45085
45358
|
function parseMvhd(buf, start, end) {
|
|
@@ -45105,7 +45378,10 @@ var __webpack_exports__ = {};
|
|
|
45105
45378
|
const afterDuration = 1 === version ? 36 : 24;
|
|
45106
45379
|
const matrixOff = start + afterDuration + 16;
|
|
45107
45380
|
const whOff = matrixOff + 36;
|
|
45381
|
+
const trackIdOff = start + (1 === version ? 20 : 12);
|
|
45382
|
+
const trackId = trackIdOff + 4 <= end ? buf.readUInt32BE(trackIdOff) : 0;
|
|
45108
45383
|
if (whOff + 8 > end) return {
|
|
45384
|
+
trackId,
|
|
45109
45385
|
width: 0,
|
|
45110
45386
|
height: 0,
|
|
45111
45387
|
rotation: 0
|
|
@@ -45119,11 +45395,25 @@ var __webpack_exports__ = {};
|
|
|
45119
45395
|
else if (Math.abs(a + 1) < 0.01 && Math.abs(b) < 0.01) rotation = 180;
|
|
45120
45396
|
else if (Math.abs(a) < 0.01 && Math.abs(b + 1) < 0.01) rotation = 270;
|
|
45121
45397
|
return {
|
|
45398
|
+
trackId,
|
|
45122
45399
|
width,
|
|
45123
45400
|
height,
|
|
45124
45401
|
rotation
|
|
45125
45402
|
};
|
|
45126
45403
|
}
|
|
45404
|
+
function parseVideoCodec(filePath) {
|
|
45405
|
+
return parseVideoMeta(filePath)?.codec ?? null;
|
|
45406
|
+
}
|
|
45407
|
+
function buildVideoMetaFromParams(filePath, metadata) {
|
|
45408
|
+
return {
|
|
45409
|
+
width: Math.round(metadata.width),
|
|
45410
|
+
height: Math.round(metadata.height),
|
|
45411
|
+
duration: metadata.duration,
|
|
45412
|
+
rotation: 0,
|
|
45413
|
+
fileSize: metadata.fileSize,
|
|
45414
|
+
codec: parseVideoCodec(filePath)
|
|
45415
|
+
};
|
|
45416
|
+
}
|
|
45127
45417
|
const MAX_DURATION_SECONDS = 28800;
|
|
45128
45418
|
const MAX_FILE_SIZE = 21474836480;
|
|
45129
45419
|
const ALLOWED_EXTENSIONS = [
|
|
@@ -45166,20 +45456,56 @@ var __webpack_exports__ = {};
|
|
|
45166
45456
|
if (length < MIN_TITLE_LENGTH) return `视频号标题至少需要 ${MIN_TITLE_LENGTH} 个字符,请补充后重试。`;
|
|
45167
45457
|
return null;
|
|
45168
45458
|
}
|
|
45169
|
-
|
|
45459
|
+
const POST_CREATE_PAGE_URL = "https://channels.weixin.qq.com/micro/content/post/create";
|
|
45460
|
+
const MICRO_CONTENT_BASE = "https://channels.weixin.qq.com/micro/content/cgi-bin/mmfinderassistant-bin";
|
|
45461
|
+
function resolveClientContext(params, fallbackUin) {
|
|
45462
|
+
const extra = params.extraParam || {};
|
|
45463
|
+
const deviceIdCookie = params.cookies.find((c)=>"device_id" === c.name || "finger_print_device_id" === c.name)?.value;
|
|
45464
|
+
return {
|
|
45465
|
+
aId: "string" == typeof extra.aId ? extra.aId : "",
|
|
45466
|
+
fingerPrintDeviceId: "string" == typeof extra.fingerPrintDeviceId ? extra.fingerPrintDeviceId : deviceIdCookie || "",
|
|
45467
|
+
uin: "string" == typeof extra.uin ? extra.uin : String(fallbackUin)
|
|
45468
|
+
};
|
|
45469
|
+
}
|
|
45470
|
+
function buildPublishHeaders(cookieString, client) {
|
|
45471
|
+
const headers = {
|
|
45472
|
+
cookie: cookieString,
|
|
45473
|
+
referer: POST_CREATE_PAGE_URL,
|
|
45474
|
+
origin: "https://channels.weixin.qq.com",
|
|
45475
|
+
"content-type": "application/json"
|
|
45476
|
+
};
|
|
45477
|
+
if (client.fingerPrintDeviceId) headers["finger-print-device-id"] = client.fingerPrintDeviceId;
|
|
45478
|
+
if (client.uin) headers["x-wechat-uin"] = client.uin;
|
|
45479
|
+
return headers;
|
|
45480
|
+
}
|
|
45481
|
+
function buildPublishQuery(client) {
|
|
45482
|
+
const query = {
|
|
45483
|
+
_rid: rid(),
|
|
45484
|
+
_pageUrl: POST_CREATE_PAGE_URL
|
|
45485
|
+
};
|
|
45486
|
+
if (client.aId) query._aid = client.aId;
|
|
45487
|
+
return query;
|
|
45488
|
+
}
|
|
45489
|
+
function buildCommonBody(finderUsername) {
|
|
45490
|
+
return {
|
|
45491
|
+
timestamp: String(Date.now()),
|
|
45492
|
+
_log_finder_uin: "",
|
|
45493
|
+
_log_finder_id: finderUsername,
|
|
45494
|
+
rawKeyBuff: "",
|
|
45495
|
+
pluginSessionId: null,
|
|
45496
|
+
scene: 7,
|
|
45497
|
+
reqScene: 7
|
|
45498
|
+
};
|
|
45499
|
+
}
|
|
45500
|
+
async function getTraceKey(auth, client, http, logger) {
|
|
45170
45501
|
logger.info("[getTraceKey] 开始获取 traceKey...");
|
|
45171
45502
|
const res = await http.api({
|
|
45172
45503
|
method: "POST",
|
|
45173
|
-
url:
|
|
45504
|
+
url: `${MICRO_CONTENT_BASE}/post/get-finder-post-trace-key`,
|
|
45505
|
+
params: buildPublishQuery(client),
|
|
45174
45506
|
data: {
|
|
45175
45507
|
objectId: "",
|
|
45176
|
-
|
|
45177
|
-
_log_finder_uin: "",
|
|
45178
|
-
_log_finder_id: auth.finderUsername,
|
|
45179
|
-
rawKeyBuff: "",
|
|
45180
|
-
pluginSessionId: null,
|
|
45181
|
-
scene: 7,
|
|
45182
|
-
reqScene: 7
|
|
45508
|
+
...buildCommonBody(auth.finderUsername)
|
|
45183
45509
|
},
|
|
45184
45510
|
defaultErrorMsg: "获取 traceKey 失败"
|
|
45185
45511
|
});
|
|
@@ -45190,15 +45516,39 @@ var __webpack_exports__ = {};
|
|
|
45190
45516
|
logger.info(`[getTraceKey] 获取成功: ${res.data.traceKey}`);
|
|
45191
45517
|
return res.data.traceKey;
|
|
45192
45518
|
}
|
|
45519
|
+
async function getObjectTagKey(auth, client, http, logger) {
|
|
45520
|
+
logger.info("[getObjectTagKey] 获取内容声明 tagKey...");
|
|
45521
|
+
try {
|
|
45522
|
+
const res = await http.api({
|
|
45523
|
+
method: "POST",
|
|
45524
|
+
url: `${MICRO_CONTENT_BASE}/post/finder_get_object_tag_list`,
|
|
45525
|
+
params: buildPublishQuery(client),
|
|
45526
|
+
data: {
|
|
45527
|
+
source: 1,
|
|
45528
|
+
...buildCommonBody(auth.finderUsername)
|
|
45529
|
+
},
|
|
45530
|
+
defaultErrorMsg: "获取内容声明标注失败"
|
|
45531
|
+
});
|
|
45532
|
+
if (0 !== res.errCode || !res.data?.tagKey) {
|
|
45533
|
+
logger.warn(`[getObjectTagKey] 未取到 tagKey: ${JSON.stringify(res)}`);
|
|
45534
|
+
return null;
|
|
45535
|
+
}
|
|
45536
|
+
logger.info(`[getObjectTagKey] tagKey: ${res.data.tagKey}`);
|
|
45537
|
+
return res.data.tagKey;
|
|
45538
|
+
} catch (error) {
|
|
45539
|
+
logger.warn(`[getObjectTagKey] 获取 tagKey 异常: ${stringifyError(error)}`);
|
|
45540
|
+
return null;
|
|
45541
|
+
}
|
|
45542
|
+
}
|
|
45193
45543
|
async function submitAndPollTranscode(opts) {
|
|
45194
|
-
const { videoUrl, videoMeta, traceKey, uploadStartTime, uploadEndTime, finderUsername, http, logger } = opts;
|
|
45544
|
+
const { videoUrl, videoMeta, traceKey, uploadStartTime, uploadEndTime, finderUsername, client, http, logger } = opts;
|
|
45195
45545
|
logger.info("[submitAndPollTranscode] 开始提交转码任务...");
|
|
45196
45546
|
const finderUrl = videoUrl.includes("wxapp.tc.qq.com") ? `https://finder.video.qq.com${videoUrl.split("qq.com")[1]}` : videoUrl;
|
|
45197
|
-
logger.info(`[submitAndPollTranscode] 视频URL: ${finderUrl}`);
|
|
45198
45547
|
logger.info(`[submitAndPollTranscode] 视频尺寸: ${videoMeta.width}x${videoMeta.height}, 时长: ${videoMeta.duration}s`);
|
|
45199
45548
|
const submitRes = await http.api({
|
|
45200
45549
|
method: "POST",
|
|
45201
|
-
url:
|
|
45550
|
+
url: `${MICRO_CONTENT_BASE}/post/post_clip_video`,
|
|
45551
|
+
params: buildPublishQuery(client),
|
|
45202
45552
|
data: {
|
|
45203
45553
|
url: finderUrl,
|
|
45204
45554
|
timeStart: 0,
|
|
@@ -45222,13 +45572,7 @@ var __webpack_exports__ = {};
|
|
|
45222
45572
|
targetHeight: videoMeta.height,
|
|
45223
45573
|
type: 4,
|
|
45224
45574
|
useAstraThumbCover: 1,
|
|
45225
|
-
|
|
45226
|
-
_log_finder_uin: "",
|
|
45227
|
-
_log_finder_id: finderUsername,
|
|
45228
|
-
rawKeyBuff: "",
|
|
45229
|
-
pluginSessionId: null,
|
|
45230
|
-
scene: 7,
|
|
45231
|
-
reqScene: 7
|
|
45575
|
+
...buildCommonBody(finderUsername)
|
|
45232
45576
|
},
|
|
45233
45577
|
defaultErrorMsg: "提交转码失败"
|
|
45234
45578
|
});
|
|
@@ -45238,28 +45582,28 @@ var __webpack_exports__ = {};
|
|
|
45238
45582
|
}
|
|
45239
45583
|
const { clipKey, draftId } = submitRes.data;
|
|
45240
45584
|
logger.info(`[submitAndPollTranscode] 转码任务已提交,clipKey: ${clipKey}, draftId: ${draftId}`);
|
|
45241
|
-
const maxPolls = 60;
|
|
45242
45585
|
const pollInterval = 5000;
|
|
45586
|
+
const pollBudget = Math.min(1800000, 300000 + 1000 * Math.ceil(1.5 * videoMeta.duration));
|
|
45587
|
+
const maxPolls = Math.ceil(pollBudget / pollInterval);
|
|
45243
45588
|
let pollCount = 0;
|
|
45244
|
-
logger.info(`[submitAndPollTranscode] 开始轮询转码结果,最多 ${maxPolls}
|
|
45589
|
+
logger.info(`[submitAndPollTranscode] 开始轮询转码结果,最多 ${maxPolls} 次(${Math.round(pollBudget / 1000)}s),间隔 ${pollInterval / 1000}s`);
|
|
45245
45590
|
while(pollCount < maxPolls){
|
|
45246
45591
|
await mock_sleep(pollInterval);
|
|
45247
45592
|
pollCount++;
|
|
45248
45593
|
const pollRes = await http.api({
|
|
45249
45594
|
method: "POST",
|
|
45250
|
-
url:
|
|
45595
|
+
url: `${MICRO_CONTENT_BASE}/post/post_clip_video_result`,
|
|
45596
|
+
params: buildPublishQuery(client),
|
|
45251
45597
|
data: {
|
|
45252
45598
|
clipKey,
|
|
45253
45599
|
draftId,
|
|
45254
|
-
|
|
45255
|
-
_log_finder_uin: "",
|
|
45256
|
-
_log_finder_id: finderUsername,
|
|
45257
|
-
rawKeyBuff: "",
|
|
45258
|
-
pluginSessionId: null,
|
|
45259
|
-
scene: 7,
|
|
45260
|
-
reqScene: 7
|
|
45600
|
+
...buildCommonBody(finderUsername)
|
|
45261
45601
|
},
|
|
45262
45602
|
defaultErrorMsg: "转码轮询失败"
|
|
45603
|
+
}, {
|
|
45604
|
+
timeout: 60000,
|
|
45605
|
+
retries: 2,
|
|
45606
|
+
retryDelay: 3000
|
|
45263
45607
|
});
|
|
45264
45608
|
if (0 !== pollRes.errCode) {
|
|
45265
45609
|
logger.error(`[submitAndPollTranscode] 转码轮询失败 (poll ${pollCount}):`, JSON.stringify(pollRes));
|
|
@@ -45294,105 +45638,96 @@ var __webpack_exports__ = {};
|
|
|
45294
45638
|
throw new Error(`转码超时 (${maxPolls * pollInterval / 1000}s)`);
|
|
45295
45639
|
}
|
|
45296
45640
|
async function publishVideo(opts) {
|
|
45297
|
-
const { params, auth, clipResult, videoUpload, coverUpload, traceKey, uploadStartTime, uploadEndTime, proxyHttp, logger } = opts;
|
|
45641
|
+
const { params, auth, client, clipResult, videoUpload, coverUpload, verticalCoverUpload, videoMeta, traceKey, tagKey, uploadStartTime, uploadEndTime, proxyHttp, logger } = opts;
|
|
45298
45642
|
logger.info("[publishVideo] 开始构建发布请求...");
|
|
45299
|
-
const
|
|
45300
|
-
|
|
45643
|
+
const toFinderUrl = (url)=>url.includes("wxapp.tc.qq.com") ? `https://finder.video.qq.com${url.split("qq.com")[1]}` : url;
|
|
45644
|
+
const thumbFinderUrl = toFinderUrl(coverUpload.downloadUrl);
|
|
45645
|
+
const coverFinderUrl = toFinderUrl(verticalCoverUpload.downloadUrl);
|
|
45301
45646
|
const md5sumUuid = external_node_crypto_default().randomUUID();
|
|
45647
|
+
const description = params.description;
|
|
45302
45648
|
logger.info("[publishVideo] 发布参数:");
|
|
45303
|
-
logger.info(` -
|
|
45304
|
-
logger.info(` - 描述: ${
|
|
45305
|
-
logger.info(` - 定时发布: ${params.
|
|
45306
|
-
|
|
45307
|
-
|
|
45308
|
-
|
|
45309
|
-
|
|
45310
|
-
|
|
45311
|
-
|
|
45312
|
-
|
|
45313
|
-
|
|
45314
|
-
|
|
45315
|
-
|
|
45316
|
-
|
|
45317
|
-
|
|
45318
|
-
|
|
45319
|
-
|
|
45320
|
-
|
|
45321
|
-
|
|
45322
|
-
|
|
45323
|
-
|
|
45324
|
-
|
|
45325
|
-
|
|
45326
|
-
|
|
45327
|
-
|
|
45328
|
-
|
|
45329
|
-
shortTitle: params.title || "",
|
|
45330
|
-
extReading: {},
|
|
45649
|
+
logger.info(` - 短标题: ${params.title || "(无)"}`);
|
|
45650
|
+
logger.info(` - 描述: ${description.substring(0, 50)}${description.length > 50 ? "..." : ""}`);
|
|
45651
|
+
logger.info(` - 定时发布: ${params.scheduledTime ? new Date(1000 * params.scheduledTime).toLocaleString() : "立即发布"}`);
|
|
45652
|
+
const objectDesc = {
|
|
45653
|
+
mpTitle: "",
|
|
45654
|
+
description,
|
|
45655
|
+
extReading: buildExtReading(params.link),
|
|
45656
|
+
mediaType: 4,
|
|
45657
|
+
location: payload_buildLocation(params.location),
|
|
45658
|
+
topic: buildTopic({
|
|
45659
|
+
description: params.description,
|
|
45660
|
+
topics: params.topics,
|
|
45661
|
+
mentionedUsers: params.mentionedUsers,
|
|
45662
|
+
collection: params.collection
|
|
45663
|
+
}),
|
|
45664
|
+
event: buildEvent(params.event),
|
|
45665
|
+
mentionedUser: buildMentionedUser(params.mentionedUsers),
|
|
45666
|
+
media: [
|
|
45667
|
+
{
|
|
45668
|
+
url: clipResult.url,
|
|
45669
|
+
fileSize: clipResult.fileSize,
|
|
45670
|
+
thumbUrl: thumbFinderUrl,
|
|
45671
|
+
fullThumbUrl: thumbFinderUrl,
|
|
45672
|
+
coverUrl: coverFinderUrl,
|
|
45673
|
+
fullCoverUrl: coverFinderUrl,
|
|
45674
|
+
shareCoverUrl: coverFinderUrl,
|
|
45331
45675
|
mediaType: 4,
|
|
45332
|
-
|
|
45333
|
-
latitude: params.location.latitude,
|
|
45334
|
-
longitude: params.location.longitude,
|
|
45335
|
-
city: params.location.city,
|
|
45336
|
-
poiClassifyId: params.location.poiClassifyId || ""
|
|
45337
|
-
} : {
|
|
45338
|
-
latitude: 0,
|
|
45339
|
-
longitude: 0,
|
|
45340
|
-
city: "",
|
|
45341
|
-
poiClassifyId: ""
|
|
45342
|
-
},
|
|
45343
|
-
topic: {
|
|
45344
|
-
finderTopicInfo: `<finder><version>1</version><valuecount>1</valuecount><style><at></at></style><value0><![CDATA[${params.description}]]></value0></finder>`
|
|
45345
|
-
},
|
|
45346
|
-
event: {},
|
|
45347
|
-
mentionedUser: [],
|
|
45348
|
-
media: [
|
|
45349
|
-
{
|
|
45350
|
-
url: clipResult.url,
|
|
45351
|
-
fileSize: clipResult.fileSize,
|
|
45352
|
-
thumbUrl: coverFinderUrl,
|
|
45353
|
-
fullThumbUrl: coverFinderUrl,
|
|
45354
|
-
coverUrl: coverFinderUrl,
|
|
45355
|
-
fullCoverUrl: coverFinderUrl,
|
|
45356
|
-
shareCoverUrl: coverFinderUrl,
|
|
45357
|
-
mediaType: 4,
|
|
45358
|
-
videoPlayLen: Math.round(clipResult.duration),
|
|
45359
|
-
width: clipResult.width,
|
|
45360
|
-
height: clipResult.height,
|
|
45361
|
-
md5sum: md5sumUuid,
|
|
45362
|
-
cardShowStyle: 2,
|
|
45363
|
-
urlCdnTaskId: clipResult.clipKey
|
|
45364
|
-
}
|
|
45365
|
-
],
|
|
45366
|
-
member: {}
|
|
45367
|
-
},
|
|
45368
|
-
effectiveTime: params.scheduleTime || 0,
|
|
45369
|
-
report: {
|
|
45370
|
-
clipKey: clipResult.clipKey,
|
|
45371
|
-
draftId: clipResult.clipKey,
|
|
45372
|
-
timestamp: String(Date.now()),
|
|
45373
|
-
_log_finder_uin: "",
|
|
45374
|
-
_log_finder_id: auth.finderUsername,
|
|
45375
|
-
rawKeyBuff: "",
|
|
45376
|
-
pluginSessionId: null,
|
|
45377
|
-
scene: 7,
|
|
45378
|
-
reqScene: 7,
|
|
45379
|
-
height: clipResult.height,
|
|
45676
|
+
videoPlayLen: Math.round(clipResult.duration),
|
|
45380
45677
|
width: clipResult.width,
|
|
45381
|
-
|
|
45382
|
-
|
|
45383
|
-
|
|
45384
|
-
|
|
45385
|
-
|
|
45386
|
-
|
|
45387
|
-
|
|
45388
|
-
|
|
45389
|
-
|
|
45390
|
-
|
|
45391
|
-
|
|
45392
|
-
|
|
45393
|
-
|
|
45394
|
-
|
|
45678
|
+
height: clipResult.height,
|
|
45679
|
+
md5sum: md5sumUuid,
|
|
45680
|
+
cardShowStyle: 2,
|
|
45681
|
+
urlCdnTaskId: clipResult.clipKey
|
|
45682
|
+
}
|
|
45683
|
+
],
|
|
45684
|
+
shortTitle: params.title ? [
|
|
45685
|
+
{
|
|
45686
|
+
shortTitle: params.title
|
|
45687
|
+
}
|
|
45688
|
+
] : [],
|
|
45689
|
+
member: {}
|
|
45690
|
+
};
|
|
45691
|
+
const publishData = {
|
|
45692
|
+
objectType: 0,
|
|
45693
|
+
longitude: 0,
|
|
45694
|
+
latitude: 0,
|
|
45695
|
+
feedLongitude: 0,
|
|
45696
|
+
feedLatitude: 0,
|
|
45697
|
+
originalFlag: params.originalFlag ?? 0,
|
|
45698
|
+
topics: params.topics || [],
|
|
45699
|
+
isFullPost: 1,
|
|
45700
|
+
handleFlag: 2,
|
|
45701
|
+
videoClipTaskId: clipResult.clipKey,
|
|
45702
|
+
traceInfo: {
|
|
45703
|
+
traceKey,
|
|
45704
|
+
uploadCdnStart: uploadStartTime,
|
|
45705
|
+
uploadCdnEnd: uploadEndTime
|
|
45395
45706
|
},
|
|
45707
|
+
objectDesc,
|
|
45708
|
+
report: {
|
|
45709
|
+
clipKey: clipResult.clipKey,
|
|
45710
|
+
draftId: clipResult.clipKey,
|
|
45711
|
+
...buildCommonBody(auth.finderUsername),
|
|
45712
|
+
height: videoMeta.height,
|
|
45713
|
+
width: videoMeta.width,
|
|
45714
|
+
duration: videoMeta.duration,
|
|
45715
|
+
fileSize: videoUpload.fileSize,
|
|
45716
|
+
uploadCost: (uploadEndTime - uploadStartTime) * 1000
|
|
45717
|
+
},
|
|
45718
|
+
postFlag: 0,
|
|
45719
|
+
mode: 1,
|
|
45720
|
+
clientid: external_node_crypto_default().randomUUID(),
|
|
45721
|
+
...buildCommonBody(auth.finderUsername)
|
|
45722
|
+
};
|
|
45723
|
+
if (params.scheduledTime) publishData.effectiveTime = params.scheduledTime;
|
|
45724
|
+
if (params.tagInfo && tagKey) publishData.tagInfo = buildTagInfo(params.tagInfo, tagKey);
|
|
45725
|
+
logger.info("[publishVideo] 开始发布视频,全部参数:" + JSON.stringify(publishData));
|
|
45726
|
+
const publishRes = await proxyHttp.api({
|
|
45727
|
+
method: "POST",
|
|
45728
|
+
url: `${MICRO_CONTENT_BASE}/post/post_create`,
|
|
45729
|
+
params: buildPublishQuery(client),
|
|
45730
|
+
data: publishData,
|
|
45396
45731
|
defaultErrorMsg: "发布视频失败"
|
|
45397
45732
|
});
|
|
45398
45733
|
logger.info(`[publishVideo] 发布响应: errCode=${publishRes.errCode}, baseResp.errcode=${publishRes.data?.baseResp?.errcode}`);
|
|
@@ -45401,40 +45736,54 @@ var __webpack_exports__ = {};
|
|
|
45401
45736
|
function mock_sleep(ms) {
|
|
45402
45737
|
return new Promise((resolve)=>setTimeout(resolve, ms));
|
|
45403
45738
|
}
|
|
45739
|
+
async function resolveLocalCoverPath(coverPath, label, tmpCachePath, logger) {
|
|
45740
|
+
if (!/^https?:\/\//i.test(coverPath)) return coverPath;
|
|
45741
|
+
const fileName = getFilenameFromUrl(coverPath);
|
|
45742
|
+
const savePath = external_node_path_default().join(tmpCachePath, `${Date.now()}-${label}-${fileName}`);
|
|
45743
|
+
await downloadImage(coverPath, savePath);
|
|
45744
|
+
return savePath;
|
|
45745
|
+
}
|
|
45404
45746
|
const shipinhaoPublishVideo_mock_mockAction = async (task, params)=>{
|
|
45405
45747
|
task.logger.info("[shipinhaoPublishVideo] 开始执行视频号视频发布 - Mock API 方式");
|
|
45406
45748
|
const updateTaskState = task.taskStageStore?.update?.bind(task.taskStageStore, task.taskId || "");
|
|
45407
45749
|
let currentStep = "初始化";
|
|
45408
45750
|
try {
|
|
45751
|
+
task.logger.info(`[shipinhaoPublishVideo] 发布方式: ${params.scheduledTime ? `定时 ${new Date(1000 * params.scheduledTime).toLocaleString()}` : "立即发布"}`);
|
|
45409
45752
|
currentStep = "解析认证信息";
|
|
45410
45753
|
const cookieString = params.cookies.map((c)=>`${c.name}=${c.value}`).join("; ");
|
|
45411
|
-
const
|
|
45412
|
-
|
|
45413
|
-
|
|
45754
|
+
const http = new Http({
|
|
45755
|
+
headers: {
|
|
45756
|
+
cookie: cookieString
|
|
45757
|
+
}
|
|
45758
|
+
});
|
|
45759
|
+
currentStep = "验证发布参数";
|
|
45760
|
+
if (!params.videoPath) return utils_response(414, "视频文件路径不能为空", "");
|
|
45761
|
+
if (!params.coverPath) return utils_response(414, "横屏封面图片路径不能为空", "");
|
|
45762
|
+
currentStep = "获取上传认证";
|
|
45763
|
+
task.logger.info("[shipinhaoPublishVideo] 获取上传认证...");
|
|
45764
|
+
const auth = await getShipinhaoUploadAuth(cookieString, http);
|
|
45765
|
+
const client = resolveClientContext(params, auth.uin);
|
|
45766
|
+
if (!client.aId) task.logger.warn("[shipinhaoPublishVideo] extraParam.aId 缺失,query 将不带 _aid");
|
|
45767
|
+
if (!client.fingerPrintDeviceId) task.logger.warn("[shipinhaoPublishVideo] extraParam.fingerPrintDeviceId 缺失,请求将不带 finger-print-device-id");
|
|
45768
|
+
const publishHeaders = buildPublishHeaders(cookieString, client);
|
|
45769
|
+
const microHttp = new Http({
|
|
45770
|
+
headers: publishHeaders
|
|
45771
|
+
});
|
|
45414
45772
|
const args = [
|
|
45415
45773
|
{
|
|
45416
|
-
headers
|
|
45774
|
+
headers: publishHeaders
|
|
45417
45775
|
},
|
|
45418
45776
|
task.logger,
|
|
45419
45777
|
params.proxyLoc,
|
|
45420
45778
|
params.accountId,
|
|
45421
45779
|
"shipinhao"
|
|
45422
45780
|
];
|
|
45423
|
-
const http = new Http({
|
|
45424
|
-
headers
|
|
45425
|
-
});
|
|
45426
45781
|
const proxyHttp = new Http(...args);
|
|
45427
|
-
currentStep = "
|
|
45428
|
-
|
|
45429
|
-
|
|
45430
|
-
currentStep = "获取上传认证";
|
|
45431
|
-
task.logger.info("[shipinhaoPublishVideo] 获取上传认证...");
|
|
45432
|
-
const auth = await getShipinhaoUploadAuth(cookieString, http);
|
|
45433
|
-
currentStep = "解析视频元数据";
|
|
45434
|
-
task.logger.info("[shipinhaoPublishVideo] 解析视频元数据...");
|
|
45435
|
-
const videoMeta = parseVideoMeta(params.videoPath);
|
|
45436
|
-
if (!videoMeta) return utils_response(414, "视频文件解析失败,请检查文件格式(仅支持 MP4)", "");
|
|
45782
|
+
currentStep = "组装视频元数据";
|
|
45783
|
+
task.logger.info("[shipinhaoPublishVideo] 组装视频元数据...");
|
|
45784
|
+
const videoMeta = buildVideoMetaFromParams(params.videoPath, params.videoMetadata);
|
|
45437
45785
|
task.logger.info(`[shipinhaoPublishVideo] 视频: ${videoMeta.width}×${videoMeta.height}, ${videoMeta.duration.toFixed(2)}s, ${(videoMeta.fileSize / 1024 / 1024).toFixed(2)}MB, codec=${videoMeta.codec || "unknown"}`);
|
|
45786
|
+
if (!videoMeta.codec) task.logger.warn("[shipinhaoPublishVideo] 未能读取视频编码格式,跳过 H.264 预检,交由服务端判断");
|
|
45438
45787
|
currentStep = "校验视频限制";
|
|
45439
45788
|
const validationError = validateShipinhaoVideo(params.videoPath, videoMeta);
|
|
45440
45789
|
if (validationError) {
|
|
@@ -45458,7 +45807,12 @@ var __webpack_exports__ = {};
|
|
|
45458
45807
|
}
|
|
45459
45808
|
currentStep = "获取 traceKey";
|
|
45460
45809
|
task.logger.info("[shipinhaoPublishVideo] 获取 traceKey...");
|
|
45461
|
-
const traceKey = await getTraceKey(auth,
|
|
45810
|
+
const traceKey = await getTraceKey(auth, client, microHttp, task.logger);
|
|
45811
|
+
let tagKey = null;
|
|
45812
|
+
if (params.tagInfo) {
|
|
45813
|
+
currentStep = "获取内容声明 tagKey";
|
|
45814
|
+
tagKey = await getObjectTagKey(auth, client, microHttp, task.logger);
|
|
45815
|
+
}
|
|
45462
45816
|
const uploadStartTime = Math.floor(Date.now() / 1000);
|
|
45463
45817
|
task.logger.info(`[shipinhaoPublishVideo] 上传开始时间: ${uploadStartTime}`);
|
|
45464
45818
|
currentStep = "上传视频";
|
|
@@ -45473,22 +45827,36 @@ var __webpack_exports__ = {};
|
|
|
45473
45827
|
http,
|
|
45474
45828
|
logger: task.logger
|
|
45475
45829
|
});
|
|
45476
|
-
task.logger.info(
|
|
45830
|
+
task.logger.info("[shipinhaoPublishVideo] 视频上传完成");
|
|
45477
45831
|
const uploadEndTime = Math.floor(Date.now() / 1000);
|
|
45478
45832
|
task.logger.info(`[shipinhaoPublishVideo] 上传结束时间: ${uploadEndTime}, 耗时: ${uploadEndTime - uploadStartTime}s`);
|
|
45479
|
-
currentStep = "
|
|
45480
|
-
task.
|
|
45481
|
-
task.logger.info(
|
|
45482
|
-
task.logger.info(`[shipinhaoPublishVideo] 封面文件类型: ${auth.pictureFileType}`);
|
|
45833
|
+
currentStep = "上传横屏封面";
|
|
45834
|
+
const localCoverPath = await resolveLocalCoverPath(params.coverPath, "横屏封面", task.getTmpPath(), task.logger);
|
|
45835
|
+
task.logger.info("[shipinhaoPublishVideo] 上传横屏封面...");
|
|
45483
45836
|
const coverUpload = await uploader_uploadFile({
|
|
45484
|
-
filePath:
|
|
45837
|
+
filePath: localCoverPath,
|
|
45485
45838
|
fileType: auth.pictureFileType,
|
|
45486
45839
|
uin: auth.uin,
|
|
45487
45840
|
authKey: auth.authKey,
|
|
45488
45841
|
http,
|
|
45489
45842
|
logger: task.logger
|
|
45490
45843
|
});
|
|
45491
|
-
task.logger.info(
|
|
45844
|
+
task.logger.info("[shipinhaoPublishVideo] 横屏封面上传完成");
|
|
45845
|
+
let verticalCoverUpload = coverUpload;
|
|
45846
|
+
if (params.verticalCoverPath) {
|
|
45847
|
+
currentStep = "上传竖屏封面";
|
|
45848
|
+
const localVerticalPath = await resolveLocalCoverPath(params.verticalCoverPath, "竖屏封面", task.getTmpPath(), task.logger);
|
|
45849
|
+
task.logger.info("[shipinhaoPublishVideo] 上传竖屏封面");
|
|
45850
|
+
verticalCoverUpload = await uploader_uploadFile({
|
|
45851
|
+
filePath: localVerticalPath,
|
|
45852
|
+
fileType: auth.pictureFileType,
|
|
45853
|
+
uin: auth.uin,
|
|
45854
|
+
authKey: auth.authKey,
|
|
45855
|
+
http,
|
|
45856
|
+
logger: task.logger
|
|
45857
|
+
});
|
|
45858
|
+
task.logger.info("[shipinhaoPublishVideo] 竖屏封面上传完成");
|
|
45859
|
+
} else task.logger.info("[shipinhaoPublishVideo] 未传竖屏封面,复用横屏封面");
|
|
45492
45860
|
currentStep = "提交转码";
|
|
45493
45861
|
task.logger.info("[shipinhaoPublishVideo] 提交转码...");
|
|
45494
45862
|
const clipResult = await submitAndPollTranscode({
|
|
@@ -45498,7 +45866,8 @@ var __webpack_exports__ = {};
|
|
|
45498
45866
|
uploadStartTime,
|
|
45499
45867
|
uploadEndTime,
|
|
45500
45868
|
finderUsername: auth.finderUsername,
|
|
45501
|
-
|
|
45869
|
+
client,
|
|
45870
|
+
http: microHttp,
|
|
45502
45871
|
logger: task.logger
|
|
45503
45872
|
});
|
|
45504
45873
|
currentStep = "发布视频";
|
|
@@ -45509,10 +45878,14 @@ var __webpack_exports__ = {};
|
|
|
45509
45878
|
publishResult = await publishVideo({
|
|
45510
45879
|
params,
|
|
45511
45880
|
auth,
|
|
45881
|
+
client,
|
|
45512
45882
|
clipResult,
|
|
45513
45883
|
videoUpload,
|
|
45514
45884
|
coverUpload,
|
|
45885
|
+
verticalCoverUpload,
|
|
45886
|
+
videoMeta,
|
|
45515
45887
|
traceKey,
|
|
45888
|
+
tagKey,
|
|
45516
45889
|
uploadStartTime,
|
|
45517
45890
|
uploadEndTime,
|
|
45518
45891
|
proxyHttp,
|
|
@@ -45539,12 +45912,13 @@ var __webpack_exports__ = {};
|
|
|
45539
45912
|
}
|
|
45540
45913
|
task.logger.info(`[shipinhaoPublishVideo] publishResult: ${JSON.stringify(publishResult)}`);
|
|
45541
45914
|
const resultCode = publishResult.data?.baseResp?.errcode ?? publishResult.errCode;
|
|
45542
|
-
const resultMsg = publishResult.data?.baseResp?.errmsg ?? "发布成功";
|
|
45915
|
+
const resultMsg = publishResult.data?.baseResp?.errmsg ?? (0 === resultCode ? "发布成功" : `发布失败(errCode=${resultCode})`);
|
|
45543
45916
|
if (0 === resultCode) {
|
|
45544
45917
|
task.logger.info("[shipinhaoPublishVideo] 发布成功");
|
|
45545
45918
|
task.logger.info(`[shipinhaoPublishVideo] 作品ID: ${clipResult.clipKey}`);
|
|
45546
45919
|
task.logger.info(`[shipinhaoPublishVideo] 视频URL: ${clipResult.url}`);
|
|
45547
|
-
task.logger.info(`[shipinhaoPublishVideo]
|
|
45920
|
+
task.logger.info(`[shipinhaoPublishVideo] 横屏封面URL: ${coverUpload.downloadUrl}`);
|
|
45921
|
+
task.logger.info(`[shipinhaoPublishVideo] 竖屏封面URL: ${verticalCoverUpload.downloadUrl}`);
|
|
45548
45922
|
await updateTaskState?.({
|
|
45549
45923
|
state: types_TaskState.SUCCESS,
|
|
45550
45924
|
result: {
|
|
@@ -45560,7 +45934,17 @@ var __webpack_exports__ = {};
|
|
|
45560
45934
|
uid: params.uid,
|
|
45561
45935
|
publishParams: {
|
|
45562
45936
|
videoPath: params.videoPath,
|
|
45563
|
-
coverPath: params.coverPath
|
|
45937
|
+
coverPath: params.coverPath,
|
|
45938
|
+
verticalCoverPath: params.verticalCoverPath,
|
|
45939
|
+
title: params.title,
|
|
45940
|
+
topics: params.topics,
|
|
45941
|
+
mentionedUsers: params.mentionedUsers,
|
|
45942
|
+
collection: params.collection,
|
|
45943
|
+
event: params.event,
|
|
45944
|
+
link: params.link,
|
|
45945
|
+
tagInfo: params.tagInfo,
|
|
45946
|
+
originalFlag: params.originalFlag,
|
|
45947
|
+
scheduledTime: params.scheduledTime
|
|
45564
45948
|
},
|
|
45565
45949
|
platform: "shipinhao"
|
|
45566
45950
|
});
|
|
@@ -45571,6 +45955,7 @@ var __webpack_exports__ = {};
|
|
|
45571
45955
|
if (-11224 === resultCode) errorMessage = "视频号管理员完成实名且绑定手机号后才可以发表";
|
|
45572
45956
|
else if (300333 === resultCode || 300334 === resultCode) errorMessage = "登录失效";
|
|
45573
45957
|
else if (300330 === resultCode) errorMessage = "未登录";
|
|
45958
|
+
else if (300002 === resultCode) errorMessage = "官方平台在校验音乐/位置/定时信息时失败了,请重新编辑后发布";
|
|
45574
45959
|
task.logger.error(`[shipinhaoPublishVideo] 发布失败: ${errorMessage} (errCode=${resultCode})`);
|
|
45575
45960
|
await updateTaskState?.({
|
|
45576
45961
|
state: types_TaskState.FAILED,
|
|
@@ -45592,9 +45977,9 @@ var __webpack_exports__ = {};
|
|
|
45592
45977
|
};
|
|
45593
45978
|
const shipinhaoPublishVideo_rpa_rpaAction = async (task, params)=>{
|
|
45594
45979
|
task.logger.info("开始微信视频号视频发布(RPA 模式)");
|
|
45595
|
-
const videoMeta =
|
|
45596
|
-
if (!videoMeta) return utils_response(414, "视频文件解析失败,请检查文件格式(仅支持 MP4)", "");
|
|
45980
|
+
const videoMeta = buildVideoMetaFromParams(params.videoPath, params.videoMetadata);
|
|
45597
45981
|
task.logger.info(`视频: ${videoMeta.width}×${videoMeta.height}, ${videoMeta.duration.toFixed(2)}s, ${(videoMeta.fileSize / 1024 / 1024).toFixed(2)}MB, codec=${videoMeta.codec || "unknown"}`);
|
|
45982
|
+
if (!videoMeta.codec) task.logger.warn("未能读取视频编码格式,跳过 H.264 预检,交由服务端判断");
|
|
45598
45983
|
const validationError = validateShipinhaoVideo(params.videoPath, videoMeta);
|
|
45599
45984
|
if (validationError) {
|
|
45600
45985
|
task.logger.error(`视频校验未通过: ${validationError}`);
|
|
@@ -45606,6 +45991,17 @@ var __webpack_exports__ = {};
|
|
|
45606
45991
|
task.logger.error(`标题校验未通过: ${titleError}`);
|
|
45607
45992
|
return utils_response(414, titleError, "");
|
|
45608
45993
|
}
|
|
45994
|
+
const unsupported = [
|
|
45995
|
+
params.verticalCoverPath && "verticalCoverPath",
|
|
45996
|
+
params.collection && "collection",
|
|
45997
|
+
params.originalFlag && "originalFlag",
|
|
45998
|
+
params.postWithMemberZoneLink && "postWithMemberZoneLink"
|
|
45999
|
+
].filter(Boolean);
|
|
46000
|
+
if (unsupported.length) task.logger.warn(`RPA 模式不支持以下参数,将被忽略: ${unsupported.join("、")};如需生效请使用 mockApi 模式`);
|
|
46001
|
+
if (params.tagInfo && 5 === params.tagInfo.tagType) {
|
|
46002
|
+
const shootInfo = params.tagInfo.shootInfo;
|
|
46003
|
+
if (shootInfo && (shootInfo.provinceCode || shootInfo.cityCode)) task.logger.warn("tagInfo.tagType=5 在 RPA 模式下仅支持拍摄时间和国家选择,省市选择需要使用 mockApi 模式");
|
|
46004
|
+
}
|
|
45609
46005
|
const tmpCachePath = task.getTmpPath();
|
|
45610
46006
|
const page = await task.createPage({
|
|
45611
46007
|
url: "https://channels.weixin.qq.com/platform/post/create",
|
|
@@ -45716,7 +46112,12 @@ var __webpack_exports__ = {};
|
|
|
45716
46112
|
}
|
|
45717
46113
|
});
|
|
45718
46114
|
}
|
|
45719
|
-
|
|
46115
|
+
const descriptionText = payload_buildDescription({
|
|
46116
|
+
description: params.description,
|
|
46117
|
+
topics: params.topics,
|
|
46118
|
+
mentionedUsers: params.mentionedUsers
|
|
46119
|
+
});
|
|
46120
|
+
if (descriptionText) {
|
|
45720
46121
|
task.logger.info("填写视频描述");
|
|
45721
46122
|
await retryAction(async ()=>{
|
|
45722
46123
|
const descEditor = await waitForElement(".input-editor", 10000);
|
|
@@ -45728,7 +46129,7 @@ var __webpack_exports__ = {};
|
|
|
45728
46129
|
});
|
|
45729
46130
|
await page.waitForTimeout(300);
|
|
45730
46131
|
task.logger.info("已清空编辑器内容");
|
|
45731
|
-
await descEditor.pressSequentially(
|
|
46132
|
+
await descEditor.pressSequentially(descriptionText, {
|
|
45732
46133
|
delay: 10
|
|
45733
46134
|
});
|
|
45734
46135
|
await page.waitForTimeout(500);
|
|
@@ -45763,7 +46164,59 @@ var __webpack_exports__ = {};
|
|
|
45763
46164
|
await poperInstance.nth(1).click();
|
|
45764
46165
|
task.logger.info("地点选择完成");
|
|
45765
46166
|
}
|
|
45766
|
-
if (params.
|
|
46167
|
+
if (params.collection) {
|
|
46168
|
+
task.logger.info(`选择合集: ${params.collection.collectionName}`);
|
|
46169
|
+
const instanceCollection = page.locator(".post-album-display-wrap");
|
|
46170
|
+
await instanceCollection.click();
|
|
46171
|
+
await page.waitForTimeout(1000);
|
|
46172
|
+
page.locator(".post-album-wrap .option-item").filter({
|
|
46173
|
+
hasText: params.collection.collectionName
|
|
46174
|
+
}).first().click({
|
|
46175
|
+
force: true
|
|
46176
|
+
});
|
|
46177
|
+
}
|
|
46178
|
+
if (params.link) {
|
|
46179
|
+
task.logger.info(`设置扩展阅读链接: ${params.link.title}`);
|
|
46180
|
+
await page.locator(".post-link-wrap .link-display-wrap").click();
|
|
46181
|
+
await page.waitForTimeout(300);
|
|
46182
|
+
const linkTypeText = 2 === params.link.urlType ? "红包封面" : "公众号文章";
|
|
46183
|
+
await page.locator(".link-option-item .title-wrap span").filter({
|
|
46184
|
+
hasText: linkTypeText
|
|
46185
|
+
}).click();
|
|
46186
|
+
await page.waitForTimeout(300);
|
|
46187
|
+
const placeholder = 2 === params.link.urlType ? "粘贴红包封面链接" : "粘贴公众号文章链接";
|
|
46188
|
+
await page.locator(`.link-input-wrap input[placeholder="${placeholder}"]`).fill(params.link.link);
|
|
46189
|
+
await page.waitForTimeout(500);
|
|
46190
|
+
task.logger.info(`已设置${linkTypeText}: ${params.link.link}`);
|
|
46191
|
+
}
|
|
46192
|
+
if (params.event) {
|
|
46193
|
+
task.logger.info(`选择活动: ${params.event.eventName}`);
|
|
46194
|
+
await page.locator(".post-activity-wrap .activity-display").click();
|
|
46195
|
+
await page.waitForTimeout(500);
|
|
46196
|
+
await page.locator(".activity-filter-wrap .weui-desktop-form__input[placeholder='搜索活动']").fill(params.event.eventName);
|
|
46197
|
+
await page.waitForTimeout(500);
|
|
46198
|
+
const searchLoading = page.locator(".search-loading");
|
|
46199
|
+
await searchLoading.waitFor({
|
|
46200
|
+
state: "hidden",
|
|
46201
|
+
timeout: 5000
|
|
46202
|
+
}).catch(()=>{
|
|
46203
|
+
task.logger.warn("活动搜索加载超时,继续尝试选择");
|
|
46204
|
+
});
|
|
46205
|
+
const activityItem = page.locator(".option-item .activity-item .activity-item-info .name").filter({
|
|
46206
|
+
hasText: params.event.eventName
|
|
46207
|
+
});
|
|
46208
|
+
const count = await activityItem.count();
|
|
46209
|
+
if (count > 0) {
|
|
46210
|
+
await activityItem.first().click();
|
|
46211
|
+
await page.waitForTimeout(300);
|
|
46212
|
+
task.logger.info(`已选择活动: ${params.event.eventName}`);
|
|
46213
|
+
} else {
|
|
46214
|
+
task.logger.warn(`未找到活动: ${params.event.eventName},将不参与活动`);
|
|
46215
|
+
await page.locator(".post-activity-wrap .activity-display").click();
|
|
46216
|
+
await page.waitForTimeout(300);
|
|
46217
|
+
}
|
|
46218
|
+
}
|
|
46219
|
+
if (params.scheduledTime) {
|
|
45767
46220
|
task.logger.info("设置定时发布");
|
|
45768
46221
|
const timingRadio = page.locator(".weui-desktop-form__check-label").filter({
|
|
45769
46222
|
hasNotText: "不定时"
|
|
@@ -45772,10 +46225,10 @@ var __webpack_exports__ = {};
|
|
|
45772
46225
|
await page.waitForTimeout(500);
|
|
45773
46226
|
const instance = page.locator(".weui-desktop-picker__date");
|
|
45774
46227
|
await instance.click();
|
|
45775
|
-
const dateD = utils_TimeFormatter.format(1000 * params.
|
|
46228
|
+
const dateD = utils_TimeFormatter.format(1000 * params.scheduledTime, "d");
|
|
45776
46229
|
const nowMonth = utils_TimeFormatter.format(Date.now(), "MM月");
|
|
45777
46230
|
const nowMonthText = utils_TimeFormatter.format(Date.now(), "M月");
|
|
45778
|
-
const month = utils_TimeFormatter.format(1000 * params.
|
|
46231
|
+
const month = utils_TimeFormatter.format(1000 * params.scheduledTime, "MM月");
|
|
45779
46232
|
const monthLocator = await page.locator("weui-desktop-picker__panel__label").filter({
|
|
45780
46233
|
hasText: month
|
|
45781
46234
|
}).first();
|
|
@@ -45792,14 +46245,85 @@ var __webpack_exports__ = {};
|
|
|
45792
46245
|
await page.locator(".weui-desktop-picker__table-row td a").filter({
|
|
45793
46246
|
hasText: dateD
|
|
45794
46247
|
}).first().click();
|
|
45795
|
-
await page.locator(".weui-desktop-form__input-wrp input[placeholder*='请选择时间']").fill(utils_TimeFormatter.format(1000 * params.
|
|
46248
|
+
await page.locator(".weui-desktop-form__input-wrp input[placeholder*='请选择时间']").fill(utils_TimeFormatter.format(1000 * params.scheduledTime, "hh:mm"));
|
|
45796
46249
|
await page.locator("i.weui-desktop-icon__time").click();
|
|
45797
46250
|
await page.locator(".post-time-wrap .form-item .label").filter({
|
|
45798
46251
|
hasText: "发表时间"
|
|
45799
46252
|
}).click();
|
|
45800
46253
|
}
|
|
46254
|
+
if (params.tagInfo) {
|
|
46255
|
+
task.logger.info(`设置视频标注: tagType=${params.tagInfo.tagType}`);
|
|
46256
|
+
await page.locator(".mark-tag-select").click();
|
|
46257
|
+
await page.waitForTimeout(300);
|
|
46258
|
+
const tagTypeTextMap = {
|
|
46259
|
+
0: "无需标注",
|
|
46260
|
+
1: "含AI生成内容",
|
|
46261
|
+
2: "内容包含营销广告",
|
|
46262
|
+
3: "内容为虚构剧情,仅供娱乐",
|
|
46263
|
+
5: "内容为自行拍摄",
|
|
46264
|
+
7: "内容为转载",
|
|
46265
|
+
8: "个人观点,仅供参考"
|
|
46266
|
+
};
|
|
46267
|
+
const tagText = tagTypeTextMap[params.tagInfo.tagType];
|
|
46268
|
+
if (tagText) {
|
|
46269
|
+
await page.locator(".mark-tag-option .option-main").filter({
|
|
46270
|
+
hasText: tagText
|
|
46271
|
+
}).click();
|
|
46272
|
+
await page.waitForTimeout(300);
|
|
46273
|
+
if (5 === params.tagInfo.tagType) {
|
|
46274
|
+
const shootInfo = params.tagInfo.shootInfo;
|
|
46275
|
+
if (shootInfo) {
|
|
46276
|
+
task.logger.info("填写拍摄时间和地点...");
|
|
46277
|
+
await page.waitForTimeout(500);
|
|
46278
|
+
if (shootInfo.postTimestamp) {
|
|
46279
|
+
task.logger.info(`设置拍摄时间: ${shootInfo.postTimestamp}`);
|
|
46280
|
+
const timestamp = 1000 * parseInt(shootInfo.postTimestamp, 10);
|
|
46281
|
+
const date = new Date(timestamp);
|
|
46282
|
+
await page.locator(".original-dialog-content .weui-desktop-picker__date input[placeholder*='请选择拍摄时间']").click();
|
|
46283
|
+
await page.waitForTimeout(300);
|
|
46284
|
+
const dayNum = date.getDate();
|
|
46285
|
+
await page.locator(".weui-desktop-picker__table a").filter({
|
|
46286
|
+
hasText: new RegExp(`^\\s*${dayNum}\\s*$`)
|
|
46287
|
+
}).first().click();
|
|
46288
|
+
await page.waitForTimeout(300);
|
|
46289
|
+
}
|
|
46290
|
+
if (shootInfo.countryCode || shootInfo.provinceCode || shootInfo.cityCode) {
|
|
46291
|
+
task.logger.info("设置拍摄地点...");
|
|
46292
|
+
await page.locator(".original-dialog-content .weui-desktop-form__dropdowncascade .weui-desktop-form__dropdowncascade__dt").click();
|
|
46293
|
+
await page.waitForTimeout(300);
|
|
46294
|
+
if (1156 === shootInfo.countryCode) {
|
|
46295
|
+
await page.locator(".weui-desktop-dropdown__list-ele .weui-desktop-dropdown__list-ele__text").filter({
|
|
46296
|
+
hasText: "中国"
|
|
46297
|
+
}).click();
|
|
46298
|
+
await page.waitForTimeout(300);
|
|
46299
|
+
task.logger.warn("RPA 模式下暂不支持选择具体省份和城市,仅选择了国家");
|
|
46300
|
+
} else task.logger.warn(`不支持的国家代码: ${shootInfo.countryCode},跳过地点设置`);
|
|
46301
|
+
}
|
|
46302
|
+
const confirmBtn = await waitForElement(".weui-desktop-dialog .weui-desktop-btn_primary");
|
|
46303
|
+
if (confirmBtn) {
|
|
46304
|
+
await confirmBtn.click();
|
|
46305
|
+
await page.waitForTimeout(300);
|
|
46306
|
+
}
|
|
46307
|
+
} else task.logger.warn("tagType=5 需要提供 shootInfo 字段(拍摄时间和地点)");
|
|
46308
|
+
}
|
|
46309
|
+
if (7 === params.tagInfo.tagType) {
|
|
46310
|
+
const repostSource = params.tagInfo.repostSource;
|
|
46311
|
+
if (repostSource) {
|
|
46312
|
+
task.logger.info(`填写转载来源: ${repostSource}`);
|
|
46313
|
+
await page.waitForTimeout(500);
|
|
46314
|
+
await page.locator(".repost-dialog-content .repost-textarea").fill(repostSource);
|
|
46315
|
+
await page.waitForTimeout(300);
|
|
46316
|
+
const confirmBtn = await waitForElement(".weui-desktop-dialog .weui-desktop-btn_primary");
|
|
46317
|
+
if (confirmBtn) {
|
|
46318
|
+
await confirmBtn.click();
|
|
46319
|
+
await page.waitForTimeout(300);
|
|
46320
|
+
}
|
|
46321
|
+
} else task.logger.warn("tagType=7 需要提供 repostSource 字段(转载来源)");
|
|
46322
|
+
}
|
|
46323
|
+
} else task.logger.warn(`未知的 tagType: ${params.tagInfo.tagType},跳过标注设置`);
|
|
46324
|
+
}
|
|
45801
46325
|
task.logger.info("准备发布...");
|
|
45802
|
-
await page.waitForTimeout(
|
|
46326
|
+
await page.waitForTimeout(500);
|
|
45803
46327
|
let videoId = "";
|
|
45804
46328
|
const handleResponse = async (response)=>{
|
|
45805
46329
|
const url = response.url();
|
|
@@ -45865,19 +46389,60 @@ var __webpack_exports__ = {};
|
|
|
45865
46389
|
};
|
|
45866
46390
|
const ShipinhaoPublishVideoParamsSchema = ActionCommonParamsSchema.extend({
|
|
45867
46391
|
videoPath: classic_schemas_string().min(1),
|
|
46392
|
+
videoMetadata: classic_schemas_object({
|
|
46393
|
+
duration: classic_schemas_number().positive(),
|
|
46394
|
+
width: classic_schemas_number().int().positive(),
|
|
46395
|
+
height: classic_schemas_number().int().positive(),
|
|
46396
|
+
fileSize: classic_schemas_number().int().positive(),
|
|
46397
|
+
path: classic_schemas_string().min(1).optional(),
|
|
46398
|
+
fileName: classic_schemas_string().min(1)
|
|
46399
|
+
}),
|
|
45868
46400
|
coverPath: classic_schemas_string().min(1),
|
|
46401
|
+
verticalCoverPath: classic_schemas_string().min(1).optional(),
|
|
45869
46402
|
description: classic_schemas_string(),
|
|
45870
46403
|
title: classic_schemas_string().optional(),
|
|
45871
|
-
|
|
46404
|
+
scheduledTime: classic_schemas_number().int().positive().optional(),
|
|
46405
|
+
isImmediatelyPublish: classic_schemas_boolean().optional(),
|
|
46406
|
+
topics: classic_schemas_array(classic_schemas_string()).optional(),
|
|
46407
|
+
mentionedUsers: classic_schemas_array(classic_schemas_object({
|
|
46408
|
+
nickname: classic_schemas_string()
|
|
46409
|
+
})).optional(),
|
|
46410
|
+
collection: classic_schemas_object({
|
|
46411
|
+
collectionId: classic_schemas_string(),
|
|
46412
|
+
collectionName: classic_schemas_string()
|
|
46413
|
+
}).optional(),
|
|
46414
|
+
event: classic_schemas_object({
|
|
46415
|
+
eventTopicId: classic_schemas_string(),
|
|
46416
|
+
eventName: classic_schemas_string(),
|
|
46417
|
+
eventCreatorNickname: classic_schemas_string().optional()
|
|
46418
|
+
}).optional(),
|
|
46419
|
+
link: classic_schemas_object({
|
|
46420
|
+
link: classic_schemas_string(),
|
|
46421
|
+
title: classic_schemas_string(),
|
|
46422
|
+
urlType: classic_schemas_number().int().default(1)
|
|
46423
|
+
}).optional(),
|
|
46424
|
+
tagInfo: looseObject({
|
|
46425
|
+
tagType: classic_schemas_number().int()
|
|
46426
|
+
}).optional(),
|
|
46427
|
+
originalFlag: schemas_union([
|
|
46428
|
+
literal(0),
|
|
46429
|
+
literal(1)
|
|
46430
|
+
]).optional(),
|
|
46431
|
+
postWithMemberZoneLink: schemas_union([
|
|
46432
|
+
literal(0),
|
|
46433
|
+
literal(1)
|
|
46434
|
+
]).optional(),
|
|
45872
46435
|
location: classic_schemas_object({
|
|
45873
46436
|
latitude: classic_schemas_number(),
|
|
45874
46437
|
longitude: classic_schemas_number(),
|
|
45875
46438
|
city: classic_schemas_string(),
|
|
46439
|
+
poiName: classic_schemas_string().optional(),
|
|
46440
|
+
address: classic_schemas_string().optional(),
|
|
45876
46441
|
poiClassifyId: classic_schemas_string().optional()
|
|
45877
46442
|
}).optional()
|
|
45878
46443
|
});
|
|
45879
46444
|
const shipinhaoPublishVideo = async (task, params)=>{
|
|
45880
|
-
task.logger.info(`shipinhaoPublishVideo actionType: ${params.actionType}`);
|
|
46445
|
+
task.logger.info(`[shipinhaoPublishVideo] actionType: ${params.actionType}`);
|
|
45881
46446
|
if ("rpa" === params.actionType) return shipinhaoPublishVideo_rpa_rpaAction(task, params);
|
|
45882
46447
|
if ("mockApi" === params.actionType) return shipinhaoPublishVideo_mock_mockAction(task, params);
|
|
45883
46448
|
return executeAction(shipinhaoPublishVideo_mock_mockAction, shipinhaoPublishVideo_rpa_rpaAction)(task, params);
|
|
@@ -51979,4 +52544,4 @@ if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_targe
|
|
|
51979
52544
|
});
|
|
51980
52545
|
|
|
51981
52546
|
//# sourceMappingURL=bundle.js.map
|
|
51982
|
-
//# debugId=
|
|
52547
|
+
//# debugId=ed6f9fc8-db66-5df4-be7c-d5593224a8b2
|