This commit is contained in:
doms9 2025-10-11 18:43:57 -04:00
parent 703c55bee4
commit 00000d9199
5 changed files with 328 additions and 30 deletions

View file

@ -31,34 +31,6 @@ def validate_category(s: str) -> str:
return s.capitalize()
def get_tvg_info(sport: str, event: str) -> tuple[str | None, str]:
match sport:
case "American Football":
if leagues.is_valid(event, "NFL"):
return leagues.info("NFL")
else:
return leagues.info("NCAA")
case "Basketball":
if leagues.is_valid(event, "NBA"):
return leagues.info("NBA")
elif leagues.is_valid(event, "WNBA"):
return leagues.info("WNBA")
# NCAA
else:
return leagues.info("Basketball")
case "Hockey":
return leagues.info("NHL")
case _:
return leagues.info(sport)
async def refresh_api_cache(
client: httpx.AsyncClient, url: str
) -> list[dict[str, Any]]:
@ -139,6 +111,7 @@ async def get_events(
base_url: str,
cached_keys: set[str],
) -> list[dict[str, str]]:
if not (api_data := API_FILE.load(per_entry=False, index=True)):
api_data = await refresh_api_cache(
client,
@ -257,7 +230,7 @@ async def scrape(client: httpx.AsyncClient) -> None:
key = f"[{sport}] {event} (STRMD)"
tvg_id, pic = get_tvg_info(sport, event)
tvg_id, pic = leagues.get_tvg_info(sport, event)
entry = {
"url": url,