mirror of
https://github.com/SoPat712/allstarr.git
synced 2026-02-09 23:55:10 -05:00
Add rate limiting delays to prevent Spotify 429 errors
- Increase delay between playlist fetches from 1s to 3s - Only delay between playlists, not after the last one - Add debug logging for rate limit delays - Spotify is very aggressive with rate limiting on their API
This commit is contained in:
@@ -297,8 +297,13 @@ public class SpotifyPlaylistFetcher : BackgroundService
|
|||||||
_logger.LogError(ex, "Error fetching playlist '{Name}'", config.Name);
|
_logger.LogError(ex, "Error fetching playlist '{Name}'", config.Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rate limiting between playlists
|
// Rate limiting between playlists - Spotify is VERY aggressive with rate limiting
|
||||||
await Task.Delay(_spotifyApiSettings.RateLimitDelayMs, cancellationToken);
|
// Wait 3 seconds between each playlist to avoid 429 TooManyRequests errors
|
||||||
|
if (config != _spotifyImportSettings.Playlists.Last())
|
||||||
|
{
|
||||||
|
_logger.LogDebug("Waiting 3 seconds before next playlist to avoid rate limits...");
|
||||||
|
await Task.Delay(TimeSpan.FromSeconds(3), cancellationToken);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.LogInformation("=== FINISHED FETCHING SPOTIFY PLAYLISTS ===");
|
_logger.LogInformation("=== FINISHED FETCHING SPOTIFY PLAYLISTS ===");
|
||||||
|
|||||||
Reference in New Issue
Block a user