Add rdio support
This commit is contained in:
parent
aca2eea4dd
commit
493482386e
7 changed files with 129 additions and 25 deletions
|
@ -37,26 +37,22 @@ module.exports.search = function(query, type, next) {
|
|||
}
|
||||
|
||||
module.exports.parseUrl = function(url, next) {
|
||||
// https://play.google.com/music/listen#/album/B3lxthejqxjxja2bhzchcw5qaci
|
||||
// https://play.google.com/music/listen#/album//Underworld/Everything%2C+Everything+(Live)
|
||||
var parsed = parse(url.replace(/\+/g, "%20"));
|
||||
var path = parsed.path;
|
||||
var hash = parsed.hash;
|
||||
console.log(path)
|
||||
if (hash) {
|
||||
var matches = hash.match(/\/album[\/]+([^\/]+)\/([^\/]+)/);
|
||||
var parts = hash.split("/");
|
||||
var type = parts[1];
|
||||
var id = parts[2];
|
||||
var artist = decodeURIComponent(parts[3]);
|
||||
var album = decodeURIComponent(parts[4]);
|
||||
|
||||
if (matches && matches[2]) {
|
||||
var artist = decodeURIComponent(matches[1]);
|
||||
var album = decodeURIComponent(matches[2]);
|
||||
if (id.length > 0) {
|
||||
return next({id: id, type: type});
|
||||
} else {
|
||||
module.exports.search(artist + " " + album, "album", function(googleAlbum) {
|
||||
next(googleAlbum);
|
||||
});
|
||||
} else {
|
||||
var matches = hash.match(/\/album[\/]+([\w]+)/);
|
||||
if (matches && matches[1]) {
|
||||
return next({id:matches[1], type: "album"});
|
||||
}
|
||||
}
|
||||
} else if(path) {
|
||||
var matches = path.match(/\/music\/m\/([\w]+)/);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue