Refine title search to whole-word matching and bump 0.1.49
This commit is contained in:
@@ -238,6 +238,14 @@ def _normalize_search_text(value: str) -> str:
|
||||
return value
|
||||
|
||||
|
||||
def _matches_query(query: str, *, title: str) -> bool:
|
||||
normalized_query = _normalize_search_text(query)
|
||||
if not normalized_query:
|
||||
return False
|
||||
haystack = f" {_normalize_search_text(title)} "
|
||||
return f" {normalized_query} " in haystack
|
||||
|
||||
|
||||
def _is_episode_tba(title: str, original_title: str) -> bool:
|
||||
combined = f"{title} {original_title}".casefold()
|
||||
markers = ("tba", "demnächst", "demnaechst", "coming soon", "to be announced")
|
||||
@@ -395,8 +403,7 @@ def _extract_genre_names_from_html(body: str) -> List[str]:
|
||||
def search_series(query: str) -> List[SeriesResult]:
|
||||
"""Sucht Serien im (/serien)-Katalog (Genre-liste) nach Titel/Alt-Titel."""
|
||||
_ensure_requests()
|
||||
normalized_query = _normalize_search_text(query)
|
||||
if not normalized_query:
|
||||
if not _normalize_search_text(query):
|
||||
return []
|
||||
# Direkter Abruf wie in fetch_serien.py.
|
||||
catalog_url = f"{_get_base_url()}/serien?by=genre"
|
||||
@@ -404,8 +411,7 @@ def search_series(query: str) -> List[SeriesResult]:
|
||||
results: List[SeriesResult] = []
|
||||
for series in parse_series_catalog(soup).values():
|
||||
for entry in series:
|
||||
haystack = _normalize_search_text(entry.title)
|
||||
if entry.title and normalized_query in haystack:
|
||||
if entry.title and _matches_query(query, title=entry.title):
|
||||
results.append(entry)
|
||||
return results
|
||||
|
||||
|
||||
Reference in New Issue
Block a user