From 2d9f8d1b6af283fa6abad6a86e8ae48f7d709df5 Mon Sep 17 00:00:00 2001 From: Jonathan Cremin Date: Thu, 11 Dec 2014 21:51:14 +0000 Subject: [PATCH] Improve Beats searches massively, increase timeout because it is slow as balls --- lib/services/beats/index.js | 6 ++++-- public/images/{googleplaymusic.png => google.png} | Bin routes/share.js | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) rename public/images/{googleplaymusic.png => google.png} (100%) diff --git a/lib/services/beats/index.js b/lib/services/beats/index.js index cf9ba5a..e4b51e4 100644 --- a/lib/services/beats/index.js +++ b/lib/services/beats/index.js @@ -100,10 +100,10 @@ module.exports.search = function(data) { var type = data.type; if (type == "album") { - query = data.artist.name + " " + data.name; + query = '"' + data.artist.name + '" "' + data.name + '"'; album = data.name; } else if (type == "track") { - query = data.artist.name + " " + data.album.name + " " + data.name; + query = '"' + data.artist.name + '" "' + data.name + '"'; album = data.album.name } @@ -123,6 +123,8 @@ module.exports.search = function(data) { deferred.resolve({service: "beats"}); } } else { + //insist on at least album or artist name being exactly right + module.exports.lookupId(res.body.data[0].id, type).then(deferred.resolve); } }); diff --git a/public/images/googleplaymusic.png b/public/images/google.png similarity index 100% rename from public/images/googleplaymusic.png rename to public/images/google.png diff --git a/routes/share.js b/routes/share.js index c8317e1..aad2671 100644 --- a/routes/share.js +++ b/routes/share.js @@ -36,7 +36,7 @@ module.exports = function(req, res, next) { Q.timeout(services[serviceId].lookupId(itemId, type), 5000).then(function(item) { for (var id in services) { if (id != serviceId) { - promises.push(Q.timeout(services[id].search(item), 5000)); + promises.push(Q.timeout(services[id].search(item), 10000)); } }