Fabrik als Provider Korrigiert
This commit is contained in:
@@ -4,6 +4,7 @@ import requests
|
||||
|
||||
from app.config import settings
|
||||
from app.models import RegionScope, WatchType
|
||||
from app.providers.utils import normalize_search_text
|
||||
|
||||
|
||||
class TicketmasterProvider:
|
||||
@@ -38,19 +39,25 @@ class TicketmasterProvider:
|
||||
response.raise_for_status()
|
||||
payload = response.json()
|
||||
items = payload.get("_embedded", {}).get("events", [])
|
||||
setattr(self, "last_status", "ok")
|
||||
setattr(
|
||||
self,
|
||||
"last_message",
|
||||
f"Ticketmaster returned {len(items)} raw events for term '{term}'.",
|
||||
)
|
||||
results: list[dict] = []
|
||||
|
||||
normalized_term = term.casefold()
|
||||
normalized_term = normalize_search_text(term)
|
||||
for item in items:
|
||||
title = item.get("name", "")
|
||||
attractions = item.get("_embedded", {}).get("attractions", [])
|
||||
attraction_names = [entry.get("name", "") for entry in attractions]
|
||||
|
||||
if watch_type == WatchType.artist:
|
||||
haystack = " ".join(attraction_names + [title]).casefold()
|
||||
haystack = normalize_search_text(" ".join(attraction_names + [title]))
|
||||
if normalized_term not in haystack:
|
||||
continue
|
||||
elif normalized_term not in title.casefold():
|
||||
elif normalized_term not in normalize_search_text(title):
|
||||
continue
|
||||
|
||||
dates = item.get("dates", {}).get("start", {})
|
||||
@@ -88,4 +95,3 @@ class TicketmasterProvider:
|
||||
)
|
||||
|
||||
return results
|
||||
|
||||
|
||||
Reference in New Issue
Block a user