WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 7dadee8

Browse files
committed
Handle empty and short transcripts in AI metadata generation
1 parent 845cb26 commit 7dadee8

File tree

2 files changed

+32
-9
lines changed

2 files changed

+32
-9
lines changed

apps/web/actions/videos/generate-ai-metadata.ts

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,19 @@ export async function generateAiMetadata(
129129
}).pipe(runPromise);
130130

131131
if (Option.isNone(vtt)) {
132-
console.error(`[generateAiMetadata] Transcript is empty`);
133-
throw new Error("Transcript is empty");
134-
} else if (vtt.value.length < 10) {
135-
console.error(
136-
`[generateAiMetadata] Transcript is too short (${vtt.value.length} chars)`,
132+
console.log(
133+
`[generateAiMetadata] Transcript is empty for ${videoId}, skipping AI metadata`,
137134
);
138-
throw new Error("Transcript is too short");
135+
await db()
136+
.update(videos)
137+
.set({
138+
metadata: {
139+
...metadata,
140+
aiProcessing: false,
141+
},
142+
})
143+
.where(eq(videos.id, videoId));
144+
return;
139145
}
140146

141147
const transcriptText = vtt.value
@@ -147,7 +153,24 @@ export async function generateAiMetadata(
147153
!/^\d+$/.test(l.trim()) &&
148154
!l.includes("-->"),
149155
)
150-
.join(" ");
156+
.join(" ")
157+
.trim();
158+
159+
if (transcriptText.length < 10) {
160+
console.log(
161+
`[generateAiMetadata] Transcript content too short for ${videoId} (${transcriptText.length} chars), skipping AI metadata`,
162+
);
163+
await db()
164+
.update(videos)
165+
.set({
166+
metadata: {
167+
...metadata,
168+
aiProcessing: false,
169+
},
170+
})
171+
.where(eq(videos.id, videoId));
172+
return;
173+
}
151174

152175
const prompt = `You are Cap AI. Summarize the transcript and provide JSON in the following format:
153176
{

apps/web/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
"version": "0.3.1",
44
"private": true,
55
"scripts": {
6-
"dev": "dotenv -e ../../.env -- next dev",
6+
"dev": "NODE_OPTIONS='--disable-warning=DEP0169' dotenv -e ../../.env -- next dev",
77
"build": "next build --turbopack",
88
"build:web": "next build --turbopack",
99
"build:docker": "cd ../.. && docker build -t cap-web-docker . --no-cache --progress=plain",
10-
"start": "next start",
10+
"start": "NODE_OPTIONS='--disable-warning=DEP0169' next start",
1111
"compress-images": "bash tools/compress-images.sh"
1212
},
1313
"dependencies": {

0 commit comments

Comments
 (0)