Automatic service for synchronizing videos from YouTube channels and playlists.
- β Automatic video downloads from YouTube channels and playlists
- β YouTube restrictions bypass using browser cookies
- β YAML configuration file
- β File naming in "Title-YYYY-MM-DD.extension" format
- β Best quality downloads
- β Individual period settings for each source
- β Built-in yt-dlp filters for efficiency
- β Plex Media Server compatibility
- β Docker containerization
- β Scheduler for automatic synchronization
- β Comprehensive logging
- Automatic synchronization of favorite YouTube channels for offline viewing
- Plex/Jellyfin integration for video collection organization
- Traffic savings - download during night hours with unlimited internet
- Saving courses and lectures from educational channels
- Creating local library for offline learning
- Archiving important content that might be deleted
- Competitor monitoring - automatic download of new videos
- Content collections creation by topics for trend analysis
- Backup own content from backup channels
- Archiving corporate YouTube channels
- Compliance requirements for content preservation
- Content analytics for marketing research
- Bypass blocks - download via VPN for later viewing
- Preserve region-blocked content
- Access content in areas with poor internet
- Bypass age restrictions - using browser cookies
Create .env file for UID/GID settings:
# Find your UID and GID
id -u # UID
id -g # GID
# Create .env file
cp .env.example .env
# Edit values in .env fileEdit config.yaml file:
youtube:
channels:
- url: "https://www.youtube.com/@yourchannel1"
period_days: 30 # Download last 30 days
output_dir: "./downloads/CHANNEL1" # Individual folder
- url: "https://www.youtube.com/@yourchannel2"
period_days: 14 # Download last 2 weeks
output_dir: "./downloads/CHANNEL2"
playlists:
- url: "https://www.youtube.com/playlist?list=PLyour_playlist"
period_days: 60 # Download last 2 months
output_dir: "./downloads/playlists/MY_PLAYLIST"
download:
output_dir: "./downloads" # Default folder
quality: "bestvideo[height<=1080][ext=mp4]+bestaudio[ext=m4a]/bestvideo[height<=1080]+bestaudio/best[height<=1080][ext=mp4]/best[height<=720]/best"
default_period_days: 30
scheduler:
sync_interval_hours: 6
first_run_time: "08:00"# Build and run
docker-compose up -d
# View logs
docker-compose logs -f ytsync
# Stop
docker-compose down# Install dependencies
pip install -r requirements.txt
# Run service
python main.pyyoutube:
channels:
- url: "https://www.youtube.com/@channel"
period_days: 30
playlists:
- url: "https://www.youtube.com/playlist?list=playlist"
period_days: 60
cookies:
enabled: true
cookie_file: "/path/to/cookies.txt"ytsync/
βββ main.py # Main service code
βββ config.yaml # Configuration
βββ requirements.txt # Python dependencies
βββ Dockerfile # Docker image
βββ docker-compose.yml # Docker Compose configuration
βββ db/ # SQLite database
β βββ ytsync.db # Downloaded videos tracking
βββ downloads/ # Downloaded videos folder
YouTube blocks access to age-restricted content without authentication. This section describes how to configure cookies to bypass restrictions.
Docker service has no access to browsers. Cookies must be extracted LOCALLY and passed to configuration.
cookies:
enabled: true
cookie_file: "/path/to/cookies.txt"Creating cookie file:
# Locally on machine with browser
yt-dlp --cookies-from-browser safari --cookies cookies.txt --no-download --simulate https://youtube.com- Locally: Extract cookies to file using yt-dlp
- On server: Copy cookie file and specify path in config.yaml
- Restart: Restart Docker container
With DEBUG logging level enabled, you'll see:
- Number of loaded cookies
- Presence of important YouTube cookies
- Cookie header preview
logging:
level: "DEBUG"- Cookies contain personal data - don't publish them
- Regularly update cookies (monthly)
- Store cookie files securely
Q: "Sign in to confirm your age" error A: YouTube requires authentication for age-restricted content. Configure browser cookies (see "Cookie Configuration" section).
Q: Cookies don't work in Docker A: Cookies must be extracted locally and passed to configuration. Docker container has no access to browsers.
Q: "HTTP Error 429" or "Too Many Requests" error A: YouTube limits request frequency. Increase synchronization interval or add delays.
Q: extract_cookies.py times out A: This tool is for local use only. Extract cookies locally and copy configuration to server.
Q: No important cookies found A: Ensure you're logged into YouTube in your browser before extracting cookies.
This project is distributed under MIT License. See LICENSE file for details.
What this means:
- β Free use in personal and commercial projects
- β Code modification and distribution
- β Creating derivative works
β οΈ Attribution requiredβ οΈ Provided "as is", without warranties
