This commit is contained in:
doms9 2025-11-15 02:05:52 -05:00
parent d7c64fdeae
commit 00000d94fc
8 changed files with 38 additions and 33 deletions

View file

@ -20,7 +20,7 @@ API_FILE = Cache("strmd-api.json", exp=28_800)
MIRRORS = ["https://streamed.pk", "https://streami.su", "https://streamed.st"]
def validate_category(s: str) -> str:
def fix_sport(s: str) -> str:
if "-" in s:
return " ".join(i.capitalize() for i in s.split("-"))
@ -138,9 +138,7 @@ async def get_events(
pattern = re.compile(r"[\n\r]+|\s{2,}")
for event in api_data:
category = event["category"]
if category == "other":
if (category := event.get("category")) == "other":
continue
if not (ts := event["date"]):
@ -153,7 +151,7 @@ async def get_events(
if not start_dt <= event_dt <= end_dt:
continue
sport = validate_category(category)
sport = fix_sport(category)
parts = pattern.split(event["title"].strip())
name = " | ".join(p.strip() for p in parts if p.strip())
@ -198,7 +196,7 @@ async def scrape(client: httpx.AsyncClient) -> None:
log.info(f"Loaded {cached_count} event(s) from cache")
if not (base_url := await network.get_base(MIRRORS)):
log.warning("No working PPV mirrors")
log.warning("No working STRMD mirrors")
CACHE_FILE.write(cached_urls)
return