generated from fahricansecer/boilerplate-be
57 lines
2.1 KiB
JavaScript
57 lines
2.1 KiB
JavaScript
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(' ');
|
|
}
|
|
|
|
const ai = new GoogleGenAI({ apiKey: process.env.GEMINI_API_KEY });
|
|
const promptText = `Generate comprehensive SEO metadata and social media content for the following video project.
|
|
|
|
TOPIC: "${videoContentSummary}"
|
|
CURRENT TITLE: "Bier: Sein 13.000 Jahre altes Geheimnis, das Sie nicht kennen? 🤯"
|
|
LANGUAGE: de (generate all text in THIS language)
|
|
|
|
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"
|
|
}
|
|
}`;
|
|
|
|
try {
|
|
const response = await ai.models.generateContent({
|
|
model: 'gemini-2.5-flash',
|
|
contents: promptText,
|
|
config: {
|
|
responseMimeType: 'application/json',
|
|
}
|
|
});
|
|
console.log("RAW TEXT:\n", response.text);
|
|
} catch (err) {
|
|
console.error(err);
|
|
}
|
|
}
|
|
main();
|