A comprehensive tool for searching and downloading YouTube videos:
- YouTube Scraper: Search YouTube and save video details to CSV
- YouTube Downloader: Download videos from the CSV with customizable quality options
- Interactive Tool: User-friendly interactive command-line interface
- Server Automation: Run as a background process to automate YouTube searches and downloads
⭐ If you find this project helpful, please consider giving it a star! Your support helps make it better.
🐛 Found a bug or have a suggestion? Please open an issue - we appreciate your feedback!
# Clone this repository
git clone https://github.com/developerabdan/youtube-scraper-downloader.git
cd youtube-scraper-downloader
# Create a virtual environment
python3 -m venv venv
# Activate the virtual environment
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install all dependencies
pip install -r requirements.txt
Note: For the scraper, you need Chrome browser installed on your system (required for Selenium)
The easiest way to use this tool is with the interactive command-line interface:
python yt_interactive.py
This will guide you through the process with simple prompts:
- Enter your search keywords
- Choose how many results to fetch
- View the search results
- Select which videos to download
- Choose your preferred quality and resolution
- Specify where to save the downloaded videos
No need to remember complex commands or arguments!
For server deployments, this tool can run as a background process that automatically:
- Reads search queries from a text file
- Processes each query to search YouTube
- Downloads the videos based on your configuration
-
Configure your settings in
config.ini
:[General] # File containing search queries (one per line) query_file = query.txt # How often to check for new queries (in minutes) check_interval_minutes = 60 # Maximum number of videos to fetch per query max_results_per_query = 5 # Automatically download videos after searching auto_download = yes # Quality setting (best, worst, audio) download_quality = best # Resolution (e.g., 360, 720, 1080) download_resolution = 720 # Duration filter (in minutes) # Set to 0 to disable filtering min_duration_minutes = 60 # Only videos longer than 60 minutes max_duration_minutes = 0 # No maximum limit
-
Add your search keywords to
query.txt
, one per line:learn python programming machine learning tutorial
-
Run the background processor:
# For testing in the foreground python auto_yt_processor.py # For server deployment (using nohup to keep running after logout) nohup python auto_yt_processor.py > auto_yt.log 2>&1 &
The processor will continually monitor the query file and process any new queries that are added, keeping track of which ones have been completed.
- Queries are read from
query.txt
- Each query is only processed once (tracked in
processed_queries.txt
) - Search results are saved to the
results
folder - Downloaded videos are organized in the
downloads
folder by query - Configuration can be customized in
config.ini
- Detailed logs are written to
auto_yt_processor.log
Run the script from the command line with a search keyword:
python youtube_scraper.py "your search keyword"
--max
: Maximum number of results to fetch (default: 10)--output
: Specify the output CSV filename
Example:
python youtube_scraper.py "python tutorial" --max 20 --output results.csv
The script generates a CSV file with the following columns:
- title: The title of the YouTube video
- link: The URL to the YouTube video
- duration: The duration of the video
If no output filename is specified, the script will generate a file with a timestamp: youtube_results_YYYYMMDD_HHMMSS.csv
This script allows you to download YouTube videos listed in your CSV file with a progress bar.
The downloader script provides several options:
python youtube_downloader.py [--csv CSV_FILE] [--output OUTPUT_DIR] [--all] [--index INDEX] [--range START-END] [--quality QUALITY] [--format FORMAT] [--resolution RES]
Arguments:
--csv
: Path to the CSV file with YouTube links (default: youtube_results.csv)--output
: Directory to save downloaded videos (default: downloads)--all
: Download all videos from the CSV--index
: Download a specific video by its index (starting from 1)--range
: Download videos in a range (e.g., 1-5)--quality
: Quality of the video to download: best, worst, audio (default: best)--format
: Format of the video: mp4, webm, etc. (default: mp4)--resolution
: Specific resolution to download (e.g., 720, 1080)
List all available videos:
python youtube_downloader.py
Download a specific video (e.g., the first video):
python youtube_downloader.py --index 1
Download a range of videos:
python youtube_downloader.py --range 1-5
Download all videos:
python youtube_downloader.py --all
Save videos to a custom folder:
python youtube_downloader.py --index 1 --output english_tutorials
Download only the audio of a video:
python youtube_downloader.py --index 1 --quality audio
Download a video in 720p resolution:
python youtube_downloader.py --index 1 --resolution 720
Download a video in webm format:
python youtube_downloader.py --index 1 --format webm
@abdansyakuro.id