From e9850c4244bcf29caa4515d6fc8bc8c24ceeb6a8 Mon Sep 17 00:00:00 2001 From: DYefremov Date: Wed, 20 Dec 2017 10:54:45 +0300 Subject: [PATCH] marker edit impl --- app/eparser/bouquets.py | 10 +++++----- app/ui/main_app_window.py | 25 +++++++++++++++++++------ 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/app/eparser/bouquets.py b/app/eparser/bouquets.py index 75642431..f3cdb29a 100644 --- a/app/eparser/bouquets.py +++ b/app/eparser/bouquets.py @@ -15,7 +15,7 @@ class BqServiceType(Enum): Bouquet = namedtuple("Bouquet", ["name", "type", "services"]) Bouquets = namedtuple("Bouquets", ["name", "type", "bouquets"]) -BouquetService = namedtuple("BouquetService", ["name", "type", "data"]) +BouquetService = namedtuple("BouquetService", ["name", "type", "data", "num"]) def get_bouquets(path): @@ -46,7 +46,7 @@ def write_bouquet(path, name, bq_type, channels): continue if ch.service_type == BqServiceType.IPTV.name or ch.service_type == BqServiceType.MARKER.name: - bouquet.append("#SERVICE {}".format(ch.fav_id)) + bouquet.append("#SERVICE {}\n".format(ch.fav_id.strip())) else: bouquet.append("#SERVICE {}\n".format(to_bouquet_id(ch))) @@ -76,12 +76,12 @@ def get_bouquet(path, name, bq_type): for ch in list(filter(lambda x: len(x) > 1, chs_list.split("#SERVICE")[1:])): # filtering [''] ch_data = ch.strip().split(":") if ch_data[1] == "64": - services.append(BouquetService(ch_data[-1].split("\n")[0], BqServiceType.MARKER, ch)) + services.append(BouquetService(ch_data[-1].split("\n")[0], BqServiceType.MARKER, ch, ch_data[2])) elif "http" in ch: - services.append(BouquetService(ch_data[-1].split("\n")[0], BqServiceType.IPTV, ch)) + services.append(BouquetService(ch_data[-1].split("\n")[0], BqServiceType.IPTV, ch, 0)) else: services.append(BouquetService(None, BqServiceType.DEFAULT, - "{}:{}:{}:{}".format(ch_data[3], ch_data[4], ch_data[5], ch_data[6]))) + "{}:{}:{}:{}".format(ch_data[3], ch_data[4], ch_data[5], ch_data[6]), 0)) return services diff --git a/app/ui/main_app_window.py b/app/ui/main_app_window.py index bf078794..c827db75 100644 --- a/app/ui/main_app_window.py +++ b/app/ui/main_app_window.py @@ -460,16 +460,18 @@ class MainAppWindow: name, bt_type = bt.name, bt.type self.__bouquets_model.append(parent, [name, bt_type]) services = [] - agr = [None] * 8 + agr = [None] * 7 for srv in bt.services: - f_id = srv.data + fav_id = srv.data # IPTV and MARKER services s_type = srv.type if s_type is BqServiceType.MARKER: - self.__channels[f_id] = Channel(*agr[0:3], srv.name, *agr[0:3], s_type.name, *agr, f_id, None) + self.__channels[fav_id] = Channel(*agr[0:3], srv.name, *agr[0:3], + s_type.name, *agr, srv.num, fav_id, None) elif s_type is BqServiceType.IPTV: - self.__channels[f_id] = Channel(*agr[0:3], srv.name, *agr[0:3], srv.type.name, *agr, f_id, None) - services.append(f_id) + self.__channels[fav_id] = Channel(*agr[0:3], srv.name, *agr[0:3], + srv.type.name, *agr, srv.num, fav_id, None) + services.append(fav_id) self.__bouquets["{}:{}".format(name, bt_type)] = services def append_services(self, data_path): @@ -766,10 +768,21 @@ class MainAppWindow: def on_edit_marker(self, view): model, paths = view.get_selection().get_selected_rows() - response = show_dialog(DialogType.INPUT, self.__main_window, text=model.get_value(model.get_iter(paths[0]), 2)) + itr = model.get_iter(paths[0]) + name, fav_id = model.get(itr, 2, 7) + response = show_dialog(DialogType.INPUT, self.__main_window, text=name) if response == Gtk.ResponseType.CANCEL: return + bq_services = self.__bouquets[self.is_bouquet_selected()] + index = bq_services.index(fav_id) + old_ch = self.__channels.pop(fav_id, None) + new_fav_id = "{}::{}\n#DESCRIPTION {}\n".format(fav_id.split("::")[0], response, response) + model.set(itr, {2: response, 7: new_fav_id}) + self.__channels[new_fav_id] = Channel(*old_ch[0:3], response, *old_ch[4:15], old_ch.data_id, new_fav_id, None) + bq_services.pop(index) + bq_services.insert(index, new_fav_id) + @run_idle def on_fav_popup(self, view, event): model, paths = view.get_selection().get_selected_rows()