From 29b65e33a7db197b1653cde5fc99899aab74495a Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Sun, 8 Feb 2026 14:07:19 +0000 Subject: [PATCH] Retry Flickr search without middle initial when no results found When the default phrase search returns no results and the name contains a middle initial (e.g. "Gary B. Fogel"), automatically retry with the middle initial removed ("Gary Fogel"). Only applies to the default search, not user-overridden searches. Co-Authored-By: Claude Opus 4.6 --- main.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/main.py b/main.py index 2a6d238..e83212e 100755 --- a/main.py +++ b/main.py @@ -722,6 +722,14 @@ def start() -> str: if page == 1: log_interaction("search_article", query=flickr_search, wikipedia_url=wikipedia_url) search_result = search_flickr(flickr_search, page) + + # If no results and using default search, retry without middle initial + if not search_result.photos and not flask.request.args.get("flickr_search"): + without_middle = re.sub(r" [A-Z]\. ", " ", name) + if without_middle != name: + flickr_search = f'"{without_middle}"' + search_result = search_flickr(flickr_search, page) + return flask.render_template( "combined.html", name=name,