Spaces:
Running
Running
Z User commited on
Commit ·
59763d4
1
Parent(s): ad34132
NetMirror: Add fuzzy title matching for better results
Browse files971 unmodified lines972973974975976977978979980981982971 unmodified linesreturn service_results, [f"{svc_name}: Search returned non-JSON"]search_results = search_data.get("searchResult", [])match = Nonefor item in search_results:if item.get("t", "").strip().lower() == title.lower():match = itembreakif not match or not match.get("id"):return service_results, [f"{svc_name}: No match found"]971 unmodified lines972973974975976977978979980981982983984985986987988989990991992993994995996997971 unmodified linesreturn service_results, [f"{svc_name}: Search returned non-JSON"]search_results = search_data.get("searchResult", [])# Fuzzy match: exact first, then starts-with, then containsmatch = Nonetitle_lower = title.lower()for item in search_results:item_title = item.get("t", "").strip().lower()if item_title == title_lower:match = itembreakif not match:for item in search_results:item_title = item.get("t", "").strip().lower()if item_title.startswith(title_lower) or title_lower.startswith(item_title):match = itembreakif not match:for item in search_results:item_title = item.get("t", "").strip().lower()if title_lower in item_title or item_title in title_lower:match = itembreakif not match or not match.get("id"):return service_results, [f"{svc_name}: No match found"]
main.py+16-1