mirror of
https://github.com/DYefremov/DemonEditor.git
synced 2025-12-22 00:19:40 +01:00
basic implementation of bouquets generation
This commit is contained in:
@@ -27,13 +27,21 @@ Transponder = namedtuple("Transponder", ["frequency", "symbol_rate", "polarizati
|
|||||||
"system", "modulation", "pls_mode", "pls_code", "is_id"])
|
"system", "modulation", "pls_mode", "pls_code", "is_id"])
|
||||||
|
|
||||||
|
|
||||||
class Type(Enum):
|
class TrType(Enum):
|
||||||
""" Types of DVB transponders """
|
""" Transponders type """
|
||||||
Satellite = "s"
|
Satellite = "s"
|
||||||
Terestrial = "t"
|
Terestrial = "t"
|
||||||
Cable = "c"
|
Cable = "c"
|
||||||
|
|
||||||
|
|
||||||
|
class BqType(Enum):
|
||||||
|
""" Bouquet type"""
|
||||||
|
BOUQUET = "bouquet"
|
||||||
|
TV = "tv"
|
||||||
|
RADIO = "radio"
|
||||||
|
WEBTV = "webtv"
|
||||||
|
|
||||||
|
|
||||||
class Flag(Enum):
|
class Flag(Enum):
|
||||||
""" Service flags
|
""" Service flags
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
""" Module for parsing bouquets """
|
""" Module for parsing bouquets """
|
||||||
from app.eparser.ecommons import BqServiceType, BouquetService, Bouquets, Bouquet
|
from app.eparser.ecommons import BqServiceType, BouquetService, Bouquets, Bouquet, BqType
|
||||||
|
|
||||||
_TV_ROOT_FILE_NAME = "bouquets.tv"
|
_TV_ROOT_FILE_NAME = "bouquets.tv"
|
||||||
_RADIO_ROOT_FILE_NAME = "bouquets.radio"
|
_RADIO_ROOT_FILE_NAME = "bouquets.radio"
|
||||||
|
|
||||||
|
|
||||||
def get_bouquets(path):
|
def get_bouquets(path):
|
||||||
return parse_bouquets(path, "bouquets.tv", "tv"), parse_bouquets(path, "bouquets.radio", "radio")
|
return parse_bouquets(path, "bouquets.tv", BqType.TV.value), parse_bouquets(path, "bouquets.radio",
|
||||||
|
BqType.RADIO.value)
|
||||||
|
|
||||||
|
|
||||||
def write_bouquets(path, bouquets):
|
def write_bouquets(path, bouquets):
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
import os
|
import os
|
||||||
from enum import Enum
|
|
||||||
from xml.dom.minidom import parse, Document
|
from xml.dom.minidom import parse, Document
|
||||||
|
|
||||||
from app.eparser.iptv import NEUTRINO_FAV_ID_FORMAT
|
from app.eparser.iptv import NEUTRINO_FAV_ID_FORMAT
|
||||||
from app.ui import LOCKED_ICON, HIDE_ICON
|
from app.ui import LOCKED_ICON, HIDE_ICON
|
||||||
from ..ecommons import Bouquets, Bouquet, BouquetService, BqServiceType, PROVIDER
|
from ..ecommons import Bouquets, Bouquet, BouquetService, BqServiceType, PROVIDER, BqType
|
||||||
|
|
||||||
_FILE = "bouquets.xml"
|
_FILE = "bouquets.xml"
|
||||||
_U_FILE = "ubouquets.xml"
|
_U_FILE = "ubouquets.xml"
|
||||||
@@ -13,12 +12,6 @@ _W_FILE = "webtv.xml"
|
|||||||
_COMMENT = " File was created in DemonEditor. Enjoy watching! "
|
_COMMENT = " File was created in DemonEditor. Enjoy watching! "
|
||||||
|
|
||||||
|
|
||||||
class BqType(Enum):
|
|
||||||
BOUQUET = "bouquet"
|
|
||||||
TV = "tv"
|
|
||||||
WEBTV = "webtv"
|
|
||||||
|
|
||||||
|
|
||||||
def get_bouquets(path):
|
def get_bouquets(path):
|
||||||
return (parse_bouquets(path + _FILE, "Providers", BqType.BOUQUET.value),
|
return (parse_bouquets(path + _FILE, "Providers", BqType.BOUQUET.value),
|
||||||
parse_bouquets(path + _U_FILE, "FAV", BqType.TV.value),
|
parse_bouquets(path + _U_FILE, "FAV", BqType.TV.value),
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ from functools import lru_cache
|
|||||||
|
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
from app.commons import run_idle, log
|
from app.commons import run_idle, log, run_task
|
||||||
from app.eparser import get_blacklist, write_blacklist, parse_m3u
|
from app.eparser import get_blacklist, write_blacklist, parse_m3u
|
||||||
from app.eparser import get_services, get_bouquets, write_bouquets, write_services, Bouquets, Bouquet, Service
|
from app.eparser import get_services, get_bouquets, write_bouquets, write_services, Bouquets, Bouquet, Service
|
||||||
from app.eparser.ecommons import CAS, Flag
|
from app.eparser.ecommons import CAS, Flag
|
||||||
@@ -18,7 +18,7 @@ from .dialogs import show_dialog, DialogType, get_chooser_dialog, WaitDialog, ge
|
|||||||
from .download_dialog import show_download_dialog
|
from .download_dialog import show_download_dialog
|
||||||
from .main_helper import edit_marker, insert_marker, move_items, rename, ViewTarget, set_flags, locate_in_services, \
|
from .main_helper import edit_marker, insert_marker, move_items, rename, ViewTarget, set_flags, locate_in_services, \
|
||||||
scroll_to, get_base_model, update_picons, copy_picon_reference, assign_picon, remove_picon, \
|
scroll_to, get_base_model, update_picons, copy_picon_reference, assign_picon, remove_picon, \
|
||||||
is_only_one_item_selected, get_gen_bouquets, BqGenType
|
is_only_one_item_selected, gen_bouquets, BqGenType
|
||||||
from .picons_dialog import PiconsDialog
|
from .picons_dialog import PiconsDialog
|
||||||
from .satellites_dialog import show_satellites_dialog
|
from .satellites_dialog import show_satellites_dialog
|
||||||
from .settings_dialog import show_settings_dialog
|
from .settings_dialog import show_settings_dialog
|
||||||
@@ -1011,12 +1011,10 @@ class MainAppWindow:
|
|||||||
def on_create_bouquet_for_each_package(self, item):
|
def on_create_bouquet_for_each_package(self, item):
|
||||||
self.create_bouquets(BqGenType.EACH_PACKAGE)
|
self.create_bouquets(BqGenType.EACH_PACKAGE)
|
||||||
|
|
||||||
|
@run_task
|
||||||
def create_bouquets(self, g_type):
|
def create_bouquets(self, g_type):
|
||||||
bqs = get_gen_bouquets(self.__services_view, self.__bouquets_model, self.__main_window, g_type, self._TV_TYPES)
|
gen_bouquets(self.__services_view, self.__bouquets_view, self.__main_window, g_type, self._TV_TYPES,
|
||||||
for bq in bqs:
|
Profile(self.__profile), self.append_bouquet)
|
||||||
self.append_bouquet(bq, self.__bouquets_model.get_iter(0))
|
|
||||||
if bqs:
|
|
||||||
self.__bouquets_view.expand_row(Gtk.TreePath(0), 0)
|
|
||||||
|
|
||||||
|
|
||||||
def start_app():
|
def start_app():
|
||||||
|
|||||||
@@ -1,14 +1,13 @@
|
|||||||
""" This is helper module for ui """
|
""" This is helper module for ui """
|
||||||
from enum import Enum
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
import shutil
|
import shutil
|
||||||
|
from enum import Enum
|
||||||
from gi.repository import GdkPixbuf
|
from gi.repository import GdkPixbuf
|
||||||
|
|
||||||
from app.eparser import Service
|
from app.eparser import Service
|
||||||
from app.eparser.ecommons import Flag, BouquetService, Bouquet
|
from app.eparser.ecommons import Flag, BouquetService, Bouquet, BqType
|
||||||
from app.eparser.enigma.bouquets import BqServiceType, to_bouquet_id
|
from app.eparser.enigma.bouquets import BqServiceType, to_bouquet_id
|
||||||
|
from app.properties import Profile
|
||||||
from . import Gtk, Gdk, HIDE_ICON, LOCKED_ICON
|
from . import Gtk, Gdk, HIDE_ICON, LOCKED_ICON
|
||||||
from .dialogs import show_dialog, DialogType, get_chooser_dialog
|
from .dialogs import show_dialog, DialogType, get_chooser_dialog
|
||||||
|
|
||||||
@@ -421,31 +420,37 @@ def get_picon_pixbuf(path):
|
|||||||
|
|
||||||
# ***************** Bouquets *********************#
|
# ***************** Bouquets *********************#
|
||||||
|
|
||||||
def get_gen_bouquets(view, bqs_model, transient, gen_type, tv_types):
|
def gen_bouquets(view, bq_view, transient, gen_type, tv_types, profile, callback):
|
||||||
""" Auto-generates and returns list of bouquets """
|
""" Auto-generate and append list of bouquets """
|
||||||
bqs = []
|
fav_id_index = 18
|
||||||
|
index = 6 if gen_type in (BqGenType.PACKAGE, BqGenType.EACH_PACKAGE) else 16
|
||||||
model, paths = view.get_selection().get_selected_rows()
|
model, paths = view.get_selection().get_selected_rows()
|
||||||
if is_only_one_item_selected(paths, transient):
|
|
||||||
model = get_base_model(model)
|
model = get_base_model(model)
|
||||||
|
bq_type = BqType.BOUQUET.value if profile is Profile.NEUTRINO_MP else BqType.TV.value
|
||||||
|
if gen_type is BqGenType.SAT or gen_type is BqGenType.PACKAGE:
|
||||||
|
if not is_only_one_item_selected(paths, transient):
|
||||||
|
return
|
||||||
service = Service(*model[paths][:])
|
service = Service(*model[paths][:])
|
||||||
fav_id_index = service.index(service.fav_id)
|
if service.service_type not in tv_types:
|
||||||
name = service.package
|
bq_type = BqType.RADIO.value
|
||||||
index = service.index(service.package)
|
append_bouquets(bq_type, bq_view, callback, fav_id_index, index, model,
|
||||||
|
[service.package if gen_type is BqGenType.PACKAGE else service.pos])
|
||||||
if gen_type is BqGenType.EACH_PACKAGE:
|
if gen_type is BqGenType.EACH_PACKAGE:
|
||||||
pass
|
append_bouquets(bq_type, bq_view, callback, fav_id_index, index, model, {row[index] for row in model})
|
||||||
elif gen_type is BqGenType.SAT:
|
|
||||||
name = service.pos
|
|
||||||
index = service.index(service.pos)
|
|
||||||
elif gen_type is BqGenType.EACH_SAT:
|
elif gen_type is BqGenType.EACH_SAT:
|
||||||
pass
|
append_bouquets(bq_type, bq_view, callback, fav_id_index, index, model, {row[index] for row in model})
|
||||||
bouquets_names = get_bouquets_names(bqs_model)
|
|
||||||
|
|
||||||
|
|
||||||
|
def append_bouquets(bq_type, bq_view, callback, fav_id_index, index, model, names):
|
||||||
|
bq_view.expand_row(Gtk.TreePath(0), 0)
|
||||||
|
bqs_model = bq_view.get_model()
|
||||||
|
bouquets_names = get_bouquets_names(bqs_model)
|
||||||
|
for pos, name in enumerate(sorted(names)):
|
||||||
if name not in bouquets_names:
|
if name not in bouquets_names:
|
||||||
services = [BouquetService(None, BqServiceType.DEFAULT, row[fav_id_index], 0)
|
services = [BouquetService(None, BqServiceType.DEFAULT, row[fav_id_index], 0)
|
||||||
for row in model if row[index] == name]
|
for row in model if row[index] == name]
|
||||||
bqs.append(Bouquet(name=name, type="tv", services=services, locked=None, hidden=None))
|
callback(Bouquet(name=name, type=bq_type, services=services, locked=None, hidden=None),
|
||||||
|
bqs_model.get_iter(0))
|
||||||
return bqs
|
|
||||||
|
|
||||||
|
|
||||||
def get_bouquets_names(model):
|
def get_bouquets_names(model):
|
||||||
|
|||||||
@@ -142,6 +142,16 @@
|
|||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="stock">gtk-select-all</property>
|
<property name="stock">gtk-select-all</property>
|
||||||
</object>
|
</object>
|
||||||
|
<object class="GtkImage" id="image8">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="stock">gtk-save</property>
|
||||||
|
</object>
|
||||||
|
<object class="GtkImage" id="image9">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="stock">gtk-select-all</property>
|
||||||
|
</object>
|
||||||
<object class="GtkImage" id="insert_image">
|
<object class="GtkImage" id="insert_image">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
@@ -240,6 +250,27 @@
|
|||||||
<signal name="activate" handler="on_create_bouquet_for_each_package" swapped="no"/>
|
<signal name="activate" handler="on_create_bouquet_for_each_package" swapped="no"/>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkSeparatorMenuItem" id="services_bouquet_separator_2">
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkImageMenuItem" id="services_create_bouquet_for_current_type_popup_item">
|
||||||
|
<property name="label" translatable="yes">For current type</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="image">image8</property>
|
||||||
|
<property name="use_stock">False</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkImageMenuItem" id="services_create_bouquet_for_each_type_popup_item">
|
||||||
|
<property name="label" translatable="yes">For each type</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="image">image9</property>
|
||||||
|
<property name="use_stock">False</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
|||||||
Reference in New Issue
Block a user