mirror of
https://github.com/DYefremov/DemonEditor.git
synced 2026-07-05 09:29:21 +02:00
streamrelay support improvement
This commit is contained in:
@@ -48,7 +48,7 @@ class StreamRelay(dict):
|
||||
log("Updating stream relay cache...")
|
||||
with suppress(FileNotFoundError):
|
||||
with open(f"{path}{_FILE_NAME}", "r", encoding="utf-8") as file:
|
||||
refs = filter(None, (x.rstrip(":\n") for x in file.readlines()))
|
||||
refs = filter(None, (x.rstrip("\n") for x in file.readlines()))
|
||||
self.update(self.get_ref_data(ref) for ref in refs)
|
||||
|
||||
def get_ref_data(self, ref):
|
||||
@@ -56,6 +56,8 @@ class StreamRelay(dict):
|
||||
data = ref.split(":")
|
||||
if len(data) == 10:
|
||||
return f"{data[3]}:{data[4]}:{data[5]}:{data[6]}", ref
|
||||
elif len(data) > 10:
|
||||
return ref.replace("%3a", "%3A"), ref
|
||||
return ref, None
|
||||
|
||||
def save(self, path):
|
||||
@@ -66,7 +68,7 @@ class StreamRelay(dict):
|
||||
f_name = f"{path}{_FILE_NAME}"
|
||||
if len(self):
|
||||
with open(f_name, "w", encoding="utf-8") as file:
|
||||
file.writelines([f"{v if v else k}{':' if v else ''}\n\n" for k, v in self.items()])
|
||||
file.writelines([f"{v if v else k}\n\n" for k, v in self.items()])
|
||||
else:
|
||||
if os.path.exists(f_name):
|
||||
os.remove(f_name)
|
||||
|
||||
@@ -2443,12 +2443,13 @@ class Application(Gtk.Application):
|
||||
locked = None
|
||||
|
||||
if s_type is BqServiceType.IPTV:
|
||||
icon = IPTV_ICON
|
||||
fav_id_data = fav_id.lstrip().split(":")
|
||||
if len(fav_id_data) > 10:
|
||||
data_id = ":".join(fav_id_data[:11])
|
||||
picon_id = "{}_{}_{}_{}_{}_{}_{}_{}_{}_{}.png".format(*fav_id_data[:10])
|
||||
icon = LINK_ICON if data_id in self._stream_relay else IPTV_ICON
|
||||
locked = LOCKED_ICON if data_id in self._blacklist else None
|
||||
|
||||
srv = Service(None, None, icon, srv.name, locked, None, None, s_type.name,
|
||||
self._picons.get(picon_id, None), picon_id, *agr, data_id, fav_id, None)
|
||||
self._services[fav_id] = srv
|
||||
@@ -4476,23 +4477,31 @@ class Application(Gtk.Application):
|
||||
if not paths:
|
||||
return
|
||||
|
||||
s_types = {BqServiceType.MARKER.name, BqServiceType.SPACE.name}
|
||||
skip_types = {BqServiceType.MARKER, BqServiceType.SPACE}
|
||||
count = 0
|
||||
for p in paths:
|
||||
if model[p][Column.FAV_TYPE] in s_types:
|
||||
s_type = BqServiceType(model[p][Column.FAV_TYPE])
|
||||
if s_type in skip_types:
|
||||
continue
|
||||
|
||||
srv = self._services.get(model[p][Column.FAV_ID], None)
|
||||
if not srv:
|
||||
continue
|
||||
|
||||
srv_id = srv.data_id if s_type is BqServiceType.IPTV else srv.fav_id
|
||||
|
||||
if remove:
|
||||
if self._stream_relay.pop(srv.fav_id, None):
|
||||
if self._stream_relay.pop(srv_id, None):
|
||||
model[p][Column.FAV_CODED] = srv.coded
|
||||
count += 1
|
||||
else:
|
||||
model[p][Column.FAV_CODED] = LINK_ICON
|
||||
ref = f"{self.get_service_ref_data(srv)}:"
|
||||
self._stream_relay[srv.fav_id] = ref
|
||||
if s_type is BqServiceType.IPTV:
|
||||
ref = f"{srv_id.replace('%3A', '%3a')}:"
|
||||
else:
|
||||
ref = f"{self.get_service_ref_data(srv)}:"
|
||||
|
||||
self._stream_relay[srv_id] = ref
|
||||
count += 1
|
||||
yield True
|
||||
|
||||
|
||||
Reference in New Issue
Block a user