Improve fallback logic for iTunes track search

This commit is contained in:
√(noham)²
2025-11-30 15:10:09 +01:00
parent ab21dfd6f3
commit 9c018860b3

View File

@@ -42,6 +42,17 @@ def get_track_extras(song, artist, album):
r = requests.get("https://itunes.apple.com/search", params=params)
json_data = r.json()
if json_data["resultCount"] == 0:
query = f"{song} {artist}"
params = {"media": "music", "entity": "song", "term": query}
r = requests.get("https://itunes.apple.com/search", params=params)
json_data = r.json()
if json_data["resultCount"] == 0:
query = f"{song} {album}"
params = {"media": "music", "entity": "song", "term": query}
r = requests.get("https://itunes.apple.com/search", params=params)
json_data = r.json()
if json_data["resultCount"] == 1:
result = json_data["results"][0]
elif json_data["resultCount"] > 1: