I worked on this assignment with my Team: Andrew Nelson, Kurt Koller and Will Boyd.
This first thing we did was to download the Last.fm API. Kurt signed up on Last.fm to register to use the API. We decided to use Python for the project so we downloaded and installed pylast from Google Code. Copying the files into the Python directory and then using the command import pylast in IDLE gave us no errors so the install was successful.
To begin our recommendation system, we started simple with getting similar artists to a given artist:
>>> artist = pylast.Artist(“The Black Keys”,”bd46f9bce716e11a6d311d77c06d2159″,”a313f7a6a587763c71eeb3cac498ca”,”)
and got a large list of similar artists! Success!
Right now we are debating whether to use Python as a command-line interface or to switch to PhP to make a simple GUI application. Will has the most experience in PhP so he has taken the lead on trying to get a simple GUI up and running. Of course we will now have to download and install the last.fm API for PhP. While Will works on the PhP version, Kurt, Andrew and I are working on the Python command-line.
To create our system, we’d like to create a menu with a list of options the user can choose:
- Input artist, output list of similar artists: artist.get_similar()
- Input artist, output top tracks: artist.get_top_tracks()
- Input track, output list of similar songs: track.getSimilar()
So, we started our basic command-line menu system. Should be pretty simple right, especially with Python. First issue we ran into was our if-statement. Prompt the user for a menu item, and then go into that if-block. We created a simple test to see if we could get option 1 from above to work. User typed in a 1 and it wouldn’t go into the corresponding if-block! WHY! We did some research online and our syntax was correct. We figured out that the raw_input() method returns a String and we were testing the value of 1 as an integer! Problem solved, we got option 1 to work!
Option 2 is not working as smoothly as the first. We keep getting errors for the method get_top_tracks(). Let me just say that the last.fm API is terrible! The syntax is wrong and the parameter values are off. The API for get_top_tracks() says it takes two arguments but when we input them into our program, we get a syntax error saying it only takes one parameter.
Code so far:
import pylast print "Welcome to the Team 3 Pylast Recommender!" print "To find an artist similar to your artist, press (1)" print "To find a list of top tracks by an artist, press (2)" print "To find a list of songs similar to a particular song, press (3)" print "To quit, press (4)" input = raw_input(">") print input if (input=="1"): print "Please enter the name of an Artist" similarArtistName = raw_input(">") similarArtist = pylast.Artist("similarArtistName", "bd46f9bce716e11a6d311d77c06d2159", "a313f7a6a587763c71eeb3cac498ca40", '') print similarArtist.get_similar() elif (input=="2"): print "Please enter the name of an Artist" trackArtistName = raw_input(">") trackArtist = pylast.Artist("trackArtistName", "bd46f9bce716e11a6d311d77c06d2159", "a313f7a6a587763c71eeb3cac498ca40", '') print pylast.Artist.get_top_tracks(trackArtist)
Will demo’ed a great PhP recommendation system in class. He used these simple last.fm API methods: Artist.get_similar(), Track.get_similar(), Geo.get_top_artist() and Geo.get_top_tracks(). Check it out here!