Skip to content

Instantly share code, notes, and snippets.

@kopiro
Created August 12, 2011 12:08
Show Gist options
  • Save kopiro/1141922 to your computer and use it in GitHub Desktop.
Save kopiro/1141922 to your computer and use it in GitHub Desktop.
Get some information from Last.FM
function loadLastFmSong() {
$.getJSON("http://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks&user=destefanoflavio&api_key=b25b959554ed76058ac220b7b2e0a026&format=json&callback=?", function(json) {
lastfmtrack = json.recenttracks.track[0];
$("#lastfm_song").html('<a target="_blank" href="'+lastfmtrack.url+'">'+lastfmtrack.name+", di "+lastfmtrack.artist["#text"]+'</a>');
$("#lastfm_song").append('<img src="http://icons.iconarchive.com/icons/fatcow/farm-fresh/16/music-icon.png" style="margin-left: 4px"/>');
});
}
function loadLastFmArtists(n) {
if (!n) n=5;
$.getJSON("http://ws.audioscrobbler.com/2.0/?method=user.gettopartists&user=destefanoflavio&api_key=b25b959554ed76058ac220b7b2e0a026&format=json&callback=?", function(json) {
lastfmtopartists = json.topartists.artist;
for (var i=0; i<n; i++) {
$("#lastfm_artists").append('<li><a target="_blank" href="'+lastfmtopartists[i].url+'">'+lastfmtopartists[i].name+"</a></li>");
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment