update Spotify API search limits for February 2026 changes
This commit is contained in:
parent
aa91d851c3
commit
ff3f547612
2 changed files with 9 additions and 9 deletions
|
|
@ -471,11 +471,11 @@ class SpotifyClient:
|
|||
return None
|
||||
|
||||
@rate_limited
|
||||
def search_tracks(self, query: str, limit: int = 20) -> List[Track]:
|
||||
def search_tracks(self, query: str, limit: int = 10) -> List[Track]:
|
||||
"""Search for tracks - falls back to iTunes if Spotify not authenticated"""
|
||||
if self.is_spotify_authenticated():
|
||||
try:
|
||||
results = self.sp.search(q=query, type='track', limit=limit)
|
||||
results = self.sp.search(q=query, type='track', limit=min(limit, 10))
|
||||
tracks = []
|
||||
|
||||
for track_data in results['tracks']['items']:
|
||||
|
|
@ -493,11 +493,11 @@ class SpotifyClient:
|
|||
return self._itunes.search_tracks(query, limit)
|
||||
|
||||
@rate_limited
|
||||
def search_artists(self, query: str, limit: int = 20) -> List[Artist]:
|
||||
def search_artists(self, query: str, limit: int = 10) -> List[Artist]:
|
||||
"""Search for artists - falls back to iTunes if Spotify not authenticated"""
|
||||
if self.is_spotify_authenticated():
|
||||
try:
|
||||
results = self.sp.search(q=query, type='artist', limit=limit)
|
||||
results = self.sp.search(q=query, type='artist', limit=min(limit, 10))
|
||||
artists = []
|
||||
|
||||
for artist_data in results['artists']['items']:
|
||||
|
|
@ -515,11 +515,11 @@ class SpotifyClient:
|
|||
return self._itunes.search_artists(query, limit)
|
||||
|
||||
@rate_limited
|
||||
def search_albums(self, query: str, limit: int = 20) -> List[Album]:
|
||||
def search_albums(self, query: str, limit: int = 10) -> List[Album]:
|
||||
"""Search for albums - falls back to iTunes if Spotify not authenticated"""
|
||||
if self.is_spotify_authenticated():
|
||||
try:
|
||||
results = self.sp.search(q=query, type='album', limit=limit)
|
||||
results = self.sp.search(q=query, type='album', limit=min(limit, 10))
|
||||
albums = []
|
||||
|
||||
for album_data in results['albums']['items']:
|
||||
|
|
|
|||
|
|
@ -3783,7 +3783,7 @@ def enhanced_search():
|
|||
})
|
||||
|
||||
# Search for albums
|
||||
album_objs = spotify_client.search_albums(query, limit=20)
|
||||
album_objs = spotify_client.search_albums(query, limit=10)
|
||||
for album in album_objs:
|
||||
# Album has 'artists' (list), convert to string
|
||||
artist_name = ', '.join(album.artists) if album.artists else 'Unknown Artist'
|
||||
|
|
@ -3799,7 +3799,7 @@ def enhanced_search():
|
|||
})
|
||||
|
||||
# Search for tracks
|
||||
track_objs = spotify_client.search_tracks(query, limit=20)
|
||||
track_objs = spotify_client.search_tracks(query, limit=10)
|
||||
for track in track_objs:
|
||||
# Track has 'artists' (list), convert to string
|
||||
artist_name = ', '.join(track.artists) if track.artists else 'Unknown Artist'
|
||||
|
|
@ -6275,7 +6275,7 @@ def _generate_artist_suggestions(search_result, is_album=False, album_result=Non
|
|||
print(f" clean_album_title: '{clean_album_title}'")
|
||||
|
||||
# Search tracks using album title to find the artist
|
||||
tracks = spotify_client.search_tracks(clean_album_title, limit=20)
|
||||
tracks = spotify_client.search_tracks(clean_album_title, limit=10)
|
||||
print(f"📊 Found {len(tracks)} tracks from album search")
|
||||
|
||||
# Collect unique artists and their associated tracks/albums
|
||||
|
|
|
|||
Loading…
Reference in a new issue