Added similar artists, artist stats
This commit is contained in:
@ -194,68 +194,25 @@ exports.getLastfm = function(req, res) {
|
|||||||
artist: 'Epica',
|
artist: 'Epica',
|
||||||
handlers: {
|
handlers: {
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
console.log(data);
|
|
||||||
|
|
||||||
var artist = {
|
var artist = {
|
||||||
name: data.artist.name,
|
name: data.artist.name,
|
||||||
image: data.artist.image.slice(-1)[0]['#text'],
|
image: data.artist.image.slice(-1)[0]['#text'],
|
||||||
tags: data.artist.tags.tag,
|
tags: data.artist.tags.tag,
|
||||||
bio: data.artist.bio.summary,
|
bio: data.artist.bio.summary,
|
||||||
stats: data.artist.stats
|
stats: data.artist.stats,
|
||||||
|
similar: data.artist.similar.artist
|
||||||
};
|
};
|
||||||
|
//
|
||||||
res.render('api/lastfm', {
|
res.render('api/lastfm', {
|
||||||
title: 'Last.fm API',
|
title: 'Last.fm API',
|
||||||
artist: artist
|
artist: artist
|
||||||
});
|
});
|
||||||
//return res.send(data.artist);
|
|
||||||
},
|
},
|
||||||
error: function(error) {
|
error: function(error) {
|
||||||
console.log(error.message);
|
res.send(error.message);
|
||||||
return error.message;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* POST /api/lastfm
|
|
||||||
* Form submission to retrieve artist/track information
|
|
||||||
* Accessed via AJAX
|
|
||||||
*/
|
|
||||||
exports.postLastfm = function(req, res) {
|
|
||||||
if (req.body.track) {
|
|
||||||
lastfm.request("track.getInfo", {
|
|
||||||
artist: 'Evanescence',
|
|
||||||
track: 'My Immortal',
|
|
||||||
handlers: {
|
|
||||||
success: function(data) {
|
|
||||||
console.log(data);
|
|
||||||
return data;
|
|
||||||
},
|
|
||||||
error: function(error) {
|
|
||||||
console.log(error.message);
|
|
||||||
return error.message;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (req.body.artist) {
|
|
||||||
lastfm.request("artist.getInfo", {
|
|
||||||
artist: 'Evanescence',
|
|
||||||
handlers: {
|
|
||||||
success: function(data) {
|
|
||||||
console.log(data);
|
|
||||||
},
|
|
||||||
error: function(error) {
|
|
||||||
console.log(error.message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -19,12 +19,17 @@ block content
|
|||||||
h3.text-primary Artist Information
|
h3.text-primary Artist Information
|
||||||
|
|
||||||
h4= artist.name
|
h4= artist.name
|
||||||
.btn.btn-sm.btn-primary-outline
|
ul.list-inline
|
||||||
|
li
|
||||||
|
small.text-primary
|
||||||
i.fa.fa-users
|
i.fa.fa-users
|
||||||
| Listeners: #{artist.stats.listeners}
|
strong Listeners:
|
||||||
.btn.btn-sm.btn-primary-outline
|
| #{artist.stats.listeners}
|
||||||
|
li
|
||||||
|
small.text-primary
|
||||||
i.fa.fa-headphones
|
i.fa.fa-headphones
|
||||||
| Scrobbles #{artist.stats.playcount}
|
strong Scrobbles:
|
||||||
|
| #{artist.stats.playcount}
|
||||||
p
|
p
|
||||||
img(src='#{artist.image}')
|
img(src='#{artist.image}')
|
||||||
p
|
p
|
||||||
@ -34,16 +39,9 @@ block content
|
|||||||
| #{tag.name}
|
| #{tag.name}
|
||||||
|
|
|
|
||||||
p!= artist.bio
|
p!= artist.bio
|
||||||
|
strong Similar Artists
|
||||||
|
ul.list
|
||||||
|
for similarArtist in artist.similar
|
||||||
|
li
|
||||||
h3.text-primary Song Information
|
!= '<img src="#{similarArtist.image[0].#text}">'
|
||||||
form.form-horizontal(role='form', method='POST')
|
a(href='#{similarArtist.url}') #{similarArtist.name}
|
||||||
.form-group
|
|
||||||
label(class='col-sm-2 control-label', for='artist') Song
|
|
||||||
.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
|
|
Reference in New Issue
Block a user