Jambase aufgeräumt und Backup script
This commit is contained in:
@@ -35,6 +35,8 @@ class JamBaseProvider:
|
||||
|
||||
payload = None
|
||||
raw_count = 0
|
||||
self.last_raw_count = 0
|
||||
self.last_match_count = 0
|
||||
tried_params: list[str] = []
|
||||
bad_request_messages: list[str] = []
|
||||
for params in self._build_param_candidates(term, watch_type, region_scope):
|
||||
@@ -74,6 +76,7 @@ class JamBaseProvider:
|
||||
return []
|
||||
raw_items = self._extract_items(payload)
|
||||
raw_count = len(raw_items)
|
||||
self.last_raw_count = raw_count
|
||||
if raw_items:
|
||||
break
|
||||
|
||||
@@ -105,7 +108,13 @@ class JamBaseProvider:
|
||||
|
||||
if region_scope == RegionScope.hamburg and normalize_search_text(city) != "hamburg":
|
||||
continue
|
||||
if region_scope == RegionScope.germany and country_code not in {"DE", "GER", "Germany"}:
|
||||
if region_scope == RegionScope.germany and country_code not in {
|
||||
"DE",
|
||||
"DEU",
|
||||
"GER",
|
||||
"Germany",
|
||||
"Deutschland",
|
||||
}:
|
||||
continue
|
||||
|
||||
event_date = self._extract_event_date(item)
|
||||
@@ -137,6 +146,7 @@ class JamBaseProvider:
|
||||
}
|
||||
)
|
||||
|
||||
self.last_match_count = len(results)
|
||||
self.last_message = (
|
||||
f"JamBase lieferte {raw_count} Roh-Events fuer '{term}', "
|
||||
f"davon {len(results)} passend nach Eventlens-Filtern."
|
||||
@@ -228,9 +238,10 @@ class JamBaseProvider:
|
||||
return names
|
||||
|
||||
def _extract_venue_name(self, item: dict) -> str | None:
|
||||
venue = item.get("venue")
|
||||
if isinstance(venue, dict):
|
||||
return self._get_first(venue, "name", "venueName", "title")
|
||||
for key in ("location", "venue"):
|
||||
venue = item.get(key)
|
||||
if isinstance(venue, dict):
|
||||
return self._get_first(venue, "name", "venueName", "title")
|
||||
return self._get_first(item, "venue_name", "venueName")
|
||||
|
||||
def _extract_city(self, item: dict) -> str | None:
|
||||
@@ -273,11 +284,6 @@ class JamBaseProvider:
|
||||
container = item.get(container_name)
|
||||
if not isinstance(container, dict):
|
||||
continue
|
||||
country = container.get("country")
|
||||
if isinstance(country, dict):
|
||||
return self._get_first(country, "countryCode", "code", "name")
|
||||
if isinstance(country, str):
|
||||
return country
|
||||
address = container.get("address")
|
||||
if isinstance(address, dict):
|
||||
country = address.get("addressCountry")
|
||||
@@ -286,6 +292,11 @@ class JamBaseProvider:
|
||||
if isinstance(country, str):
|
||||
return country
|
||||
return self._get_first(address, "countryCode", "country")
|
||||
country = container.get("country")
|
||||
if isinstance(country, dict):
|
||||
return self._get_first(country, "countryCode", "code", "identifier", "name")
|
||||
if isinstance(country, str):
|
||||
return country
|
||||
return self._get_first(item, "country_code", "countryCode", "country")
|
||||
|
||||
def _extract_event_date(self, item: dict) -> datetime | None:
|
||||
@@ -326,7 +337,7 @@ class JamBaseProvider:
|
||||
return None
|
||||
|
||||
def _extract_image_url(self, item: dict) -> str | None:
|
||||
for key in ("image", "image_url", "imageUrl"):
|
||||
for key in ("x-promoImage", "image", "image_url", "imageUrl"):
|
||||
value = item.get(key)
|
||||
if isinstance(value, str) and value:
|
||||
return value
|
||||
|
||||
Reference in New Issue
Block a user