Automated YouTube video generation, upload, and optimization pipeline. A production-ready CLI tool for creating faceless YouTube channels with intelligent content selection, A/B testing, and adaptive learning.
- Channel Blueprints: YAML-based configuration with Zod validation
- Dual-Format Support: Shorts (< 60s) and Longform videos with auto-switching
- Multi-Stage Pipeline: Research → Plan → Script → TTS → Visuals → Edit → Package → Upload → A/B Test → Report
- Adaptive Learning: Daily analytics processing with winner/loser detection and policy weight updates
- Scheduler Daemon: Ramp-up phases, jitter, caps, and emergency stop
- Compliance System: Niche classification, safety filtering, and fact verification
- Originality System: Cooldowns, diversity constraints, and similarity detection
- A/B Testing: Bayesian CTR analysis for thumbnails and titles
- Cost Estimation: Pre-run estimates and post-run tracking
- Shadow Mode: Unlisted QA publishing before going public
- Rights Ledger: Asset usage tracking with attribution
- Node.js 20+
- FFmpeg (for video editing)
- API keys for providers (OpenAI, ElevenLabs, Pexels, YouTube)
# Clone the repository
git clone https://github.com/your-org/yt-factory.git
cd yt-factory
# Install dependencies
npm install
# Build
npm run build
# Link globally (optional)
npm link# 1. Initialize project structure
yt-factory init
# 2. Configure environment variables
# Edit .env with your API keys
# 3. Create a channel blueprint
yt-factory blueprint init --preset nature_facts --slug my-nature-channel
# 4. Validate the blueprint
yt-factory blueprint validate --channel my-nature-channel
# 5. Estimate costs before running
yt-factory estimate --channel my-nature-channel --format short --count 5
# 6. Run a single video
yt-factory run --channel my-nature-channel --prompt "fascinating facts about octopuses"
# 7. Start the scheduler for automated publishing
yt-factory schedule start --channel my-nature-channel# LLM Provider
OPENAI_API_KEY=sk-...
OPENAI_MODEL=gpt-4o
# Text-to-Speech
ELEVENLABS_API_KEY=...
ELEVENLABS_VOICE_ID=...
# Visuals
PEXELS_API_KEY=...
# YouTube
YOUTUBE_CLIENT_ID=...
YOUTUBE_CLIENT_SECRET=...
YOUTUBE_REFRESH_TOKEN=...
# Research (optional)
TAVILY_API_KEY=...
# YouTube Analytics (optional)
YOUTUBE_ANALYTICS_ENABLED=trueproviders:
llm:
type: openai
model: gpt-4o
tts:
type: elevenlabs
voiceId: your-voice-id
visual:
type: pexels
music:
type: royalty_free
upload:
type: youtube
database:
path: ./data/yt-factory.db
output:
directory: ./out
logging:
level: info
file: ./logs/yt-factory.logBlueprints define your channel's content strategy, rules, and constraints.
# Use a preset
yt-factory blueprint init --preset nature_facts --slug wildlife-daily
# List existing blueprints
yt-factory blueprint list
# Validate a blueprint
yt-factory blueprint validate --channel wildlife-daily
# Validate with a specific prompt
yt-factory blueprint validate --channel wildlife-daily --prompt "why do birds migrate"Blueprints are stored in ./channels/{slug}/blueprint.yaml:
version: "1.0"
channel:
name: "Nature Facts Daily"
description: "Fascinating nature facts for curious minds"
niche:
id: nature_facts
description: "Educational nature content"
allowedTopics:
- wildlife
- marine_life
- ecosystems
forbiddenTopics:
- hunting
- animal_cruelty
format:
type: shorts
shorts:
targetDuration: 45
maxDuration: 58
contentRules:
tone: educational_engaging
targetAudience: general
monetizationSafe: true
starterTopicFamilies:
families:
- id: marine_wonders
themes:
- "Deep sea creatures"
- "Coral reef ecosystems"
angles:
- surprising_adaptation
- record_holder
templateLibrary:
shortsTemplates:
- id: fact_rapid
name: "Rapid Facts"
structure:
hookStyle: question
pacing: fast
publishing:
selectedPreset: conservative
cadencePresets:
- name: conservative
shortsMaxPerDay: 2
longformMaxPerDay: 0
maxPublishesPerDay: 2
shadowMode:
enabled: true
minUnlistedViews: 100
minWatchTimePercent: 40
safetyControls:
costControls:
dailyBudgetUSD: 25
monthlyBudgetUSD: 300The video generation pipeline consists of 10 stages:
- Research: Gather viral best practices and trending topics
- Plan: Generate video outline with sections and timings
- Script: Write narration script with hooks and CTAs
- TTS: Convert script to speech audio
- Visuals: Source stock footage and images
- Edit: Assemble video with FFmpeg
- Packaging: Generate thumbnails and metadata variations
- Upload: Publish to YouTube (or save locally)
- A/B Testing: Set up and monitor variant tests
- Report: Generate job summary and costs
Jobs are checkpointed after each stage. If a job fails, it can be resumed:
# List resumable jobs
yt-factory resume --list
# Resume a specific job
yt-factory resume --job abc123
# Resume latest for a channel
yt-factory resume --channel my-channelThe scheduler daemon handles automated content publishing with safety controls.
New channels start with conservative publishing and gradually increase:
| Phase | Duration | Max/Day |
|---|---|---|
| 1 | Days 1-7 | 1 |
| 2 | Days 8-14 | 2 |
| 3 | Days 15-21 | 3 |
| 4 | Day 22+ | Preset max |
# Start the scheduler
yt-factory schedule start --channel my-channel
# Check status
yt-factory schedule status
yt-factory schedule status --channel my-channel
# Pause/resume
yt-factory schedule pause --channel my-channel --reason "maintenance"
yt-factory schedule resume --channel my-channel
# Preview daily plan
yt-factory schedule plan --channel my-channel# Stop a channel immediately
yt-factory emergency stop --channel my-channel --reason "content issue"
# Stop all channels
yt-factory emergency stop --reason "system maintenance"
# Full lockdown
yt-factory emergency lockdown --reason "critical issue" --confirm
# Check status
yt-factory emergency status
# Clear emergency stop
yt-factory emergency clear --channel my-channel --confirmThe analytics brain processes YouTube metrics daily to improve content selection.
- Sync Metrics: Pull views, watch time, CTR, engagement from YouTube Analytics
- Classify Performance: Identify winners (>1.5x median) and losers (<0.5x median)
- Generate Signals: Create learning signals for templates and topic families
- Update Weights: Adjust policy weights using gradient descent
# Sync analytics data
yt-factory analytics sync --channel my-channel --days 7
# Run daily analysis
yt-factory analytics daily --channel my-channel
# Generate report
yt-factory analytics report --channel my-channel --period weekly
# View specific video
yt-factory analytics video --video VIDEO_ID# View learning status
yt-factory learning status --channel my-channel
# View policy weights
yt-factory learning weights --channel my-channel --sort weight
# Reset learning (start fresh)
yt-factory learning reset --channel my-channel --all --confirm
# Export learning data
yt-factory learning export --channel my-channel > learning.jsonAutomatic variant testing for thumbnails and titles.
abTesting:
thumbnailTesting:
enabled: true
variants: 3
titleTesting:
enabled: true
variants: 2
algorithm: bayesian
minSampleSize: 100
confidenceThreshold: 0.9
maxTestDurationHours: 72# View A/B test status
yt-factory ab status --channel my-channel
# Analyze a specific test
yt-factory ab analyze --test TEST_ID
# Manually decide a winner
yt-factory ab decide --test TEST_ID --winner variant_a
# View test history
yt-factory ab history --channel my-channelTemplates define video structures for consistent output.
# List templates
yt-factory templates list --channel my-channel
# Show template details
yt-factory templates show --channel my-channel --id fact_rapid
# Add a new template
yt-factory templates add --channel my-channel --format short \
--id quick_list --name "Quick List" \
--hook statement --pacing fast --cta end
# Remove a template
yt-factory templates remove --channel my-channel --id old_template --confirm
# View usage statistics
yt-factory templates usage --channel my-channelTrack and control API spending.
# Estimate single video
yt-factory estimate --channel my-channel --format short
# Estimate batch
yt-factory estimate --channel my-channel --format short --count 10Set in blueprint.yaml:
safetyControls:
costControls:
dailyBudgetUSD: 25
monthlyBudgetUSD: 300
alertThresholdPercent: 80The pipeline will refuse to run if:
- Estimated cost would exceed daily budget
- Monthly spending is at capacity
Test videos as unlisted before public release.
- Videos are published as unlisted initially
- Share link in controlled community for testing
- Monitor metrics against thresholds
- Promote to public when thresholds met
shadowMode:
enabled: true
minUnlistedViews: 100
minWatchTimePercent: 40
minDaysUnlisted: 1
autoPromote: true# Force shadow mode for a run
yt-factory run --channel my-channel --prompt "..." --shadowAutomatic fact-checking with citations.
factVerification:
enabled: true
sources:
- wikipedia
- scientific_journals
minConfidence: 0.8
requireCitations: trueFacts are verified during the script stage. Low-confidence claims are flagged or removed.
Track asset usage and attribution.
Every video maintains a rights ledger of:
- Stock footage sources and licenses
- Music tracks and attribution
- Font licenses
- AI model usage
yt-factory/
├── channels/ # Channel blueprints
│ └── {slug}/
│ └── blueprint.yaml
├── out/ # Generated videos
│ └── {slug}/
│ └── {jobId}/
├── data/ # SQLite database
├── credentials/ # OAuth tokens
├── assets/
│ ├── music/ # Royalty-free music
│ └── stock/ # Stock footage cache
├── logs/ # Application logs
└── src/
├── cli/ # CLI commands
├── core/ # Core business logic
│ ├── blueprint/ # Schema & validation
│ ├── compliance/# Niche, safety, facts
│ ├── cost/ # Estimation & tracking
│ ├── learning/ # Analytics brain
│ ├── originality/# Diversity & similarity
│ ├── pipeline/ # Job runner & stages
│ └── scheduler/ # Daemon & planner
├── db/ # SQLite & models
├── providers/ # External services
└── utils/ # Helpers
- Create a project in Google Cloud Console
- Enable YouTube Data API v3 and YouTube Analytics API
- Create OAuth 2.0 credentials (Desktop app)
- Download credentials and place in
./credentials/oauth.json - Run the auth flow:
# First run will open browser for OAuth consent
yt-factory run --channel my-channel --prompt "test" --dry-run- Refresh token is saved automatically
The system includes guardrails for advertiser-friendly content:
- Allowed topics: Defined in niche configuration
- Forbidden topics: Explicitly blocked
- Safety filter: Checks for policy violations
- Tone enforcement: Maintains family-friendly language
- Content review: Optional human review queue
# Run in development
npm run dev
# Run tests
npm test
# Lint
npm run lint
# Type check
npm run typecheck"Blueprint validation failed"
- Check YAML syntax
- Ensure all required fields are present
- Run
yt-factory blueprint validate --channel <slug>
"Prompt is OUT OF NICHE"
- Review allowed/forbidden topics in blueprint
- Use more specific, on-topic prompts
"Would exceed daily budget"
- Wait for budget reset (midnight UTC)
- Increase
dailyBudgetUSDin blueprint - Use
--dry-runto estimate without spending
"No YouTube credentials"
- Complete OAuth setup
- Check
YOUTUBE_*environment variables - Verify refresh token is valid
# View recent logs
tail -f logs/yt-factory.log
# Filter by level
grep "ERROR" logs/yt-factory.logMIT
- Fork the repository
- Create a feature branch
- Submit a pull request
See CONTRIBUTING.md for guidelines.