mirror of
https://github.com/DYefremov/DemonEditor.git
synced 2026-01-07 16:22:03 +01:00
improved picon conversion tab
* conversion for the selected bouquet * oscam picons ui prototype
This commit is contained in:
@@ -32,6 +32,7 @@ import re
|
||||
import shutil
|
||||
import subprocess
|
||||
from collections import namedtuple
|
||||
from enum import IntEnum
|
||||
from html.parser import HTMLParser
|
||||
|
||||
import requests
|
||||
@@ -51,6 +52,12 @@ class PiconsError(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class PiconFormat(IntEnum):
|
||||
ENIGMA2 = 0
|
||||
NEUTRINO = 1
|
||||
OSCAM = 3
|
||||
|
||||
|
||||
class PiconsCzDownloader:
|
||||
""" The main class for loading picons from the https://picon.cz/ source (by Chocholoušek). """
|
||||
|
||||
@@ -509,21 +516,40 @@ def download_picon(src_url, dest_path):
|
||||
|
||||
|
||||
@run_task
|
||||
def convert_to(src_path, dest_path, s_type, done_callback):
|
||||
""" Converts names format of picons.
|
||||
def convert_to(src_path, dest_path, p_format, ids=None, done_callback=None):
|
||||
""" Converts format [names] of picons.
|
||||
|
||||
Copies resulting files from src to dest and writes state to callback.
|
||||
"""
|
||||
pattern = "/*_0_0_0.png" if s_type is SettingsType.ENIGMA_2 else "/*.png"
|
||||
pattern = "/*_0_0_0.png" if p_format is PiconFormat.NEUTRINO else "/*.png"
|
||||
to_convert = []
|
||||
for file in glob.glob(src_path + pattern):
|
||||
base_name = os.path.basename(file)
|
||||
if ids is not None and base_name not in ids:
|
||||
continue
|
||||
|
||||
to_convert.append((base_name, dest_path, file))
|
||||
|
||||
if p_format is PiconFormat.NEUTRINO:
|
||||
convert_to_neutrino(to_convert)
|
||||
elif p_format is PiconFormat.OSCAM:
|
||||
convert_to_oscam(to_convert)
|
||||
|
||||
if done_callback:
|
||||
done_callback()
|
||||
|
||||
|
||||
def convert_to_neutrino(files):
|
||||
for base_name, dest_path, file in files:
|
||||
pic_data = base_name.rstrip(".png").split("_")
|
||||
dest_file = _NEUTRINO_PICON_KEY.format(int(pic_data[4], 16), int(pic_data[5], 16), int(pic_data[3], 16))
|
||||
dest = "{}/{}".format(dest_path, dest_file)
|
||||
log('Converting "{}" to "{}"'.format(base_name, dest_file))
|
||||
dest = f"{dest_path}{os.sep}{dest_file}"
|
||||
log(f'Converting "{base_name}" to "{dest_file}"')
|
||||
shutil.copyfile(file, dest)
|
||||
|
||||
done_callback()
|
||||
|
||||
def convert_to_oscam(files):
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -610,8 +610,8 @@ Author: Dmitriy Yefremov
|
||||
<property name="can-focus">False</property>
|
||||
<child>
|
||||
<object class="GtkCheckButton" id="src_filter_button">
|
||||
<property name="visible" bind-source="filter_button" bind-property="active">False</property>
|
||||
<property name="label" translatable="yes">Filter</property>
|
||||
<property name="visible" bind-source="filter_button" bind-property="active">False</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="focus-on-click">False</property>
|
||||
<property name="receives-default">False</property>
|
||||
@@ -745,8 +745,8 @@ Author: Dmitriy Yefremov
|
||||
<property name="can-focus">False</property>
|
||||
<child>
|
||||
<object class="GtkCheckButton" id="dst_filter_button">
|
||||
<property name="visible" bind-source="filter_button" bind-property="active">False</property>
|
||||
<property name="label" translatable="yes">Filter</property>
|
||||
<property name="visible" bind-source="filter_button" bind-property="active">False</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="focus-on-click">False</property>
|
||||
<property name="receives-default">False</property>
|
||||
@@ -1048,9 +1048,9 @@ Author: Dmitriy Yefremov
|
||||
<child>
|
||||
<object class="GtkSpinner" id="loading_data_spinner">
|
||||
<property name="visible" bind-source="satellite_label" bind-property="visible" bind-flags="invert-boolean">True</property>
|
||||
<property name="active" bind-source="satellite_label" bind-property="visible" bind-flags="invert-boolean">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="margin-right">5</property>
|
||||
<property name="active" bind-source="satellite_label" bind-property="visible" bind-flags="invert-boolean">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
@@ -1063,9 +1063,9 @@ Author: Dmitriy Yefremov
|
||||
<object class="GtkGrid" id="satellite_filter_grid">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="tooltip-text" translatable="yes">Filter by current satellite positions</property>
|
||||
<property name="margin-right">5</property>
|
||||
<property name="column-spacing">5</property>
|
||||
<property name="tooltip-text" translatable="yes">Filter by current satellite positions</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="satellite_filter_label">
|
||||
<property name="visible">True</property>
|
||||
@@ -1580,110 +1580,24 @@ Author: Dmitriy Yefremov
|
||||
<object class="GtkBox" id="converter_box">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="margin-left">5</property>
|
||||
<property name="margin-right">5</property>
|
||||
<property name="margin-top">5</property>
|
||||
<property name="margin-bottom">5</property>
|
||||
<property name="margin-start">10</property>
|
||||
<property name="margin-end">10</property>
|
||||
<property name="margin-top">10</property>
|
||||
<property name="margin-bottom">10</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="spacing">2</property>
|
||||
<property name="spacing">5</property>
|
||||
<child>
|
||||
<!-- n-columns=3 n-rows=4 -->
|
||||
<object class="GtkGrid" id="converter_grid">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="margin-left">10</property>
|
||||
<property name="margin-right">10</property>
|
||||
<property name="margin-top">10</property>
|
||||
<property name="row-spacing">5</property>
|
||||
<property name="column-spacing">2</property>
|
||||
<property name="column-homogeneous">True</property>
|
||||
<child>
|
||||
<object class="GtkFileChooserButton" id="enigma2_path_button">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="action">select-folder</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="picons_path_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes">Path to Enigma2 picons:</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="save_to_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes">Path to save:</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkFileChooserButton" id="save_to_button">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="action">select-folder</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="convert_to_label">
|
||||
<property name="visible">True</property>
|
||||
<object class="GtkLabel" id="convert_to_nt_label">
|
||||
<property name="visible" bind-source="converter_nt_button" bind-property="active">False</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="margin-bottom">10</property>
|
||||
<property name="label" translatable="yes">Enigma2 -> Neutrino-MP</property>
|
||||
<property name="label">Enigma2 -> Neutrino-MP</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="pack-type">end</property>
|
||||
<property name="position">1</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
@@ -1697,9 +1611,154 @@ Author: Dmitriy Yefremov
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="pack-type">end</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="convert_to_sc_label">
|
||||
<property name="visible" bind-source="converter_sc_button" bind-property="active">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="margin-bottom">10</property>
|
||||
<property name="label">Enigma2 -> OSCam</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="pack-type">end</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButtonBox" id="converter_format_box">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="halign">center</property>
|
||||
<property name="margin-top">10</property>
|
||||
<property name="homogeneous">True</property>
|
||||
<property name="layout-style">expand</property>
|
||||
<child>
|
||||
<object class="GtkRadioButton" id="converter_sc_button">
|
||||
<property name="label" translatable="yes">OSCam</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">False</property>
|
||||
<property name="draw-indicator">False</property>
|
||||
<property name="group">converter_nt_button</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkRadioButton" id="converter_nt_button">
|
||||
<property name="label" translatable="yes">Neutrino-MP</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">False</property>
|
||||
<property name="draw-indicator">False</property>
|
||||
<property name="group">converter_sc_button</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox" id="converter_select_bq_box">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="margin-top">5</property>
|
||||
<property name="margin-bottom">5</property>
|
||||
<property name="spacing">5</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="coverter_bq_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="halign">end</property>
|
||||
<property name="label">Convert for selected bouquets</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSwitch" id="converter_bq_button">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="picons_path_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes">Path to Enigma2 picons:</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">4</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkFileChooserButton" id="enigma2_path_button">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="action">select-folder</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">5</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="save_to_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes">Path to save:</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">6</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkFileChooserButton" id="save_to_button">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="action">select-folder</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">7</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child type="label_item">
|
||||
|
||||
@@ -40,7 +40,7 @@ from app.commons import run_idle, run_task, run_with_delay, log
|
||||
from app.connections import upload_data, DownloadType, download_data, remove_picons
|
||||
from app.settings import SettingsType, Settings, SEP, IS_DARWIN
|
||||
from app.tools.picons import (PiconsParser, parse_providers, Provider, convert_to, download_picon, PiconsCzDownloader,
|
||||
PiconsError)
|
||||
PiconsError, PiconFormat)
|
||||
from app.tools.satellites import SatellitesParser, SatelliteSource
|
||||
from .dialogs import show_dialog, DialogType, translate, get_builder, get_chooser_dialog
|
||||
from .main_helper import (scroll_to, on_popup_menu, get_base_model, set_picon, get_picon_pixbuf, get_picon_dialog,
|
||||
@@ -153,6 +153,9 @@ class PiconManager(Gtk.Box):
|
||||
self._bouquet_filter_switch = builder.get_object("bouquet_filter_switch")
|
||||
self._providers_header_box = builder.get_object("providers_header_box")
|
||||
self._header_download_box = builder.get_object("header_download_box")
|
||||
self._converter_sc_button = builder.get_object("converter_sc_button")
|
||||
self._converter_nt_button = builder.get_object("converter_nt_button")
|
||||
self._converter_bq_button = builder.get_object("converter_bq_button")
|
||||
# Info.
|
||||
self._dst_count_label = builder.get_object("dst_count_label")
|
||||
self._info_check_button = builder.get_object("info_check_button")
|
||||
@@ -999,10 +1002,22 @@ class PiconManager(Gtk.Box):
|
||||
return
|
||||
|
||||
self._app.change_action_state("on_logs_show", GLib.Variant.new_boolean(True))
|
||||
convert_to(src_path=picons_path,
|
||||
dest_path=save_path,
|
||||
s_type=SettingsType.ENIGMA_2,
|
||||
done_callback=lambda: self.show_info_message(translate("Done!"), Gtk.MessageType.INFO))
|
||||
ids = None
|
||||
p_format = PiconFormat.NEUTRINO if self._converter_nt_button.get_active() else PiconFormat.OSCAM
|
||||
|
||||
if self._converter_bq_button.get_active():
|
||||
bq_selected = self._app.check_bouquet_selection()
|
||||
if not bq_selected:
|
||||
return
|
||||
|
||||
services = self._app.current_services
|
||||
ids = {services.get(s).picon_id for s in self._app.current_bouquets.get(bq_selected) if s in services}
|
||||
|
||||
if self._converter_nt_button.get_active():
|
||||
convert_to(src_path=picons_path, dest_path=save_path, p_format=p_format, ids=ids,
|
||||
done_callback=lambda: self.show_info_message(translate("Done!"), Gtk.MessageType.INFO))
|
||||
else:
|
||||
self.show_info_message("Not implemented yet!", Gtk.MessageType.ERROR)
|
||||
|
||||
@run_idle
|
||||
def update_receive_button_state(self):
|
||||
|
||||
Reference in New Issue
Block a user