// Test YouTube API key
const https = require('https');

const API_KEY = 'AIzaSyCn5pHLCpvmaIH5sG2HL_JBwRgfp36oq3g';

function testAPI() {
  const url = `https://www.googleapis.com/youtube/v3/search?key=${API_KEY}&part=snippet&q=music&type=video&maxResults=1`;
  
  https.get(url, (res) => {
    let data = '';
    
    res.on('data', (chunk) => {
      data += chunk;
    });
    
    res.on('end', () => {
      console.log('Status Code:', res.statusCode);
      
      if (res.statusCode === 200) {
        const response = JSON.parse(data);
        console.log('✅ API Key is working!');
        console.log('Items found:', response.items?.length || 0);
        if (response.items?.length > 0) {
          console.log('Sample result:', response.items[0].snippet.title);
        }
      } else {
        console.log('❌ API Key failed with status:', res.statusCode);
        console.log('Response:', data);
      }
    });
  }).on('error', (err) => {
    console.error('Error:', err.message);
  });
}

testAPI();