mirror of
https://github.com/doms9/iptv.git
synced 2026-04-21 19:46:59 +02:00
e
This commit is contained in:
parent
77e8805fa8
commit
00000d9f56
2 changed files with 14 additions and 35 deletions
|
|
@ -13,8 +13,6 @@ TAG = "STP"
|
|||
|
||||
CACHE_FILE = Cache(TAG, exp=19_800)
|
||||
|
||||
API_FILE = Cache(f"{TAG}-api", exp=19_800)
|
||||
|
||||
API_URL = "https://streamtpnew.com/eventos.json"
|
||||
|
||||
|
||||
|
|
@ -53,22 +51,14 @@ async def process_event(url: str, url_num: int) -> str | None:
|
|||
|
||||
|
||||
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)):
|
||||
log.info("Refreshing API cache")
|
||||
|
||||
api_data = [{"timestamp": now.timestamp()}]
|
||||
|
||||
if r := await network.request(API_URL, log=log):
|
||||
api_data: list[dict[str, str]] = r.json()
|
||||
|
||||
api_data[-1]["timestamp"] = now.timestamp()
|
||||
|
||||
API_FILE.write(api_data)
|
||||
|
||||
events = []
|
||||
|
||||
if not (api_req := await network.request(API_URL, log=log)):
|
||||
return events
|
||||
|
||||
elif not (api_data := api_req.json()):
|
||||
return events
|
||||
|
||||
for event in api_data:
|
||||
name = event.get("title")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue