Improve rdio matching
This commit is contained in:
parent
1f3d692007
commit
d4b2b9feb5
3 changed files with 12 additions and 5 deletions
13
lib/rdio.js
13
lib/rdio.js
|
@ -81,13 +81,22 @@ module.exports.search = function(data, next) {
|
||||||
} else if (type == "track") {
|
} else if (type == "track") {
|
||||||
query = data.artist.name + " " + data.album.name + " " + data.name;
|
query = data.artist.name + " " + data.album.name + " " + data.name;
|
||||||
}
|
}
|
||||||
console.log(query)
|
|
||||||
rdio.api("", "", {
|
rdio.api("", "", {
|
||||||
query: query,
|
query: query,
|
||||||
method: 'search',
|
method: 'search',
|
||||||
types: type,
|
types: type,
|
||||||
}, function(err, results) {
|
}, 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) {
|
if (!result) {
|
||||||
return next({});
|
return next({});
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,8 +58,6 @@ module.exports.search = function(data, next) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(data[type + "s"].items[1])
|
|
||||||
|
|
||||||
var item = data[type + "s"].items[0];
|
var item = data[type + "s"].items[0];
|
||||||
|
|
||||||
module.exports.lookupId(item.id, type, next);
|
module.exports.lookupId(item.id, type, next);
|
||||||
|
|
|
@ -18,7 +18,7 @@ header h1 a {
|
||||||
color: #fff;
|
color: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
header h1 a:hover {
|
header h1 a:hover, header h1 a:focus{
|
||||||
color: #f2c4ad;
|
color: #f2c4ad;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue