Add rate limit check to search_tracks and search_albums in Spotify client
Both methods were calling Spotify API without checking the global rate limit, causing 429 errors to spam the logs even when the ban was active.
This commit is contained in:
parent
429306c7f3
commit
655e1e251d
1 changed files with 44 additions and 34 deletions
|
|
@ -967,6 +967,11 @@ class SpotifyClient:
|
||||||
if tracks:
|
if tracks:
|
||||||
return tracks
|
return tracks
|
||||||
|
|
||||||
|
# Skip Spotify if globally rate limited — fall through to fallback
|
||||||
|
if self.is_rate_limited():
|
||||||
|
logger.debug(f"Spotify rate limited, skipping track search for: {query}")
|
||||||
|
use_spotify = False
|
||||||
|
else:
|
||||||
try:
|
try:
|
||||||
results = self.sp.search(q=query, type='track', limit=effective_limit)
|
results = self.sp.search(q=query, type='track', limit=effective_limit)
|
||||||
tracks = []
|
tracks = []
|
||||||
|
|
@ -1069,6 +1074,11 @@ class SpotifyClient:
|
||||||
return albums
|
return albums
|
||||||
|
|
||||||
if use_spotify:
|
if use_spotify:
|
||||||
|
# Skip Spotify if globally rate limited — fall through to fallback
|
||||||
|
if self.is_rate_limited():
|
||||||
|
logger.debug(f"Spotify rate limited, skipping album search for: {query}")
|
||||||
|
use_spotify = False
|
||||||
|
else:
|
||||||
try:
|
try:
|
||||||
results = self.sp.search(q=query, type='album', limit=min(limit, 10))
|
results = self.sp.search(q=query, type='album', limit=min(limit, 10))
|
||||||
albums = []
|
albums = []
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue