diff --git a/lib/spotify.js b/lib/spotify.js index e90eb3a..fe32460 100644 --- a/lib/spotify.js +++ b/lib/spotify.js @@ -989,6 +989,17 @@ Spotify.prototype.isTrackAvailable = function (track, country) { Spotify.prototype.recurseAlternatives = function (track, country, fn) { debug('recurseAlternatives()'); + var enumCatalogue = { + "AD" : 0 , + "SUBSCRIPTION" : 1, + "SHUFFLE" : 2, + "undefined" : 3 + } + track.restriction.forEach(function(r) { + if (r.catalogue) { + r.catalogue = r.catalogue.map(function(x) { return enumCatalogue[x]; }); + } + }); function done () { process.nextTick(function () { fn(null, track); @@ -996,7 +1007,8 @@ Spotify.prototype.recurseAlternatives = function (track, country, fn) { } if (this.isTrackAvailable(track, country)) { return done(); - } else if (Array.isArray(track.alternative)) { + } + if (Array.isArray(track.alternative)) { var tracks = track.alternative; for (var i = 0; i < tracks.length; i++) { debug('checking alternative track %j', track.uri);