I love spotify, I have a payed account on it and I use it every day.
But despite my love for it, there are a couple of things that are a pain in my ass when it comes to spotify:
- You can easily make a new playlist and share it with your friends.
- However, the HTML-link fails to show the songs and is actually nothing more than a page that lists the title of the playlist and a play button.
- The URI is not a complete URL, so you can’t just Copy/Paste it in your browser to see the songs.
- The “embed code” has <iframe> junk attached to it
If however you just lean the “embed code” until just the bear URL, you will get a page with all the songs. But it’s a marked up page, and I just really want the titles and artists!
- There just isn’t a version for my mobile phone,.. And I know several others with android phones where Spotify fails to play a song.
There I fixed it!
After some searching on the net I couldn’t find any sufficient software to do what i wanted. So I ended up making the software to do just that myself.
It’s over at Github: https://github.com/woutervddn/SpotifyScrapeAndDownload and please, feel free to use and modify it as much as you want!
The project is based up on 2 shell scripts and 1 perl scraper: spot2mp3.sh, ytlikely.sh and spotify-scrape.pl
The scrapper was originally made by Jonathan Spruytte, and used the whole embed code as argument. I cleaned it up a little so it would work with just the URI. His code however can still be found over at pastebin.
The basic way of working still remains the same though. It works by changing the URI to a full spotify URL and then uses the perl web-scraper to get all the titles and artist out. Those files are then put on the terminal.
#perl ./spotify-scrape.pl ‘spotify:track:2qpmEFEoc6bVpYhc4Lp5Uo’
#perl ./spotify-scrape.pl ‘spotify-uri’
ytlikely.sh, short for YoutubeMostLikely, is a simple script that uses Google’s YouTube API.
It simply accepts a query as argument, then it pushes that into the API, and echo’s the most likely video from that query.
#sh ./ytlikely.sh ‘daft punk – technologic’
#sh ./ytlikely.sh ‘search – term’
Last but not least we’ve got spot2mp3.sh, this shell script combines the former 2 scripts. overall it the following:
it makes a new directory from an argument provided to it.
it takes the spotify URI and get’s all songs from that using the spotify-scraper perl script.
for each of those songs he uses ytlikely.sh to see which video is the most likely.
then it uses youtube-dl to acutally get that video from youtube (it downloads the 360 mp4 version).
Youtube-dl then continues by convert that song to mp3, saves it to the new directory and removes the video file.
It then jumps to the next song and does it all over again
#sh ./spot2mp3.sh ‘spotify:track:1iNeZGJsoC0D7ZyJTdIbDS’ ‘DaftPunkTechnoLogic’
#sh ./spot2mp3.sh ‘spotify-uri’ ‘foldername’
I hope some of these scripts or info was useful to you. If so, drop me a line on twitter: @woutervddn
See you all next time