diff --git a/app/eparser/enigma/lamedb.py b/app/eparser/enigma/lamedb.py index bcec6e6d..55e2bed4 100644 --- a/app/eparser/enigma/lamedb.py +++ b/app/eparser/enigma/lamedb.py @@ -1,12 +1,11 @@ """ This module used for parsing lamedb file Currently implemented only for satellite channels!!! - Description of format taken from here: http://www.satsupreme.com/showthread.php/194074-Lamedb-format-explained """ from app.commons import log from app.ui.uicommons import CODED_ICON, LOCKED_ICON, HIDE_ICON from .blacklist import get_blacklist -from ..ecommons import Service, POLARIZATION, SYSTEM, FEC, SERVICE_TYPE, Flag +from ..ecommons import Service, POLARIZATION, FEC, SERVICE_TYPE, Flag _HEADER = "eDVB services /4/" _SEP = ":" # separator @@ -42,8 +41,13 @@ def write_services(path, services): file.writelines(lines) -def parse(path): +def parse(path, version=None): """ Parsing lamedb """ + return parse_v4(path) + + +def parse_v4(path): + """ Parsing version 4 """ with open(path + _FILE_NAME, "r", encoding="utf-8", errors="replace") as file: try: data = str(file.read()) @@ -61,6 +65,25 @@ def parse(path): return parse_services(services.split("\n"), transponders.split("/"), path) +def parse_v5(path): + """ Parsing version 5 """ + with open(path + "lamedb5", "r", encoding="utf-8", errors="replace") as file: + lns = file.readlines() + + if lns and not lns[0].endswith("/5/\n"): + raise SyntaxError("lamedb v.5 parsing error: unsupported format.") + + trs, srvs = {}, [""] + for l in lns: + if l.startswith("s:"): + srvs.extend(l.strip("s:").split(",", 2)) + elif l.startswith("t:"): + tr, srv = l.split(",") + trs[tr.strip("t:")] = srv.strip() + + return parse_services(srvs, trs, path) + + def parse_transponders(arg): """ Parsing transponders """ transponders = {} @@ -77,7 +100,6 @@ def parse_services(services, transponders, path): channels = [] transponders = parse_transponders(transponders) blacklist = str(get_blacklist(path)) - srv = split(services, 3) if srv[0][0] == "": # remove first empty element srv.remove(srv[0]) diff --git a/app/properties.py b/app/properties.py index f80bd484..4347ff15 100644 --- a/app/properties.py +++ b/app/properties.py @@ -48,7 +48,8 @@ def get_default_settings(): "satellites_xml_path": "/etc/tuxbox/", "picons_path": "/usr/share/enigma2/picon", "data_dir_path": DATA_PATH + "enigma2/", - "picons_dir_path": DATA_PATH + "enigma2/picons/"}, + "picons_dir_path": DATA_PATH + "enigma2/picons/", + "v5_support": False}, Profile.NEUTRINO_MP.value: { "host": "127.0.0.1", "port": "21", "user": "root", "password": "root", diff --git a/app/ui/dialogs.glade b/app/ui/dialogs.glade index 080a8627..5d0e1ca7 100644 --- a/app/ui/dialogs.glade +++ b/app/ui/dialogs.glade @@ -1425,7 +1425,7 @@ - + True False 2 @@ -1550,7 +1550,7 @@ - + True False 5 @@ -1564,75 +1564,120 @@ - + True False - 5 - vertical + 0 + in + + True + False + 5 + 5 + 5 + 5 + vertical + + + Enigma2 + True + True + False + 0 + True + True + neutrino_radio_button + + + + False + True + 0 + + + + + Ver. 5 support +(experimental) + True + True + False + 0 + True + + + False + True + 1 + + + + + True + False + + + False + True + 2 + 2 + + + + + Neutrino-MP +(experimental) + True + True + False + 0 + True + True + enigma_radio_button + + + True + True + 3 + + + + + True + False + + + False + True + 2 + 4 + + + + + Reset profile + True + True + True + 3 + + + + False + True + end + 5 + + + + + True False Active profile: - 0.20000000298023224 - - False - True - 0 - - - - - Enigma2 - True - True - False - 0 - True - True - neutrino_radio_button - - - - False - True - 1 - - - - - Neutrino-MP -(experimental) - True - True - False - 0 - True - True - enigma_radio_button - - - False - True - 2 - - - - - Reset profile - True - True - True - 0.49000000953674316 - - - - False - True - end - 3 - diff --git a/app/ui/settings_dialog.py b/app/ui/settings_dialog.py index f6139e94..23795df7 100644 --- a/app/ui/settings_dialog.py +++ b/app/ui/settings_dialog.py @@ -8,6 +8,7 @@ def show_settings_dialog(transient, options): class SettingsDialog: + def __init__(self, transient, options): handlers = {"on_data_dir_field_icon_press": self.on_data_dir_field_icon_press, "on_picons_dir_field_icon_press": self.on_picons_dir_field_icon_press, @@ -39,11 +40,14 @@ class SettingsDialog: self._picons_dir_field = builder.get_object("picons_dir_field") self._enigma_radio_button = builder.get_object("enigma_radio_button") self._neutrino_radio_button = builder.get_object("neutrino_radio_button") + self._support_ver5_check_button = builder.get_object("support_ver5_check_button") self._options = options self._active_profile = options.get("profile") self.set_settings() - self._neutrino_radio_button.set_active(Profile(self._active_profile) is Profile.NEUTRINO_MP) + profile = Profile(self._active_profile) + self._neutrino_radio_button.set_active(profile is Profile.NEUTRINO_MP) + self._support_ver5_check_button.set_sensitive(profile is not Profile.NEUTRINO_MP) def show(self): response = self._dialog.run() @@ -61,7 +65,9 @@ class SettingsDialog: update_entry_data(entry, self._dialog, self._options.get(self._options.get("profile"))) def on_profile_changed(self, item): - self.set_profile(Profile.ENIGMA_2 if self._enigma_radio_button.get_active() else Profile.NEUTRINO_MP) + profile = Profile.ENIGMA_2 if self._enigma_radio_button.get_active() else Profile.NEUTRINO_MP + self.set_profile(profile) + self._support_ver5_check_button.set_sensitive(profile is Profile.ENIGMA_2) def set_profile(self, profile): self._active_profile = profile.value @@ -94,11 +100,13 @@ class SettingsDialog: self._picons_field.set_text(options.get("picons_path", "")) self._data_dir_field.set_text(options.get("data_dir_path", "")) self._picons_dir_field.set_text(options.get("picons_dir_path", "")) + if Profile(self._active_profile) is Profile.ENIGMA_2: + self._support_ver5_check_button.set_active(options.get("v5_support", False)) def apply_settings(self, item=None): - profile = Profile.ENIGMA_2.value if self._enigma_radio_button.get_active() else Profile.NEUTRINO_MP.value - self._active_profile = profile - self._options["profile"] = profile + profile = Profile.ENIGMA_2 if self._enigma_radio_button.get_active() else Profile.NEUTRINO_MP + self._active_profile = profile.value + self._options["profile"] = self._active_profile options = self._options.get(self._active_profile) options["host"] = self._host_field.get_text() options["port"] = self._port_field.get_text() @@ -114,6 +122,8 @@ class SettingsDialog: options["picons_path"] = self._picons_field.get_text() options["data_dir_path"] = self._data_dir_field.get_text() options["picons_dir_path"] = self._picons_dir_field.get_text() + if profile is Profile.ENIGMA_2: + options["v5_support"] = self._support_ver5_check_button.get_active() if __name__ == "__main__":