More bluebird, fetch larger artwork
This commit is contained in:
parent
e671b823e9
commit
23896f7ee6
16 changed files with 117 additions and 81 deletions
|
@ -33,27 +33,30 @@ module.exports.parseUrl = function(url) {
|
|||
|
||||
module.exports.lookupId = function(id, type) {
|
||||
if (type == "album") {
|
||||
return request.get(apiRoot + "/albums/" + id + "/images/default?size=medium&client_id=" + credentials.key).redirects(0).promise().then(function(res) {
|
||||
var artwork = res.headers.location;
|
||||
return request.get(apiRoot + "/albums/" + id + "?client_id=" + credentials.key).promise().then(function(res) {
|
||||
if (!res.body.data) {
|
||||
var error = new Error("Not Found");
|
||||
error.status = 404;
|
||||
throw error;
|
||||
}
|
||||
var result = res.body.data;
|
||||
return {
|
||||
service: "beats",
|
||||
type: "album",
|
||||
id: result.id,
|
||||
name: result.title,
|
||||
streamUrl: "https://listen.beatsmusic.com/albums/" + result.id,
|
||||
purchaseUrl: null,
|
||||
artwork: artwork.replace("http:", "https:"),
|
||||
artist: {
|
||||
name: result.artist_display_name
|
||||
return request.get(apiRoot + "/albums/" + id + "/images/default?size=large&client_id=" + credentials.key).redirects(0).promise().then(function(res) {
|
||||
var artwork = {large: res.headers.location.replace("http:", "https:")};
|
||||
return request.get(apiRoot + "/albums/" + id + "/images/default?client_id=" + credentials.key).redirects(0).promise().then(function(res) {
|
||||
artwork.small = res.headers.location.replace("http:", "https:");
|
||||
return request.get(apiRoot + "/albums/" + id + "?client_id=" + credentials.key).promise().then(function(res) {
|
||||
if (!res.body.data) {
|
||||
var error = new Error("Not Found");
|
||||
error.status = 404;
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
var result = res.body.data;
|
||||
return {
|
||||
service: "beats",
|
||||
type: "album",
|
||||
id: result.id,
|
||||
name: result.title,
|
||||
streamUrl: "https://listen.beatsmusic.com/albums/" + result.id,
|
||||
purchaseUrl: null,
|
||||
artwork: artwork,
|
||||
artist: {
|
||||
name: result.artist_display_name
|
||||
}
|
||||
};
|
||||
});
|
||||
});
|
||||
});
|
||||
} else if (type == "track") {
|
||||
|
@ -64,23 +67,26 @@ module.exports.lookupId = function(id, type) {
|
|||
throw error;
|
||||
}
|
||||
var result = res.body.data;
|
||||
return request.get(apiRoot + "/albums/" + result.refs.album.id + "/images/default?size=medium&client_id=" + credentials.key).redirects(0).promise().then(function(res) {
|
||||
var artwork = res.headers.location;
|
||||
return {
|
||||
service: "beats",
|
||||
type: "track",
|
||||
id: result.id,
|
||||
name: result.title,
|
||||
streamUrl: "https://listen.beatsmusic.com/albums/" + result.refs.album.id + "/tracks/" + result.id,
|
||||
purchaseUrl: null,
|
||||
artwork: artwork.replace("http:", "https:"),
|
||||
artist: {
|
||||
name: result.artist_display_name
|
||||
},
|
||||
album: {
|
||||
name: result.refs.album.display
|
||||
}
|
||||
};
|
||||
return request.get(apiRoot + "/albums/" + result.refs.album.id + "/images/default?size=large&client_id=" + credentials.key).redirects(0).promise().then(function(res) {
|
||||
var artwork = {large: res.headers.location.replace("http:", "https:")};
|
||||
return request.get(apiRoot + "/albums/" + result.refs.album.id + "/images/default?client_id=" + credentials.key).redirects(0).promise().then(function(res) {
|
||||
artwork.small = res.headers.location.replace("http:", "https:");
|
||||
return {
|
||||
service: "beats",
|
||||
type: "track",
|
||||
id: result.id,
|
||||
name: result.title,
|
||||
streamUrl: "https://listen.beatsmusic.com/albums/" + result.refs.album.id + "/tracks/" + result.id,
|
||||
purchaseUrl: null,
|
||||
artwork: artwork,
|
||||
artist: {
|
||||
name: result.artist_display_name
|
||||
},
|
||||
album: {
|
||||
name: result.refs.album.display
|
||||
}
|
||||
};
|
||||
});
|
||||
});
|
||||
});
|
||||
} else {
|
||||
|
|
|
@ -32,7 +32,10 @@ module.exports.lookupId = function(id, type) {
|
|||
}
|
||||
var cover = result.cover || result.album.cover;
|
||||
return request.get(cover).redirects(0).promise().then(function(res) {
|
||||
var artwork = res.headers.location.replace("120x120", "200x200");
|
||||
var artwork = {
|
||||
small: res.headers.location.replace("120x120", "200x200"),
|
||||
large: res.headers.location.replace("120x120", "800x800")
|
||||
};
|
||||
if (type == "album") {
|
||||
return {
|
||||
service: "deezer",
|
||||
|
|
|
@ -53,7 +53,10 @@ module.exports.lookupId = function(id, type) {
|
|||
name: album.name,
|
||||
streamUrl: "https://play.google.com/music/listen#/album/" + album.albumId,
|
||||
purchaseUrl: "https://play.google.com/store/music/album?id=" + album.albumId,
|
||||
artwork: album.albumArtRef.replace("http:", "https:"),
|
||||
artwork: {
|
||||
small: album.albumArtRef.replace("http:", "https:"),
|
||||
large: album.albumArtRef.replace("http:", "https:")
|
||||
},
|
||||
artist: {
|
||||
name: album.artist
|
||||
}
|
||||
|
@ -70,7 +73,10 @@ module.exports.lookupId = function(id, type) {
|
|||
name: track.title,
|
||||
streamUrl: "https://play.google.com/music/listen#/track/" + track.nid + "/" + track.albumId,
|
||||
purchaseUrl: "https://play.google.com/store/music/album?id=" + track.albumId,
|
||||
artwork: track.albumArtRef[0].url.replace("http:", "https:"),
|
||||
artwork: {
|
||||
small: track.albumArtRef[0].url.replace("http:", "https:"),
|
||||
large: track.albumArtRef[0].url.replace("http:", "https:")
|
||||
},
|
||||
album: {
|
||||
name: track.album
|
||||
},
|
||||
|
|
|
@ -57,7 +57,10 @@ module.exports.lookupId = function(id, type, cc) {
|
|||
name: result.trackName ? result.trackName : result.collectionName,
|
||||
streamUrl: null,
|
||||
purchaseUrl: result.collectionViewUrl,
|
||||
artwork: "https://match.audio/itunes/" + result.artworkUrl100.replace("100x100", "200x200").replace("http://", ""),
|
||||
artwork: {
|
||||
small: "https://match.audio/itunes/" + result.artworkUrl100.replace("100x100", "200x200").replace("http://", ""),
|
||||
large: "https://match.audio/itunes/" + result.artworkUrl100.replace("100x100", "600x600").replace("http://", ""),
|
||||
},
|
||||
artist: {
|
||||
name: result.artistName
|
||||
}
|
||||
|
@ -115,7 +118,10 @@ module.exports.search = function(data) {
|
|||
name: result.trackName ? result.trackName : result.collectionName,
|
||||
streamUrl: null,
|
||||
purchaseUrl: result.collectionViewUrl,
|
||||
artwork: "https://match.audio/itunes/" + result.artworkUrl100.replace("100x100", "200x200").replace("http://", ""),
|
||||
artwork: {
|
||||
small: "https://match.audio/itunes/" + result.artworkUrl100.replace("100x100", "200x200").replace("http://", ""),
|
||||
large: "https://match.audio/itunes/" + result.artworkUrl100.replace("100x100", "600x600").replace("http://", ""),
|
||||
},
|
||||
artist: {
|
||||
name: result.artistName
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ module.exports.lookupId = function(id) {
|
|||
var parsed = parse(result.shortUrl)
|
||||
var id = parsed.path.replace("/x/", "").replace("/", "");
|
||||
var type = result.album ? "track" : "album";
|
||||
|
||||
var item = {
|
||||
service: "rdio",
|
||||
type: type,
|
||||
|
@ -36,7 +37,10 @@ module.exports.lookupId = function(id) {
|
|||
name: result.name,
|
||||
streamUrl: result.shortUrl,
|
||||
purchaseUrl: null,
|
||||
artwork: result.icon.replace("square-200", "square-250").replace("http:", "https:"),
|
||||
artwork: {
|
||||
small: result.icon.replace("square-200", "square-250").replace("http:", "https:"),
|
||||
large: result.icon.replace("square-200", "square-600").replace("http:", "https:")
|
||||
},
|
||||
artist: {
|
||||
name: result.artist
|
||||
}
|
||||
|
@ -89,7 +93,10 @@ module.exports.parseUrl = function(url) {
|
|||
name: result.name,
|
||||
streamUrl: result.shortUrl,
|
||||
purchaseUrl: null,
|
||||
artwork: result.icon.replace("square-200", "square-250").replace("http:", "https:"),
|
||||
artwork: {
|
||||
small: result.icon.replace("square-200", "square-250").replace("http:", "https:"),
|
||||
large: result.icon.replace("square-200", "square-600").replace("http:", "https:")
|
||||
},
|
||||
artist: {
|
||||
name: result.artist
|
||||
}
|
||||
|
|
|
@ -33,7 +33,10 @@ module.exports.lookupId = function(id, type) {
|
|||
name: data.name,
|
||||
streamUrl: "https://play.spotify.com/" + type + "/" + data.id,
|
||||
purchaseUrl: null,
|
||||
artwork: data.images ? data.images[1].url.replace("http:", "https:") : data.album.images[1].url.replace("http:", "https:"),
|
||||
artwork: {
|
||||
small: data.images[1].url.replace("http:", "https:"),
|
||||
large: data.images[0].url.replace("http:", "https:"),
|
||||
},
|
||||
artist: {
|
||||
name: artist.name
|
||||
}
|
||||
|
@ -46,7 +49,10 @@ module.exports.lookupId = function(id, type) {
|
|||
name: data.name,
|
||||
streamUrl: "https://play.spotify.com/" + type + "/" + data.id,
|
||||
purchaseUrl: null,
|
||||
artwork: data.images ? data.images[1].url.replace("http:", "https:") : data.album.images[1].url.replace("http:", "https:"),
|
||||
artwork: {
|
||||
small: data.album.images[1].url.replace("http:", "https:"),
|
||||
large: data.album.images[0].url.replace("http:", "https:"),
|
||||
},
|
||||
artist: {
|
||||
name: artist.name
|
||||
},
|
||||
|
|
|
@ -46,7 +46,10 @@ module.exports.search = function(data) {
|
|||
name: result.snippet.title,
|
||||
streamUrl: "https://www.youtube.com/watch?v=" + result.id.videoId,
|
||||
purchaseUrl: null,
|
||||
artwork: result.snippet.thumbnails.medium.url,
|
||||
artwork: {
|
||||
small: result.snippet.thumbnails.medium.url,
|
||||
large: result.snippet.thumbnails.high.url,
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue