Do a second search without trailing brackets
This commit is contained in:
parent
f7b1fcd53f
commit
8802ffe959
6 changed files with 113 additions and 39 deletions
lib/services
|
@ -115,22 +115,34 @@ module.exports.search = function(data) {
|
|||
}).shift();
|
||||
|
||||
if (!result) {
|
||||
return deferred.resolve({service: "rdio"});
|
||||
}
|
||||
var parsed = parse(result.shortUrl)
|
||||
var id = parsed.path.replace("/x/", "").replace("/", "");
|
||||
deferred.resolve({
|
||||
service: "rdio",
|
||||
type: type,
|
||||
id: id,
|
||||
name: result.name,
|
||||
streamUrl: result.shortUrl,
|
||||
purchaseUrl: null,
|
||||
artwork: result.icon.replace("http:", "").replace("square-200", "square-250"),
|
||||
artist: {
|
||||
name: result.artist
|
||||
var matches = album.match(/^[^\(\[]+/);
|
||||
if (matches[0]) {
|
||||
var cleanedData = JSON.parse(JSON.stringify(data));
|
||||
if (type == "album") {
|
||||
cleanedData.name = matches[0].trim();
|
||||
} else if (type == "track") {
|
||||
cleanedData.album = matches[0].trim();
|
||||
}
|
||||
module.exports.search(cleanedData).then(deferred.resolve);
|
||||
} else {
|
||||
deferred.resolve({service: "rdio"});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
var parsed = parse(result.shortUrl)
|
||||
var id = parsed.path.replace("/x/", "").replace("/", "");
|
||||
deferred.resolve({
|
||||
service: "rdio",
|
||||
type: type,
|
||||
id: id,
|
||||
name: result.name,
|
||||
streamUrl: result.shortUrl,
|
||||
purchaseUrl: null,
|
||||
artwork: result.icon.replace("http:", "").replace("square-200", "square-250"),
|
||||
artist: {
|
||||
name: result.artist
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
return deferred.promise;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue