Download playlists from YouTube and Apple Music as MP3 files (or MP4 for YouTube video).
| Source | What happens |
|---|---|
| YouTube playlist | Downloaded directly via yt-dlp |
| Apple Music playlist | Track metadata scraped from the public page; each track is then found on YouTube and downloaded |
- Python 3.10+
- ffmpeg — required for MP3 conversion
macOS:brew install ffmpeg
Ubuntu/Debian:sudo apt install ffmpeg
Windows: download from https://ffmpeg.org/download.html
git clone https://github.com/sujay1599/youtubePlaylistDL.git
cd youtubePlaylistDL
pip install -r requirements.txtpython playlist_downloader.py <URL> [options]
python playlist_downloader.py "https://www.youtube.com/playlist?list=PLxxxxxx" -o ~/Musicpython playlist_downloader.py "https://www.youtube.com/playlist?list=PLxxxxxx" --video -o ~/Videospython playlist_downloader.py "https://music.apple.com/us/playlist/my-playlist/pl.xxxxxx" -o ~/MusicThe playlist must be public. The tool scrapes track names and artists from the Apple Music page, searches YouTube for each track, and downloads the audio.
usage: playlist_downloader.py [-h] [-o DIR] [--video] url
positional arguments:
url YouTube playlist URL or Apple Music playlist URL
options:
-h, --help show this help message and exit
-o DIR, --output DIR Output directory (default: downloads)
--video Download video (MP4) instead of audio — YouTube only
- Fetches the public Apple Music playlist page.
- Extracts track titles and artist names from the page's embedded JSON data
(
JSON-LDand Apple's shoebox cache). - For each track, runs a
yt-dlpYouTube search (ytsearch1:artist - title official audio). - Downloads the best audio match and converts it to MP3 via ffmpeg.
Note: Apple Music playlist pages are mostly server-rendered, so track data is typically available without JavaScript execution. However, private playlists or playlists behind a login wall cannot be scraped.
Files are saved as:
{output_dir}/
001 - Artist - Track Title.mp3
002 - Artist - Track Title.mp3
...
YouTube playlists use the playlist index as the prefix automatically.
| Problem | Solution |
|---|---|
ffmpeg not found |
Install ffmpeg and ensure it is on your PATH |
Apple Music: No tracks found |
Check the playlist is public; try again (page caching can vary) |
| YouTube: video unavailable | yt-dlp skips unavailable videos automatically (--ignore-errors) |
| Rate limiting from YouTube | Increase the time.sleep(1) delay in download_apple_music_playlist() |