I wanted a way to download my Spotify songs for offline listening. Ideally I’d subscribe to Spotify to make use of Offline feature, but they haven’t officially launched here so that’s out of the question.
A while back, I’d used spotify_to_mp3 which made use of Grooveshark to download, but Grooveshark shut down, leaving the script defunct. This gave me an idea to build something similar.
With this as the motivation, I built Spotify-dl to scratch an itch as well as to improve my Python skills. Since Spotify doesn’t allow you to download songs directly, I followed the same approach as spotify_to_mp3 - which is
- Login to your Spotify library
- Fetch all your “My Music” tracks using Spotify Web API
- Parse the artist name & track name
- Search for the artist name & track name against YouTube using their Data API and grab their YouTube URLs
- Pass the YouTube URLs to youtube-dl to download the songs
- Profit!
It didn’t take me long to build the glue script & python made it that much easier. The script is available on my github. Huge thanks to Rohan to contributing the youtube-dl integration part.
The readme has the required documentation on how to get it up and running. Any feedback is welcome