Add suppport for tracks, basic design, minor refactor

This commit is contained in:
Jonathan Cremin 2014-12-03 23:03:34 +00:00
parent e20b3b86c4
commit acb129899d
13 changed files with 267 additions and 77 deletions

View file

@ -21,14 +21,15 @@ module.exports.lookupId = function(id, next) {
var id = parsed.path.replace("/x/", "").replace("/", "");
var type = result.album ? "track" : "album";
next({
service: "rdio",
type: type,
id: id,
name: result.name,
url: result.shortUrl,
artwork: result.icon.replace("http:", ""),
artwork: result.icon.replace("http:", "").replace("square-200", "square-500"),
artist: {
name: result.artist
},
type: type
}
});
});
};
@ -58,19 +59,29 @@ module.exports.lookupUrl = function(url, next) {
var id = parsed.path.replace("/x/", "").replace("/", "");
var type = result.album ? "track" : "album";
next({
service: "rdio",
type: type,
id: id,
name: result.name,
url: result.shortUrl,
artwork: result.icon.replace("http:", ""),
artwork: result.icon.replace("http:", "").replace("square-200", "square-500"),
artist: {
name: result.artist
},
type: type
}
});
});
};
module.exports.search = function(query, type, next) {
module.exports.search = function(data, next) {
var query;
var type = data.type;
if (type == "album") {
query = data.artist.name + " " + data.name;
} else if (type == "track") {
query = data.artist.name + " " + data.album.name + " " + data.name;
}
console.log(query)
rdio.api("", "", {
query: query,
method: 'search',
@ -83,14 +94,15 @@ module.exports.search = function(query, type, next) {
var parsed = parse(result.shortUrl)
var id = parsed.path.replace("/x/", "").replace("/", "");
next({
service: "rdio",
type: type,
id: id,
name: result.name,
url: result.shortUrl,
artwork: result.icon.replace("http:", ""),
artwork: result.icon.replace("http:", "").replace("square-200", "square-500"),
artist: {
name: result.artist
},
type: type
}
});
});
};