Skip to content

Commit

Permalink
add support for last.fm
Browse files Browse the repository at this point in the history
  • Loading branch information
christianvuerings committed May 14, 2011
1 parent f96f45a commit 529a06d
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 12 deletions.
7 changes: 6 additions & 1 deletion example.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,11 @@
color: #e9e9e9;
}
#lifestream_css_v2 .lifestream-delicious { background-image: url("images/delicious_color.gif"); }
#lifestream_css_v2 .lifestream-github { background-image: url("images/github_text_color.png"); }
#lifestream_css_v2 .lifestream-googlereader { background-image: url("images/googlereader_color.png"); }
#lifestream_css_v2 .lifestream-lastfm { background-image: url("images/lastfm_color.png"); }
#lifestream_css_v2 .lifestream-stackoverflow { background-image: url("images/stackoverflow_color.png"); }
#lifestream_css_v2 .lifestream-twitter { background-image: url("images/twitter_text.png"); }
#lifestream_css_v2 .lifestream-github { background-image: url("images/github_text_color.png"); }
#lifestream_css_v2 .lifestream-youtube { background-image: url("images/youtube_text.png"); }
</style>

Expand Down Expand Up @@ -99,6 +100,10 @@ <h2>Lifestream - formatted with CSS</h2>
"service": "github",
"user": "christianv"
},
{
"service": "lastfm",
"user": "denbuzze"
},
{
"service": "stackoverflow",
"user": "117193"
Expand Down
Binary file added images/lastfm_color.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 12 additions & 11 deletions jquery.lifestream-compiled.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 44 additions & 0 deletions jquery.lifestream.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,50 @@

};

$.fn.lifestream.feeds.lastfm = function(obj, callback){

var parseLastfmEntry = function(entry){
var output = "";

output +='loved <a href="'+ entry.url + '">'
+ entry.name + '</a> by <a href="' + entry.artist.url + '">'
+ entry.artist.name + "</a>";

return output;
}

var parseLastfm = function(input){
var output = [];

if(input.query && input.query.count && input.query.count > 0
&& input.query.results.lovedtracks
&& input.query.results.lovedtracks.track){
var list = input.query.results.lovedtracks.track;
for(var i=0, j=list.length; i<j; i++){
var entry = list[i];
output.push({
"date": new Date(parseInt((entry.date.uts * 1000), 10)),
"service": obj.service,
"html": parseLastfmEntry(entry)
});
}
}
return output;
};

$.ajax({
"url": createYqlUrl('select * from xml where url='
+ '"http://ws.audioscrobbler.com/2.0/user/'
+ obj.user + '/lovedtracks.xml"')
}).success(function(data){
if(typeof data === "string"){
data = $.parseJSON(data);
}
callback(parseLastfm(data));
});

};

$.fn.lifestream.feeds.stackoverflow = function(obj, callback){

var parseStackoverflowItem = function(item){
Expand Down

0 comments on commit 529a06d

Please sign in to comment.