diff --git a/app/eparser/lamedb.py b/app/eparser/lamedb.py
index 1c0587bc..f37da14f 100644
--- a/app/eparser/lamedb.py
+++ b/app/eparser/lamedb.py
@@ -7,13 +7,16 @@ from collections import namedtuple
from app.commons import log
from app.eparser.__constants import POLARIZATION, SYSTEM, FEC, SERVICE_TYPE
+from app.ui import CODED_ICON, LOCKED_ICON, HIDE_ICON
+from .blacklist import get_blacklist
_HEADER = "eDVB services /4/"
_FILE_PATH = "../data/lamedb"
_SEP = ":" # separator
+_FILE_NAME = "lamedb"
-Channel = namedtuple("Channel", ["flags_cas", "transponder_type", "service", "package", "service_type",
- "ssid", "freq", "rate", "pol", "fec",
+Channel = namedtuple("Channel", ["flags_cas", "transponder_type", "coded", "service", "locked", "hide",
+ "package", "service_type", "ssid", "freq", "rate", "pol", "fec",
"system", "pos", "data_id", "fav_id", "transponder"])
@@ -42,13 +45,13 @@ def write_channels(path, channels):
lines.extend(services_lines)
lines.append("end\nFile was created in DemonEditor.\n....Enjoy watching!....\n")
- with open(path + "lamedb", "w") as file:
+ with open(path + _FILE_NAME, "w") as file:
file.writelines(lines)
def parse(path):
""" Parsing lamedb """
- with open(path, "r") as file:
+ with open(path + _FILE_NAME, "r") as file:
try:
data = str(file.read())
except UnicodeDecodeError as e:
@@ -58,7 +61,7 @@ def parse(path):
transponders, sep, services = services.partition("services") # 2 step
services, sep, _ = services.partition("end") # 3 step
- return parse_channels(services.split("\n"), transponders.split("/"))
+ return parse_channels(services.split("\n"), transponders.split("/"), path)
def parse_transponders(arg):
@@ -72,12 +75,13 @@ def parse_transponders(arg):
return transponders
-def parse_channels(*args):
+def parse_channels(services, transponders, path):
""" Parsing channels """
channels = []
- transponders = parse_transponders(args[1])
+ transponders = parse_transponders(transponders)
+ blacklist = get_blacklist(path)
- srv = split(args[0], 3)
+ srv = split(services, 3)
if srv[0][0] == "": # remove first empty element
srv.remove(srv[0])
@@ -86,8 +90,14 @@ def parse_channels(*args):
sp = "0"
# For comparison in bouquets. Needed in upper case!!!
fav_id = "{}:{}:{}:{}".format(str(data[0]).lstrip(sp), str(data[2]).lstrip(sp),
- str(data[3]).lstrip(sp), str(data[1]).lstrip(sp))
- package = list(filter(lambda x: x.startswith("p:"), ch[2].split(",")))
+ str(data[3]).lstrip(sp), str(data[1]).lstrip(sp)).upper()
+ all_flags = ch[2].split(",")
+ coded = CODED_ICON if list(filter(lambda x: x.startswith("C:"), all_flags)) else None
+ flags = list(filter(lambda x: x.startswith("f:"), all_flags))
+ hide = HIDE_ICON if flags and int(flags[0][2:]) == 2 else None
+ locked = LOCKED_ICON if blacklist and fav_id in blacklist else None
+
+ package = list(filter(lambda x: x.startswith("p:"), all_flags))
package = package[0][2:] if package else None
transponder_id = "{}:{}:{}".format(data[1], data[2], data[3])
@@ -99,7 +109,10 @@ def parse_channels(*args):
service_type = SERVICE_TYPE.get(data[4], SERVICE_TYPE["-2"])
channels.append(Channel(flags_cas=ch[2],
transponder_type=tr_type,
+ coded=coded,
service=ch[1],
+ locked=locked,
+ hide=hide,
package=package,
service_type=service_type,
ssid=data[0],
@@ -110,7 +123,7 @@ def parse_channels(*args):
system=SYSTEM[tr[6]],
pos="{}{}.{}".format(*list(tr[4])),
data_id=ch[0],
- fav_id=fav_id.upper(),
+ fav_id=fav_id,
transponder=transponder))
return channels
diff --git a/app/ui/__init__.py b/app/ui/__init__.py
index 95d04306..1092480d 100644
--- a/app/ui/__init__.py
+++ b/app/ui/__init__.py
@@ -3,5 +3,10 @@ import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, Gdk
+CODED_ICON = Gtk.IconTheme.get_default().load_icon("emblem-readonly", 16, 0)
+LOCKED_ICON = Gtk.IconTheme.get_default().load_icon("system-lock-screen", 16, 0)
+HIDE_ICON = Gtk.IconTheme.get_default().load_icon("go-jump", 16, 0)
+TV_ICON = Gtk.IconTheme.get_default().load_icon("tv-symbolic", 16, 0)
+
if __name__ == "__main__":
pass
diff --git a/app/ui/main_app_window.py b/app/ui/main_app_window.py
index 405d0cb8..0bbecd7d 100644
--- a/app/ui/main_app_window.py
+++ b/app/ui/main_app_window.py
@@ -2,8 +2,8 @@ import os
from contextlib import suppress
from app.commons import run_idle
-from app.eparser import get_channels, get_bouquets, write_bouquets, write_channels, Bouquets, Bouquet, Channel, \
- get_blacklist
+from app.eparser import get_blacklist, write_blacklist
+from app.eparser import get_channels, get_bouquets, write_bouquets, write_channels, Bouquets, Bouquet, Channel
from app.eparser.__constants import CAS, FLAG
from app.properties import get_config, write_config
from . import Gtk, Gdk
@@ -442,7 +442,7 @@ class MainAppWindow:
self.__bouquets["{}:{}".format(name, bt_type)] = bt.services
def append_services(self, data_path):
- channels = get_channels(data_path + "lamedb")
+ channels = get_channels(data_path)
if channels:
for ch in channels:
# adding channels to dict with fav_id as keys
@@ -483,6 +483,8 @@ class MainAppWindow:
# Getting services
services = [Channel(*row[:]) for row in services_model]
write_channels(path, services)
+ # blacklist
+ write_blacklist(path, self.__blacklist)
def on_services_selection(self, model, path, column):
self.delete_selection(self.__fav_view)
@@ -631,7 +633,8 @@ class MainAppWindow:
if flag is FLAG.HIDE:
pass
elif flag is FLAG.LOCK:
- pass
+ if self.__lock_check_button.get_active():
+ pass
def start_app():
diff --git a/app/ui/main_window.glade b/app/ui/main_window.glade
index 4af80b73..3cf7aeba 100644
--- a/app/ui/main_window.glade
+++ b/app/ui/main_window.glade
@@ -104,7 +104,7 @@
-
@@ -809,13 +845,13 @@
Freq
True
True
- 6
+ 9
0.50999999046325684
- 6
+ 9
@@ -826,13 +862,13 @@
Rate
True
True
- 7
+ 10
0.50999999046325684
- 7
+ 10
@@ -843,13 +879,13 @@
Pol
True
True
- 8
+ 11
0.50999999046325684
- 8
+ 11
@@ -860,13 +896,13 @@
FEC
True
True
- 9
+ 12
0.50999999046325684
- 9
+ 12
@@ -877,13 +913,13 @@
System
True
True
- 10
+ 13
0.50999999046325684
- 10
+ 13
@@ -893,13 +929,13 @@
True
Pos
True
- 11
+ 14
0.50999999046325684
- 11
+ 14
@@ -911,7 +947,7 @@
- 12
+ 15
@@ -923,7 +959,7 @@
- 13
+ 16
@@ -933,9 +969,9 @@
False
transponder
-
+
- 14
+ 17