const { PrismaClient } = require('@prisma/client'); const { GoogleGenAI } = require('@google/genai'); const prisma = new PrismaClient(); async function main() { const project = await prisma.project.findUnique({ where: { id: '686d6496-2963-4527-8703-02b843e50159' } }); const scriptJson = project.scriptJson || {}; let videoContentSummary = project.title; if (scriptJson.scenes && Array.isArray(scriptJson.scenes)) { videoContentSummary = scriptJson.scenes.map((s) => s.narration).join(' '); } else if (project.prompt) { videoContentSummary = project.prompt.substring(0, 1000); } const promptText = `Generate comprehensive SEO metadata and social media content for the following video project. TOPIC: "${videoContentSummary.substring(0, 2000)}" CURRENT TITLE: "${project.title}" LANGUAGE: ${project.language} (generate all text in THIS language) EXISTING KEYWORDS: ${(project.seoKeywords || []).join(', ')} Return ONLY valid JSON matching this exact structure, with no markdown formatting or backticks: { "seo": { "title": "SEO optimized title (under 60 chars)", "description": "Meta description (150-200 chars)", "keywords": ["keyword1", "keyword2", "keyword3", "keyword4", "keyword5"], "hashtags": ["#hashtag1", "#hashtag2", "#hashtag3"], "trendingHashtags": ["#trending1", "#trending2"], "estimatedSearchVolume": "Summary of search volume for keywords", "schemaMarkup": { "@type": "VideoObject", "name": "..." } }, "socialContent": { "youtubeTitle": "Clickable YouTube title with emojis", "youtubeDescription": "Full YouTube description including hashtags and call to actions", "tiktokCaption": "Catchy TikTok caption with trending hashtags", "instagramCaption": "Engaging Instagram caption with emojis and hashtags", "twitterText": "Viral X (Twitter) post text under 280 characters" } }`; const ai = new GoogleGenAI({ apiKey: process.env.GEMINI_API_KEY }); try { const response = await ai.models.generateContent({ model: 'gemini-2.5-flash', // Trying flash 8b if flash not found, or maybe just 'gemini-1.5-flash' contents: promptText, config: { temperature: 0.8, topP: 0.95, maxOutputTokens: 2048, responseMimeType: 'text/plain', }, }); console.log("RAW TEXT:\n", response.text); } catch (err) { if (err.status === 404) { try { const response2 = await ai.models.generateContent({ model: 'gemini-1.5-flash', contents: promptText, config: { temperature: 0.8, topP: 0.95, maxOutputTokens: 2048, responseMimeType: 'text/plain', }, }); console.log("RAW TEXT:\n", response2.text); } catch (err2) { console.error("Failed again:", err2); } } else { console.error(err); } } } main();