mirror of
https://github.com/DYefremov/DemonEditor.git
synced 2025-12-21 16:09:41 +01:00
added extra tab for IPTV
This commit is contained in:
@@ -40,6 +40,7 @@ from app.ui.uicommons import IPTV_ICON
|
||||
NEUTRINO_FAV_ID_FORMAT = "{}::{}::{}::{}::{}::{}::{}::{}::{}::{}"
|
||||
ENIGMA2_FAV_ID_FORMAT = " {}:{}:{}:{:X}:{:X}:{:X}:{:X}:0:0:0:{}:{}\n#DESCRIPTION: {}\n"
|
||||
MARKER_FORMAT = " 1:64:{}:0:0:0:0:0:0:0::{}\n#DESCRIPTION {}\n"
|
||||
PICON_FORMAT = "{}_{}_{:X}_{:X}_{:X}_{:X}_{:X}_0_0_0.png"
|
||||
|
||||
|
||||
class StreamType(Enum):
|
||||
@@ -115,6 +116,9 @@ def parse_m3u(path, s_type, detect_encoding=True, params=None):
|
||||
params[0] = sid_counter
|
||||
sid_counter += 1
|
||||
fav_id = get_fav_id(url, name, s_type, params)
|
||||
if s_type is SettingsType.ENIGMA_2:
|
||||
p_id = get_picon_id(params)
|
||||
|
||||
if all((name, url, fav_id)):
|
||||
srv = Service(None, None, IPTV_ICON, name, *aggr[0:3], st, picon, p_id, *s_aggr, url, fav_id, None)
|
||||
services.append(srv)
|
||||
@@ -159,5 +163,11 @@ def get_fav_id(url, name, settings_type, params=None, st_type=None, s_id=0, srv_
|
||||
return NEUTRINO_FAV_ID_FORMAT.format(url, "", 0, None, None, None, None, "", "", 1)
|
||||
|
||||
|
||||
def get_picon_id(params=None, st_type=None, s_id=0, srv_type=1):
|
||||
st_type = st_type or StreamType.NONE_TS.value
|
||||
params = params or (0, 0, 0, 0)
|
||||
return PICON_FORMAT.format(st_type, s_id, srv_type, *params)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
pass
|
||||
|
||||
@@ -617,10 +617,10 @@ class TimerTool(Gtk.Box):
|
||||
return
|
||||
|
||||
fav_id = None
|
||||
if source == self._app.FAV_MODEL_NAME:
|
||||
if source == self._app.FAV_MODEL:
|
||||
model = self._app.fav_view.get_model()
|
||||
fav_id = model.get_value(model.get_iter_from_string(itrs[0]), Column.FAV_ID)
|
||||
elif source == self._app.SERVICE_MODEL_NAME:
|
||||
elif source == self._app.SERVICE_MODEL:
|
||||
model = self._app.services_view.get_model()
|
||||
fav_id = model.get_value(model.get_iter_from_string(itrs[0]), Column.SRV_FAV_ID)
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#
|
||||
# The MIT License (MIT)
|
||||
#
|
||||
# Copyright (c) 2018-2021 Dmitriy Yefremov
|
||||
# Copyright (c) 2018-2022 Dmitriy Yefremov
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -44,7 +44,7 @@ from app.eparser.iptv import (NEUTRINO_FAV_ID_FORMAT, StreamType, ENIGMA2_FAV_ID
|
||||
from app.settings import SettingsType
|
||||
from app.tools.yt import YouTubeException, YouTube
|
||||
from app.ui.dialogs import Action, show_dialog, DialogType, get_message, get_builder
|
||||
from app.ui.main_helper import get_base_model, get_iptv_url, on_popup_menu, get_picon_pixbuf
|
||||
from app.ui.main_helper import get_iptv_url, on_popup_menu, get_picon_pixbuf
|
||||
from app.ui.uicommons import (Gtk, Gdk, UI_RESOURCES_PATH, IPTV_ICON, Column, KeyboardKey, get_yt_icon)
|
||||
|
||||
_DIGIT_ENTRY_NAME = "digit-entry"
|
||||
@@ -77,7 +77,7 @@ def get_stream_type(box):
|
||||
|
||||
class IptvDialog:
|
||||
|
||||
def __init__(self, transient, view, services, bouquet, settings, action=Action.ADD):
|
||||
def __init__(self, app, view, bouquet=None, service=None, action=Action.ADD):
|
||||
handlers = {"on_response": self.on_response,
|
||||
"on_entry_changed": self.on_entry_changed,
|
||||
"on_url_changed": self.on_url_changed,
|
||||
@@ -86,11 +86,11 @@ class IptvDialog:
|
||||
"on_yt_quality_changed": self.on_yt_quality_changed,
|
||||
"on_info_bar_close": self.on_info_bar_close}
|
||||
|
||||
self._app = app
|
||||
self._action = action
|
||||
self._s_type = settings.setting_type
|
||||
self._settings = settings
|
||||
self._settings = app.app_settings
|
||||
self._s_type = self._settings.setting_type
|
||||
self._bouquet = bouquet
|
||||
self._services = services
|
||||
self._yt_links = None
|
||||
self._yt_dl = None
|
||||
|
||||
@@ -98,7 +98,7 @@ class IptvDialog:
|
||||
objects=("iptv_dialog", "stream_type_liststore", "yt_quality_liststore"))
|
||||
|
||||
self._dialog = builder.get_object("iptv_dialog")
|
||||
self._dialog.set_transient_for(transient)
|
||||
self._dialog.set_transient_for(app.app_window)
|
||||
self._name_entry = builder.get_object("name_entry")
|
||||
self._description_entry = builder.get_object("description_entry")
|
||||
self._url_entry = builder.get_object("url_entry")
|
||||
@@ -142,7 +142,7 @@ class IptvDialog:
|
||||
self.update_reference_entry()
|
||||
self._stream_type_combobox.set_active(1)
|
||||
elif self._action is Action.EDIT:
|
||||
self._current_srv = get_base_model(self._model)[self._paths][:]
|
||||
self._current_srv = service
|
||||
self.init_data(self._current_srv)
|
||||
|
||||
def show(self):
|
||||
@@ -167,8 +167,8 @@ class IptvDialog:
|
||||
self._dialog.destroy()
|
||||
|
||||
def init_data(self, srv):
|
||||
name, fav_id = srv[2], srv[7]
|
||||
self._name_entry.set_text(name)
|
||||
fav_id = srv.fav_id
|
||||
self._name_entry.set_text(srv.service)
|
||||
self.init_enigma2_data(fav_id) if self._s_type is SettingsType.ENIGMA_2 else self.init_neutrino_data(fav_id)
|
||||
|
||||
def init_enigma2_data(self, fav_id):
|
||||
@@ -307,11 +307,12 @@ class IptvDialog:
|
||||
int(self._namespace_entry.get_text()),
|
||||
quote(self._url_entry.get_text()),
|
||||
name, name)
|
||||
|
||||
self.update_bouquet_data(name, fav_id)
|
||||
|
||||
def save_neutrino_data(self):
|
||||
if self._action is Action.EDIT:
|
||||
id_data = self._current_srv[7].split("::")
|
||||
id_data = self._current_srv.fav_id.split("::")
|
||||
else:
|
||||
id_data = ["", "", "0", None, None, None, None, "", "", "1"]
|
||||
id_data[0] = self._url_entry.get_text()
|
||||
@@ -320,20 +321,25 @@ class IptvDialog:
|
||||
self._dialog.destroy()
|
||||
|
||||
def update_bouquet_data(self, name, fav_id):
|
||||
picon_id = f"{self._reference_entry.get_text().replace(':', '_')}.png"
|
||||
|
||||
if self._action is Action.EDIT:
|
||||
old_srv = self._services.pop(self._current_srv[7])
|
||||
self._services[fav_id] = old_srv._replace(service=name, fav_id=fav_id)
|
||||
self._bouquet[self._paths[0][0]] = fav_id
|
||||
self._model.set(self._model.get_iter(self._paths), {Column.FAV_SERVICE: name, Column.FAV_ID: fav_id})
|
||||
services = self._app.current_services
|
||||
old_srv = services.pop(self._current_srv.fav_id)
|
||||
new_service = old_srv._replace(service=name, fav_id=fav_id, picon_id=picon_id)
|
||||
services[fav_id] = new_service
|
||||
self._app.emit("iptv-service-edited", (old_srv, new_service))
|
||||
else:
|
||||
aggr = [None] * 10
|
||||
aggr = [None] * 8
|
||||
s_type = BqServiceType.IPTV.name
|
||||
srv = (None, None, name, None, None, s_type, None, fav_id, *aggr[0:3])
|
||||
itr = self._model.insert_after(self._model.get_iter(self._paths[0]),
|
||||
srv) if self._paths else self._model.insert(0, srv)
|
||||
self._model.set_value(itr, 1, IPTV_ICON)
|
||||
self._bouquet.insert(self._model.get_path(itr)[0], fav_id)
|
||||
self._services[fav_id] = Service(None, None, IPTV_ICON, name, *aggr[0:3], s_type, *aggr, fav_id, None)
|
||||
service = Service(None, None, IPTV_ICON, name, *aggr[0:3], s_type, None, picon_id, *aggr, fav_id, None)
|
||||
self._app.current_services[fav_id] = service
|
||||
self._app.emit("iptv-service-added", (service,))
|
||||
|
||||
@run_idle
|
||||
def on_info_bar_close(self, bar=None, resp=None):
|
||||
@@ -833,7 +839,7 @@ class M3uImportDialog(IptvListDialog):
|
||||
|
||||
|
||||
class YtListImportDialog:
|
||||
def __init__(self, transient, settings, appender):
|
||||
def __init__(self, app):
|
||||
handlers = {"on_import": self.on_import,
|
||||
"on_receive": self.on_receive,
|
||||
"on_yt_url_entry_changed": self.on_url_entry_changed,
|
||||
@@ -845,12 +851,13 @@ class YtListImportDialog:
|
||||
"on_key_press": self.on_key_press,
|
||||
"on_close": self.on_close}
|
||||
|
||||
self.appender = appender
|
||||
self._s_type = settings.setting_type
|
||||
# self._main_window, self._settings, self.append_imported_services
|
||||
self.appender = app.append_imported_services
|
||||
self._settings = app.app_settings
|
||||
self._s_type = self._settings.setting_type
|
||||
self._download_task = False
|
||||
self._yt_list_id = None
|
||||
self._yt_list_title = None
|
||||
self._settings = settings
|
||||
self._yt = None
|
||||
|
||||
builder = get_builder(_UI_PATH, handlers, use_str=True,
|
||||
@@ -859,7 +866,7 @@ class YtListImportDialog:
|
||||
"yt_import_image"))
|
||||
|
||||
self._dialog = builder.get_object("yt_import_dialog_window")
|
||||
self._dialog.set_transient_for(transient)
|
||||
self._dialog.set_transient_for(app.app_window)
|
||||
self._list_view_scrolled_window = builder.get_object("yt_list_view_scrolled_window")
|
||||
self._model = builder.get_object("yt_liststore")
|
||||
self._progress_bar = builder.get_object("yt_progress_bar")
|
||||
|
||||
2018
app/ui/main.glade
2018
app/ui/main.glade
File diff suppressed because it is too large
Load Diff
554
app/ui/main.py
554
app/ui/main.py
File diff suppressed because it is too large
Load Diff
@@ -360,7 +360,7 @@ def has_locked_hide(model, paths, col_num):
|
||||
|
||||
# ***************** Location *******************#
|
||||
|
||||
def locate_in_services(fav_view, services_view, parent_window):
|
||||
def locate_in_services(fav_view, services_view, column, parent_window):
|
||||
""" Locating and scrolling to the service """
|
||||
model, paths = fav_view.get_selection().get_selected_rows()
|
||||
|
||||
@@ -372,7 +372,7 @@ def locate_in_services(fav_view, services_view, parent_window):
|
||||
|
||||
fav_id = model.get_value(model.get_iter(paths[0]), Column.FAV_ID)
|
||||
for index, row in enumerate(services_view.get_model()):
|
||||
if row[Column.SRV_FAV_ID] == fav_id:
|
||||
if row[column] == fav_id:
|
||||
scroll_to(index, services_view)
|
||||
break
|
||||
|
||||
|
||||
@@ -377,7 +377,7 @@ class PiconManager(Gtk.Box):
|
||||
return
|
||||
|
||||
itr_str, sep, src = txt.partition(self._app.DRAG_SEP)
|
||||
if src == self._app.BQ_MODEL_NAME:
|
||||
if src == self._app.BQ_MODEL:
|
||||
return
|
||||
|
||||
path, pos = view.get_dest_row_at_pos(x, y) or (None, None)
|
||||
@@ -385,7 +385,7 @@ class PiconManager(Gtk.Box):
|
||||
return
|
||||
|
||||
model = view.get_model()
|
||||
if src == self._app.FAV_MODEL_NAME:
|
||||
if src == self._app.FAV_MODEL:
|
||||
target_view = self._app.fav_view
|
||||
c_id = Column.FAV_ID
|
||||
else:
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#
|
||||
# The MIT License (MIT)
|
||||
#
|
||||
# Copyright (c) 2018-2021 Dmitriy Yefremov
|
||||
# Copyright (c) 2018-2022 Dmitriy Yefremov
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -62,7 +62,7 @@ class ServiceDetailsDialog:
|
||||
|
||||
_DIGIT_ENTRY_NAME = "digit-entry"
|
||||
|
||||
def __init__(self, transient, settings, srv_view, fav_view, services, bouquets, new_color, action=Action.EDIT):
|
||||
def __init__(self, app, new_color, action=Action.EDIT):
|
||||
handlers = {"on_system_changed": self.on_system_changed,
|
||||
"on_save": self.on_save,
|
||||
"on_create_new": self.on_create_new,
|
||||
@@ -76,19 +76,19 @@ class ServiceDetailsDialog:
|
||||
|
||||
builder = get_builder(_UI_PATH, handlers, use_str=True)
|
||||
self._builder = builder
|
||||
settings = app.app_settings
|
||||
|
||||
self._dialog = builder.get_object("service_details_dialog")
|
||||
self._dialog.set_transient_for(transient)
|
||||
self._dialog.set_transient_for(app.app_window)
|
||||
self._s_type = settings.setting_type
|
||||
self._tr_type = TrType.Satellite
|
||||
self._satellites_xml_path = settings.profile_data_path + "satellites.xml"
|
||||
self._picons_path = settings.profile_picons_path
|
||||
self._services_view = srv_view
|
||||
self._fav_view = fav_view
|
||||
self._services_view = app.services_view
|
||||
self._fav_view = app.fav_view
|
||||
self._action = action
|
||||
self._old_service = None
|
||||
self._services = services
|
||||
self._bouquets = bouquets
|
||||
self._services = app.current_services
|
||||
self._bouquets = app.current_bouquets
|
||||
self._new_color = new_color
|
||||
self._transponder_services_iters = None
|
||||
self._current_model = None
|
||||
|
||||
@@ -189,6 +189,7 @@ class ViewTarget(Enum):
|
||||
BOUQUET = 0
|
||||
FAV = 1
|
||||
SERVICES = 2
|
||||
IPTV = 3
|
||||
|
||||
|
||||
class BqGenType(Enum):
|
||||
@@ -259,6 +260,13 @@ class Column(IntEnum):
|
||||
REC_LEN = 3
|
||||
REC_FILE = 4
|
||||
REC_DESC = 5
|
||||
# IPTV view
|
||||
IPTV_SERVICE = 0
|
||||
IPTV_TYPE = 1
|
||||
IPTV_PICON = 2
|
||||
IPTV_REF = 3
|
||||
IPTV_FAV_ID = 4
|
||||
IPTV_PICON_ID = 5
|
||||
|
||||
def __index__(self):
|
||||
""" Overridden to get the index in slices directly """
|
||||
|
||||
Reference in New Issue
Block a user