(videoId: string)
| 96 | } |
| 97 | |
| 98 | async 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 | |
| 152 | async function markSkipped(videoId: string): Promise<void> { |
| 153 | "use step"; |
no test coverage detected