I’ve always been a geek when it comes to music, and the lonely nights of lockdown gave me the chance this year to work on a project I’d wanted to do for some time: building my own online music library.
Ever since I started downloading songs from iTunes back in the day, I’ve always wanted to be able to see what songs or artists I’ve been listening to most over a given length of time. iTunes had limited abilities in that, but when I signed up with Last.fm first all the way back in 2009 this now brought charts for the last week, last month and last year as well as all time.
However, even Last.fm has had its limits – with times where it doesn’t pick up all the songs I’ve listened to, either from iTunes or from Spotify (which I’ve moved to using exclusively over the last few years).
My friend charlieegan3 paved the way for this sort of project a couple of years ago with his own music library, which gave me the building blocks of what I’d want to do with my own one (even though mine is less advanced!)
So with some time on my hands this year, I’ve been able to create something that includes all the functionality I’d want to browse through my music library and listen to it, and in the process add some features that don’t exist in iTunes, Last.fm for even Spotify.
The technical bit
At its core, the library represents an intersection between various different music APIs which I’ve linked together to showcase the music I listen to.
As Last.fm is where this data has been stored for most of the decade, using their API allowed me to pull all of the track plays I’ve had in the past.
Moving forward, the library now takes all of this data directly from Spotify – which is less prone to the hiccups of authentication that Last.fm seems to have. The Spotify API also has the added bonus of bringing with it an image for each artist, data about each song, artist and album and the ability to embed a track on the page.
One of the things that integrating with the Spotify API has also allowed me to do is to use my music library as the search function to queue songs on Spotify. Searching for songs in your library is something that Spotify isn’t great at, but now I can quickly find the songs I’m looking for and queue them at the push of a button.
Another big source of info for the library comes from MusicBrainz, which is an open-source database of information about songs and artists. This brings in information about where an artist is from and other biographical info, as well as information about genres.
Finally, some of the data even comes from my iTunes database on my own computer. Spotify and Last.fm only allow you to like or favourite a song, whereas iTunes has always allowed a rating out of 5, which I’ve always liked and used when building playlists. So I was able to take that star rating data out of iTunes and link it up with the songs in the new library.
Once all the connections were in place there was some more manual work needed to clean things up, such as crediting artists correctly on tracks with featured artists and bringing songs with slightly different names in different places under the same name, but after all that groundwork has been done the maintenance of it should be relatively simple.
The cool new things bit
Bringing all of this data into one place has allowed me to do some cool things aside from tracking my own music habits.
One thing that always bugged me about iTunes and Last.fm is that if more than two artists appeared on a song, it wouldn’t handle them separately, for instance, “One Kiss” by Calvin Harris and Dua Lipa is credited to them both – so when searching through either Calvin Harris or Dua Lipa songs it wouldn’t show up. But now with the work I’ve done on the database it shows up in both artists’ track lists. It’s a small thing but makes a big difference to some artists’ play counts.
My favourite of the new features is my artist visualiser – which shows how the artists in my library have collaborated with each other in the past. Songs in the modern era quite commonly have different bands and artists working together, either as featured artists, remixing songs or having joint-billing, and I had always wondered just now networked the artists are through these connections. It turns out to be quite a lot! With the visualiser you can see that hundreds of artists are only a couple of degrees of separation from each other, and think it’s a really cool way to see how even disparate artists might be closer to each other than you’d think.
With the MusicBrainz data on where artists are from I was able to plot a world map (via Google Maps) of where artists are from. Again it’s quite cool to see exactly where the hotspots are that produce the music I like best, but also to see the variety of places from around the world too.
For each artist page I’ve created a related artist section that works pretty well. This is based on where artists have collaborated on tracks in my library, but then based off shared genres (courtesy of Spotify and MusicBrainz’ data) and where they come from.
Finally, I was able to automate my usual end-of-year chart generation to see my favourite songs so far this year. This used to be a convoluted process of going between iTunes and Excel, but it now auto-updates.
There’s more that I’d like to add in time, in terms of recognising different playlists I have and syncing them between my library and Spotify, developing charts for when songs were released (1980s, 1990s etc.) or working on some algorithms that build better play shuffles for myself, but I’m pretty pleased with where it’s at for now.
So please feel free to have a browse through the library and find some tunes to listen to!