bouquet import fix

This commit is contained in:
DYefremov
2020-07-12 19:18:11 +03:00
parent 6b360d48c4
commit 4fd2a2a600
3 changed files with 14 additions and 8 deletions

View File

@@ -21,7 +21,7 @@ def import_bouquet(transient, model, path, settings, services, appender, file_pa
if profile is SettingsType.ENIGMA_2:
pattern = ".{}".format(bq_type.value)
f_pattern = "userbouquet.*{}".format(pattern)
f_pattern = "*" + pattern if settings.is_darwin else "userbouquet.*{}".format(pattern)
elif profile is SettingsType.NEUTRINO_MP:
pattern = "webtv.xml" if bq_type is BqType.WEBTV else "bouquets.xml"
f_pattern = "bouquets.xml"
@@ -34,11 +34,15 @@ def import_bouquet(transient, model, path, settings, services, appender, file_pa
if file_path == Gtk.ResponseType.CANCEL:
return
if not str(file_path).endswith(pattern):
if not file_path.endswith(pattern):
show_dialog(DialogType.ERROR, transient, text="No bouquet file is selected!")
return
if profile is SettingsType.ENIGMA_2:
if settings.is_darwin and file_path.rfind("userbouquet.") < 0:
show_dialog(DialogType.ERROR, transient, text="No bouquet file is selected!")
return
bq = get_enigma2_bouquet(file_path)
imported = list(filter(lambda x: x.data in services or x.type is BqServiceType.IPTV, bq.services))

View File

@@ -501,6 +501,7 @@ class Application(Gtk.Application):
self._bouquets_view.drag_source_set_target_list(None)
self._bouquets_view.drag_dest_add_text_targets()
self._bouquets_view.drag_source_add_text_targets()
self._bouquets_view.drag_dest_add_uri_targets()
def init_colors(self, update=False):
""" Initialisation of background colors for the services.
@@ -1036,13 +1037,15 @@ class Application(Gtk.Application):
def on_bq_view_drag_data_received(self, view, drag_context, x, y, data, info, time):
model_name, model = get_model_data(view)
drop_info = view.get_dest_row_at_pos(x, y)
data = data.get_text()
if not data:
uris = data.get_uris()
if uris:
from urllib.parse import unquote, urlparse
self.on_import_bouquet(None, file_path=urlparse(unquote(uris[0])).path.strip())
return
if data.startswith("file://"):
from urllib.parse import unquote, urlparse
self.on_import_bouquet(None, file_path=urlparse(unquote(data)).path.strip())
data = data.get_text()
if not data:
return
itr_str, sep, source = data.partition("::::")

View File

@@ -2923,7 +2923,6 @@ Author: Dmitriy Yefremov
<property name="tooltip_text" translatable="yes">No connection to the receiver!</property>
<property name="margin_left">10</property>
<property name="margin_right">10</property>
<property name="pixel_size">24</property>
<property name="icon_name">network-offline</property>
</object>
<packing>