From 6cd421ed6913c09935cc29d9c13d05500ccb8eeb Mon Sep 17 00:00:00 2001 From: Bram Date: Wed, 11 Feb 2026 19:22:10 +0100 Subject: [PATCH] try to add images --- Dockers/self-hosted-iptv/main.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Dockers/self-hosted-iptv/main.py b/Dockers/self-hosted-iptv/main.py index f03d85d..087329a 100644 --- a/Dockers/self-hosted-iptv/main.py +++ b/Dockers/self-hosted-iptv/main.py @@ -78,6 +78,8 @@ TMDB_CACHE_TTL_SEC = 24 * 3600 TMDB_RATE_LIMIT_REQUESTS = 40 TMDB_RATE_LIMIT_WINDOW_SEC = 10.0 TMDB_CACHE_DIR = DATA_ROOT / "tmdb_cache" +TMDB_IMAGE_BASE = "https://image.tmdb.org/t/p" +TMDB_IMAGE_STILL_SIZE = "w500" # episode still width for EPG icon _tmdb_series_cache: dict[str, tuple[int, str, float]] = {} # programme_name -> (series_id, series_name_nl, ts) _tmdb_series_details_cache: dict[int, tuple[dict, float]] = {} # series_id -> ({genres, country}, ts) _tmdb_episode_cache: dict[tuple[int, int, int], tuple[dict, float]] = {} # (series_id, s, e) -> (meta, ts) @@ -470,7 +472,10 @@ def _tmdb_get_episode(series_id: int, season: int, episode: int) -> dict | None: name = (data.get("name") or "").strip() overview = (data.get("overview") or "").strip() air_date = (data.get("air_date") or "").strip() # YYYY-MM-DD - meta = {"name": name, "overview": overview, "air_date": air_date} + still_path = (data.get("still_path") or "").strip() + if still_path and not still_path.startswith("/"): + still_path = "/" + still_path + meta = {"name": name, "overview": overview, "air_date": air_date, "still_path": still_path or None} _tmdb_episode_cache[key_tuple] = (meta, now) _tmdb_write_disk_cache("episode", key, meta) return meta @@ -547,6 +552,12 @@ def get_episode_metadata(programme_name: str, path: Path) -> dict | None: air_date = ep.get("air_date") or "" date_str = _air_date_to_xmltv_date(air_date) or "20090101" # fallback if missing + still_path = ep.get("still_path") or "" + if still_path and still_path.startswith("/"): + icon_url = f"{TMDB_IMAGE_BASE}/{TMDB_IMAGE_STILL_SIZE}{still_path}" + else: + icon_url = None + details = _tmdb_get_series_details(series_id) genres = (details.get("genres") or []) if details else [] country = (details.get("country") or "") if details else "" @@ -565,6 +576,7 @@ def get_episode_metadata(programme_name: str, path: Path) -> dict | None: "sub_title": sub_title, "desc": overview, "lang": TMDB_LANGUAGE, + "icon": icon_url, "directors": directors, "actors": actors, "producers": producers, @@ -641,6 +653,8 @@ def build_epg_xml() -> str: ET.SubElement(prog, "sub-title", lang=lang).text = meta["sub_title"] if meta.get("desc"): ET.SubElement(prog, "desc", lang=lang).text = meta["desc"] + if meta.get("icon"): + ET.SubElement(prog, "icon", attrib={"src": meta["icon"]}) directors = meta.get("directors") or [] actors = meta.get("actors") or [] producers = meta.get("producers") or []