Improve Spotify artist search for short names using field filter
This commit is contained in:
parent
97502ec600
commit
0193f53d28
2 changed files with 4 additions and 2 deletions
|
|
@ -596,7 +596,8 @@ class SpotifyClient:
|
||||||
"""Search for artists - falls back to iTunes if Spotify not authenticated"""
|
"""Search for artists - falls back to iTunes if Spotify not authenticated"""
|
||||||
if self.is_spotify_authenticated():
|
if self.is_spotify_authenticated():
|
||||||
try:
|
try:
|
||||||
results = self.sp.search(q=query, type='artist', limit=min(limit, 10))
|
search_query = f'artist:{query}' if len(query.strip()) <= 4 else query
|
||||||
|
results = self.sp.search(q=search_query, type='artist', limit=min(limit, 10))
|
||||||
artists = []
|
artists = []
|
||||||
|
|
||||||
for artist_data in results['artists']['items']:
|
for artist_data in results['artists']['items']:
|
||||||
|
|
|
||||||
|
|
@ -23350,7 +23350,8 @@ def search_artists_for_playlist():
|
||||||
if hydrabase_worker and dev_mode_enabled:
|
if hydrabase_worker and dev_mode_enabled:
|
||||||
hydrabase_worker.enqueue(query, 'artist')
|
hydrabase_worker.enqueue(query, 'artist')
|
||||||
|
|
||||||
results = spotify_client.sp.search(q=query, type='artist', limit=10)
|
search_query = f'artist:{query}' if len(query.strip()) <= 4 else query
|
||||||
|
results = spotify_client.sp.search(q=search_query, type='artist', limit=10)
|
||||||
if results and 'artists' in results and 'items' in results['artists']:
|
if results and 'artists' in results and 'items' in results['artists']:
|
||||||
for artist in results['artists']['items']:
|
for artist in results['artists']['items']:
|
||||||
artists.append({
|
artists.append({
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue