MCPcopy Index your code
hub / github.com/CapSoftware/Cap / fetchTranscript

Function fetchTranscript

apps/web/workflows/generate-ai.ts:150–179  ·  view source on GitHub ↗
(
	videoId: string,
	userId: string,
	video: typeof videos.$inferSelect,
)

Source from the content-addressed store, hash-verified

148}
149
150async function fetchTranscript(
151 videoId: string,
152 userId: string,
153 video: typeof videos.$inferSelect,
154): Promise<TranscriptData | null> {
155 "use step";
156
157 const vtt = await Effect.gen(function* () {
158 const [bucket] = yield* Storage.getAccessForVideo(
159 decodeStorageVideo(video),
160 );
161 return yield* bucket.getObject(`${userId}/${videoId}/transcription.vtt`);
162 }).pipe(runPromise);
163
164 if (Option.isNone(vtt)) {
165 return null;
166 }
167
168 const segments = parseVttWithTimestamps(vtt.value);
169 const text = segments
170 .map((s) => s.text)
171 .join(" ")
172 .trim();
173
174 if (text.length < 10) {
175 return null;
176 }
177
178 return { segments, text };
179}
180
181async function markSkipped(
182 videoId: string,

Callers 1

generateAiWorkflowFunction · 0.85

Calls 2

decodeStorageVideoFunction · 0.90
parseVttWithTimestampsFunction · 0.85

Tested by

no test coverage detected