Audioscrobbler (Last.FM) API: Determining What's An Album
Last.FM's API may be the most informative out there, but its data still has issues, such as duplicated tracks on a particular album, that differ slightly -- such as one added exclamation mark. Being able to filter out those tracks may be easy, but one problem I did face when dealing with the API today was determining what constitutes album.
Unfortunately there is no easy way to determine what constitutes an album and what's a single (SP, EP). The reason for this is clear, searching for the artist "Oasis" returns a plethora of albums, the majority of which aren't albums.
When I have used the API in the past, I have decided what's an album based off of the MBID field. The simple logic worked like so, if the MBID is empty then it is not an album, otherwise class it as an album. This was all fine and dandy until you look at the smaller bands, take for example the post-rock band, Maybeshewill.
As Maybeshewill is a small band, there are no MBIDs for any of their albums, and therefore the aforementioned logic reveals its flaw.
Today I decided that there must be a way based on the data available in that API to determine what is an album. The logic I arrived at seems to work for all the artists I have tried. Of course it's not perfect because this data is extremely variable, and nothing can be taken for granted.
What I did was the following, in pseudo code:
Get the "reach" value of the first album;
Get the "reach" value for any subsequent;
Calculate the percentage of the current album compared to the most popular;
If the current is less than 10% then ignore it.
The reach value is, in essence, how popular that particular album is. Naturally, non-albums are less popular than albums. 10% is a value that was arrived at through some inspection of the break down of the percentages.
To exemplify, if the top album has a reach of 65,000, and the second album in the list has a reach of 40,000, we would use the following equation:
(40,000 / 65,000) * 100 = 61.5%
Whereas the smaller so-called albums would have a much smaller reach value and therefore, the majority, not all, will fall below the 10% line.
You can of course alter the 10% value as this is purely based off of my personal judgement. Don't expect it to be perfect. It will miss some that are albums, and it will include some that aren't albums.
Without making subsequent calls to clarify, however, this is perhaps the best, at least insofar as I can see, way to determine what is and what isn't an album.
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
The Following User Says Thank You to Wildhoney For This Useful Post: