A Python-based YouTube MP3 Downloader that allows you to download audio from YouTube videos or playlists and convert them to MP3 format.
- Download audio from individual YouTube videos or entire playlists.
- Convert downloaded audio to MP3 format.
- Display download progress.
- Retry mechanism for failed downloads.
- Skip age-restricted content.
- Organize and save downloaded files to a specified directory.
This project requires the following Python libraries:
pytube
: For downloading YouTube videos.pydub
: For converting audio files.tqdm
: For displaying download progress.requests
: For making HTTP requests.ffmpeg
: Required bypydub
for audio conversion.
-
Clone the repository:
git clone https://github.com/yourusername/youtube-mp3-downloader.git cd youtube-mp3-downloader
-
Install the required dependencies:
pip install -r requirements.txt
Ensure your requirements.txt contains:
pytube pydub tqdm requests
- Run the script:
python download_youtube.py
- Enter the YouTube playlist or Mix URL when prompted.
- Enter the download destination path when prompted.
-
Windows:
- Download the
ffmpeg
build for Windows from FFmpeg.org. - Extract the downloaded zip file.
- Move the
bin
folder (which containsffmpeg.exe
) to a convenient location, for example,C:\ffmpeg\bin
.
- Download the
-
MacOS:
-
Install
ffmpeg
using Homebrew:Installffmpeg
using your package manager, for example, on Ubuntu:brew install ffmpeg
-
-
Linux:
sudo apt update
sudo apt install ffmpeg
-
Windows:
- Open the Start Search, type in "env", and select "Edit the system environment variables."
- In the System Properties window, click on the "Environment Variables" button.
- In the Environment Variables window, under System variables, find the PATH variable, select it, and click Edit.
- Click New and add the path to the
ffmpeg
bin directory, e.g.,C:\ffmpeg\bin
. - Click OK to close all the windows.
-
MacOS and Linux:
- Open your terminal and add
ffmpeg
to your PATH by editing your shell configuration file (.bashrc
,.zshrc
, etc.):
- Open your terminal and add
export PATH="/usr/local/bin:$PATH"
-
- Save the file and source it:
source ~/.bashrc # or source ~/.zshrc
To ensure that ffmpeg
is properly installed and accessible from your PATH, open a terminal or command prompt and run:
ffmpeg -version
You should see the ffmpeg
version information printed, indicating that it's correctly installed.
Contributions are welcome! Please fork this repository and submit pull requests with your changes. Make sure to follow the coding standards and add appropriate documentation.