Add rdio support
This commit is contained in:
parent
aca2eea4dd
commit
493482386e
7 changed files with 129 additions and 25 deletions
|
@ -3,9 +3,7 @@ var router = express.Router();
|
|||
|
||||
var googleplaymusic = require('../lib/googleplaymusic');
|
||||
var spotify = require('../lib/spotify');
|
||||
|
||||
//https://play.spotify.com/album/3W3ENDBQMJ9bD2qmxWI2f0
|
||||
//https://play.google.com/music/listen#/album/B3lxthejqxjxja2bhzchcw5qaci
|
||||
var rdio = require('../lib/rdio');
|
||||
|
||||
router.get('/:service/:type/:id', function(req, res) {
|
||||
var service = req.params.service;
|
||||
|
@ -16,14 +14,27 @@ router.get('/:service/:type/:id', function(req, res) {
|
|||
case "spotify":
|
||||
spotify.lookupId(id, type, function(spotifyAlbum) {
|
||||
googleplaymusic.search(spotifyAlbum.artist.name + " " + spotifyAlbum.name, "album", function(googleAlbum) {
|
||||
res.render('album', {googleAlbum: googleAlbum, spotifyAlbum: spotifyAlbum});
|
||||
rdio.search(googleAlbum.artist.name + " " + googleAlbum.name, "album", function(rdioAlbum) {
|
||||
res.render('album', {rdioAlbum: rdioAlbum, googleAlbum: googleAlbum, spotifyAlbum: spotifyAlbum});
|
||||
});
|
||||
});
|
||||
});
|
||||
break;
|
||||
case "google":
|
||||
googleplaymusic.lookupId(id, type, function(googleAlbum) {
|
||||
spotify.search(googleAlbum.artist.name + " " + googleAlbum.name, "album", function(spotifyAlbum) {
|
||||
res.render('album', {googleAlbum: googleAlbum, spotifyAlbum: spotifyAlbum});
|
||||
rdio.search(googleAlbum.artist.name + " " + googleAlbum.name, "album", function(rdioAlbum) {
|
||||
res.render('album', {rdioAlbum: rdioAlbum, googleAlbum: googleAlbum, spotifyAlbum: spotifyAlbum});
|
||||
});
|
||||
});
|
||||
});
|
||||
break;
|
||||
case "rdio":
|
||||
rdio.lookupId(id, function(rdioAlbum) {
|
||||
googleplaymusic.search(rdioAlbum.artist.name + " " + rdioAlbum.name, "album", function(googleAlbum) {
|
||||
spotify.search(rdioAlbum.artist.name + " " + rdioAlbum.name, "album", function(spotifyAlbum) {
|
||||
res.render('album', {rdioAlbum: rdioAlbum, googleAlbum: googleAlbum, spotifyAlbum: spotifyAlbum});
|
||||
});
|
||||
});
|
||||
});
|
||||
break;
|
||||
|
@ -34,7 +45,15 @@ router.post('/search', function(req, res) {
|
|||
// determine spotify or google music
|
||||
var url = req.body.url;
|
||||
|
||||
if (url.match(/spotify\.com/)) {
|
||||
if (url.match(/rd\.io/) || url.match(/rdio\.com/)) {
|
||||
rdio.lookupUrl(url, function(result) {
|
||||
if (!result.id) {
|
||||
req.flash('search-error', 'No match found for this link');
|
||||
res.redirect('/');
|
||||
}
|
||||
res.redirect("/rdio/" + result.type + "/" + result.id);
|
||||
});
|
||||
} else if (url.match(/spotify\.com/)) {
|
||||
spotify.parseUrl(url, function(result) {
|
||||
if (!result.id) {
|
||||
req.flash('search-error', 'No match found for this link');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue