More sanity checking on passed IDs

This commit is contained in:
Jonathan Cremin 2014-12-05 18:08:40 +00:00
parent a33570e1d0
commit ff698cff14
4 changed files with 22 additions and 2 deletions

View file

@ -18,6 +18,12 @@ module.exports.lookupId = function(id, type) {
request.get(apiRoot + path, function(res) {
var result = res.body;
if (res.body.error) {
var error = new Error("Not Found");
error.status = 404;
deferred.reject(error);
return;
}
var cover = result.cover || result.album.cover;
request.get(cover).redirects(0).end(function(res) {
var artwork = res.headers.location.replace("120x120", "200x200");