rate limiting

This commit is contained in:
Broque Thomas 2025-08-16 10:24:07 -07:00
parent 3bd6a29bfd
commit 1bf7995864
2 changed files with 10 additions and 0 deletions

View file

@ -432,6 +432,7 @@ class SpotifyClient:
logger.error(f"Error fetching track features: {e}")
return None
@rate_limited
def get_album(self, album_id: str) -> Optional[Dict[str, Any]]:
"""Get album information including tracks"""
if not self.is_authenticated():
@ -445,6 +446,7 @@ class SpotifyClient:
logger.error(f"Error fetching album: {e}")
return None
@rate_limited
def get_album_tracks(self, album_id: str) -> Optional[Dict[str, Any]]:
"""Get album tracks"""
if not self.is_authenticated():

View file

@ -115,6 +115,10 @@ class WatchlistScanWorker(QThread):
total_albums += 1
else:
total_singles_eps_releases += 1 # Count the release, not the tracks
# Rate limiting: small delay between album fetches to avoid hitting Spotify limits
import time
time.sleep(0.1) # 100ms delay between albums
except Exception as e:
logger.warning(f"Error analyzing album {album.name} for totals: {e}")
@ -166,6 +170,10 @@ class WatchlistScanWorker(QThread):
# Emit release completion signal
self.release_completed.emit(watchlist_artist.artist_name, album.name, len(tracks))
# Rate limiting: small delay between album processing to avoid hitting Spotify limits
import time
time.sleep(0.1) # 100ms delay between albums
except Exception as e:
logger.warning(f"Error checking album {album.name}: {e}")