mirror of
https://github.com/DYefremov/DemonEditor.git
synced 2025-12-21 16:09:41 +01:00
small rework of screenshot mode
This commit is contained in:
@@ -51,7 +51,7 @@ class HttpRequestType(Enum):
|
||||
PLAYER_PREV = "mediaplayercmd?command=previous"
|
||||
PLAYER_STOP = "mediaplayercmd?command=stop"
|
||||
PLAYER_REMOVE = "mediaplayerremove?file="
|
||||
GRUB = "grab?format=jpg&mode="
|
||||
GRUB = "grab?format=jpg&"
|
||||
|
||||
|
||||
class TestException(Exception):
|
||||
@@ -329,6 +329,7 @@ class HttpAPI:
|
||||
self._main_url = None
|
||||
self._base_url = None
|
||||
self._data = None
|
||||
self._is_owif = True
|
||||
self.init()
|
||||
|
||||
from concurrent.futures import ThreadPoolExecutor as PoolExecutor
|
||||
@@ -339,18 +340,20 @@ class HttpAPI:
|
||||
return
|
||||
|
||||
url = self._base_url + req_type.value
|
||||
data = self._data
|
||||
|
||||
if req_type is HttpRequestType.ZAP or req_type is HttpRequestType.STREAM:
|
||||
url += urllib.parse.quote(ref)
|
||||
elif req_type is HttpRequestType.PLAY or req_type is HttpRequestType.PLAYER_REMOVE:
|
||||
url += "{}{}".format(ref_prefix, urllib.parse.quote(ref).replace("%3A", "%253A"))
|
||||
elif req_type is HttpRequestType.GRUB:
|
||||
data = None # Must be disabled for token-based security.
|
||||
url = "{}/{}{}".format(self._main_url, req_type.value, ref)
|
||||
|
||||
def done_callback(f):
|
||||
callback(f.result())
|
||||
|
||||
future = self._executor.submit(get_response, req_type, url, self._data)
|
||||
future = self._executor.submit(get_response, req_type, url, data)
|
||||
future.add_done_callback(done_callback)
|
||||
|
||||
@run_task
|
||||
@@ -365,6 +368,19 @@ class HttpAPI:
|
||||
if s_id != "0":
|
||||
self._data = urllib.parse.urlencode({"user": user, "password": password, "sessionid": s_id}).encode("utf-8")
|
||||
|
||||
self.send(HttpRequestType.INFO, None, self.init_callback)
|
||||
|
||||
def init_callback(self, info):
|
||||
if info:
|
||||
version = info.get("e2webifversion", "").upper()
|
||||
self._is_owif = "OWIF" in version
|
||||
log("HTTP API initialized. Web Interface version: {}".format(version))
|
||||
|
||||
@property
|
||||
def is_owif(self):
|
||||
""" Returns true if the web interface is OpenWebif. """
|
||||
return self._is_owif
|
||||
|
||||
@run_task
|
||||
def close(self):
|
||||
self._shutdown = True
|
||||
|
||||
@@ -2246,13 +2246,13 @@ class Application(Gtk.Application):
|
||||
# ******************** Screenshots ************************#
|
||||
|
||||
def on_screenshot_all(self, action, value=None):
|
||||
self._http_api.send(HttpRequestType.GRUB, "all", self.on_screenshot)
|
||||
self._http_api.send(HttpRequestType.GRUB, "mode=all" if self._http_api.is_owif else "d=", self.on_screenshot)
|
||||
|
||||
def on_screenshot_video(self, action, value=None):
|
||||
self._http_api.send(HttpRequestType.GRUB, "video", self.on_screenshot)
|
||||
self._http_api.send(HttpRequestType.GRUB, "mode=video" if self._http_api.is_owif else "v=", self.on_screenshot)
|
||||
|
||||
def on_screenshot_osd(self, action, value=None):
|
||||
self._http_api.send(HttpRequestType.GRUB, "osd", self.on_screenshot)
|
||||
self._http_api.send(HttpRequestType.GRUB, "mode=osd" if self._http_api.is_owif else "o=", self.on_screenshot)
|
||||
|
||||
def on_screenshot(self, data):
|
||||
if "error_code" in data:
|
||||
|
||||
Reference in New Issue
Block a user