MCPcopy
hub / github.com/CapSoftware/Cap / validateVideo

Function validateVideo

apps/web/workflows/transcribe.ts:98–150  ·  view source on GitHub ↗
(videoId: string)

Source from the content-addressed store, hash-verified

96}
97
98async function validateVideo(videoId: string): Promise<VideoData> {
99 "use step";
100
101 if (!serverEnv().DEEPGRAM_API_KEY) {
102 throw new FatalError("Missing DEEPGRAM_API_KEY");
103 }
104
105 const query = await db()
106 .select({
107 video: videos,
108 settings: videos.settings,
109 orgSettings: organizations.settings,
110 owner: users,
111 })
112 .from(videos)
113 .leftJoin(organizations, eq(videos.orgId, organizations.id))
114 .innerJoin(users, eq(videos.ownerId, users.id))
115 .where(eq(videos.id, videoId as Video.VideoId));
116
117 if (query.length === 0) {
118 throw new FatalError("Video does not exist");
119 }
120
121 const result = query[0];
122 if (!result?.video) {
123 throw new FatalError("Video information is missing");
124 }
125
126 const transcriptionDisabled =
127 result.video.settings?.disableTranscript ??
128 result.orgSettings?.disableTranscript ??
129 false;
130
131 const isOwnerPro = userIsPro(result.owner);
132
133 console.log(
134 `[transcribe] Owner check: stripeSubscriptionStatus=${result.owner.stripeSubscriptionStatus}, thirdPartyStripeSubscriptionId=${result.owner.thirdPartyStripeSubscriptionId}, isOwnerPro=${isOwnerPro}`,
135 );
136
137 await db()
138 .update(videos)
139 .set({ transcriptionStatus: "PROCESSING" })
140 .where(eq(videos.id, videoId as Video.VideoId));
141
142 return {
143 video: result.video,
144 transcriptionDisabled,
145 isOwnerPro,
146 aiGenerationLanguage: parseAiGenerationLanguage(
147 result.orgSettings?.aiGenerationLanguage,
148 ),
149 };
150}
151
152async function markSkipped(videoId: string): Promise<void> {
153 "use step";

Callers 1

transcribeVideoWorkflowFunction · 0.85

Calls 5

serverEnvFunction · 0.90
dbFunction · 0.90
userIsProFunction · 0.90
updateMethod · 0.80

Tested by

no test coverage detected