This commit is contained in:
doms9 2025-09-03 15:00:17 -04:00
parent dece752803
commit 00000d9440
12 changed files with 371 additions and 133 deletions

View file

@ -4,8 +4,7 @@ from urllib.parse import urljoin
import httpx
from selectolax.parser import HTMLParser
from .tvpass import logos
from .utils.logger import get_logger
from .utils import LOGOS, get_base, get_logger
log = get_logger(__name__)
@ -19,23 +18,6 @@ MIRRORS = [
]
async def check_status(client: httpx.AsyncClient, url: str) -> bool:
try:
r = await client.get(url)
r.raise_for_status()
except Exception:
return False
return r.status_code == 200
async def get_base(client: httpx.AsyncClient, mirrors: list[str]) -> str:
tasks = [check_status(client, link) for link in mirrors]
results = await asyncio.gather(*tasks)
return [url for url, ok in zip(mirrors, results) if ok][0]
async def get_hrefs(client: httpx.AsyncClient, base_url: str) -> list[tuple[str, str]]:
log.info(f'Scraping from "{base_url}"')
@ -125,7 +107,7 @@ async def main(client: httpx.AsyncClient) -> None:
urls[key] = {
"url": link,
"logo": logos.get(
"logo": LOGOS.get(
event,
"https://i.gyazo.com/ec27417a9644ae517196494afa72d2b9.png",
),