Request.YQL + Last.fm

Get the album information by passing the artist name and album title.

HTML

<ul id="tracks"></ul>

JavaScript

Request.YQL = new Class({

    Extends: Request.JSONP,

    options: {
        url: 'http://query.yahooapis.com/v1/public/yql?q=',
        allTables: true,
        data: {
            format: 'json',
            env: 'store://datatables.org/alltableswithkeys'
        }
    },

    initialize: function(options) {
        this.setOptions(options);
        this.options.url = this.options.url + encodeURIComponent(this.options.query);
        this.running = false;
        this.requests = 0;
        this.triesRemaining = [];
    }

});

var yqlQuery = "SELECT * FROM lastfm.album.getinfo WHERE api_key=\"2ba28857a0d040e22ad357ec8199a8bf\" and album=\"{album}\" and artist=\"{artist}\"".substitute({
    artist: 'City and Colour',
    album: 'Bring Me Your Love'
});
alert(yqlQuery);
// make the YQL call
new Request.YQL({
    query: yqlQuery,
    allTables: true,
    onSuccess: function(result) {
        var albumInfo = result.query.results.lfm.album;
        Element('img', {
            src: albumInfo.image[2].content
        }).inject(document.body, 'top');
        
        albumInfo.tracks.track.each(function(track){
            Element('li', {
                text: track.name
            }).inject(document.id('tracks'));
        });
    }
}).send();