- edit domain for watchfooty.py
- misc edits
This commit is contained in:
doms9 2026-03-07 11:52:59 -05:00
parent 7e924aa3a9
commit 00000d9379
2 changed files with 15 additions and 20 deletions

View file

@ -17,19 +17,19 @@ CACHE_FILE = Cache(TAG, exp=10_800)
HTML_CACHE = Cache(f"{TAG}-html", exp=19_800)
BASE_URL = "https://livesports4u.net"
BASE_URL = "https://streamhub.pro"
SPORT_ENDPOINTS = [
f"sport_{sport_id}"
for sport_id in [
# "68c02a4465113", # American Football
"68c02a446582f", # Baseball
# "68c02a446582f", # Baseball
"68c02a4466011", # Basketball
"68c02a4466f56", # Hockey
"68c02a44674e9", # MMA
"68c02a4467a48", # Racing
# "68c02a44674e9", # MMA
# "68c02a4467a48", # Racing
"68c02a4464a38", # Soccer
"68c02a4468cf7", # Tennis
# "68c02a4468cf7", # Tennis
]
]
@ -107,7 +107,7 @@ async def get_events(cached_keys: list[str]) -> list[dict[str, str]]:
now.timestamp(),
)
for date in [now.date(), now.delta(days=1).date()]
for sport_id in SPORT_ENDPOINTS.values()
for sport_id in SPORT_ENDPOINTS
]
results = await asyncio.gather(*tasks)
@ -193,6 +193,8 @@ async def scrape(browser: Browser) -> None:
if url:
valid_count += 1
entry["url"] = url.split("?")[0]
urls[key] = entry
log.info(f"Collected and cached {valid_count - cached_count} new event(s)")

View file

@ -19,9 +19,9 @@ CACHE_FILE = Cache(TAG, exp=10_800)
API_FILE = Cache(f"{TAG}-api", exp=19_800)
API_URL = "https://api.watchfooty.st"
BASE_DOMAIN = "watchfooty.pw"
BASE_MIRRORS = ["https://www.watchfooty.pw"]
API_URL, BASE_URL = f"https://api.{BASE_DOMAIN}", f"https://www.{BASE_DOMAIN}"
VALID_SPORTS = [
# "american-football",
@ -119,7 +119,7 @@ async def process_event(
embed = re.sub(
pattern=r"^.*\/stream",
repl="https://spiderembed.top/embed",
repl="https://pikachusports.top/embed",
string=stream_url,
)
@ -165,7 +165,7 @@ async def process_event(
page.remove_listener("request", handler)
async def get_events(base_url: str, cached_keys: list[str]) -> list[dict[str, str]]:
async def get_events(cached_keys: list[str]) -> list[dict[str, str]]:
now = Time.clean(Time.now())
if not (api_data := API_FILE.load(per_entry=False, index=-1)):
@ -214,7 +214,7 @@ async def get_events(base_url: str, cached_keys: list[str]) -> list[dict[str, st
{
"sport": sport,
"event": name,
"link": urljoin(base_url, f"stream/{match_id}"),
"link": urljoin(BASE_URL, f"stream/{match_id}"),
"match-id": match_id,
"logo": logo,
"timestamp": event_dt.timestamp(),
@ -235,16 +235,9 @@ async def scrape(browser: Browser) -> None:
log.info(f"Loaded {cached_count} event(s) from cache")
if not (base_url := await network.get_base(BASE_MIRRORS)):
log.warning("No working Watch Footy mirrors")
log.info(f'Scraping from "{BASE_URL}"')
CACHE_FILE.write(cached_urls)
return
log.info(f'Scraping from "{base_url}"')
if events := await get_events(base_url, cached_urls.keys()):
if events := await get_events(cached_urls.keys()):
log.info(f"Processing {len(events)} new URL(s)")
async with network.event_context(browser, stealth=False) as context: