The response is something like this:
<div id="nowPlayingSong">BLACK HOLE SUN</div>
Yeah, that's right, it's 2012, and they're still playing "Black Hole Sun" (hey, I like the song too - but a bit less than when it was released in the early/mid 90's).
Now that we have a "easy" way of obtaining the current artist/song information, the next step is to find out the release date. Fortunately, Apple's dominance of the recorded music business comes in handy here. iTunes makes it easy to search for something - they even have a convenient API guide: http://www.apple.com/itunes/affiliates/resources/documentation/itunes-store-web-service-search-api.html
Thus, the search URI looks something like this: https://itunes.apple.com/search?media=music&term=SOUNDGARDEN+BLACK+HOLE+SUN
The result is a JSON array (very nice!) containing 43 matches. The hard part here is going to be finding the "correct" entry among all of the values. It seems that the "ideal" way to accomplish this is to find the object(s) which match (case insensitive!) these property values:
"trackName":"Black Hole Sun",
In this case, there's a few "correct" matches, and each has a different release date:
In this case, the "solution" is to simply pick the oldest release date.
Saving it for laterThe next part is accumulating that information and storing (persisting) it so that an continual analysis can be performed. Otherwise, it's possible that a particular DJ may prefer the "classic" songs over the newer ones, and thus would skew the overall results. The big question here is "what's the average age of the songs played on this station?"
Since this is being stored "in the cloud", a few options are available.
- Google App Engine Datastore, which is effectively a key/object store.
- MongoDB, a document store
- Something relational, like AWS RDS, Microsoft SQL, or Google Cloud SQL
For this trivial app (small amount of persistence), any of them will suffice. More on that, and the eventual code/implementation coming later.