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 <noreply@anthropic.com>
This commit is contained in:
parent
7b741e951f
commit
29b65e33a7
1 changed files with 8 additions and 0 deletions
8
main.py
8
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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue