diff --git a/app/eparser/ecommons.py b/app/eparser/ecommons.py
index b3c17ef1..30118cab 100644
--- a/app/eparser/ecommons.py
+++ b/app/eparser/ecommons.py
@@ -47,6 +47,10 @@ class BqServiceType(Enum):
ALT = "ALT" # Service with alternatives
BOUQUET = "BOUQUET" # Sub bouquet.
+ @classmethod
+ def _missing_(cls, value):
+ return cls.DEFAULT
+
Bouquet = namedtuple("Bouquet", ["name", "type", "services", "locked", "hidden", "file"])
Bouquet.__new__.__defaults__ = (None, BqServiceType.DEFAULT, [], None, None, None) # For Python3 < 3.7
diff --git a/app/eparser/iptv.py b/app/eparser/iptv.py
index 651d1fb5..1a6b82cb 100644
--- a/app/eparser/iptv.py
+++ b/app/eparser/iptv.py
@@ -112,12 +112,12 @@ def parse_m3u(path, s_type, detect_encoding=True, params=None):
srv = Service(None, None, IPTV_ICON, name, *aggr[0:3], st, picon, p_id, *s_aggr, url, fav_id, None)
services.append(srv)
else:
- log("*.m3u* parse error ['{}']: name[{}], url[{}], fav id[{}]".format(path, name, url, fav_id))
+ log(f"*.m3u* parse error ['{path}']: name[{name}], url[{url}], fav id[{fav_id}]")
return services
-def export_to_m3u(path, bouquet, s_type):
+def export_to_m3u(path, bouquet, s_type, url=None):
pattern = re.compile(".*:(http.*):.*") if s_type is SettingsType.ENIGMA_2 else re.compile("(http.*?)::::.*")
lines = ["#EXTM3U\n"]
current_grp = None
@@ -128,15 +128,17 @@ def export_to_m3u(path, bouquet, s_type):
res = re.match(pattern, s.data)
if not res:
continue
- data = res.group(1)
- lines.append("#EXTINF:-1,{}\n".format(s.name))
- if current_grp:
- lines.append(current_grp)
- lines.append("{}\n".format(unquote(data.strip())))
+ lines.append(f"#EXTINF:-1,{s.name}\n")
+ lines.append(current_grp) if current_grp else None
+ lines.append(f"{unquote(res.group(1).strip())}\n")
elif s_type is BqServiceType.MARKER:
- current_grp = "#EXTGRP:{}\n".format(s.name)
+ current_grp = f"#EXTGRP:{s.name}\n"
+ elif s_type is BqServiceType.DEFAULT and url:
+ lines.append(f"#EXTINF:-1,{s.name}\n")
+ lines.append(current_grp) if current_grp else None
+ lines.append(f"{url}{s.data}\n")
- with open(path + "{}.m3u".format(bouquet.name), "w", encoding="utf-8") as file:
+ with open(f"{path}{bouquet.name}.m3u", "w", encoding="utf-8") as file:
file.writelines(lines)
diff --git a/app/ui/app_menu.ui b/app/ui/app_menu.ui
index 3f9d12f8..55cf70aa 100644
--- a/app/ui/app_menu.ui
+++ b/app/ui/app_menu.ui
@@ -380,7 +380,7 @@
-
Export to m3u
- app.on_export_to_m3u
+ app.on_export_iptv_to_m3u
-
diff --git a/app/ui/main.glade b/app/ui/main.glade
index 0162afb3..6974bde7 100644
--- a/app/ui/main.glade
+++ b/app/ui/main.glade
@@ -138,11 +138,63 @@ Author: Dmitriy Yefremov
False
gtk-index
+
+
+
+
+
-
@@ -2455,16 +2517,16 @@ Author: Dmitriy Yefremov
-