mirror of
https://github.com/doms9/iptv.git
synced 2026-01-21 03:59:03 +01:00
e
fix scraper crashing if api url(s) do not work misc. edits
This commit is contained in:
parent
51598ce2a2
commit
00000d903e
9 changed files with 18 additions and 24 deletions
|
|
@ -18,12 +18,14 @@ API_URL = "https://api.cdn-live.tv/api/v1/events/sports"
|
|||
|
||||
|
||||
async def get_events(cached_keys: list[str]) -> list[dict[str, str]]:
|
||||
now = Time.clean(Time.now())
|
||||
|
||||
events = []
|
||||
|
||||
if not (api_data := API_FILE.load(per_entry=False)):
|
||||
log.info("Refreshing API cache")
|
||||
|
||||
api_data = {}
|
||||
api_data = {"timestamp": now.timestamp()}
|
||||
|
||||
if r := await network.request(
|
||||
API_URL,
|
||||
|
|
@ -32,13 +34,13 @@ async def get_events(cached_keys: list[str]) -> list[dict[str, str]]:
|
|||
):
|
||||
api_data: dict = r.json()
|
||||
|
||||
api_data["timestamp"] = now.timestamp()
|
||||
|
||||
API_FILE.write(api_data)
|
||||
|
||||
if not (data := api_data.get("cdn-live-tv")):
|
||||
return events
|
||||
|
||||
now = Time.clean(Time.now())
|
||||
|
||||
start_dt = now.delta(minutes=-30)
|
||||
end_dt = now.delta(minutes=30)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue