Somebody Loves this Album
A time, temperature, and location-specific music recommender that pulls from user-generated categories on last.fm.
Try it out here
There are a million and one websites out there that recommend albums based on what you already listen to, and they do it really well. Spotify can whip up a playlist instantly based on a single song you liked, with dozens more just like it.
But where are you supposed to go when you want something totally new? When you’re sick of your perfectly-curated, highly-specific genres that your streaming platform of choice has served up for you?
Enter “Somebody Loves this Album,” the music recommender that uses your geolocation data (latitude & longitude) as well as the local time and temperature to source an album recommendation from user-generated tags on last.fm.
Albums are pulled from the top 50 results from tags like “my favorite albums” and “amazing,” resulting in a piece of music loved by at least a few people. Because the tag & album are chosen based on changing values (time, temp, your location), the recommendation changes every time you open the page.
RESULT EXAMPLES
time: 20 : 41, lat: 40.69[...], lon: -73.93[...], temp: 8°F
time: 21:19 , lat: 40.69[...] , lon: -73.933[...] , temp: 64.04°F
time: 22:26, lat: 40.69[...], lon: -73.93[...], temp: 62.85°F
HOW IT WORKS
PROCESS
I didn’t set out to use the user-generated tags that I ended up using for the base of this project. My original idea was for the end result to be a genre for the user to explore, so I tried to find a list of every genre on last.fm. That is not something I could access through the API, so I began by looking up popular tags for popular releases and saw many that I expected, like “alternative rock” and “indie.” But then I saw ones like “favourite albums” and “albums i own” that Last.fm users had tagged themselves. It’s a really interesting way to see how people catalog their music, and it’s something I didn’t think would be able to access. I ran a few more with albums from different genres to see what they would come up with.
Then, I plugged in a tag and got the top 15 albums that are tagged with that tag.
My goal was to create a website that people can visit throughout the day and get a different recommendation based on changing variables like the time and temperature, even if they stay in the same location. To achieve this, I had to figure out how to turn those types of data into numbers I could work with to result in a single album.
Here are some of the chaotic pages of my notebook in which i attempted to figure out how this algorithm would work.
For the list of tags to pull from, I first looked at the top tags from famous albums. From there, I found tags that likely had many results associated with them, and then searched similar words. I ended up with this list, which all had at least 50 albums with that tag applied.
great, favorite, love, perfect albums, favourite album, best album ever, underrated excellent, album of the year, favourite albums, best albums, my favorites, great albums good albums, love at first listen, favorite albums, good music, cool, my favourites album of the year, favorite album, perfect, best album, amazing, awesome, the best favorite albums ever, albums i love, essential, beautiful, favorite, my favorite albums, essential albums, best, flawless, favorites, sweet, epic, genius, unique, fun album of the year, stunning, incredible, brilliant, lovely, pleasant, pretty, good.
Getting all of the API data to load correctly was the next challenge. Because the location data takes a full 5 seconds to load, I had to write a few functions within functions so it would load in order, to avoid this:
The flowchart above goes into more detail, but this is the simplified version:
1. Log the hour + minute from the local time when the page is opened.
2. Run the location API.
3. Only when that has returns a result, load the weather API with the latitude & longitude from the location API.
4. Log the temperature
5. Run the numbers & get the album recommendation.
REFERENCES
2. Temperature data from the openWeather API
3. Album data from the last.fm API
4. Code for the typewriter text effect from this sketch by aferriss
5. APIs and Asynchronous JavaScript by Chris Ferdinandi