Fix second lookups

This commit is contained in:
Jonathan Cremin 2014-12-05 22:26:12 +00:00
parent e9a5f6713d
commit 88ae9b401c
6 changed files with 8 additions and 8 deletions

View file

@ -96,7 +96,7 @@ module.exports.search = function(data) {
if (type == "album") { if (type == "album") {
cleanedData.name = matches[0].trim(); cleanedData.name = matches[0].trim();
} else if (type == "track") { } else if (type == "track") {
cleanedData.album = matches[0].trim(); cleanedData.album.name = matches[0].trim();
} }
module.exports.search(cleanedData).then(deferred.resolve); module.exports.search(cleanedData).then(deferred.resolve);
} else { } else {

View file

@ -84,7 +84,7 @@ module.exports.search = function(data, next) {
if (type == "album") { if (type == "album") {
cleanedData.name = matches[0].trim(); cleanedData.name = matches[0].trim();
} else if (type == "track") { } else if (type == "track") {
cleanedData.album = matches[0].trim(); cleanedData.album.name = matches[0].trim();
} }
module.exports.search(cleanedData).then(deferred.resolve); module.exports.search(cleanedData).then(deferred.resolve);
} else { } else {

View file

@ -89,7 +89,7 @@ module.exports.search = function(data) {
if (type == "album") { if (type == "album") {
cleanedData.name = matches[0].trim(); cleanedData.name = matches[0].trim();
} else if (type == "track") { } else if (type == "track") {
cleanedData.album = matches[0].trim(); cleanedData.album.name = matches[0].trim();
} }
module.exports.search(cleanedData).then(deferred.resolve); module.exports.search(cleanedData).then(deferred.resolve);
} else { } else {

View file

@ -77,7 +77,7 @@ module.exports.search = function(data) {
if (type == "album") { if (type == "album") {
cleanedData.name = matches[0].trim(); cleanedData.name = matches[0].trim();
} else if (type == "track") { } else if (type == "track") {
cleanedData.album = matches[0].trim(); cleanedData.album.name = matches[0].trim();
} }
module.exports.search(cleanedData).then(deferred.resolve); module.exports.search(cleanedData).then(deferred.resolve);
} else { } else {

View file

@ -115,19 +115,19 @@ module.exports.search = function(data) {
var result = results.filter(function(result) { var result = results.filter(function(result) {
if (type == "album" && result.name.match(/([^\(\[]+)/)[0] == albumClean) { if (type == "album" && result.name.match(/([^\(\[]+)/)[0] == albumClean) {
return result; return result;
} else if (type == "track" && result.album.match(/([^\(\[]+)/)[0] == albumClean) { } else if (type == "track" && result.album.name.match(/([^\(\[]+)/)[0] == albumClean) {
return result; return result;
} }
}).shift(); }).shift();
if (!result) { if (!result) {
var matches = albumClean.match(/^[^\(\[]+/); var matches = albumClean.match(/^[^\(\[]+/);
if (matches[0] && matches[0] != album) { if (matches[0] && matches[0] != albumClean) {
var cleanedData = JSON.parse(JSON.stringify(data)); var cleanedData = JSON.parse(JSON.stringify(data));
if (type == "album") { if (type == "album") {
cleanedData.name = matches[0].trim(); cleanedData.name = matches[0].trim();
} else if (type == "track") { } else if (type == "track") {
cleanedData.album = matches[0].trim(); cleanedData.album.name = matches[0].trim();
} }
module.exports.search(cleanedData).then(deferred.resolve); module.exports.search(cleanedData).then(deferred.resolve);
} else { } else {

View file

@ -82,7 +82,7 @@ module.exports.search = function(data) {
if (type == "album") { if (type == "album") {
cleanedData.name = matches[0].trim(); cleanedData.name = matches[0].trim();
} else if (type == "track") { } else if (type == "track") {
cleanedData.album = matches[0].trim(); cleanedData.album.name = matches[0].trim();
} }
module.exports.search(cleanedData).then(deferred.resolve); module.exports.search(cleanedData).then(deferred.resolve);
} else { } else {