From c8eb31116c5969211965b8ec7ab87b1509c1d11b Mon Sep 17 00:00:00 2001 From: Jonathan Cremin Date: Fri, 5 Dec 2014 17:40:35 +0000 Subject: [PATCH] Fix google second search --- lib/services/googleplaymusic.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/services/googleplaymusic.js b/lib/services/googleplaymusic.js index bf1290f..16f5a7c 100644 --- a/lib/services/googleplaymusic.js +++ b/lib/services/googleplaymusic.js @@ -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;