A powerful command-line YouTube video downloader with an interactive Terminal User Interface (TUI) built in C using yt-dlp.
- Fast Downloads: Uses yt-dlp for reliable video downloading
- Format Selection: Interactive format selection with detailed information
- Quality Options: Choose from available resolutions, codecs, and file sizes
- Flexible Output: Custom output directories with organized file naming
- Progress Tracking: Real-time download progress in TUI mode
- Interactive Navigation: Arrow key navigation through available formats
- Visual Selection: Highlighted selection with real-time updates
- Clean Interface: Professional ncurses-based interface
- Progress Display: Download progress with completion status
- Responsive Design: Adapts to terminal size and color support
- Cross-Platform: Works on Linux, macOS, and other Unix-like systems
- Memory Safe: Comprehensive error handling and memory management
- Clean Architecture: Modular design with clear separation of concerns
- Robust Parsing: JSON format parsing with jansson library
- Secure Execution: Safe external command execution with proper error handling
- Installation
- Dependencies
- Building
- Usage
- Examples
- TUI Features
- Command Line Options
- Configuration
- Troubleshooting
- Contributing
- License
- GCC compiler (C11 standard support)
- Make build system
- yt-dlp (latest version recommended)
# Clone the repository
git clone https://github.com/yourusername/youtube-video-downloader.git
cd youtube-video-downloader
# Build the project
make clean && make-
yt-dlp: YouTube downloader backend
# Install yt-dlp curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -o /usr/local/bin/yt-dlp chmod a+rx /usr/local/bin/yt-dlp -
jansson: JSON parsing library
# Ubuntu/Debian sudo apt-get install libjansson-dev # macOS (with Homebrew) brew install jansson # CentOS/RHEL/Fedora sudo dnf install jansson-devel
- ncurses: Terminal user interface
# Ubuntu/Debian sudo apt-get install libncurses5-dev libncursesw5-dev # macOS (with Homebrew) brew install ncurses # CentOS/RHEL/Fedora sudo dnf install ncurses-devel
The project uses GNU Make for building:
# Build with TUI support (if ncurses is available)
make
# Build without TUI (fallback mode)
make USE_NCURSES=0
# Clean build artifacts
make clean
# Rebuild from scratch
make clean && make- Automatic Detection: Makefile automatically detects ncurses availability
- Fallback Mode: Builds without TUI if ncurses is not found
- Debug Builds: Add
-gflag for debugging symbols - Optimization: Add
-O2for release builds
# Download to current directory
./ytdl "https://www.youtube.com/watch?v=VIDEO_ID"
# Download to specific directory
./ytdl -o /path/to/downloads "https://www.youtube.com/watch?v=VIDEO_ID"
# Show help
./ytdl --helpWhen ncurses is available, the program launches an interactive TUI:
- Video Information Display: Shows title, channel, duration
- Format Selection: Navigate available formats with arrow keys
- Download Progress: Real-time progress tracking
- Clean Completion: Returns to normal terminal after download
When ncurses is not available, uses text-based format selection:
Available formats:
1. 137 - 1920x1080 (mp4) - 1.5 GB
2. 136 - 1280x720 (mp4) - 313 MB
3. 135 - 854x480 (mp4) - 157 MB
...
Enter format code (blank for best):
./ytdl "https://www.youtube.com/watch?v=dQw4w9WgXcQ"./ytdl -o ~/Videos "https://www.youtube.com/watch?v=dQw4w9WgXcQ"./ytdl "https://www.youtube.com/playlist?list=PLAYLIST_ID"# In TUI mode, select audio-only formats
./ytdl "https://www.youtube.com/watch?v=dQw4w9WgXcQ"- β/β Arrow Keys: Navigate through available formats
- Enter: Select current format and start download
- q/Esc: Cancel and exit
ββ YouTube Video Downloader v2.0 βββββββββββββββββββββββββββββββββββββββ
β Video: Rick Astley - Never Gonna Give You Up β
β Channel: Rick Astley Official β
β Duration: 3:32 β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
ββ Available Formats (15 total) βββββββββββββββββββββββββββββββββββββββ
β# Format Resolution Type Size Quality β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β1 137 1920x1080 mp4 1.5 GB Full HD β
β2 136 1280x720 mp4 313 MB HD β
β3 135 854x480 mp4 157 MB SD β
β4 140 audio only m4a 111 MB Audio Only β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
ββ Download Progress βββββββββββββββββββββββββββββββββββββββββββββββββββ
β Stage: Preparing download... β
β Downloaded: 0 B / 1.5 GB β
β [βββββββββββββββββββββββββββββββββββββββββββ] 60% β
β Elapsed: 2m 15s | ETA: 1m 30s β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
- Format Code: yt-dlp format identifier
- Resolution: Video resolution (e.g., 1920x1080)
- Type: File format (mp4, webm, m4a, etc.)
- Size: File size estimate
- Quality: Quality indicator (4K, Full HD, HD, SD, Audio Only)
| Option | Long Form | Description |
|---|---|---|
-h |
--help |
Display help message and exit |
-o |
--output PATH |
Specify output directory (default: current directory) |
- TERM: Terminal type (affects TUI rendering)
- COLUMNS/LINES: Terminal dimensions (auto-detected)
- Output Directory: Specified with
-oflag or current directory - File Naming:
%(title)s.%(ext)s(yt-dlp default)
- Minimum Size: 80x24 characters
- Color Support: Optional (automatic detection)
- Unicode Support: Recommended for special characters
ncurses not found:
# Install ncurses development libraries
sudo apt-get install libncurses5-dev libncursesw5-devjansson not found:
# Install jansson development libraries
sudo apt-get install libjansson-devTUI not working:
- Check if ncurses is installed
- Try running in a different terminal (xterm, gnome-terminal, etc.)
- Check
TERMenvironment variable
Download fails:
- Ensure yt-dlp is installed and up-to-date
- Check internet connection
- Verify YouTube URL is valid
- Try updating yt-dlp:
yt-dlp -U
Permission errors:
- Check write permissions for output directory
- Ensure yt-dlp has execute permissions
# Build with debug symbols
make CFLAGS="-g -O0"
# Run with debug output
gdb ./ytdl# Fork and clone the repository
git clone https://github.com/yourusername/youtube-video-downloader.git
cd youtube-video-downloader
# Create feature branch
git checkout -b feature/your-feature
# Build and test
make clean && make
./ytdl --help- Use descriptive commit messages
- Reference issue numbers when applicable
- Keep commits focused and atomic
- Test before committing
- Update documentation for any new features
- Add tests for new functionality
- Ensure all existing tests pass
- Update README.md if needed
- Request review from maintainers
- May you do good and not evil.
- May you find forgiveness for yourself and forgive others.
- May you share freely, never taking more than you give.
- yt-dlp: For the excellent YouTube downloading backend
- jansson: For JSON parsing capabilities
- ncurses: For terminal user interface functionality
- GNU: For development tools and standards
Happy Downloading! π₯π₯