Change fallback query to add artist and use Deezer's advanced search

Including artist name ensures that tracks with identical titles and album titles don't get included in results.

Deezer advanced search provides more accurate results.
This commit is contained in:
They Who Shall Be Named
2025-08-16 04:11:01 -04:00
committed by GitHub
parent b8d0161e00
commit a1469791b0

View File

@@ -419,6 +419,8 @@ class DeeLogin:
spo_title = track_json.get('name', '') spo_title = track_json.get('name', '')
spo_album_title = (track_json.get('album') or {}).get('name', '') spo_album_title = (track_json.get('album') or {}).get('name', '')
spo_tracknum = int(track_json.get('track_number') or 0) spo_tracknum = int(track_json.get('track_number') or 0)
spo_artists = track_json.get('artists') or []
spo_main_artist = (spo_artists[0].get('name') if spo_artists else '') or ''
try: try:
dz = API.get_track_json(f"isrc:{spo_isrc}") dz = API.get_track_json(f"isrc:{spo_isrc}")
@@ -435,8 +437,8 @@ class DeeLogin:
except Exception: except Exception:
pass pass
# Fallback: search by title + album # Fallback: search by title + artist + album
query = f'"{spo_title} {spo_album_title}"' query = f'"track:\'{spo_title}\' artist:\'{spo_main_artist}\' album:\'{spo_album_title}\'"'
try: try:
candidates = API.search_tracks_raw(query, limit=5) candidates = API.search_tracks_raw(query, limit=5)
except Exception: except Exception: