mirror of
https://github.com/DYefremov/DemonEditor.git
synced 2025-12-21 16:09:41 +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"])
|
||||
|
||||
|
||||
class Type(Enum):
|
||||
""" Types of DVB transponders """
|
||||
class TrType(Enum):
|
||||
""" Transponders type """
|
||||
Satellite = "s"
|
||||
Terestrial = "t"
|
||||
Cable = "c"
|
||||
|
||||
|
||||
class BqType(Enum):
|
||||
""" Bouquet type"""
|
||||
BOUQUET = "bouquet"
|
||||
TV = "tv"
|
||||
RADIO = "radio"
|
||||
WEBTV = "webtv"
|
||||
|
||||
|
||||
class Flag(Enum):
|
||||
""" Service flags
|
||||
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
""" 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"
|
||||
_RADIO_ROOT_FILE_NAME = "bouquets.radio"
|
||||
|
||||
|
||||
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):
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import os
|
||||
from enum import Enum
|
||||
from xml.dom.minidom import parse, Document
|
||||
|
||||
from app.eparser.iptv import NEUTRINO_FAV_ID_FORMAT
|
||||
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"
|
||||
_U_FILE = "ubouquets.xml"
|
||||
@@ -13,12 +12,6 @@ _W_FILE = "webtv.xml"
|
||||
_COMMENT = " File was created in DemonEditor. Enjoy watching! "
|
||||
|
||||
|
||||
class BqType(Enum):
|
||||
BOUQUET = "bouquet"
|
||||
TV = "tv"
|
||||
WEBTV = "webtv"
|
||||
|
||||
|
||||
def get_bouquets(path):
|
||||
return (parse_bouquets(path + _FILE, "Providers", BqType.BOUQUET.value),
|
||||
parse_bouquets(path + _U_FILE, "FAV", BqType.TV.value),
|
||||
|
||||
@@ -4,7 +4,7 @@ from functools import lru_cache
|
||||
|
||||
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_services, get_bouquets, write_bouquets, write_services, Bouquets, Bouquet, Service
|
||||
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 .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, \
|
||||
is_only_one_item_selected, get_gen_bouquets, BqGenType
|
||||
is_only_one_item_selected, gen_bouquets, BqGenType
|
||||
from .picons_dialog import PiconsDialog
|
||||
from .satellites_dialog import show_satellites_dialog
|
||||
from .settings_dialog import show_settings_dialog
|
||||
@@ -1011,12 +1011,10 @@ class MainAppWindow:
|
||||
def on_create_bouquet_for_each_package(self, item):
|
||||
self.create_bouquets(BqGenType.EACH_PACKAGE)
|
||||
|
||||
@run_task
|
||||
def create_bouquets(self, g_type):
|
||||
bqs = get_gen_bouquets(self.__services_view, self.__bouquets_model, self.__main_window, g_type, self._TV_TYPES)
|
||||
for bq in bqs:
|
||||
self.append_bouquet(bq, self.__bouquets_model.get_iter(0))
|
||||
if bqs:
|
||||
self.__bouquets_view.expand_row(Gtk.TreePath(0), 0)
|
||||
gen_bouquets(self.__services_view, self.__bouquets_view, self.__main_window, g_type, self._TV_TYPES,
|
||||
Profile(self.__profile), self.append_bouquet)
|
||||
|
||||
|
||||
def start_app():
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
""" This is helper module for ui """
|
||||
from enum import Enum
|
||||
|
||||
import os
|
||||
|
||||
import shutil
|
||||
from enum import Enum
|
||||
from gi.repository import GdkPixbuf
|
||||
|
||||
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.properties import Profile
|
||||
from . import Gtk, Gdk, HIDE_ICON, LOCKED_ICON
|
||||
from .dialogs import show_dialog, DialogType, get_chooser_dialog
|
||||
|
||||
@@ -421,31 +420,37 @@ def get_picon_pixbuf(path):
|
||||
|
||||
# ***************** Bouquets *********************#
|
||||
|
||||
def get_gen_bouquets(view, bqs_model, transient, gen_type, tv_types):
|
||||
""" Auto-generates and returns list of bouquets """
|
||||
bqs = []
|
||||
def gen_bouquets(view, bq_view, transient, gen_type, tv_types, profile, callback):
|
||||
""" Auto-generate and append list of bouquets """
|
||||
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()
|
||||
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][:])
|
||||
fav_id_index = service.index(service.fav_id)
|
||||
name = service.package
|
||||
index = service.index(service.package)
|
||||
if gen_type is BqGenType.EACH_PACKAGE:
|
||||
pass
|
||||
elif gen_type is BqGenType.SAT:
|
||||
name = service.pos
|
||||
index = service.index(service.pos)
|
||||
elif gen_type is BqGenType.EACH_SAT:
|
||||
pass
|
||||
bouquets_names = get_bouquets_names(bqs_model)
|
||||
if service.service_type not in tv_types:
|
||||
bq_type = BqType.RADIO.value
|
||||
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:
|
||||
append_bouquets(bq_type, bq_view, callback, fav_id_index, index, model, {row[index] for row in model})
|
||||
elif gen_type is BqGenType.EACH_SAT:
|
||||
append_bouquets(bq_type, bq_view, callback, fav_id_index, index, model, {row[index] for row in 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:
|
||||
services = [BouquetService(None, BqServiceType.DEFAULT, row[fav_id_index], 0)
|
||||
for row in model if row[index] == name]
|
||||
bqs.append(Bouquet(name=name, type="tv", services=services, locked=None, hidden=None))
|
||||
|
||||
return bqs
|
||||
callback(Bouquet(name=name, type=bq_type, services=services, locked=None, hidden=None),
|
||||
bqs_model.get_iter(0))
|
||||
|
||||
|
||||
def get_bouquets_names(model):
|
||||
|
||||
@@ -142,6 +142,16 @@
|
||||
<property name="can_focus">False</property>
|
||||
<property name="stock">gtk-select-all</property>
|
||||
</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">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
@@ -240,6 +250,27 @@
|
||||
<signal name="activate" handler="on_create_bouquet_for_each_package" swapped="no"/>
|
||||
</object>
|
||||
</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>
|
||||
</child>
|
||||
</object>
|
||||
|
||||
Reference in New Issue
Block a user