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);
|
var lastfm = new LastFmNode(secrets.lastfm);
|
||||||
async.parallel({
|
async.parallel({
|
||||||
artistInfo: function(done) {
|
artistInfo: function(done) {
|
||||||
lastfm.request("artist.getInfo", {
|
lastfm.request('artist.getInfo', {
|
||||||
artist: 'Epica',
|
artist: 'Sirenia',
|
||||||
handlers: {
|
handlers: {
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
done(null, 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) {
|
artistTopAlbums: function(done) {
|
||||||
lastfm.request("artist.getTopAlbums", {
|
lastfm.request('artist.getTopAlbums', {
|
||||||
artist: 'Epica',
|
artist: 'Sirenia',
|
||||||
handlers: {
|
handlers: {
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
var albums = [];
|
var albums = [];
|
||||||
@ -231,7 +248,8 @@ exports.getLastfm = function(req, res, next) {
|
|||||||
bio: results.artistInfo.artist.bio.summary,
|
bio: results.artistInfo.artist.bio.summary,
|
||||||
stats: results.artistInfo.artist.stats,
|
stats: results.artistInfo.artist.stats,
|
||||||
similar: results.artistInfo.artist.similar.artist,
|
similar: results.artistInfo.artist.similar.artist,
|
||||||
topAlbums: results.artistTopAlbums
|
topAlbums: results.artistTopAlbums,
|
||||||
|
topTracks: results.artistTopTracks
|
||||||
};
|
};
|
||||||
res.render('api/lastfm', {
|
res.render('api/lastfm', {
|
||||||
title: 'Last.fm API',
|
title: 'Last.fm API',
|
||||||
@ -556,7 +574,7 @@ exports.getInstagram = function(req, res, next) {
|
|||||||
|
|
||||||
async.parallel({
|
async.parallel({
|
||||||
searchByUsername: function(done) {
|
searchByUsername: function(done) {
|
||||||
ig.user_search('lisa_veronica', function(err, users, limit) {
|
ig.user_search('richellemead', function(err, users, limit) {
|
||||||
done(err, users);
|
done(err, users);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -38,7 +38,7 @@ block content
|
|||||||
.col-sm-4
|
.col-sm-4
|
||||||
.panel.panel-default
|
.panel.panel-default
|
||||||
.panel-body
|
.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
|
a(href='/api/lastfm') Last.fm
|
||||||
.col-sm-4
|
.col-sm-4
|
||||||
.panel.panel-default
|
.panel.panel-default
|
||||||
|
@ -3,9 +3,8 @@ extends ../layout
|
|||||||
block content
|
block content
|
||||||
.page-header
|
.page-header
|
||||||
h2
|
h2
|
||||||
i.fa.fa-music
|
i.fa.fa-play-circle-o(style='color: #db1302')
|
||||||
| Last.fm API
|
| Last.fm API
|
||||||
|
|
||||||
.btn-group.btn-group-justified
|
.btn-group.btn-group-justified
|
||||||
a.btn.btn-primary(href='https://github.com/jammus/lastfm-node#lastfm-node', target='_blank')
|
a.btn.btn-primary(href='https://github.com/jammus/lastfm-node#lastfm-node', target='_blank')
|
||||||
i.fa.fa-check-square-o
|
i.fa.fa-check-square-o
|
||||||
@ -17,41 +16,32 @@ block content
|
|||||||
i.fa.fa-code-fork
|
i.fa.fa-code-fork
|
||||||
| API Endpoints
|
| API Endpoints
|
||||||
|
|
||||||
h3.text-primary Artist Information
|
h3= artist.name
|
||||||
|
img.thumbnail(src='#{artist.image}')
|
||||||
|
|
||||||
h4= artist.name
|
h3 Tags
|
||||||
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}
|
|
||||||
|
|
||||||
p
|
|
||||||
img(src='#{artist.image}')
|
|
||||||
|
|
||||||
p
|
|
||||||
for tag in artist.tags
|
for tag in artist.tags
|
||||||
span.label.label-primary
|
span.label.label-primary
|
||||||
i.fa.fa-tag
|
i.fa.fa-tag
|
||||||
| #{tag.name}
|
| #{tag.name}
|
||||||
|
|
|
|
||||||
|
|
||||||
.panel.panel-primary
|
h3 Biography
|
||||||
.panel-heading Biography
|
p!= artist.bio
|
||||||
.panel-body
|
|
||||||
!= artist.bio
|
|
||||||
|
|
||||||
h4 Top Albums
|
h3 Top Albums
|
||||||
for album in artist.topAlbums
|
for album in artist.topAlbums
|
||||||
img(src='#{album}', width=150, height=150)
|
img(src='#{album}', width=150, height=150)
|
||||||
|
|
|
|
||||||
|
|
||||||
h4 Similar Artists
|
h3 Top Tracks
|
||||||
ul.list-unstyled
|
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
|
for similarArtist in artist.similar
|
||||||
li
|
li
|
||||||
a.lead(href='#{similarArtist.url}') #{similarArtist.name}
|
a(href='#{similarArtist.url}') #{similarArtist.name}
|
Reference in New Issue
Block a user