Skip to content

Commit

Permalink
fix error where track not playable in country - TooTallNate#90
Browse files Browse the repository at this point in the history
  • Loading branch information
Anthony Brown committed Jun 22, 2015
1 parent 91efc0b commit 3f953d1
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lib/spotify.js
Original file line number Diff line number Diff line change
Expand Up @@ -989,14 +989,26 @@ 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);
});
}
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);
Expand Down

0 comments on commit 3f953d1

Please sign in to comment.