Improve matching and metadata extraction
This commit is contained in:
parent
7c1b8aa771
commit
e4a856e228
6 changed files with 74 additions and 36 deletions
|
@ -82,17 +82,19 @@ module.exports.lookupId = function(id, type) {
|
|||
};
|
||||
|
||||
module.exports.search = function(data) {
|
||||
var cleanParam = function(str) {
|
||||
return str.replace(/[\:\?\&]+/, "");
|
||||
}
|
||||
var query, album;
|
||||
var type = data.type;
|
||||
|
||||
if (type == "album") {
|
||||
query = data.artist.name + " " + data.name;
|
||||
query = cleanParam(data.artist.name.substring(0, data.artist.name.indexOf('&'))) + " " + cleanParam(data.name);
|
||||
album = data.name;
|
||||
} else if (type == "track") {
|
||||
query = data.artist.name + " " + data.name;
|
||||
query = cleanParam(data.artist.name.substring(0, data.artist.name.indexOf('&'))) + " " + cleanParam(data.name);
|
||||
album = data.album.name
|
||||
}
|
||||
|
||||
return getAccessToken().then(function(access_token){
|
||||
var path = "/music/search?q=" + encodeURIComponent(query) + "&filters=" + type + "s";
|
||||
return request.get(apiRoot + path).set("Authorization", "Bearer " + access_token).promise().then(function(res) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue