This commit is contained in:
@@ -75,6 +75,9 @@ class CacheManager:
|
||||
"""
|
||||
If channels.json has changed, clear all caches and return True.
|
||||
Otherwise return False.
|
||||
Only clear when we have a stored hash that explicitly differs; when
|
||||
stored is None (hash file missing), do not delete cache files — they
|
||||
may be valid and we don't want to destroy them on every restart.
|
||||
"""
|
||||
current = get_channels_hash(self._channels_file)
|
||||
stored = self._get_stored_hash()
|
||||
@@ -82,7 +85,7 @@ class CacheManager:
|
||||
if current is None:
|
||||
return False
|
||||
|
||||
if stored != current:
|
||||
if stored is not None and stored != current:
|
||||
logger.info("Channels changed (hash %s -> %s), invalidating cache", stored, current)
|
||||
self._clear_cache()
|
||||
if self._schedule_builder and hasattr(self._schedule_builder, "invalidate_cache"):
|
||||
|
||||
@@ -74,6 +74,11 @@ class IPTVHandler(BaseHTTPRequestHandler):
|
||||
self.end_headers()
|
||||
self.wfile.write(body.encode("utf-8"))
|
||||
|
||||
def _extinf_channel(self, cid: str, name: str) -> str:
|
||||
"""Build EXTINF line with tvg-id for EPG matching and persistence."""
|
||||
safe = lambda s: (s or "").replace("\\", "\\\\").replace('"', '\\"')
|
||||
return f'#EXTINF:-1 tvg-id="{safe(cid)}" tvg-name="{safe(name)}",{name}'
|
||||
|
||||
def send_channels_m3u(self):
|
||||
"""Master M3U for Plex DVR: one live stream URL per channel."""
|
||||
base = get_base_url(self)
|
||||
@@ -82,7 +87,7 @@ class IPTVHandler(BaseHTTPRequestHandler):
|
||||
for ch in channels:
|
||||
cid = ch.get("id", ch.get("name", ""))
|
||||
name = ch.get("name", cid)
|
||||
lines.append(f"#EXTINF:-1,{name}")
|
||||
lines.append(self._extinf_channel(cid, name))
|
||||
lines.append(f"{base}/live/{cid}")
|
||||
body = "\n".join(lines) + "\n"
|
||||
self.send_response(200)
|
||||
|
||||
Reference in New Issue
Block a user