e
This commit is contained in:
parent
4f6e1caa5f
commit
00000d9c6d
16 changed files with 106 additions and 89 deletions
|
|
@ -2,7 +2,6 @@ import asyncio
|
|||
import re
|
||||
from functools import partial
|
||||
from itertools import chain
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
from urllib.parse import urljoin
|
||||
|
||||
|
|
@ -15,9 +14,9 @@ log = get_logger(__name__)
|
|||
|
||||
urls: dict[str, dict[str, str | float]] = {}
|
||||
|
||||
API_FILE = Cache(Path(__file__).parent / "caches" / "watchfty_api.json", exp=28_800)
|
||||
CACHE_FILE = Cache("watchfty.json", exp=10_800)
|
||||
|
||||
CACHE_FILE = Cache(Path(__file__).parent / "caches" / "watchfty.json", exp=10_800)
|
||||
API_FILE = Cache("watchfty-api.json", exp=28_800)
|
||||
|
||||
MIRRORS = [
|
||||
"https://www.watchfooty.cc",
|
||||
|
|
@ -26,23 +25,30 @@ MIRRORS = [
|
|||
]
|
||||
|
||||
SPORT_ENDPOINTS = [
|
||||
"football",
|
||||
"american-football",
|
||||
"hockey",
|
||||
"basketball",
|
||||
"australian-football",
|
||||
"baseball",
|
||||
"racing",
|
||||
"basketball",
|
||||
"cricket",
|
||||
"darts",
|
||||
"fighting",
|
||||
"football",
|
||||
"golf",
|
||||
"hockey",
|
||||
"racing",
|
||||
"rugby",
|
||||
"tennis",
|
||||
"volleyball",
|
||||
]
|
||||
|
||||
|
||||
async def get_api_data(client: httpx.AsyncClient, url: str) -> list[dict[str, Any]]:
|
||||
try:
|
||||
r = await client.get(url, timeout=10)
|
||||
r = await client.get(url, timeout=5)
|
||||
r.raise_for_status()
|
||||
except Exception as e:
|
||||
log.error(f'Failed to fetch "{url}": {e}')
|
||||
|
||||
return []
|
||||
|
||||
return r.json()
|
||||
|
|
@ -85,7 +91,11 @@ async def process_event(
|
|||
|
||||
got_one = asyncio.Event()
|
||||
|
||||
handler = partial(network.capture_req, captured=captured, got_one=got_one)
|
||||
handler = partial(
|
||||
network.capture_req,
|
||||
captured=captured,
|
||||
got_one=got_one,
|
||||
)
|
||||
|
||||
page.on("request", handler)
|
||||
|
||||
|
|
@ -159,7 +169,7 @@ async def get_events(
|
|||
|
||||
API_FILE.write(api_data)
|
||||
|
||||
events: list[dict[str, str]] = []
|
||||
events = []
|
||||
|
||||
now = Time.clean(Time.now())
|
||||
start_dt = now.delta(hours=-1)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue