mirror of
https://github.com/doms9/iptv.git
synced 2026-01-21 03:59:03 +01:00
e
This commit is contained in:
parent
ad80c3c982
commit
00000d998e
2 changed files with 51 additions and 59 deletions
|
|
@ -141,7 +141,7 @@ async def get_events(
|
||||||
|
|
||||||
live = []
|
live = []
|
||||||
|
|
||||||
start_ts = now.delta(minutes=-30).timestamp()
|
start_ts = now.delta(hours=-1).timestamp()
|
||||||
end_ts = now.delta(minutes=5).timestamp()
|
end_ts = now.delta(minutes=5).timestamp()
|
||||||
|
|
||||||
for k, v in events.items():
|
for k, v in events.items():
|
||||||
|
|
@ -158,9 +158,8 @@ async def get_events(
|
||||||
|
|
||||||
async def scrape(client: httpx.AsyncClient) -> None:
|
async def scrape(client: httpx.AsyncClient) -> None:
|
||||||
cached_urls = CACHE_FILE.load()
|
cached_urls = CACHE_FILE.load()
|
||||||
valid_urls = {k: v for k, v in cached_urls.items() if v["url"]}
|
cached_count = len(cached_urls)
|
||||||
valid_count = cached_count = len(valid_urls)
|
urls.update(cached_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")
|
||||||
|
|
||||||
|
|
@ -190,36 +189,33 @@ async def scrape(client: httpx.AsyncClient) -> 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:
|
||||||
valid_count += 1
|
sport, event, logo, link, ts = (
|
||||||
urls[key] = entry
|
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,
|
||||||
|
}
|
||||||
|
|
||||||
|
urls[key] = cached_urls[key] = entry
|
||||||
|
|
||||||
await browser.close()
|
await browser.close()
|
||||||
|
|
||||||
if new_count := valid_count - cached_count:
|
if new_count := len(cached_urls) - 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:
|
||||||
log.info("No new events found")
|
log.info("No new events found")
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ async def get_events(
|
||||||
|
|
||||||
events = []
|
events = []
|
||||||
|
|
||||||
start_dt = now.delta(minutes=-30)
|
start_dt = now.delta(hours=-1)
|
||||||
end_dt = now.delta(minutes=5)
|
end_dt = now.delta(minutes=5)
|
||||||
|
|
||||||
for stream_group in api_data:
|
for stream_group in api_data:
|
||||||
|
|
@ -139,9 +139,8 @@ async def get_events(
|
||||||
|
|
||||||
async def scrape(client: httpx.AsyncClient) -> None:
|
async def scrape(client: httpx.AsyncClient) -> None:
|
||||||
cached_urls = CACHE_FILE.load()
|
cached_urls = CACHE_FILE.load()
|
||||||
valid_urls = {k: v for k, v in cached_urls.items() if v["url"]}
|
cached_count = len(cached_urls)
|
||||||
valid_count = cached_count = len(valid_urls)
|
urls.update(cached_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")
|
||||||
|
|
||||||
|
|
@ -170,35 +169,32 @@ async def scrape(client: httpx.AsyncClient) -> None:
|
||||||
log=log,
|
log=log,
|
||||||
)
|
)
|
||||||
|
|
||||||
sport, event, ts, link = (
|
|
||||||
ev["sport"],
|
|
||||||
ev["event"],
|
|
||||||
ev["timestamp"],
|
|
||||||
ev["link"],
|
|
||||||
)
|
|
||||||
|
|
||||||
key = f"[{sport}] {event} ({TAG})"
|
|
||||||
|
|
||||||
tvg_id, logo = leagues.get_tvg_info(sport, event)
|
|
||||||
|
|
||||||
entry = {
|
|
||||||
"url": url,
|
|
||||||
"logo": logo,
|
|
||||||
"base": BASE_URL,
|
|
||||||
"timestamp": ts,
|
|
||||||
"id": tvg_id or "Live.Event.us",
|
|
||||||
"link": link,
|
|
||||||
}
|
|
||||||
|
|
||||||
cached_urls[key] = entry
|
|
||||||
|
|
||||||
if url:
|
if url:
|
||||||
valid_count += 1
|
sport, event, ts, link = (
|
||||||
urls[key] = entry
|
ev["sport"],
|
||||||
|
ev["event"],
|
||||||
|
ev["timestamp"],
|
||||||
|
ev["link"],
|
||||||
|
)
|
||||||
|
|
||||||
|
key = f"[{sport}] {event} ({TAG})"
|
||||||
|
|
||||||
|
tvg_id, logo = leagues.get_tvg_info(sport, event)
|
||||||
|
|
||||||
|
entry = {
|
||||||
|
"url": url,
|
||||||
|
"logo": logo,
|
||||||
|
"base": BASE_URL,
|
||||||
|
"timestamp": ts,
|
||||||
|
"id": tvg_id or "Live.Event.us",
|
||||||
|
"link": link,
|
||||||
|
}
|
||||||
|
|
||||||
|
urls[key] = cached_urls[key] = entry
|
||||||
|
|
||||||
await browser.close()
|
await browser.close()
|
||||||
|
|
||||||
if new_count := valid_count - cached_count:
|
if new_count := len(cached_urls) - 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:
|
||||||
log.info("No new events found")
|
log.info("No new events found")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue