export async function getYoutubeSubscriberCount(): Promise { const apiKey = process.env.YOUTUBE_API_KEY; const channelId = process.env.YOUTUBE_CHANNEL_ID; if (!apiKey || !channelId) return null; try { const res = await fetch( `https://www.googleapis.com/youtube/v3/channels?part=statistics&id=${encodeURIComponent(channelId)}&key=${encodeURIComponent(apiKey)}`, { next: { revalidate: 3600 }, signal: AbortSignal.timeout(5000) } ); if (!res.ok) return null; const data = await res.json(); const count = data.items?.[0]?.statistics?.subscriberCount; return count ? Number(count) : null; } catch { return null; } }