iptv/M3U8/scrapers/utils/config.py
2025-09-21 15:24:47 -04:00

35 lines
865 B
Python

import json
from datetime import datetime
from pathlib import Path
import pytz
TZ = pytz.timezone("America/New_York")
now = datetime.now(TZ)
live_img = "https://i.gyazo.com/978f2eb4a199ca5b56b447aded0cb9e3.png"
leagues_file = Path(__file__).parent / "leagues.json"
LEAGUES: dict[str, dict[str, str]] = json.loads(
leagues_file.read_text(encoding="utf-8")
)
def league_info(name: str) -> tuple[str | None, str]:
if match := next(
(
(tvg_id, league_data.get("logo"))
for tvg_id, leagues in LEAGUES.items()
for league_entry in leagues
for league_name, league_data in league_entry.items()
if name == league_name or name in league_data.get("names", [])
),
None,
):
tvg_id, logo = match
return (tvg_id, logo or live_img)
return (None, live_img)