@xiaohhhh1/canvas-agent 0.4.62 → 0.4.63
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.
|
@@ -30,11 +30,13 @@ type VideoArchiveUpload = {
|
|
|
30
30
|
publicUrl: string;
|
|
31
31
|
headers?: Record<string, string>;
|
|
32
32
|
maxBytes?: number;
|
|
33
|
+
alreadyUploaded?: boolean;
|
|
34
|
+
downloadUrl?: string | null;
|
|
33
35
|
};
|
|
34
36
|
export declare function shouldUploadVideoArchive(input: {
|
|
35
37
|
kind: "uploaded-mp4" | "tiktok";
|
|
36
38
|
url: string;
|
|
37
|
-
}, publicUrl: string): boolean;
|
|
39
|
+
}, publicUrl: string, alreadyUploaded?: boolean): boolean;
|
|
38
40
|
export declare class LocalVideoIntelligence {
|
|
39
41
|
private readonly fastmoss;
|
|
40
42
|
constructor(fastmoss: FastMossIntegration);
|
|
@@ -10,8 +10,8 @@ const TRANSCRIPT_LANGUAGES = "en.*,es.*,zh.*,pt.*,fr.*,de.*,vi.*,th.*,id.*,ms.*,
|
|
|
10
10
|
const LOCAL_ASR_MODEL = "onnx-community/whisper-base";
|
|
11
11
|
const VIDEO_INTELLIGENCE_SCHEMA_VERSION = "commerce-video-intelligence-v5";
|
|
12
12
|
let localAsrPipeline;
|
|
13
|
-
export function shouldUploadVideoArchive(input, publicUrl) {
|
|
14
|
-
return input.kind !== "uploaded-mp4" || input.url !== publicUrl;
|
|
13
|
+
export function shouldUploadVideoArchive(input, publicUrl, alreadyUploaded = false) {
|
|
14
|
+
return !alreadyUploaded && (input.kind !== "uploaded-mp4" || input.url !== publicUrl);
|
|
15
15
|
}
|
|
16
16
|
export class LocalVideoIntelligence {
|
|
17
17
|
fastmoss;
|
|
@@ -19,7 +19,10 @@ export class LocalVideoIntelligence {
|
|
|
19
19
|
this.fastmoss = fastmoss;
|
|
20
20
|
}
|
|
21
21
|
async archive(source, upload) {
|
|
22
|
-
const
|
|
22
|
+
const verifiedInput = verifiedVideoLearningSource(source);
|
|
23
|
+
const input = upload?.downloadUrl
|
|
24
|
+
? { ...verifiedInput, url: verifiedHttpsUrl(upload.downloadUrl, "站内下载地址无效") }
|
|
25
|
+
: verifiedInput;
|
|
23
26
|
const uploadUrl = verifiedHttpsUrl(upload?.uploadUrl, "站内上传地址无效");
|
|
24
27
|
const publicUrl = verifiedHttpsUrl(upload?.publicUrl, "站内视频地址无效");
|
|
25
28
|
const maxBytes = Math.min(500 * 1024 * 1024, Math.max(1, Number(upload?.maxBytes || 100 * 1024 * 1024)));
|
|
@@ -29,7 +32,7 @@ export class LocalVideoIntelligence {
|
|
|
29
32
|
? await downloadUploadedMp4(input.url, workDir, maxBytes)
|
|
30
33
|
: await downloadVideoArchive(input.url, workDir, maxBytes);
|
|
31
34
|
const bytes = await readFile(downloaded.file);
|
|
32
|
-
if (shouldUploadVideoArchive(input, publicUrl)) {
|
|
35
|
+
if (shouldUploadVideoArchive(input, publicUrl, upload.alreadyUploaded)) {
|
|
33
36
|
const response = await fetch(uploadUrl, {
|
|
34
37
|
method: "PUT",
|
|
35
38
|
headers: { "Content-Type": "video/mp4" },
|