mirror of
https://github.com/DYefremov/DemonEditor.git
synced 2025-12-21 16:09:41 +01:00
added the channel watching in the program
This commit is contained in:
@@ -15,6 +15,7 @@ Clipboard is **"rubber"**. There is an accumulation before the insertion!
|
|||||||
* **Ctrl + L** - parental lock.
|
* **Ctrl + L** - parental lock.
|
||||||
* **Ctrl + H** - hide/skip.
|
* **Ctrl + H** - hide/skip.
|
||||||
* **Ctrl + P** - start play IPTV or other stream in the bouquet list.
|
* **Ctrl + P** - start play IPTV or other stream in the bouquet list.
|
||||||
|
* **Ctrl + W** - switch to the channel and watch in the program.
|
||||||
* **Ctrl + Z** - switch(**zap**) the channel(works when the HTTP API is enabled, Enigma2 only).
|
* **Ctrl + Z** - switch(**zap**) the channel(works when the HTTP API is enabled, Enigma2 only).
|
||||||
* **Space** - select/deselect.
|
* **Space** - select/deselect.
|
||||||
* **Left/Right** - remove selection.
|
* **Left/Right** - remove selection.
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ class HttpRequestType(Enum):
|
|||||||
ZAP = "zap?sRef="
|
ZAP = "zap?sRef="
|
||||||
INFO = "about"
|
INFO = "about"
|
||||||
SIGNAL = "tunersignal"
|
SIGNAL = "tunersignal"
|
||||||
|
STREAM = "streamcurrentm3u"
|
||||||
|
|
||||||
|
|
||||||
class TestException(Exception):
|
class TestException(Exception):
|
||||||
@@ -267,10 +268,15 @@ def http_request(host, port, user, password):
|
|||||||
url = base_url + HttpRequestType.INFO.value
|
url = base_url + HttpRequestType.INFO.value
|
||||||
elif req_type is HttpRequestType.SIGNAL:
|
elif req_type is HttpRequestType.SIGNAL:
|
||||||
url = base_url + HttpRequestType.SIGNAL.value
|
url = base_url + HttpRequestType.SIGNAL.value
|
||||||
|
elif req_type is HttpRequestType.STREAM:
|
||||||
|
url = base_url + HttpRequestType.STREAM.value
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with urlopen(url, timeout=5) as f:
|
with urlopen(url, timeout=5) as f:
|
||||||
yield json.loads(f.read().decode("utf-8"))
|
if req_type is HttpRequestType.STREAM:
|
||||||
|
yield f.read().decode("utf-8")
|
||||||
|
else:
|
||||||
|
yield json.loads(f.read().decode("utf-8"))
|
||||||
except (URLError, HTTPError):
|
except (URLError, HTTPError):
|
||||||
yield None
|
yield None
|
||||||
|
|
||||||
|
|||||||
@@ -1057,6 +1057,8 @@ class Application(Gtk.Application):
|
|||||||
elif ctrl and model_name == self._FAV_LIST_NAME:
|
elif ctrl and model_name == self._FAV_LIST_NAME:
|
||||||
if key is KeyboardKey.P:
|
if key is KeyboardKey.P:
|
||||||
self.on_play_stream()
|
self.on_play_stream()
|
||||||
|
if key is KeyboardKey.W:
|
||||||
|
self.on_zap(self.on_watch)
|
||||||
if key is KeyboardKey.Z:
|
if key is KeyboardKey.Z:
|
||||||
self.on_zap()
|
self.on_zap()
|
||||||
elif key is KeyboardKey.CTRL_L or key is KeyboardKey.CTRL_R:
|
elif key is KeyboardKey.CTRL_L or key is KeyboardKey.CTRL_R:
|
||||||
@@ -1368,19 +1370,37 @@ class Application(Gtk.Application):
|
|||||||
GLib.timeout_add_seconds(1, self.update_receiver_info)
|
GLib.timeout_add_seconds(1, self.update_receiver_info)
|
||||||
|
|
||||||
@run_idle
|
@run_idle
|
||||||
def on_zap(self):
|
def on_watch(self):
|
||||||
|
""" Switch to the channel and watch in the player """
|
||||||
|
m3u = self._http_api.send((HttpRequestType.STREAM, None))
|
||||||
|
next(self._http_api)
|
||||||
|
if m3u:
|
||||||
|
url = [s for s in m3u.split("\n") if not s.startswith("#")]
|
||||||
|
if url:
|
||||||
|
GLib.timeout_add_seconds(1, self.play, url[0])
|
||||||
|
|
||||||
|
@run_task
|
||||||
|
def on_zap(self, callback=None):
|
||||||
|
""" Switch(zap) the channel """
|
||||||
path, column = self._fav_view.get_cursor()
|
path, column = self._fav_view.get_cursor()
|
||||||
if not path or not self._http_api:
|
if not path or not self._http_api:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if self._player and self._player.is_playing():
|
||||||
|
self._player.stop()
|
||||||
|
|
||||||
row = self._fav_model[path][:]
|
row = self._fav_model[path][:]
|
||||||
srv = self._services.get(row[-2], None)
|
srv = self._services.get(row[-2], None)
|
||||||
if srv and srv.transponder:
|
if srv and srv.transponder:
|
||||||
ref = srv.picon_id.rstrip(".png").replace("_", ":")
|
ref = srv.picon_id.rstrip(".png").replace("_", ":")
|
||||||
|
|
||||||
req = self._http_api.send((HttpRequestType.ZAP, ref))
|
req = self._http_api.send((HttpRequestType.ZAP, ref))
|
||||||
next(self._http_api)
|
next(self._http_api)
|
||||||
if req and req.get("result", False):
|
if req and req.get("result", False):
|
||||||
GLib.timeout_add_seconds(2, self.update_service_info)
|
GLib.timeout_add_seconds(2, self.update_service_info)
|
||||||
|
GLib.idle_add(scroll_to, path, self._fav_view)
|
||||||
|
if callback is not None:
|
||||||
|
callback()
|
||||||
|
|
||||||
@run_task
|
@run_task
|
||||||
def update_receiver_info(self):
|
def update_receiver_info(self):
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ class KeyboardKey(Enum):
|
|||||||
X = 53
|
X = 53
|
||||||
C = 54
|
C = 54
|
||||||
V = 55
|
V = 55
|
||||||
|
W = 25
|
||||||
Z = 52
|
Z = 52
|
||||||
INSERT = 118
|
INSERT = 118
|
||||||
HOME = 110
|
HOME = 110
|
||||||
|
|||||||
Reference in New Issue
Block a user