diff --git a/app/picons/picons.py b/app/picons/picons.py
index 250370ea..165a3cd4 100644
--- a/app/picons/picons.py
+++ b/app/picons/picons.py
@@ -3,13 +3,11 @@ import shutil
from collections import namedtuple
from html.parser import HTMLParser
-from app.commons import log
+from app.commons import log, run_task
from app.properties import Profile
-
-_ENIGMA2_PICON_NAME = "1_0_{}_{:X}_{:X}_{:X}_{:X}0000_0_0_0.png"
-_NEUTRINO_PICON_NAME = "{:x}{:04x}{:04x}.png"
-
+_ENIGMA2_PICON_KEY = "{:X}:{:X}:{:X}0000"
+_NEUTRINO_PICON_KEY = "{:x}{:04x}{:04x}.png"
Provider = namedtuple("Provider", ["logo", "name", "pos", "url", "on_id", "selected"])
Picon = namedtuple("Picon", ["ref", "ssid", "v_pid"])
@@ -73,7 +71,7 @@ class PiconsParser(HTMLParser):
pass
@staticmethod
- def parse(open_path, picons_path, tmp_path, on_id, pos, profile=Profile.ENIGMA_2):
+ def parse(open_path, picons_path, tmp_path, on_id, pos, picon_ids, profile=Profile.ENIGMA_2):
with open(open_path, encoding="utf-8", errors="replace") as f:
parser = PiconsParser()
parser.reset()
@@ -83,19 +81,20 @@ class PiconsParser(HTMLParser):
os.makedirs(picons_path, exist_ok=True)
for p in picons:
try:
- picon_file_name = picons_path + PiconsParser.format(p.ssid, on_id, p.v_pid, pos, profile)
- shutil.copyfile(tmp_path + "www.lyngsat.com/" + p.ref.lstrip("."), picon_file_name)
+ name = PiconsParser.format(p.ssid, on_id, p.v_pid, pos, picon_ids, profile)
+ p_name = picons_path + (name if name else os.path.basename(p.ref))
+ shutil.copyfile(tmp_path + "www.lyngsat.com/" + p.ref.lstrip("."), p_name)
except (TypeError, ValueError) as e:
- log("Picons format parse error: {} {} {}".format(p.ref, p.ssid, p.v_pid) + "\n" + str(e))
+ log("Picons format parse error: {}".format(p) + "\n" + str(e))
print(e)
@staticmethod
- def format(ssid, on_id, v_pid, pos, profile: Profile):
+ def format(ssid, on_id, v_pid, pos, picon_ids, profile: Profile):
tr_id = int(ssid[:-2] if len(ssid) < 4 else ssid[:2])
if profile is Profile.ENIGMA_2:
- return _ENIGMA2_PICON_NAME.format(1 if v_pid else 2, int(ssid), tr_id, int(on_id), int(pos))
+ return picon_ids.get(_ENIGMA2_PICON_KEY.format(int(ssid), int(on_id), int(pos)), None)
elif profile is Profile.NEUTRINO_MP:
- return _NEUTRINO_PICON_NAME.format(tr_id, int(on_id), int(ssid))
+ return _NEUTRINO_PICON_KEY.format(tr_id, int(on_id), int(ssid))
else:
return "{}.png".format(ssid)
@@ -168,15 +167,16 @@ class ProviderParser(HTMLParser):
def error(self, message):
pass
- def reset_counter(self):
+ def reset(self):
+ super().reset()
self._counter = 0
def parse_providers(open_path):
+ parser = ProviderParser()
+ parser.reset()
+
with open(open_path, encoding="utf-8", errors="replace") as f:
- parser = ProviderParser()
- parser.reset()
- parser.reset_counter()
parser.feed(f.read())
rows = parser.rows
diff --git a/app/ui/main_app_window.py b/app/ui/main_app_window.py
index c40e550c..22f70e72 100644
--- a/app/ui/main_app_window.py
+++ b/app/ui/main_app_window.py
@@ -132,6 +132,7 @@ class MainAppWindow:
self.__profile_label.set_text("Enigma2 v.4" if Profile(self.__profile) is Profile.ENIGMA_2 else "Neutrino-MP")
# dynamically active elements depending on the selected view
self.__tool_elements = {k: builder.get_object(k) for k in self.__DYNAMIC_ELEMENTS}
+ self.__picons_download_tool_button = builder.get_object("picons_download_tool_button")
self.__cas_label = builder.get_object("cas_label")
self.__fav_count_label = builder.get_object("fav_count_label")
self.__bouquets_count_label = builder.get_object("bouquets_count_label")
@@ -499,6 +500,7 @@ class MainAppWindow:
self.append_services(data_path)
self.update_services_counts(len(self.__services_model))
self.update_picons()
+ self.__picons_download_tool_button.set_sensitive(len(self.__services_model))
except FileNotFoundError as e:
show_dialog(DialogType.ERROR, self.__main_window, getattr(e, "message", str(e)) +
"\n\nPlease, download files from receiver or setup your path for read data!")
@@ -664,6 +666,7 @@ class MainAppWindow:
self.__profile = profile
self.clear_current_data()
self.update_services_counts()
+ self.__picons_download_tool_button.set_sensitive(len(self.__services_model))
def on_tree_view_key_release(self, view, event):
""" Handling keystrokes """
@@ -836,8 +839,15 @@ class MainAppWindow:
def on_locate_in_services(self, view):
locate_in_services(view, self.__services_view, self.__main_window)
+ @run_idle
def on_picons_loader_show(self, item):
- dialog = PiconsDialog(self.__main_window, self.__options.get(self.__profile), Profile(self.__profile))
+ ids = {}
+ if Profile(self.__profile) is Profile.ENIGMA_2:
+ for r in self.__services_model:
+ data = r[9].split("_")
+ ids["{}:{}:{}".format(data[3], data[5], data[6])] = r[9]
+
+ dialog = PiconsDialog(self.__main_window, self.__options.get(self.__profile), ids, Profile(self.__profile))
dialog.show()
self.update_picons()
diff --git a/app/ui/main_window.glade b/app/ui/main_window.glade
index ed29a9f0..74c50561 100644
--- a/app/ui/main_window.glade
+++ b/app/ui/main_window.glade
@@ -446,7 +446,7 @@
@@ -1090,6 +1090,7 @@