Updated last.fm api example
This commit is contained in:
@ -192,8 +192,8 @@ exports.getLastfm = function(req, res, next) {
|
||||
var lastfm = new LastFmNode(secrets.lastfm);
|
||||
async.parallel({
|
||||
artistInfo: function(done) {
|
||||
lastfm.request("artist.getInfo", {
|
||||
artist: 'Epica',
|
||||
lastfm.request('artist.getInfo', {
|
||||
artist: 'Sirenia',
|
||||
handlers: {
|
||||
success: function(data) {
|
||||
done(null, data);
|
||||
@ -204,9 +204,26 @@ exports.getLastfm = function(req, res, next) {
|
||||
}
|
||||
});
|
||||
},
|
||||
artistTopTracks: function(done) {
|
||||
lastfm.request('artist.getTopTracks', {
|
||||
artist: 'Sirenia',
|
||||
handlers: {
|
||||
success: function(data) {
|
||||
var tracks = [];
|
||||
_.each(data.toptracks.track, function(track) {
|
||||
tracks.push(track);
|
||||
});
|
||||
done(null, tracks.slice(0,10));
|
||||
},
|
||||
error: function(err) {
|
||||
done(err);
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
artistTopAlbums: function(done) {
|
||||
lastfm.request("artist.getTopAlbums", {
|
||||
artist: 'Epica',
|
||||
lastfm.request('artist.getTopAlbums', {
|
||||
artist: 'Sirenia',
|
||||
handlers: {
|
||||
success: function(data) {
|
||||
var albums = [];
|
||||
@ -231,7 +248,8 @@ exports.getLastfm = function(req, res, next) {
|
||||
bio: results.artistInfo.artist.bio.summary,
|
||||
stats: results.artistInfo.artist.stats,
|
||||
similar: results.artistInfo.artist.similar.artist,
|
||||
topAlbums: results.artistTopAlbums
|
||||
topAlbums: results.artistTopAlbums,
|
||||
topTracks: results.artistTopTracks
|
||||
};
|
||||
res.render('api/lastfm', {
|
||||
title: 'Last.fm API',
|
||||
@ -556,7 +574,7 @@ exports.getInstagram = function(req, res, next) {
|
||||
|
||||
async.parallel({
|
||||
searchByUsername: function(done) {
|
||||
ig.user_search('lisa_veronica', function(err, users, limit) {
|
||||
ig.user_search('richellemead', function(err, users, limit) {
|
||||
done(err, users);
|
||||
});
|
||||
},
|
||||
|
@ -38,7 +38,7 @@ block content
|
||||
.col-sm-4
|
||||
.panel.panel-default
|
||||
.panel-body
|
||||
img(src='http://www.bigbigtrain.com/pics/gfx/lastfm_logo.png', height=40)
|
||||
img(src='http://fontslogo.com/wp-content/uploads/2013/02/Lastfm-Logo-Font.jpg', height=40)
|
||||
a(href='/api/lastfm') Last.fm
|
||||
.col-sm-4
|
||||
.panel.panel-default
|
||||
|
@ -3,9 +3,8 @@ extends ../layout
|
||||
block content
|
||||
.page-header
|
||||
h2
|
||||
i.fa.fa-music
|
||||
i.fa.fa-play-circle-o(style='color: #db1302')
|
||||
| Last.fm API
|
||||
|
||||
.btn-group.btn-group-justified
|
||||
a.btn.btn-primary(href='https://github.com/jammus/lastfm-node#lastfm-node', target='_blank')
|
||||
i.fa.fa-check-square-o
|
||||
@ -17,41 +16,32 @@ block content
|
||||
i.fa.fa-code-fork
|
||||
| API Endpoints
|
||||
|
||||
h3.text-primary Artist Information
|
||||
h3= artist.name
|
||||
img.thumbnail(src='#{artist.image}')
|
||||
|
||||
h4= artist.name
|
||||
ul.list-inline
|
||||
li
|
||||
small.text-primary
|
||||
i.fa.fa-users
|
||||
| Listeners: #{artist.stats.listeners}
|
||||
li
|
||||
small.text-primary
|
||||
i.fa.fa-headphones
|
||||
| Scrobbles: #{artist.stats.playcount}
|
||||
h3 Tags
|
||||
for tag in artist.tags
|
||||
span.label.label-primary
|
||||
i.fa.fa-tag
|
||||
| #{tag.name}
|
||||
|
|
||||
|
||||
p
|
||||
img(src='#{artist.image}')
|
||||
h3 Biography
|
||||
p!= artist.bio
|
||||
|
||||
p
|
||||
for tag in artist.tags
|
||||
span.label.label-primary
|
||||
i.fa.fa-tag
|
||||
| #{tag.name}
|
||||
|
|
||||
|
||||
.panel.panel-primary
|
||||
.panel-heading Biography
|
||||
.panel-body
|
||||
!= artist.bio
|
||||
|
||||
h4 Top Albums
|
||||
h3 Top Albums
|
||||
for album in artist.topAlbums
|
||||
img(src='#{album}', width=150, height=150)
|
||||
|
|
||||
|
||||
h4 Similar Artists
|
||||
ul.list-unstyled
|
||||
h3 Top Tracks
|
||||
ol
|
||||
for track in artist.topTracks
|
||||
li
|
||||
a(href='#{track.url}') #{track.name}
|
||||
|
||||
h3 Similar Artists
|
||||
ul.list-unstyled.list-inline
|
||||
for similarArtist in artist.similar
|
||||
li
|
||||
a.lead(href='#{similarArtist.url}') #{similarArtist.name}
|
||||
a(href='#{similarArtist.url}') #{similarArtist.name}
|
Reference in New Issue
Block a user