An AI-powered YouTube to MP3 converter that actually gets your metadata right!
🤖 AI-Powered Metadata Cleaning - Uses Ollama (Gemma3:4b) to extract proper song titles and artists from messy YouTube titles
🎵 High-Quality Audio - Downloads best available audio and converts to 192kbps MP3
🖼️ Album Art Embedding - Automatically downloads and embeds YouTube thumbnails as album covers
📊 MusicBrainz Integration - Fetches additional metadata like album names and release years
📁 Smart File Organization - Clean, sanitized filenames that work across all operating systems
⚡ Robust Pipeline - Handles errors gracefully with fallback options
1. Python 3.11 Make sure you have Python installed. Check with:
python --version2. FFmpeg Download and install FFmpeg:
- Windows: Download from ffmpeg.org and add to PATH
- macOS:
brew install ffmpeg - Linux:
sudo apt install ffmpeg(Ubuntu/Debian) or equivalent
3. Ollama Download and install Ollama and pull the Gemma3 model:
ollama pull gemma3:4b- Clone the repository
git clone https://github.com/bdwarker/yt2mp3.git
cd yt2mp3- Install Python dependencies
pip install -r requirements.txt- Run the program
python main.pySimply run the script and enter a YouTube URL when prompted:
Enter YouTube URL:
The program will:
- 📥 Download the audio from YouTube
- 🤖 Use AI to clean up the title and extract artist info
- 🔍 Fetch additional metadata from MusicBrainz
- 🖼️ Download and embed album artwork
- 🏷️ Tag the MP3 file with proper metadata
- 💾 Save everything in the
downloads/folder
YouTube URL → yt-dlp → Raw Audio + Metadata
↓
AI Cleaning (Ollama/Gemma3) → Clean Title + Artist
↓
MusicBrainz API → Album + Year Info
↓
Thumbnail Download → Album Art
↓
MP3 Tagging → Final Tagged File
Before (Raw YouTube title):
"Rick Astley - Never Gonna Give You Up (Official Video) 4K Remaster"
After (AI-cleaned metadata):
Title: Never Gonna Give You Up
Artist: Rick Astley
Album: Whenever You Need Somebody
Year: 1987
yt2mp3/
├── main.py # Main application
├── requirements.txt # Python dependencies
├── downloads/ # Output folder (auto-created)
├── README.md # This file
└── LICENSE # MIT License
The following constants can be modified at the top of main.py:
DOWNLOAD_DIR: Output directory (default: 'downloads')OLLAMA_MODEL: AI model to use (recommended: 'gemma3:4b')
"FFmpeg not found"
- Make sure FFmpeg is installed and added to your system PATH
"Ollama model not found"
- Run
ollama pull gemma3:4bto download the AI model
"Permission denied" errors
- Check if the downloads folder is writable
- On Linux/macOS, you might need to adjust permissions
Poor metadata extraction
- The AI occasionally misinterprets titles. The original filename is preserved as a fallback
This project is licensed under the MIT License - see the LICENSE file for details.
- yt-dlp - The best YouTube downloader
- Ollama - For making local AI simple
- MusicBrainz - The open music encyclopedia
- Mutagen - Audio metadata handling
Made by Mohammed Shaan
If this saved you from manually renaming a thousand music files, consider giving it a ⭐!