A Python application that downloads audio from YouTube playlists and Spotify playlists, converting them to MP3 format for offline listening.
- YouTube Playlist Download: Download entire YouTube playlists as MP3 files
- Spotify Playlist Download: Download tracks from Spotify playlists by searching YouTube
- Audio Playback: Built-in music player using pygame
- High Quality Audio: Downloads audio in 192kbps MP3 format
- Easy to Use: Simple command-line interface
- Python 3.11.11 or higher
- uv (Python package manager)
- FFmpeg (for audio conversion)
- Spotify API credentials (for Spotify playlist downloads)
- Clone the repository:
git clone <repository-url>
cd yt-mp3- Install uv (if not already installed):
curl -LsSf https://astral.sh/uv/install.sh | sh- Install dependencies using uv:
uv sync- Install FFmpeg:
- macOS:
brew install ffmpeg - Ubuntu/Debian:
sudo apt install ffmpeg - Windows: Download from FFmpeg website
- macOS:
Run the main script to download a YouTube playlist:
uv run python main.pyEnter the YouTube playlist URL when prompted. The script will:
- Download all videos from the playlist as MP3 files
- Save them to the
downloaded_mp3/directory - Automatically play the downloaded music
For Spotify playlists, you'll need to set up Spotify API credentials first:
- Go to Spotify Developer Dashboard
- Create a new app and get your Client ID and Client Secret
- Update the credentials in
spotify.py:SPOTIFY_CLIENT_ID = "your_client_id_here" SPOTIFY_CLIENT_SECRET = "your_client_secret_here"
Then run:
uv run python spotify.pyEnter the Spotify playlist URL when prompted. The script will:
- Fetch track information from the Spotify playlist
- Search for each track on YouTube
- Download the best matching audio as MP3
- Save them to the
spotify_downloaded_mp3/directory
yt-mp3/
├── main.py # YouTube playlist downloader
├── spotify.py # Spotify playlist downloader
├── downloaded_mp3/ # YouTube downloads directory
├── spotify_downloaded_mp3/ # Spotify downloads directory
├── requirements.txt # Python dependencies
├── pyproject.toml # Project configuration
└── README.md # This file
yt-dlp: YouTube video/audio downloadingspotipy: Spotify Web API clientpygame: Audio playbackffmpeg-python: Audio format conversion
- Downloaded files are saved in MP3 format with 192kbps quality
- The application respects YouTube's terms of service
- Make sure you have the right to download the content you're accessing
- Large playlists may take considerable time to download
This project is for educational purposes only. Please respect copyright laws and terms of service of the platforms you're downloading from.