diff --git a/lib/googleplaymusic.js b/lib/googleplaymusic.js index f4ba52c..96a0259 100644 --- a/lib/googleplaymusic.js +++ b/lib/googleplaymusic.js @@ -40,20 +40,26 @@ 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 matches = hash.match(/\/album[\/]+([^\/]+)\/([^\/]+)/); - - if (matches && matches[2]) { - var artist = decodeURIComponent(matches[1]); - var album = decodeURIComponent(matches[2]); - 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"}) + if (matches && matches[2]) { + var artist = decodeURIComponent(matches[1]); + var album = decodeURIComponent(matches[2]); + 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]+)/); + return next({id:matches[1], type: "album"}); } }