Add support for sharing tracks
This commit is contained in:
parent
39a22f65d9
commit
7e6527855b
5 changed files with 72 additions and 37 deletions
|
@ -13,8 +13,8 @@ module.exports.lookupId = function(id, type, next) {
|
|||
next({
|
||||
id: data.id,
|
||||
name: data.name,
|
||||
url: "https://play.spotify.com/album/" + data.id,
|
||||
artwork: data.images[0].url.replace("http:", ""),
|
||||
url: "https://play.spotify.com/" + type + "/" + data.id,
|
||||
artwork: data.images ? data.images[0].url.replace("http:", "") : data.album.images[0].url.replace("http:", ""),
|
||||
artist: {
|
||||
name: artist.name
|
||||
}
|
||||
|
@ -29,16 +29,16 @@ module.exports.search = function(query, type, next) {
|
|||
return;
|
||||
}
|
||||
|
||||
album = data.albums.items[0];
|
||||
var item = data[type + "s"].items[0];
|
||||
|
||||
module.exports.lookupId(album.id, "album", next);
|
||||
module.exports.lookupId(item.id, type, next);
|
||||
});
|
||||
}
|
||||
|
||||
module.exports.parseUrl = function(url, next) {
|
||||
var matches = parse(url).path.match(/\/album[\/]+([^\/]+)/);
|
||||
var matches = parse(url).path.match(/\/(album|track)[\/]+([^\/]+)/);
|
||||
|
||||
if (matches && matches[1]) {
|
||||
next({id:matches[1], type: "album"})
|
||||
if (matches && matches[2]) {
|
||||
next({id:matches[2], type: matches[1]})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue