Skip to content

b9nn/SleepyPlays

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

YouTube Shorts Automation

A fully automated system for creating and posting AI-generated story videos to YouTube Shorts every 6 hours.

Features

  • AI Story Generation: Uses OpenAI GPT-4 to create unique stories (horror, romance, action, wholesome)
  • Natural Voice Narration: Converts stories to speech using ElevenLabs TTS
  • Professional Video Composition: Overlays narration on gameplay footage with subtitles
  • Automated YouTube Upload: Posts videos every 6 hours with optimized titles and descriptions
  • Analytics Tracking: Monitors performance and identifies trending story types
  • Background Music: Adds royalty-free background music for enhanced engagement
  • Cloud-Ready: Designed for deployment on cloud platforms (AWS, GCP, Azure)

Architecture

┌─────────────────┐
│ Story Generator │ (OpenAI GPT-4)
└────────┬────────┘
         │
         ▼
┌─────────────────┐
│ Voice Generator │ (ElevenLabs TTS)
└────────┬────────┘
         │
         ▼
┌─────────────────┐
│ Video Composer  │ (FFmpeg)
└────────┬────────┘
         │
         ▼
┌─────────────────┐
│ YouTube Uploader│ (YouTube Data API)
└────────┬────────┘
         │
         ▼
┌─────────────────┐
│ Analytics       │ (Performance Tracking)
└─────────────────┘

Prerequisites

  • Node.js 18+ and npm
  • FFmpeg (installed automatically via ffmpeg-static)
  • OpenAI API key
  • ElevenLabs API key
  • YouTube Data API credentials
  • (Optional) AWS S3 for asset storage
  • (Optional) Pexels/Pixabay API keys for background videos

Installation

1. Clone and Install Dependencies

npm install

2. Configure Environment Variables

Copy the example environment file:

cp .env.example .env

Edit .env and add your API keys:

# Required
OPENAI_API_KEY=your_openai_key
ELEVENLABS_API_KEY=your_elevenlabs_key
YOUTUBE_CLIENT_ID=your_youtube_client_id
YOUTUBE_CLIENT_SECRET=your_youtube_client_secret

# Optional but recommended
PEXELS_API_KEY=your_pexels_key
PIXABAY_API_KEY=your_pixabay_key

3. Set Up YouTube Authentication

node src/scripts/setupYouTube.js

Follow the prompts to authorize the application and get your refresh token.

4. Add Background Assets

Create directories and add your assets:

mkdir -p assets/videos
mkdir -p assets/music

Add royalty-free gameplay videos to assets/videos/ and background music to assets/music/.

Optionally organize by story type:

assets/
├── videos/
│   ├── horror/
│   ├── romantic/
│   ├── action/
│   └── wholesome/
└── music/
    └── ambient-music.mp3

Usage

Run the Full Automation

npm start

This starts the scheduler that will:

  • Generate a new video every 6 hours
  • Upload to YouTube automatically
  • Track analytics daily

Test Individual Components

Generate a story:

npm run generate-story
# Or specify type:
node src/scripts/generateStory.js horror

Test the complete pipeline (without uploading):

node src/scripts/testPipeline.js

Configuration

Edit src/config/config.js or use environment variables:

  • UPLOAD_INTERVAL_HOURS: Change posting frequency (default: 6)
  • VIDEO_WIDTH / VIDEO_HEIGHT: Video dimensions (default: 1080x1920)
  • STORY_DURATION_SECONDS: Target story length (default: 50)
  • RUN_ON_STARTUP: Run immediately on start (default: false)
  • CLEANUP_FILES: Delete files after upload (default: false)

Project Structure

youtube-shorts-automation/
├── src/
│   ├── config/
│   │   └── config.js              # Configuration management
│   ├── services/
│   │   ├── storyGenerator.js      # AI story generation
│   │   ├── voiceoverGenerator.js  # TTS voice generation
│   │   ├── backgroundManager.js   # Video background handling
│   │   ├── videoComposer.js       # Video composition with FFmpeg
│   │   ├── youtubeUploader.js     # YouTube API integration
│   │   ├── contentPipeline.js     # Main pipeline orchestration
│   │   └── analyticsTracker.js    # Performance tracking
│   ├── utils/
│   │   └── logger.js              # Winston logging
│   ├── scripts/
│   │   ├── generateStory.js       # Test story generation
│   │   ├── testPipeline.js        # Test full pipeline
│   │   └── setupYouTube.js        # YouTube OAuth setup
│   └── index.js                   # Main entry point with scheduler
├── assets/
│   ├── videos/                    # Background videos
│   └── music/                     # Background music
├── output/                        # Generated videos
├── logs/                          # Application logs
├── .env                           # Environment configuration
├── .env.example                   # Example environment file
├── package.json
└── README.md

API Keys Setup Guide

OpenAI API

  1. Go to https://platform.openai.com/api-keys
  2. Create a new API key
  3. Add to .env as OPENAI_API_KEY

ElevenLabs

  1. Sign up at https://elevenlabs.io
  2. Go to Profile Settings → API Key
  3. Add to .env as ELEVENLABS_API_KEY
  4. Get voice IDs from Voice Library and add as ELEVENLABS_VOICE_ID

YouTube Data API

  1. Go to https://console.cloud.google.com
  2. Create a new project
  3. Enable YouTube Data API v3
  4. Create OAuth 2.0 credentials (Desktop app)
  5. Add Client ID and Secret to .env
  6. Run node src/scripts/setupYouTube.js to get refresh token

Pexels (Optional)

  1. Sign up at https://www.pexels.com/api
  2. Get API key and add to .env

Pixabay (Optional)

  1. Sign up at https://pixabay.com/api
  2. Get API key and add to .env

Cloud Deployment

Deploy on AWS EC2

  1. Launch an EC2 instance (Ubuntu 20.04+)
  2. Install Node.js and dependencies
  3. Clone repository and configure
  4. Use PM2 for process management:
npm install -g pm2
pm2 start src/index.js --name youtube-automation
pm2 save
pm2 startup

Deploy on Google Cloud Run

# Build and deploy
gcloud run deploy youtube-automation \
  --source . \
  --platform managed \
  --region us-central1 \
  --allow-unauthenticated

Deploy with Docker

FROM node:18-alpine

WORKDIR /app
COPY package*.json ./
RUN npm install --production
COPY . .

CMD ["npm", "start"]

Analytics and Monitoring

The system automatically tracks:

  • Video views, likes, and comments
  • Performance by story type
  • Channel growth metrics
  • Best performing content

Generate a performance report:

const analyticsTracker = require('./src/services/analyticsTracker');
const report = analyticsTracker.generateReport();
console.log(report);

View logs:

# Combined logs
tail -f logs/combined.log

# Error logs only
tail -f logs/error.log

# Upload logs
tail -f logs/uploads.log

Troubleshooting

FFmpeg Errors

  • Ensure FFmpeg is properly installed
  • Check video/audio file formats are compatible
  • Verify file paths don't contain special characters

YouTube Upload Fails

  • Verify OAuth tokens are valid
  • Check YouTube API quota limits
  • Ensure video meets YouTube's requirements (duration, format, etc.)

Story Generation Issues

  • Check OpenAI API key and quota
  • Verify API model access (GPT-4)
  • Review rate limits

Voice Generation Issues

  • Verify ElevenLabs API key
  • Check character quota
  • Ensure voice ID is valid

Cost Estimation

Monthly costs for 4 videos/day (120 videos/month):

  • OpenAI GPT-4: ~$6-12 (depending on token usage)
  • ElevenLabs: ~$5-22 (Creator tier recommended)
  • YouTube API: Free (within quota limits)
  • Cloud hosting: ~$5-20 (depending on provider)
  • Total: $16-54/month

Legal & Ethics

  • Only use royalty-free or properly licensed content
  • Comply with YouTube's Terms of Service
  • Follow monetization policies
  • Disclose AI-generated content when required
  • Respect copyright and intellectual property laws

Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Submit a pull request

License

MIT License - See LICENSE file for details

Support

For issues and questions:

  • Check the logs in logs/ directory
  • Review the troubleshooting section
  • Open an issue on GitHub

Roadmap

  • Multi-language support
  • Custom voice training
  • Advanced analytics dashboard
  • A/B testing for titles/thumbnails
  • Integration with more video platforms
  • Automated thumbnail generation
  • Content moderation and safety checks
  • Advanced scheduling options

Acknowledgments

  • OpenAI for GPT-4 API
  • ElevenLabs for TTS API
  • FFmpeg for video processing
  • YouTube Data API
  • All open-source contributors

Note: This is an automated content creation tool. Always review and comply with platform policies and local regulations.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors