mirror of
https://github.com/doms9/iptv.git
synced 2026-01-21 03:59:03 +01:00
e
update streamhub caching
This commit is contained in:
parent
501a8d2847
commit
00000d9cd4
1 changed files with 30 additions and 24 deletions
|
|
@ -135,9 +135,11 @@ async def get_events(cached_keys: list[str]) -> list[dict[str, str]]:
|
||||||
async def scrape() -> None:
|
async def scrape() -> None:
|
||||||
cached_urls = CACHE_FILE.load()
|
cached_urls = CACHE_FILE.load()
|
||||||
|
|
||||||
cached_count = len(cached_urls)
|
valid_urls = {k: v for k, v in cached_urls.items() if v["url"]}
|
||||||
|
|
||||||
urls.update(cached_urls)
|
valid_count = cached_count = len(valid_urls)
|
||||||
|
|
||||||
|
urls.update(valid_urls)
|
||||||
|
|
||||||
log.info(f"Loaded {cached_count} event(s) from cache")
|
log.info(f"Loaded {cached_count} event(s) from cache")
|
||||||
|
|
||||||
|
|
@ -169,34 +171,38 @@ async def scrape() -> None:
|
||||||
log=log,
|
log=log,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
sport, event, logo, link, ts = (
|
||||||
|
ev["sport"],
|
||||||
|
ev["event"],
|
||||||
|
ev["logo"],
|
||||||
|
ev["link"],
|
||||||
|
ev["event_ts"],
|
||||||
|
)
|
||||||
|
|
||||||
|
key = f"[{sport}] {event} ({TAG})"
|
||||||
|
|
||||||
|
tvg_id, pic = leagues.get_tvg_info(sport, event)
|
||||||
|
|
||||||
|
entry = {
|
||||||
|
"url": url,
|
||||||
|
"logo": logo or pic,
|
||||||
|
"base": "https://storytrench.net/",
|
||||||
|
"timestamp": ts,
|
||||||
|
"id": tvg_id or "Live.Event.us",
|
||||||
|
"link": link,
|
||||||
|
}
|
||||||
|
|
||||||
|
cached_urls[key] = entry
|
||||||
|
|
||||||
if url:
|
if url:
|
||||||
sport, event, logo, link, ts = (
|
valid_count += 1
|
||||||
ev["sport"],
|
|
||||||
ev["event"],
|
|
||||||
ev["logo"],
|
|
||||||
ev["link"],
|
|
||||||
ev["event_ts"],
|
|
||||||
)
|
|
||||||
|
|
||||||
key = f"[{sport}] {event} ({TAG})"
|
urls[key] = entry
|
||||||
|
|
||||||
tvg_id, pic = leagues.get_tvg_info(sport, event)
|
|
||||||
|
|
||||||
entry = {
|
|
||||||
"url": url,
|
|
||||||
"logo": logo or pic,
|
|
||||||
"base": "https://storytrench.net/",
|
|
||||||
"timestamp": ts,
|
|
||||||
"id": tvg_id or "Live.Event.us",
|
|
||||||
"link": link,
|
|
||||||
}
|
|
||||||
|
|
||||||
urls[key] = cached_urls[key] = entry
|
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
await browser.close()
|
await browser.close()
|
||||||
|
|
||||||
if new_count := len(cached_urls) - cached_count:
|
if new_count := valid_count - cached_count:
|
||||||
log.info(f"Collected and cached {new_count} new event(s)")
|
log.info(f"Collected and cached {new_count} new event(s)")
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue