This Python script allows you to download audio from YouTube videos and convert it to MP3 format.
Before you begin, ensure you have met the following requirements:
- Python 3.x installed on your system. You can download it from python.org.
yt-dlp
library: You can install this using pip. See setup instructions below.ffmpeg
executable available in your system path. This is essential for audio conversion.
-
Clone the Repository (if applicable) or download the script directly.
-
Install Required Libraries:
Open a terminal or command prompt and execute:
pip install yt-dlp
-
FFmpeg Installation:
- Download a static build of FFmpeg from the official website.
- Extract it to a directory (e.g.,
C:\ffmpeg
for Windows users). - Add the execution to the path directory.
- Link for instructions youtube Guide.
-
Script Configuration:
- Open the script in your preferred text editor or IDE (such as Visual Studio Code).
- Update the
ffmpeg_path
variable with the correct path to your FFmpeg installation, ensuring it points to thebin
directory.
-
Run the Script:
Execute the script using Python:
python path/to/your/main.py
Replace
path/to/your/main.py
with the actual path to where your Python script is located.or Your perosnal IDE
-
Follow the Prompts:
- Enter the YouTube video URL you want to download.
- Specify the download directory for the MP3 file. Defaults to
downloads
if not specified.
- The script uses
yt-dlp
to fetch and process the YouTube video, andffmpeg
to convert the audio to MP3 format. - Upon execution, the script will download the highest quality audio track available, converting it to MP3 in the specified directory.
- Ensure that the provided YouTube URLs are accessible and authorized for downloading.
- Use this tool responsibly and adhere to YouTube's terms of service.