From 9c018860b32847ac5daab28ea18ca7b57959e8fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=88=9A=28noham=29=C2=B2?= <100566912+NohamR@users.noreply.github.com> Date: Sun, 30 Nov 2025 15:10:09 +0100 Subject: [PATCH] Improve fallback logic for iTunes track search --- user/export.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/user/export.py b/user/export.py index 91c563c..07e3be1 100644 --- a/user/export.py +++ b/user/export.py @@ -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: