Added artist information on last.fm example with bio, tags, cover image, and stats
This commit is contained in:
1
app.js
1
app.js
@ -26,6 +26,7 @@ var app = express();
|
||||
app.set('port', process.env.PORT || 3000);
|
||||
app.set('views', path.join(__dirname, 'views'));
|
||||
app.set('view engine', 'jade');
|
||||
app.locals.pretty = true;
|
||||
app.use(express.favicon());
|
||||
app.use(express.logger('dev'));
|
||||
app.use(express.cookieParser());
|
||||
|
@ -174,6 +174,10 @@ exports.getEtsy = function(req, res) {
|
||||
*/
|
||||
exports.getNewYorkTimes = function(req, res) {
|
||||
|
||||
res.render('api/nyt', {
|
||||
title: 'New York Times API',
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
@ -186,10 +190,34 @@ exports.getLastfm = function(req, res) {
|
||||
secret: '4ae76d10d76cf680cebf4f0c8dea1aa4'
|
||||
});
|
||||
|
||||
lastfm.request("artist.getInfo", {
|
||||
artist: 'Epica',
|
||||
handlers: {
|
||||
success: function(data) {
|
||||
console.log(data);
|
||||
|
||||
var artist = {
|
||||
name: data.artist.name,
|
||||
image: data.artist.image.slice(-1)[0]['#text'],
|
||||
tags: data.artist.tags.tag,
|
||||
bio: data.artist.bio.summary,
|
||||
stats: data.artist.stats
|
||||
};
|
||||
|
||||
res.render('api/lastfm', {
|
||||
title: 'Last.fm API',
|
||||
|
||||
artist: artist
|
||||
});
|
||||
//return res.send(data.artist);
|
||||
},
|
||||
error: function(error) {
|
||||
console.log(error.message);
|
||||
return error.message;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -17,26 +17,25 @@ block content
|
||||
| Documentation
|
||||
|
||||
h3.text-primary Artist Information
|
||||
form.form-horizontal(role='form', method='POST')
|
||||
.form-group
|
||||
label(class='col-sm-2 control-label', for='artist') Artist
|
||||
.col-sm-4
|
||||
input.form-control(type='text', name='artist', id='artist')
|
||||
.form-group
|
||||
.col-sm-offset-2.col-sm-4
|
||||
button.btn.btn-primary-outline(type='submit') Submit
|
||||
|
||||
.panel.panel-default
|
||||
.panel-heading
|
||||
h3.title #{artist.name}
|
||||
.panel-body
|
||||
.row
|
||||
.col-xs-3
|
||||
h4= artist.name
|
||||
.btn.btn-sm.btn-primary-outline
|
||||
i.fa.fa-users
|
||||
| Listeners: #{artist.stats.listeners}
|
||||
.btn.btn-sm.btn-primary-outline
|
||||
i.fa.fa-headphones
|
||||
| Scrobbles #{artist.stats.playcount}
|
||||
p
|
||||
img(src='#{artist.image}')
|
||||
.col-xs-9
|
||||
strong Artist Bio
|
||||
br
|
||||
p= artist.bio
|
||||
p
|
||||
for tag in artist.tags
|
||||
span.label.label-primary
|
||||
i.fa.fa-tag
|
||||
| #{tag.name}
|
||||
|
|
||||
p!= artist.bio
|
||||
|
||||
|
||||
|
||||
|
||||
h3.text-primary Song Information
|
||||
|
Reference in New Issue
Block a user