Skip to content

Commit c6d5923

Browse files
author
Miriad
committed
feat: add sanity-plugin-media + file fields + numbered statuses
- Install sanity-plugin-media for browsing all assets in Studio - Add file type fields (audioFile, videoFile, shortFile) alongside URLs so media is previewable directly in Sanity Studio - Pipeline now stores both file references and URLs on upload - Status options now numbered (1-Draft through 6-Published) with descriptions for clarity in Studio - Register media() plugin in sanity.config.ts
1 parent 895f2dc commit c6d5923

5 files changed

Lines changed: 485 additions & 10 deletions

File tree

lib/services/video-pipeline.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,14 @@ export async function processVideoProduction(documentId: string): Promise<void>
144144
const audioUrl = audioResult.url;
145145
console.log(`[VIDEO-PIPELINE] Audio uploaded: ${audioUrl} (${audioResult.size} bytes)`);
146146

147-
// Step 6: Update Sanity doc with audioUrl
148-
await updateStatus(client, documentId, { audioUrl });
147+
// Step 6: Update Sanity doc with audioUrl and file reference
148+
await updateStatus(client, documentId, {
149+
audioUrl,
150+
audioFile: {
151+
_type: 'file',
152+
asset: { _type: 'reference', _ref: audioResult.assetId },
153+
},
154+
});
149155

150156
// Step 7: Fetch B-roll for scenes
151157
console.log(`[VIDEO-PIPELINE] Fetching B-roll for ${script.scenes.length} scenes...`);
@@ -229,12 +235,20 @@ export async function processVideoProduction(documentId: string): Promise<void>
229235
`[VIDEO-PIPELINE] Videos uploaded — main: ${mainUploadResult.url}, short: ${shortUploadResult.url}`
230236
);
231237

232-
// Step 12: Update status to video_gen with video URLs
238+
// Step 12: Update status to video_gen with video URLs and file references
233239
console.log(`[VIDEO-PIPELINE] Updating status to "video_gen" with video URLs`);
234240
await updateStatus(client, documentId, {
235241
status: 'video_gen',
236242
videoUrl: mainUploadResult.url,
243+
videoFile: {
244+
_type: 'file',
245+
asset: { _type: 'reference', _ref: mainUploadResult.assetId },
246+
},
237247
shortUrl: shortUploadResult.url,
248+
shortFile: {
249+
_type: 'file',
250+
asset: { _type: 'reference', _ref: shortUploadResult.assetId },
251+
},
238252
});
239253

240254
console.log(`[VIDEO-PIPELINE] ✅ Pipeline complete for document: ${documentId}`);

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@
105105
"resend": "^6.9.3",
106106
"sanity": "^5.12.0",
107107
"sanity-plugin-cloudinary": "^1.4.1",
108+
"sanity-plugin-media": "^4.1.1",
108109
"server-only": "^0.0.1",
109110
"sonner": "^2.0.7",
110111
"styled-components": "^6.1.19",

0 commit comments

Comments
 (0)