Fix google second search
This commit is contained in:
parent
d48824ab49
commit
c8eb31116c
1 changed files with 8 additions and 4 deletions
|
@ -26,7 +26,7 @@ module.exports.lookupId = function(id, type, next) {
|
|||
var deferred = Q.defer();
|
||||
ready.promise.then(function() {
|
||||
if (type == "album") {
|
||||
pm.getAlbum(id, true, function(album) {
|
||||
pm.getAlbum(id, false, function(album) {
|
||||
deferred.resolve({
|
||||
service: "googleplaymusic",
|
||||
type: "album",
|
||||
|
@ -39,6 +39,8 @@ module.exports.lookupId = function(id, type, next) {
|
|||
name: album.artist
|
||||
}
|
||||
});
|
||||
}, function(error) {
|
||||
deferred.reject(error);
|
||||
});
|
||||
} else if (type == "track") {
|
||||
pm.getAllAccessTrack(id, function(track) {
|
||||
|
@ -57,6 +59,8 @@ module.exports.lookupId = function(id, type, next) {
|
|||
name: track.artist
|
||||
}
|
||||
});
|
||||
}, function(error) {
|
||||
deferred.reject(error);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -77,8 +81,8 @@ module.exports.search = function(data) {
|
|||
album = data.album.name;
|
||||
}
|
||||
|
||||
pm.search(query, 5, function(data) {
|
||||
if (!data.entries) {
|
||||
pm.search(query, 5, function(result) {
|
||||
if (!result.entries) {
|
||||
var matches = album.match(/^[^\(\[]+/);
|
||||
if (matches[0]) {
|
||||
var cleanedData = JSON.parse(JSON.stringify(data));
|
||||
|
@ -93,7 +97,7 @@ module.exports.search = function(data) {
|
|||
}
|
||||
return;
|
||||
}
|
||||
var result = data.entries.filter(function(result) {
|
||||
var result = result.entries.filter(function(result) {
|
||||
return result[type];
|
||||
}).sort(function(a, b) { // sort by match score
|
||||
return a.score < b.score;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue