@xiaohhhh1/canvas-agent 0.4.36 → 0.4.37

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.
@@ -46,13 +46,14 @@ export class LocalVideoIntelligence {
46
46
  const sourceUrl = verifiedTikTokSourceUrl(source);
47
47
  const archivedVideoUrl = String(source.archivedVideoUrl || source.archived_video_url || "").trim();
48
48
  const archivedTranscript = String(source.archivedTranscript || source.archived_transcript || "").trim();
49
+ const hasArchivedMedia = Boolean(archivedVideoUrl);
49
50
  const mediaUrl = archivedVideoUrl ? verifiedHttpsUrl(archivedVideoUrl, "站内视频副本地址无效") : sourceUrl;
50
51
  const platformVideoId = String(source.platformVideoId || source.platform_video_id || "").trim();
51
52
  const workDir = await mkdtemp(path.join(os.tmpdir(), "canvas-video-intelligence-"));
52
53
  try {
53
54
  const [visualEvidence, transcript] = await Promise.all([
54
55
  this.fastmoss.capturePublicVideoFrames(mediaUrl, platformVideoId),
55
- archivedTranscript ? Promise.resolve(archivedTranscript) : extractTimedTranscript(sourceUrl, workDir),
56
+ hasArchivedMedia ? Promise.resolve(archivedTranscript) : extractTimedTranscript(sourceUrl, workDir),
56
57
  ]);
57
58
  if (!visualEvidence.frames.length)
58
59
  throw new Error("没有取得任何真实视频画面,已停止分析");
@@ -69,7 +70,7 @@ export class LocalVideoIntelligence {
69
70
  frameCount: attachments.length,
70
71
  transcriptCueCount: transcript.split("\n").filter(Boolean).length,
71
72
  visualSource: archivedVideoUrl ? "website-archive" : visualEvidence.playerUrl,
72
- transcriptSource: archivedTranscript ? "website-archive" : "TikTok native/automatic timed captions via local yt-dlp",
73
+ transcriptSource: hasArchivedMedia ? "website-archive" : "TikTok native/automatic timed captions via local yt-dlp",
73
74
  },
74
75
  };
75
76
  }
@@ -240,7 +241,8 @@ async function downloadVideoArchive(sourceUrl, workDir, maxBytes) {
240
241
  throw new Error("视频下载完成但没有生成 MP4 文件");
241
242
  if (video.size > maxBytes)
242
243
  throw new Error(`视频超过站内存储上限(${Math.ceil(maxBytes / 1024 / 1024)} MiB)`);
243
- return { file: video.file, transcript: await transcriptFromDirectory(workDir, lastError) };
244
+ const transcript = await transcriptFromDirectory(workDir, lastError).catch(() => "");
245
+ return { file: video.file, transcript };
244
246
  }
245
247
  async function transcriptFromDirectory(workDir, lastError = "") {
246
248
  const subtitleFiles = (await readdir(workDir)).filter((name) => name.toLowerCase().endsWith(".vtt"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xiaohhhh1/canvas-agent",
3
- "version": "0.4.36",
3
+ "version": "0.4.37",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",