- Alpine-based Docker image with yt-dlp - Configurable channel sync script - Unraid template for Community Applications - Automatic scheduling via cron - Emby/Plex/Jellyfin compatible output structure
4.7 KiB
4.7 KiB
YouTube Channel Sync Docker
Automatically download and organize YouTube channel videos for Emby, Plex, or Jellyfin media servers.
Features
- Downloads videos in best quality up to 1080p (configurable)
- Organizes videos by season folders (year-based)
- Proper episode naming for media servers:
S2026E001 - Video Title - [VideoID].mp4 - Embeds thumbnails and metadata
- Creates
tvshow.nfofiles for Emby/Plex - Tracks downloaded videos to avoid re-downloading
- Supports YouTube cookies for authentication (bypasses bot detection)
- Scheduled automatic syncs via cron
- Lightweight Alpine Linux base (~200MB)
Quick Start (Unraid)
- Install from Community Applications: Search for "YouTube Sync"
- Configure paths:
- Download Directory:
/mnt/user/media/YouTube(or your media location) - Config Directory:
/mnt/user/appdata/youtube-sync
- Download Directory:
- Edit
/mnt/user/appdata/youtube-sync/channels.txtand add your channels - (Optional) Add YouTube cookies to
/mnt/user/appdata/youtube-sync/cookies.txt - Start the container
Configuration
channels.txt Format
# Format: CHANNEL_ID|Channel Name
UCfDNi1aEljAQ17mUrfUjkvg|Alton Brown
UCoq2qlWgvvKJzW_hBkLIE8w|Flavour Trip
Finding Channel IDs:
- Go to the channel's main page on YouTube
- View page source (Ctrl+U or Cmd+U)
- Search for "channelId" or check the URL structure
YouTube Cookies (Optional but Recommended)
YouTube may block downloads without authentication. To fix this:
Method 1: Browser Extension
- Install "Get cookies.txt LOCALLY" extension for Firefox/Chrome
- Go to YouTube.com while logged in
- Click the extension icon and export cookies
- Save as
/mnt/user/appdata/youtube-sync/cookies.txt
Method 2: yt-dlp command
yt-dlp --cookies-from-browser firefox --cookies cookies.txt --skip-download "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
Environment Variables
| Variable | Default | Description |
|---|---|---|
SYNC_SCHEDULE |
0 2 * * * |
Cron schedule (2 AM daily). Use manual to disable. |
MAX_QUALITY |
1080 |
Maximum video quality (480, 720, 1080, 1440, 2160) |
SLEEP_INTERVAL |
2 |
Seconds between downloads (helps avoid rate limiting) |
TZ |
America/Phoenix |
Timezone for scheduling |
PUID |
99 |
User ID for file ownership |
PGID |
100 |
Group ID for file ownership |
Docker Compose
version: '3'
services:
youtube-sync:
image: azcomputerguru/youtube-sync:latest
container_name: youtube-sync
environment:
- SYNC_SCHEDULE=0 2 * * *
- MAX_QUALITY=1080
- SLEEP_INTERVAL=2
- TZ=America/Phoenix
- PUID=99
- PGID=100
volumes:
- /mnt/user/media/YouTube:/downloads
- /mnt/user/appdata/youtube-sync:/config
restart: unless-stopped
Docker CLI
docker run -d \
--name youtube-sync \
-e SYNC_SCHEDULE="0 2 * * *" \
-e MAX_QUALITY=1080 \
-e TZ=America/Phoenix \
-v /mnt/user/media/YouTube:/downloads \
-v /mnt/user/appdata/youtube-sync:/config \
azcomputerguru/youtube-sync:latest
Manual Sync
To run a sync immediately:
docker exec youtube-sync /app/sync.sh
Output Structure
/downloads/
├── Alton Brown/
│ ├── tvshow.nfo
│ ├── .downloaded.txt (tracking file)
│ ├── Season 2024/
│ │ ├── S2024E001 - Title - [VideoID].mp4
│ │ ├── S2024E001 - Title - [VideoID].info.json
│ │ └── ...
│ └── Season 2025/
│ └── ...
└── Flavour Trip/
├── tvshow.nfo
└── Season 2026/
└── ...
Emby/Plex Setup
- Add the download directory as a TV Shows library
- Use "Local Media Assets (TV)" scanner
- Episodes will appear organized by channel name and year
Troubleshooting
"Sign in to confirm you're not a bot" Error
YouTube is blocking downloads. Solution: Add cookies.txt (see Configuration section)
Videos Not Downloading
- Check
channels.txtformat (must beCHANNEL_ID|Name, no spaces around|) - Verify channel IDs are correct
- Check container logs:
docker logs youtube-sync - Ensure
/downloadsdirectory is writable
Scheduling Not Working
- Verify cron schedule format is correct
- Check timezone is set properly
- Set
SYNC_SCHEDULE=manualand run manually to test - Check logs:
docker logs youtube-sync
Building From Source
git clone https://github.com/azcomputerguru/youtube-sync-docker
cd youtube-sync-docker
docker build -t youtube-sync .
Support
Issues and pull requests: https://github.com/azcomputerguru/youtube-sync-docker
License
MIT License - See LICENSE file for details
Credits
Built by Arizona Computer Guru LLC using yt-dlp