A collection of Python scripts for downloading YouTube videos with different approaches - single video downloads and concurrent batch downloads.
simple-youtube-scraper.py- Single video downloader with command-line interfaceyoutube-scraper.py- Concurrent batch downloader that reads URLs from a text fileexample_urls.txt- Example text file with YouTube URLs for batch downloadingrequirements.txt- Python dependencies
- Clone or download this repository
- Install the required dependencies:
pip install -r requirements.txtpython simple-youtube-scraper.py "https://www.youtube.com/watch?v=VIDEO_ID"python youtube-scraper.py example_urls.txt- Python 3.7+
- yt-dlp (YouTube downloader library)
- FFmpeg (for audio extraction)
Windows:
- Download from FFmpeg website
- Add to your system PATH
macOS:
brew install ffmpegLinux (Ubuntu/Debian):
sudo apt update
sudo apt install ffmpegA single-threaded YouTube video downloader with comprehensive options.
- Download single videos with custom quality settings
- Audio-only downloads (MP3 format)
- Custom output directory
- Format listing without downloading
- Detailed progress information
# Basic download
python simple-youtube-scraper.py "https://www.youtube.com/watch?v=VIDEO_ID"
# Download with specific quality
python simple-youtube-scraper.py "https://www.youtube.com/watch?v=VIDEO_ID" --quality 720p
# Audio-only download
python simple-youtube-scraper.py "https://www.youtube.com/watch?v=VIDEO_ID" --audio-only
# Custom output directory
python simple-youtube-scraper.py "https://www.youtube.com/watch?v=VIDEO_ID" --output ./my_videos
# List available formats
python simple-youtube-scraper.py "https://www.youtube.com/watch?v=VIDEO_ID" --list-formats| Option | Short | Description | Default |
|---|---|---|---|
--output |
-o |
Output directory | ./downloads |
--quality |
-q |
Video quality | best |
--audio-only |
-a |
Download audio only | False |
--list-formats |
List available formats | False |
A concurrent YouTube video downloader that processes multiple URLs from a text file.
- Concurrent downloads with configurable worker threads (default: 10)
- Text file input for batch processing
- Progress tracking with worker IDs
- Error handling and summary reporting
- Support for comments and empty lines in URL files
# Basic batch download
python youtube-scraper.py example_urls.txt
# Custom output directory and quality
python youtube-scraper.py example_urls.txt --output ./my_videos --quality 720p
# Audio-only downloads with 5 workers
python youtube-scraper.py example_urls.txt --audio-only --workers 5
# List URLs without downloading
python youtube-scraper.py example_urls.txt --list-urls| Option | Short | Description | Default |
|---|---|---|---|
--output |
-o |
Output directory | ./downloads |
--quality |
-q |
Video quality | best |
--audio-only |
-a |
Download audio only | False |
--workers |
-w |
Number of concurrent workers | 10 |
--list-urls |
List URLs without downloading | False |
The youtube-scraper.py script reads URLs from a text file with the following format:
# This is a comment line (ignored)
https://www.youtube.com/watch?v=VIDEO_ID_1
https://www.youtube.com/watch?v=VIDEO_ID_2
# Another comment
https://youtu.be/VIDEO_ID_3
# Empty lines are also ignored
https://www.youtube.com/watch?v=VIDEO_ID_4
https://www.youtube.com/watch?v=VIDEO_IDhttps://youtu.be/VIDEO_IDhttps://youtube.com/watch?v=VIDEO_ID
Both scripts support various quality settings:
best- Highest available quality (default)worst- Lowest available quality720p- 720p resolution480p- 480p resolution360p- 360p resolutionbestaudio- Best audio quality only
The youtube-scraper.py script uses ThreadPoolExecutor for concurrent downloads:
- Default: 10 concurrent workers
- Range: 1-20 workers (configurable)
- Benefit: Significantly faster for multiple downloads
- Resource: Uses more bandwidth and CPU
- Low-end systems: 3-5 workers
- Standard systems: 8-10 workers
- High-end systems: 15-20 workers
- Bandwidth-limited: 2-3 workers
-
"FFmpeg not found" error
- Install FFmpeg and add it to your system PATH
- Required for audio extraction
-
"No valid YouTube URLs found"
- Check URL format in your text file
- Ensure URLs start with supported prefixes
-
Download failures
- Check internet connection
- Verify video is not private/restricted
- Try reducing the number of workers
-
Permission errors
- Ensure write permissions for output directory
- Run as administrator if necessary
Both scripts include comprehensive error handling:
- Invalid URLs are skipped with warnings
- Failed downloads don't stop other downloads
- Detailed error messages for troubleshooting
- Summary reports show success/failure counts
This project is licensed under the MIT License - see the LICENSE file for details.
This tool is for educational and personal use only. Please respect YouTube's Terms of Service and copyright laws. Users are responsible for ensuring they have the right to download content.