Improve rdio matching

This commit is contained in:
Jonathan Cremin 2014-12-04 00:17:35 +00:00
parent 1f3d692007
commit d4b2b9feb5
3 changed files with 12 additions and 5 deletions

View file

@ -81,13 +81,22 @@ module.exports.search = function(data, next) {
} else if (type == "track") {
query = data.artist.name + " " + data.album.name + " " + data.name;
}
console.log(query)
rdio.api("", "", {
query: query,
method: 'search',
types: type,
}, function(err, results) {
var result = JSON.parse(results).result.results[0];
var results = JSON.parse(results).result.results;
var result = results.filter(function(result) {
if (type == "album" && result.name == data.name) {
return result;
} else if (type == "track" && result.album.name == data.album) {
return result;
}
}).shift();
console.log(result)
if (!result) {
return next({});
}

View file

@ -58,8 +58,6 @@ module.exports.search = function(data, next) {
return;
}
console.log(data[type + "s"].items[1])
var item = data[type + "s"].items[0];
module.exports.lookupId(item.id, type, next);

View file

@ -18,7 +18,7 @@ header h1 a {
color: #fff;
}
header h1 a:hover {
header h1 a:hover, header h1 a:focus{
color: #f2c4ad;
text-decoration: none;
}