bouquet auto generation by type

This commit is contained in:
DYefremov
2018-04-07 23:49:36 +03:00
parent 5f68eb0f1a
commit 30e38dde3f
3 changed files with 42 additions and 35 deletions

View File

@@ -4,7 +4,7 @@ from functools import lru_cache
import shutil
from app.commons import run_idle, log, run_task
from app.commons import run_idle, log
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
@@ -121,7 +121,9 @@ class MainAppWindow:
"on_create_bouquet_for_current_satellite": self.on_create_bouquet_for_current_satellite,
"on_create_bouquet_for_each_satellite": self.on_create_bouquet_for_each_satellite,
"on_create_bouquet_for_current_package": self.on_create_bouquet_for_current_package,
"on_create_bouquet_for_each_package": self.on_create_bouquet_for_each_package}
"on_create_bouquet_for_each_package": self.on_create_bouquet_for_each_package,
"on_create_bouquet_for_current_type": self.on_create_bouquet_for_current_type,
"on_create_bouquet_for_each_type": self.on_create_bouquet_for_each_type}
self._options = get_config()
self._profile = self._options.get("profile")
@@ -1021,7 +1023,12 @@ class MainAppWindow:
def on_create_bouquet_for_each_package(self, item):
self.create_bouquets(BqGenType.EACH_PACKAGE)
@run_task
def on_create_bouquet_for_current_type(self, item):
self.create_bouquets(BqGenType.TYPE)
def on_create_bouquet_for_each_type(self, item):
self.create_bouquets(BqGenType.EACH_TYPE)
def create_bouquets(self, g_type):
gen_bouquets(self._services_view, self._bouquets_view, self._main_window, g_type, self._TV_TYPES,
Profile(self._profile), self.append_bouquet)

View File

@@ -4,6 +4,7 @@ import shutil
from enum import Enum
from gi.repository import GdkPixbuf
from app.commons import run_idle, run_task
from app.eparser import Service
from app.eparser.ecommons import Flag, BouquetService, Bouquet, BqType
from app.eparser.enigma.bouquets import BqServiceType, to_bouquet_id
@@ -25,6 +26,8 @@ class BqGenType(Enum):
EACH_SAT = 1
PACKAGE = 2
EACH_PACKAGE = 3
TYPE = 4
EACH_TYPE = 5
# ***************** Markers *******************#
@@ -423,24 +426,25 @@ def get_picon_pixbuf(path):
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
index = 6 if gen_type in (BqGenType.PACKAGE, BqGenType.EACH_PACKAGE) else 16 if gen_type in (
BqGenType.SAT, BqGenType.EACH_SAT) else 7
model, paths = view.get_selection().get_selected_rows()
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 gen_type in (BqGenType.SAT, BqGenType.PACKAGE, BqGenType.TYPE):
if not is_only_one_item_selected(paths, transient):
return
service = Service(*model[paths][:])
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:
[service.package if gen_type is BqGenType.PACKAGE else
service.pos if gen_type is BqGenType.SAT else service.service_type])
else:
append_bouquets(bq_type, bq_view, callback, fav_id_index, index, model, {row[index] for row in model})
@run_task
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()

View File

@@ -120,7 +120,7 @@
<object class="GtkImage" id="image1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-save</property>
<property name="stock">gtk-save-as</property>
</object>
<object class="GtkImage" id="image4">
<property name="visible">True</property>
@@ -135,7 +135,7 @@
<object class="GtkImage" id="image6">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-save</property>
<property name="stock">gtk-save-as</property>
</object>
<object class="GtkImage" id="image7">
<property name="visible">True</property>
@@ -145,7 +145,7 @@
<object class="GtkImage" id="image8">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-save</property>
<property name="stock">gtk-save-as</property>
</object>
<object class="GtkImage" id="image9">
<property name="visible">True</property>
@@ -215,13 +215,23 @@
</object>
</child>
<child>
<object class="GtkImageMenuItem" id="services_create_bouquet_for_each_sat_popup_item">
<property name="label" translatable="yes">For each satellite</property>
<object class="GtkImageMenuItem" id="services_create_bouquet_for_current_package_popup_item">
<property name="label" translatable="yes">For current package</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="image">image4</property>
<property name="image">image6</property>
<property name="use_stock">False</property>
<signal name="activate" handler="on_create_bouquet_for_each_satellite" swapped="no"/>
<signal name="activate" handler="on_create_bouquet_for_current_package" swapped="no"/>
</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="visible">True</property>
<property name="can_focus">False</property>
<property name="image">image8</property>
<property name="use_stock">False</property>
<signal name="activate" handler="on_create_bouquet_for_current_type" swapped="no"/>
</object>
</child>
<child>
@@ -231,13 +241,13 @@
</object>
</child>
<child>
<object class="GtkImageMenuItem" id="services_create_bouquet_for_current_package_popup_item">
<property name="label" translatable="yes">For current package</property>
<object class="GtkImageMenuItem" id="services_create_bouquet_for_each_sat_popup_item">
<property name="label" translatable="yes">For each satellite</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="image">image6</property>
<property name="image">image4</property>
<property name="use_stock">False</property>
<signal name="activate" handler="on_create_bouquet_for_current_package" swapped="no"/>
<signal name="activate" handler="on_create_bouquet_for_each_satellite" swapped="no"/>
</object>
</child>
<child>
@@ -250,21 +260,6 @@
<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="visible">True</property>
<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="visible">True</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>
@@ -272,6 +267,7 @@
<property name="can_focus">False</property>
<property name="image">image9</property>
<property name="use_stock">False</property>
<signal name="activate" handler="on_create_bouquet_for_each_type" swapped="no"/>
</object>
</child>
</object>