@iflyrpa/actions 4.0.9-beta.4 → 4.1.0-beta.5
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 +51 -0
- package/dist/actions/shipinhaoPublishVideo/mock.d.ts +4 -0
- package/dist/actions/shipinhaoPublishVideo/rpa.d.ts +6 -0
- package/dist/actions/shipinhaoPublishVideo/uploader.d.ts +38 -0
- package/dist/actions/shipinhaoPublishVideo/videoMeta.d.ts +27 -0
- package/dist/actions/shipinhaoPublishVideo/videoValidator.d.ts +35 -0
- package/dist/bundle.js +1127 -8
- package/dist/bundle.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +1127 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1127 -9
- package/dist/index.mjs.map +1 -1
- package/dist/utils/http.d.ts +7 -0
- package/dist/utils/imageValidator.d.ts +67 -0
- package/dist/utils/shipinhao/auth.d.ts +31 -0
- package/package.json +1 -1
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { CommonAction } from "@iflyrpa/share";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
export declare const ShipinhaoPublishVideoParamsSchema: z.ZodObject<{
|
|
4
|
+
id: z.ZodOptional<z.ZodString>;
|
|
5
|
+
userAgent: z.ZodOptional<z.ZodString>;
|
|
6
|
+
viewport: z.ZodNullable<z.ZodOptional<z.ZodObject<{
|
|
7
|
+
width: z.ZodNumber;
|
|
8
|
+
height: z.ZodNumber;
|
|
9
|
+
}, z.core.$strip>>>;
|
|
10
|
+
url: z.ZodOptional<z.ZodString>;
|
|
11
|
+
cookies: z.ZodArray<z.ZodObject<{
|
|
12
|
+
name: z.ZodString;
|
|
13
|
+
value: z.ZodString;
|
|
14
|
+
domain: z.ZodOptional<z.ZodString>;
|
|
15
|
+
path: z.ZodOptional<z.ZodString>;
|
|
16
|
+
expires: z.ZodOptional<z.ZodNumber>;
|
|
17
|
+
httpOnly: z.ZodOptional<z.ZodBoolean>;
|
|
18
|
+
secure: z.ZodOptional<z.ZodBoolean>;
|
|
19
|
+
}, z.core.$catchall<z.ZodUnknown>>>;
|
|
20
|
+
localStorage: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
21
|
+
key: z.ZodString;
|
|
22
|
+
value: z.ZodString;
|
|
23
|
+
}, z.core.$catchall<z.ZodUnknown>>>>;
|
|
24
|
+
extraParam: z.ZodOptional<z.ZodAny>;
|
|
25
|
+
actionType: z.ZodOptional<z.ZodEnum<{
|
|
26
|
+
mockApi: "mockApi";
|
|
27
|
+
rpa: "rpa";
|
|
28
|
+
server: "server";
|
|
29
|
+
}>>;
|
|
30
|
+
accountId: z.ZodOptional<z.ZodNumber>;
|
|
31
|
+
proxyLoc: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
32
|
+
localIP: z.ZodOptional<z.ZodString>;
|
|
33
|
+
huiwenToken: z.ZodOptional<z.ZodString>;
|
|
34
|
+
articleId: z.ZodOptional<z.ZodString>;
|
|
35
|
+
saveType: z.ZodOptional<z.ZodString>;
|
|
36
|
+
uid: z.ZodOptional<z.ZodString>;
|
|
37
|
+
videoPath: z.ZodString;
|
|
38
|
+
coverPath: z.ZodString;
|
|
39
|
+
description: z.ZodString;
|
|
40
|
+
title: z.ZodOptional<z.ZodString>;
|
|
41
|
+
scheduleTime: z.ZodOptional<z.ZodNumber>;
|
|
42
|
+
location: z.ZodOptional<z.ZodObject<{
|
|
43
|
+
latitude: z.ZodNumber;
|
|
44
|
+
longitude: z.ZodNumber;
|
|
45
|
+
city: z.ZodString;
|
|
46
|
+
poiClassifyId: z.ZodOptional<z.ZodString>;
|
|
47
|
+
}, z.core.$strip>>;
|
|
48
|
+
}, z.core.$strip>;
|
|
49
|
+
export type ShipinhaoPublishVideoParams = z.infer<typeof ShipinhaoPublishVideoParamsSchema>;
|
|
50
|
+
export type PublishVideoAction = CommonAction<ShipinhaoPublishVideoParams, string>;
|
|
51
|
+
export declare const shipinhaoPublishVideo: PublishVideoAction;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 视频号 CDN 上传器(视频 20302 / 封面 20304)
|
|
3
|
+
*
|
|
4
|
+
* 三阶段:applyupload → uploadpart×N → completepart
|
|
5
|
+
* 分片大小 8MB,ETag 用本地 MD5 拼装(服务端 ETag == 分片 MD5 已实测确认)
|
|
6
|
+
* 支持秒传/续传:同 taskid 已传分片服务端保留,不必重传
|
|
7
|
+
*
|
|
8
|
+
* 数据来源:network-logs.json (8/20) + network-logs1.json (8/19)
|
|
9
|
+
*/
|
|
10
|
+
import type { Http } from "../../utils/http";
|
|
11
|
+
export interface UploadOptions {
|
|
12
|
+
filePath: string;
|
|
13
|
+
/** filetype: 20302=视频, 20304=封面 */
|
|
14
|
+
fileType: number;
|
|
15
|
+
uin: number;
|
|
16
|
+
authKey: string;
|
|
17
|
+
http: Http;
|
|
18
|
+
logger?: {
|
|
19
|
+
info: (msg: string) => void;
|
|
20
|
+
error: (msg: string, ...args: any[]) => void;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export interface UploadResult {
|
|
24
|
+
/** completepart 返回的 DownloadURL */
|
|
25
|
+
downloadUrl: string;
|
|
26
|
+
/** 文件 MD5 */
|
|
27
|
+
md5: string;
|
|
28
|
+
fileSize: number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* 上传单个文件到视频号 CDN
|
|
32
|
+
*
|
|
33
|
+
* @param opts.filePath 本地文件路径
|
|
34
|
+
* @param opts.fileType 20302=视频 / 20304=封面
|
|
35
|
+
* @param opts.uin weixinnum
|
|
36
|
+
* @param opts.authKey Authorization 头
|
|
37
|
+
*/
|
|
38
|
+
export declare function uploadFile(opts: UploadOptions): Promise<UploadResult>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 从 MP4 文件解析视频元数据(宽高、时长)
|
|
3
|
+
*
|
|
4
|
+
* 算法来源:scripts/api-explorer/shipinhao-video-upload/mp4-parse-poc.mjs
|
|
5
|
+
* 已通过合成样本 8/8 + 真实 Chrome 编码视频交叉验证(见该 PoC)。
|
|
6
|
+
*
|
|
7
|
+
* 只读 ISO BMFF box 头部做跳转,不解码帧数据,内存占用与文件大小无关。
|
|
8
|
+
* 支持 MP4(ISO base media file format),不支持 AVI/MKV/FLV。
|
|
9
|
+
*
|
|
10
|
+
* @param filePath 本地视频文件路径
|
|
11
|
+
* @returns {width, height, duration, rotation, fileSize} 或 null(解析失败)
|
|
12
|
+
*/
|
|
13
|
+
export interface VideoMeta {
|
|
14
|
+
width: number;
|
|
15
|
+
height: number;
|
|
16
|
+
/** 时长(秒,浮点数) */
|
|
17
|
+
duration: number;
|
|
18
|
+
/** 旋转角度(0/90/180/270),手机竖屏视频常为 90 */
|
|
19
|
+
rotation: number;
|
|
20
|
+
fileSize: number;
|
|
21
|
+
/**
|
|
22
|
+
* 视频轨编码格式(stsd 里的 sample entry fourcc,小写)
|
|
23
|
+
* H.264 为 avc1/avc3,H.265 为 hvc1/hev1,解析不到时为 null
|
|
24
|
+
*/
|
|
25
|
+
codec: string | null;
|
|
26
|
+
}
|
|
27
|
+
export declare function parseVideoMeta(filePath: string): VideoMeta | null;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { VideoMeta } from "./videoMeta";
|
|
2
|
+
/**
|
|
3
|
+
* 视频号视频发布前的本地校验
|
|
4
|
+
*
|
|
5
|
+
* 平台限制:时长 8 小时内、大小不超过 20GB、格式为 MP4/H.264。
|
|
6
|
+
* 在上传前拦截,避免把超限文件传完才被服务端拒绝。
|
|
7
|
+
*/
|
|
8
|
+
/** 时长上限:8 小时 */
|
|
9
|
+
export declare const MAX_DURATION_SECONDS: number;
|
|
10
|
+
/** 大小上限:20GB */
|
|
11
|
+
export declare const MAX_FILE_SIZE: number;
|
|
12
|
+
/** 容器格式白名单 */
|
|
13
|
+
export declare const ALLOWED_EXTENSIONS: readonly [".mp4"];
|
|
14
|
+
/** 视频轨编码白名单(ISO BMFF sample entry fourcc):H.264 */
|
|
15
|
+
export declare const ALLOWED_CODECS: readonly ["avc1", "avc3"];
|
|
16
|
+
/** 标题最少字符数 */
|
|
17
|
+
export declare const MIN_TITLE_LENGTH = 6;
|
|
18
|
+
/**
|
|
19
|
+
* 校验视频是否满足视频号限制
|
|
20
|
+
*
|
|
21
|
+
* @param filePath 视频文件路径(用于取扩展名和文件名做提示)
|
|
22
|
+
* @param meta parseVideoMeta 的解析结果
|
|
23
|
+
* @returns 不满足时返回中文错误提示,满足时返回 null
|
|
24
|
+
*/
|
|
25
|
+
export declare function validateShipinhaoVideo(filePath: string, meta: VideoMeta): string | null;
|
|
26
|
+
/**
|
|
27
|
+
* 校验标题是否满足视频号限制
|
|
28
|
+
*
|
|
29
|
+
* 标题为可选参数:未传时不校验;传了就必须满足最少字符数。
|
|
30
|
+
* 按 Unicode 码点计数,避免 emoji 等字符被算成多个。
|
|
31
|
+
*
|
|
32
|
+
* @param title 标题,可为空
|
|
33
|
+
* @returns 不满足时返回中文错误提示,满足时返回 null
|
|
34
|
+
*/
|
|
35
|
+
export declare function validateShipinhaoTitle(title?: string): string | null;
|