How pkanderi-abio/youtube-autopilot works
Purpose and Entry Points
YouTube Autopilot is a GitHub Actions-driven, unattended video-production system for multiple YouTube channels. It discovers topics, creates short- and long-form videos, schedules uploads, and records channel history. The primary runtime entry point is backend/src/run-pipeline.js; scheduled orchestration is defined in .github/workflows/pipeline.yml. The static dashboard begins at frontend/index.html.
Channel Configuration and Persistent State
Channels, their topic strategy, formats, and cadence are centrally defined in backend/config/channels.json. Pipeline state and publishing history are maintained as committed JSON data, including backend/data/history-channel1.json and backend/data/history-channel2.json. This makes GitHub repository state both the durable record and the dashboard’s primary data source.
Pipeline Orchestrator
backend/src/run-pipeline.js coordinates the numbered production stages, selects applicable channel/format work, tracks stage outcomes, and establishes the failure boundary for a run. Shared state handling is isolated in backend/src/lib/state.js, while channel-specific historical performance can be accessed through backend/src/lib/analytics.js.
Topic Discovery and Content Generation
The first stage, backend/src/steps/1-discover-topic.js, chooses either current trends or a configured evergreen pool. Trend acquisition is abstracted by backend/src/lib/trends.js. Script generation in backend/src/steps/2-generate-script.js uses the local LLM integration in backend/src/lib/llm.js, so generative text does not require a paid hosted model API. backend/src/steps/3-optimize-seo.js transforms the content into YouTube-oriented metadata.
Media Production
Voice generation is performed by backend/src/steps/4-generate-voice.js. Background creation in backend/src/steps/5-generate-background.js uses stock footage through backend/src/lib/stockFootage.js, with a gradient fallback when usable footage is unavailable. Video assembly is performed by backend/src/steps/6-assemble-video.js, implying a local ffmpeg runtime boundary. Nursery audio assets and their lookup manifest are held under backend/audio/nursery/ and backend/audio/nursery-manifest.json, accessed through backend/src/lib/nurseryAudio.js.
Publishing and External Boundaries
Thumbnail generation is a distinct late-stage artifact step in backend/src/steps/7-generate-thumbnail.js. backend/src/steps/8-upload-youtube.js publishes and schedules completed media through the YouTube integration in backend/src/lib/youtube.js. External service boundaries are YouTube APIs, Pexels’ stock-footage API, local Ollama, free TTS tooling, and ffmpeg; credentials are expected through environment configuration such as backend/.env.example.
Automation, Analytics, and Dashboard
GitHub Actions supplies cron execution and repository-write automation via .github/workflows/pipeline.yml. Post-publication analytics can be fetched with backend/scripts/fetch-analytics.js and persisted in files such as backend/data/analytics-channel1.json; .github/workflows/analytics.yml likely schedules this independently. The frontend is a static control panel whose data is assembled by frontend/build-data.js and rendered by frontend/index.html, separating operational visualization from the production runtime.
Main entry points: run-pipeline.js Run pipeline · 1-discover-topic.js Discover topic · 2-generate-script.js Generate script · 4-generate-voice.js Generate voice
Components 23
Automation
- Pipeline workflow · Cron-triggered repository-write automation.
.github/workflows/pipeline.yml - Analytics workflow
.github/workflows/analytics.yml
Production Pipeline
- Channel configuration · Defines channel strategy, formats, and cadence.
backend/config/channels.json - Run pipeline · Selects work, coordinates stages, and owns run failures.
backend/src/run-pipeline.js - State handling
backend/src/lib/state.js - Channel history
backend/data/history-channel1.json - Discover topic · Chooses trend or evergreen topics.
backend/src/steps/1-discover-topic.js - Generate script
backend/src/steps/2-generate-script.js - Optimize SEO · Produces YouTube-oriented metadata.
backend/src/steps/3-optimize-seo.js - Trend sources
backend/src/lib/trends.js - Local Ollama
backend/src/lib/llm.js
Media Runtime
- Generate voice
backend/src/steps/4-generate-voice.js - Generate background · Uses footage or a gradient fallback.
backend/src/steps/5-generate-background.js - Assemble video
backend/src/steps/6-assemble-video.js - Pexels API
backend/src/lib/stockFootage.js - TTS and ffmpeg
Publishing & Analytics
- Generate thumbnail
backend/src/steps/7-generate-thumbnail.js - Upload YouTube · Publishes and schedules completed media.
backend/src/steps/8-upload-youtube.js - YouTube APIs
backend/src/lib/youtube.js - Fetch analytics · Persists post-publication channel metrics.
backend/scripts/fetch-analytics.js - Channel analytics
backend/data/analytics-channel1.json
Dashboard
- Build dashboard data
frontend/build-data.js - Static dashboard
frontend/index.html
Connections 24
- Pipeline workflow → Run pipeline: runs
- Run pipeline → Channel configuration: reads
- Run pipeline → State handling: uses
- State handling → Channel history: updates
- Run pipeline → Discover topic: starts
- Discover topic → Trend sources: gets trends
- Discover topic → Generate script: topic
- Generate script → Local Ollama: generates via
- Generate script → Optimize SEO: script
- Optimize SEO → Generate voice: content
- Generate voice → TTS and ffmpeg: TTS
- Generate voice → Generate background: audio
- Generate background → Pexels API: fetches footage
- Generate background → Assemble video: visuals
- Assemble video → TTS and ffmpeg: ffmpeg
- Assemble video → Generate thumbnail: video
- Generate thumbnail → Upload YouTube: media package
- Upload YouTube → YouTube APIs: publishes
- Analytics workflow → Fetch analytics: runs
- Fetch analytics → YouTube APIs: retrieves metrics
- Fetch analytics → Channel analytics: persists
- Channel history → Build dashboard data: supplies state
- Channel analytics → Build dashboard data: supplies metrics
- Build dashboard data → Static dashboard: builds data for