Jekyll data playlists
In 2008, I started creating a playlist for every season. I kept my playlists in iTunes, but have migrated to Rdio. These playlists are my audio diaries. I can listen to one and remember where I was, where I was going, who I was with, and how I felt. I love these playlists.
Jail breaking the playlists
When I got a new computer in 2012, I didn’t save my playlists in iTunes properly. In short, my files got disconnected from my library. It was a hot mess, but thankfully I had the original
iTunes Music Library.xml. I found a great tutorial that taught me how to import the data in the XML into an Access database. Now I had a table containing all my playlists with track title, artist, and album.
Next, I migrated the database to PHPmyadmin. Using PHP I spun out each playlist into markup and pasted the contents into its own post on this site. It worked great, a little time consuming, but it worked.
Importing to Rdio
After some more hacking, I was able to import the playlists into Rdio using re/spin. Re/spin imports any Last.fm or Spotify playlist into Rdio. The service also accept XSPF. I was able to save each playlist as an XSPF and import it into Rdio.
Not all songs transferred over, but enough did to make it worth it. Re/spin will want to find something if Rdio doesn’t have a match, so beware of some funky replacements. Otherwise, re/spin is a fabulous service.
At this point I had my playlist data stored in an SQL table, in Rdio, and in individual posts. I started to feel guilty about shoveling my data in every direction.
I decided to tighten up the process.
Jekyll data files
I ditched the database and moved the playlists into a single YAML file. Using PHP, I outputted the playlist data into YAML format. I had to clean out special characters, but in all it worked beautifully. I saved my data into
playlists.yml in my site’s
Using liquid, I could now spin through the data. To test, I created a playlist master page that pulls all the data from
playlists.yml into a beautiful list.
Things were looking tighter, but I still had duplicated data on my site. I had the playlists stored in the YAML file and I had the markup I copied and pasted into individual posts.
I put Jekyll to work.
- I ripped out the content from all the playlist posts.
- I matched the names of the posts to the names of the playlists.
- To my post layout, I added the condition that if the
page.category == 'playlists'then
single-playlist.htmlwill then loop through
playists.ymlwhere the post title equals a playlist name. If the playlist name matches, it will output the data for that playlist only.
- Since I replaced the content for these posts, I updated my feed to link directly to the Rdio playlist and have no content.
Now I can adjust the markup of my playlist posts just by changing
single-playlist.html. Likewise, I can control all the playlist data by editing
Adding new data
My new workflow for adding a playlist to my site at the end of the season:
- Open up the Rdio playlist to be exported.
- Run the bookmarklet to output the playlist in YAML format (more about this below).
- Copy and paste the YAML at the bottom of
- Create a new post title with the same name as the playlist.
- Serve Jekyll/commit and the playlist data will automatically populate into the new post.
I found this great bookmarklet that scrapes the title, artist, and album from a given Rdio playlist. I’ve had little experience with bookmarklets, but I hacked away at it. My version outputs the playlist into YAML. It also grabs the playlist title, image, and link to the playlist on Rdio.
Now, I need to make sure that the entire playlist is loaded and that I open the “Share” modal, otherwise the bookmarklet won’t find those values. I’ll make the bookmarklet sweet on a rainy day, but for now it works despite the conditions.
Rdio playlist to YAML bookmarklet
It felt great to get my playlists under one roof. It felt even better to figure out how to use data files in Jekyll.