Skip to content

Commit

Permalink
Detect too high Spotify rate limits
Browse files Browse the repository at this point in the history
  • Loading branch information
Marekkon5 committed Mar 14, 2024
1 parent dbe4c7f commit a872556
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions crates/onetagger-platforms/src/spotify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ impl Spotify {
// Rate limit
if r.status() == 429 {
let delay = r.header("Retry-After").map(|v| v.parse().ok()).flatten().unwrap_or(3);
if delay > 600 {
error!("Spotify rate limit too high!: {delay}");
return Err(anyhow!("Too high rate limit by Spotify"));
}

warn!("Spotify rate limit hit, sleeping for: {delay}s...");
std::thread::sleep(Duration::from_secs(delay));
return self.rate_limit_wrap(f);
Expand Down

0 comments on commit a872556

Please sign in to comment.