Fix Genius search blind fallback matching wrong artists/songs
This commit is contained in:
parent
f26f6f8266
commit
87db94554a
1 changed files with 6 additions and 12 deletions
|
|
@ -154,12 +154,8 @@ class GeniusClient:
|
||||||
logger.debug(f"Found song match: {result.get('title')} by {result.get('artist_names')}")
|
logger.debug(f"Found song match: {result.get('title')} by {result.get('artist_names')}")
|
||||||
return result
|
return result
|
||||||
|
|
||||||
# Fall back to first result
|
# No confident match — let the worker mark as not_found and retry later
|
||||||
first = hits[0].get('result')
|
logger.debug(f"No song match found in search results for: {artist_name} - {track_title}")
|
||||||
if first:
|
|
||||||
logger.debug(f"Using first result: {first.get('title')} by {first.get('artist_names')}")
|
|
||||||
return first
|
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# ── Song Methods ──
|
# ── Song Methods ──
|
||||||
|
|
@ -206,15 +202,13 @@ class GeniusClient:
|
||||||
for hit in hits:
|
for hit in hits:
|
||||||
result = hit.get('result', {})
|
result = hit.get('result', {})
|
||||||
primary = result.get('primary_artist', {})
|
primary = result.get('primary_artist', {})
|
||||||
if primary and artist_lower in (primary.get('name') or '').lower():
|
primary_name = (primary.get('name') or '').lower()
|
||||||
|
if primary and (artist_lower in primary_name or primary_name in artist_lower):
|
||||||
logger.debug(f"Found artist: {primary.get('name')}")
|
logger.debug(f"Found artist: {primary.get('name')}")
|
||||||
return primary
|
return primary
|
||||||
|
|
||||||
# Fall back to first result's primary artist
|
# No confident match — let the worker mark as not_found and retry later
|
||||||
first_artist = hits[0].get('result', {}).get('primary_artist')
|
logger.debug(f"No artist match found in search results for: {artist_name}")
|
||||||
if first_artist:
|
|
||||||
return first_artist
|
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@rate_limited
|
@rate_limited
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue