This commit is contained in:
@@ -213,6 +213,29 @@ def _format_xmltv_time(dt: datetime) -> str:
|
|||||||
return dt.strftime("%Y%m%d%H%M%S ") + tz
|
return dt.strftime("%Y%m%d%H%M%S ") + tz
|
||||||
|
|
||||||
|
|
||||||
|
def get_programme_name_from_path(path: Path) -> str:
|
||||||
|
"""
|
||||||
|
Return the series/movie name from the folder (e.g. series/W817/... -> W817,
|
||||||
|
movies/MyMovie/... -> MyMovie). If the file is directly under root, use stem.
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
if SERIES_ROOT in path.parents:
|
||||||
|
rel = path.relative_to(SERIES_ROOT)
|
||||||
|
parts = rel.parts
|
||||||
|
if len(parts) > 1:
|
||||||
|
return parts[0]
|
||||||
|
return path.stem
|
||||||
|
if MOVIES_ROOT in path.parents:
|
||||||
|
rel = path.relative_to(MOVIES_ROOT)
|
||||||
|
parts = rel.parts
|
||||||
|
if len(parts) > 1:
|
||||||
|
return parts[0]
|
||||||
|
return path.stem
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
return path.stem
|
||||||
|
|
||||||
|
|
||||||
def build_epg_xml() -> str:
|
def build_epg_xml() -> str:
|
||||||
"""
|
"""
|
||||||
Build XMLTV EPG for all channels. Schedule repeats from midnight UTC (same
|
Build XMLTV EPG for all channels. Schedule repeats from midnight UTC (same
|
||||||
@@ -264,8 +287,9 @@ def build_epg_xml() -> str:
|
|||||||
stop=_format_xmltv_time(stop_dt),
|
stop=_format_xmltv_time(stop_dt),
|
||||||
channel=cid,
|
channel=cid,
|
||||||
)
|
)
|
||||||
title = path.stem
|
programme_name = get_programme_name_from_path(path)
|
||||||
ET.SubElement(prog, "title", lang="en").text = title
|
ET.SubElement(prog, "title", lang="en").text = programme_name
|
||||||
|
ET.SubElement(prog, "sub-title", lang="en").text = path.stem
|
||||||
cycle_start += cycle_delta
|
cycle_start += cycle_delta
|
||||||
|
|
||||||
ET.indent(root, space=" ")
|
ET.indent(root, space=" ")
|
||||||
|
|||||||
Reference in New Issue
Block a user