1212import { createClient , type SanityClient } from 'next-sanity' ;
1313import { apiVersion , dataset , projectId } from '@/sanity/lib/api' ;
1414import { generateSpeechFromScript } from '@/lib/services/elevenlabs' ;
15- import { uploadAudio , uploadVideo } from '@/lib/services/gcs ' ;
15+ import { uploadAudioToSanity , uploadVideoToSanity } from '@/lib/services/sanity-upload ' ;
1616import { getBRollForScenes } from '@/lib/services/pexels' ;
1717import { renderBothFormats } from '@/lib/services/remotion' ;
1818
@@ -87,10 +87,10 @@ async function updateStatus(
8787 * 1. Fetch document from Sanity
8888 * 2. Validate script structure
8989 * 3. Generate TTS audio (ElevenLabs)
90- * 4. Upload audio to GCS
90+ * 4. Upload audio to Sanity
9191 * 5. Fetch B-roll clips (Pexels)
9292 * 6. Render both video formats (Remotion Lambda)
93- * 7. Upload videos to GCS
93+ * 7. Upload videos to Sanity
9494 * 8. Update Sanity with video URLs and status
9595 *
9696 * On failure: sets status to "flagged" with flaggedReason.
@@ -138,9 +138,9 @@ export async function processVideoProduction(documentId: string): Promise<void>
138138 } ) ;
139139 console . log ( `[VIDEO-PIPELINE] TTS audio generated: ${ audioBuffer . length } bytes` ) ;
140140
141- // Step 5: Upload audio to GCS
142- console . log ( `[VIDEO-PIPELINE] Uploading audio to GCS ...` ) ;
143- const audioResult = await uploadAudio ( audioBuffer , documentId ) ;
141+ // Step 5: Upload audio to Sanity
142+ console . log ( `[VIDEO-PIPELINE] Uploading audio to Sanity ...` ) ;
143+ const audioResult = await uploadAudioToSanity ( audioBuffer , ` ${ documentId } .mp3` ) ;
144144 const audioUrl = audioResult . url ;
145145 console . log ( `[VIDEO-PIPELINE] Audio uploaded: ${ audioUrl } (${ audioResult . size } bytes)` ) ;
146146
@@ -201,8 +201,8 @@ export async function processVideoProduction(documentId: string): Promise<void>
201201 `[VIDEO-PIPELINE] Render complete — main: ${ renderResults . main . fileSizeBytes } bytes, short: ${ renderResults . short . fileSizeBytes } bytes`
202202 ) ;
203203
204- // Step 11: Download rendered videos and upload to GCS
205- console . log ( `[VIDEO-PIPELINE] Downloading and re-uploading rendered videos to GCS ...` ) ;
204+ // Step 11: Download rendered videos and upload to Sanity
205+ console . log ( `[VIDEO-PIPELINE] Downloading and re-uploading rendered videos to Sanity ...` ) ;
206206 const [ mainVideoResponse , shortVideoResponse ] = await Promise . all ( [
207207 fetch ( renderResults . main . videoUrl ) ,
208208 fetch ( renderResults . short . videoUrl ) ,
@@ -221,8 +221,8 @@ export async function processVideoProduction(documentId: string): Promise<void>
221221 ] ) ;
222222
223223 const [ mainUploadResult , shortUploadResult ] = await Promise . all ( [
224- uploadVideo ( mainVideoBuffer , documentId , ' main' ) ,
225- uploadVideo ( shortVideoBuffer , documentId , ' short' ) ,
224+ uploadVideoToSanity ( mainVideoBuffer , ` ${ documentId } - main.mp4` ) ,
225+ uploadVideoToSanity ( shortVideoBuffer , ` ${ documentId } - short.mp4` ) ,
226226 ] ) ;
227227
228228 console . log (
0 commit comments