Add support for sharing tracks
This commit is contained in:
parent
39a22f65d9
commit
7e6527855b
5 changed files with 72 additions and 37 deletions
11
lib/rdio.js
11
lib/rdio.js
|
@ -18,6 +18,7 @@ module.exports.lookupId = function(id, next) {
|
|||
var result = JSON.parse(results).result;
|
||||
var parsed = parse(result.shortUrl)
|
||||
var id = parsed.path.replace("/x/", "").replace("/", "");
|
||||
var type = result.album ? "track" : "album";
|
||||
next({
|
||||
id: id,
|
||||
name: result.name,
|
||||
|
@ -26,7 +27,7 @@ module.exports.lookupId = function(id, next) {
|
|||
artist: {
|
||||
name: result.artist
|
||||
},
|
||||
type: "album"
|
||||
type: type
|
||||
});
|
||||
});
|
||||
};
|
||||
|
@ -54,6 +55,7 @@ module.exports.lookupUrl = function(url, next) {
|
|||
var result = JSON.parse(results).result;
|
||||
var parsed = parse(result.shortUrl)
|
||||
var id = parsed.path.replace("/x/", "").replace("/", "");
|
||||
var type = result.album ? "track" : "album";
|
||||
next({
|
||||
id: id,
|
||||
name: result.name,
|
||||
|
@ -62,7 +64,7 @@ module.exports.lookupUrl = function(url, next) {
|
|||
artist: {
|
||||
name: result.artist
|
||||
},
|
||||
type: "album"
|
||||
type: type
|
||||
});
|
||||
});
|
||||
};
|
||||
|
@ -74,6 +76,9 @@ module.exports.search = function(query, type, next) {
|
|||
types: type,
|
||||
}, function(err, results) {
|
||||
var result = JSON.parse(results).result.results[0];
|
||||
if (!result) {
|
||||
return next({});
|
||||
}
|
||||
var parsed = parse(result.shortUrl)
|
||||
var id = parsed.path.replace("/x/", "").replace("/", "");
|
||||
next({
|
||||
|
@ -84,7 +89,7 @@ module.exports.search = function(query, type, next) {
|
|||
artist: {
|
||||
name: result.artist
|
||||
},
|
||||
type: "album"
|
||||
type: type
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue