From 926665ba42d1349840abe7abf39b7be983259d81 Mon Sep 17 00:00:00 2001 From: Christoph Rohrer Date: Mon, 13 Nov 2017 00:02:59 +0100 Subject: [PATCH] fixes problem with ratelimits when requesting huge playlists from spotify --- spotifyPlaylist.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/spotifyPlaylist.js b/spotifyPlaylist.js index 6502f27..4d8c1bf 100644 --- a/spotifyPlaylist.js +++ b/spotifyPlaylist.js @@ -50,15 +50,14 @@ function getTracks(playlistName, offset){ let data = ''; if(res.statusCode !== 200) { - spotifyHelper.checkForRateLimit(res, 'requesting playlist tracks', () => spotifyPlaylist.getTracks(playlistName, offset)) + spotifyHelper.checkForRateLimit(res, 'requesting playlist tracks', () => resolve(spotifyPlaylist.getTracks(playlistName, offset))) .then(() => { if(res.statusCode === 401){ spotifyOAuth.refresh() .then(require('./main').start); - } else { + } else if(res.statusCode !== 429) { var error = "Error getting tracks from playlist. Status "+res.statusCode; logger.log(error, playlistName); - reject(error); process.exit(1); } });