A powerful and user-friendly Python script designed to download YouTube videos or entire playlists in your preferred quality, directly to your computer. This cross-platform tool is compatible with Windows, Linux, and macOS, making it accessible for all users.
- Features
- Dependencies
- Installation Guide
- Usage
- Examples
- Troubleshooting
- License
- Contribution
- Project Structure
- Additional Resources
- Download Single Videos: Easily download individual YouTube videos by providing their URL.
- Download Playlists: Download entire YouTube playlists or choose specific videos from a playlist.
- Choose Video Quality: Select from multiple video quality options (Best, High, Medium, Low).
- Cross-Platform Compatibility: Works seamlessly on Windows, Linux, and macOS.
- Automated Setup: Use a Makefile to automate environment setup and dependency installation.
- Virtual Environment Support: Ensures project dependencies are isolated and managed efficiently.
To run this script, the following dependencies are required:
- Python 3.x
- Ensure Python 3 is installed on your system.
- Download Python
- yt-dlp
- A command-line tool to download videos from YouTube and other sites.
- ffmpeg
- A multimedia framework for handling video, audio, and other multimedia files and streams.
First, clone this repository to your local machine using Git:
git clone https://github.com/orcalinux/youtube_downloader.git
cd youtube_downloader
A Makefile
is provided to automate the setup process, including creating a virtual environment, installing dependencies, and running the application.
-
Linux/macOS:
make
is typically pre-installed. Verify by running:make --version
-
Windows: Install Make for Windows or use Windows Subsystem for Linux (WSL) to access Unix-like tools.
Run the following command in the project directory:
make install
What This Does:
- Creates a virtual environment named
venv
. - Installs Python dependencies listed in
requirements.txt
. - Checks if
ffmpeg
is installed on your system.
If ffmpeg
is not installed, follow the instructions in Manual Setup to install it.
After installation, execute the script using:
make run
What This Does:
- Activates the virtual environment.
- Runs
app.py
within the virtual environment.
To remove the virtual environment and clean up dependencies, use:
make clean
If you prefer not to use the Makefile
, follow these steps to set up the project manually.
Navigate to the project directory and create a virtual environment named venv
:
python3 -m venv venv
-
Linux/macOS:
source venv/bin/activate
-
Windows:
venv\Scripts\activate
With the virtual environment activated, install the required Python packages:
pip install --upgrade pip
pip install -r requirements.txt
Ensure ffmpeg
is installed on your system.
-
Windows:
- Download the latest
ffmpeg
release from ffmpeg.org. - Extract the downloaded archive.
- Add the
bin
directory offfmpeg
to your system's PATH.
- Download the latest
-
Linux:
sudo apt-get update sudo apt-get install ffmpeg
-
macOS (Using Homebrew):
brew install ffmpeg
After setting up the environment and installing dependencies, you can run the YouTube downloader script.
Activate the virtual environment (if not already activated):
-
Linux/macOS:
source venv/bin/activate
-
Windows:
venv\Scripts\activate
Run the application:
python app.py
- Enter the URL: Provide the URL of the YouTube video or playlist you wish to download.
- Select Playlist or Single Video: If the URL is a playlist, choose whether to download the entire playlist or specific videos.
- Choose Quality: Select your preferred video quality (Best, High, Medium, Low).
- Download: The script will download the selected video(s) and save them to your
Downloads
folder.
python app.py
- Input:
- URL:
https://youtu.be/W13gbCLVU40
- Quality:
2
(High 1080p)
- URL:
- Output: The video is downloaded and saved to your
Downloads
folder.
python app.py
- Input:
- URL:
https://www.youtube.com/playlist?list=PLxwbQuwnqw4fFmABIFU_xFP-Sp5DKW-b2
- Download Entire Playlist:
y
- Quality:
1
(Best quality)
- URL:
- Output: All videos in the playlist are downloaded to your
Downloads
folder.
python app.py
- Input:
- URL:
https://www.youtube.com/playlist?list=PLxwbQuwnqw4fFmABIFU_xFP-Sp5DKW-b2
- Download Entire Playlist:
n
- Select Videos:
1, 3, 5
- Quality:
3
(Medium quality)
- URL:
- Output: Only videos 1, 3, and 5 from the playlist are downloaded to your
Downloads
folder.
-
Network Errors: Ensure your internet connection is stable.
-
Permission Issues: Make sure you have write permissions to the
Downloads
directory. -
Missing Dependencies: Verify that
yt-dlp
andffmpeg
are installed correctly and accessible via your system's PATH. -
ModuleNotFoundError: If you encounter
ModuleNotFoundError: No module named 'yt_dlp'
, ensure you've installedyt-dlp
within your virtual environment:pip install yt-dlp
-
ffmpeg Not Found: If the script cannot locate
ffmpeg
, ensure it is installed and added to your system's PATH.
This script is provided under the MIT License. You are free to use, modify, and distribute this script. See the LICENSE file for more details.
Contributions are welcome! If you encounter any issues or have suggestions for improvements, feel free to submit an issue or open a pull request on the GitHub repository.
.
├── app.py
├── LICENSE
├── Makefile
├── README.md
└── requirements.txt
- app.py: The main Python script for downloading YouTube videos and playlists.
- LICENSE: The MIT License file.
- Makefile: Automates environment setup, dependency installation, and running the application.
- README.md: Project documentation.
- requirements.txt: Lists Python dependencies.
- yt-dlp Documentation: https://github.com/yt-dlp/yt-dlp
- ffmpeg Documentation: https://ffmpeg.org/documentation.html
- Python Virtual Environments: https://docs.python.org/3/library/venv.html
- Makefile Basics: GNU Make Manual