async function analyzeVideo(videoId: string) {
const apiKey = process.env.YT_API_KEY;
// 1. Get video metadata
const videoResponse = await fetch(
`https://api.scriptbase.app/api/v1/videos/${videoId}?includeTranscript=true`,
{ headers: { 'X-API-Key': apiKey } }
);
const { data: video } = await videoResponse.json();
// 2. Analyze the content
const analysis = {
title: video.title,
channel: video.channel.name,
duration: video.duration,
views: video.viewCount,
transcript: video.transcript.content,
wordCount: video.transcript.content.split(' ').length,
// Add your analysis logic here
};
return analysis;
}