This commit is contained in:
@@ -6,6 +6,7 @@ with randomized order so the same show never appears twice in a row.
|
||||
|
||||
import logging
|
||||
import os
|
||||
import threading
|
||||
|
||||
from iptv.config import (
|
||||
CHANNELS_FILE,
|
||||
@@ -58,9 +59,31 @@ def main():
|
||||
"Ensure /data is mounted read-write (not :ro).",
|
||||
cache_manager._cache_dir,
|
||||
)
|
||||
else:
|
||||
# Bootstrap hash from existing cache if hash file was lost (e.g. restart)
|
||||
epg_path = cache_manager._epg_cache_file()
|
||||
if not cache_manager._bootstrap_hash_if_recent(epg_path):
|
||||
for ch in channel_repo.get_all():
|
||||
cid = ch.get("id", ch.get("name", ""))
|
||||
sched_path = cache_manager._schedule_cache_path(cid)
|
||||
if cache_manager._bootstrap_hash_if_recent(sched_path):
|
||||
break
|
||||
tmdb_client = TMDBClient()
|
||||
prefetcher = MetadataPrefetcher(schedule_builder, tmdb_client, channel_repo)
|
||||
prefetcher.start()
|
||||
|
||||
def _warmup_schedules():
|
||||
"""Preload schedules so first stream starts quickly."""
|
||||
for ch in channel_repo.get_all():
|
||||
cid = ch.get("id", ch.get("name", ""))
|
||||
try:
|
||||
schedule_builder.get_or_build(cid)
|
||||
except Exception as e:
|
||||
logger.debug("Schedule warmup %s: %s", cid, e)
|
||||
|
||||
threading.Thread(target=_warmup_schedules, daemon=True).start()
|
||||
logger.info("Schedule warmup started in background")
|
||||
|
||||
epg_builder = EPGBuilder(
|
||||
schedule_builder, tmdb_client, channel_repo, cache_manager, prefetcher
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user