Skip to content

🎬 Open-source, self-hosted AI agent that runs a YouTube channel end to end: researches topics, writes scripts, generates narration, visuals and video, optimizes SEO, and publishes after your approval, then learns from analytics. Works with Gemini, OpenAI, OpenRouter, DeepSeek and more.

v2.2.1: Fix dashboard when API_KEY is set; fix always-red status indicator

darkzOGx890fb4736f3d
diff --git a/dashboard/index.html b/dashboard/index.html
index 5eec977..cf689c2 100644
--- a/dashboard/index.html
+++ b/dashboard/index.html
@@ -285,7 +285,7 @@
overview.innerHTML = `
<p><strong>Status:</strong> ${data.initialized ? 'Initialized' : 'Initializing'}</p>
<p><strong>Agents Active:</strong> ${data.agents ? data.agents.length : 0}/7</p>
- <p><strong>Uptime:</strong> ${formatUptime(process?.uptime?.() || 0)}</p>
+ <p><strong>Uptime:</strong> ${formatUptime(data.uptime || 0)}</p>
<p><strong>Last Updated:</strong> ${new Date().toLocaleTimeString()}</p>
`;
@@ -372,20 +372,56 @@
return `${hours}h ${minutes}m`;
}
+ // API key handling for protected endpoints (API_KEY in .env)
+ function getStoredApiKey() {
+ return localStorage.getItem('yaa_api_key') || '';
+ }
+
+ function promptForApiKey() {
+ const key = prompt('This server requires an API key (the API_KEY value from your .env):', getStoredApiKey());
+ if (key === null) return null; // user cancelled
+ localStorage.setItem('yaa_api_key', key.trim());
+ return key.trim();
+ }
+
+ async function postWithApiKey(url, body) {
+ const doFetch = (key) => fetch(url, {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ ...(key ? { 'x-api-key': key } : {})
+ },
+ body: JSON.stringify(body)
+ });
+
+ let response = await doFetch(getStoredApiKey());
+ if (response.status === 401) {
+ const key = promptForApiKey();
+ if (key !== null) {
+ response = await doFetch(key);
+ }
+ }
+ return response;
+ }
+
async function generateContent() {
- if (confirm('Generate content now? This will create a new video for your channel.')) {
- try {
- const response = await fetch('/generate', {
- method: 'POST',
- headers: { 'Content-Type': 'application/json' },
- body: JSON.stringify({ topic: null, style: 'story' })
- });
- const result = await response.json();
- alert(`Content generation started! Title: ${result.result?.title || 'New Content'}`);
- refreshDashboard();
- } catch (error) {
- alert('Content generation failed. Please try again.');
+ if (!confirm('Generate content now? This will create a new video for your channel.')) {
+ return;
+ }
+
+ try {
+ const response = await postWithApiKey('/generate', { topic: null, style: 'story' });
+ const result = await response.json().catch(() => ({}));
+
+ if (!response.ok) {
+ alert(`Content generation failed: ${result.error || response.statusText}`);
+ return;
}
+
+ alert(`Content generation started! Title: ${result.result?.title || 'New Content'}`);
+ refreshDashboard();
+ } catch (error) {
+ alert('Content generation failed. Please try again.');
}
}
diff --git a/index.js b/index.js
index fe00824..951b776 100644
--- a/index.js
+++ b/index.js
@@ -208,6 +208,7 @@ class YouTubeAutomationAgent {
status: 'healthy',
initialized: this.isInitialized,
agents: Object.keys(this.agents),
+ uptime: process.uptime(),
timestamp: new Date().toISOString()
});
});
diff --git a/package.json b/package.json
index b080d02..48a9d70 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "youtube-automation-agent",
- "version": "2.2.0",
+ "version": "2.2.1",
"description": "Fully automated YouTube channel management system with specialized AI agents",
"main": "index.js",
"scripts": {