예제 #1
0
    def run(self):
        # Webview needs to be run in the MainThread.

        # Prepare for version 2.3 before calling create_window(), which might block forever.
        self.display_window = webview
        # Since webview.create_window might take exclusive and permanent lock on the main thread,
        # we need to start this wait_load function before we start webview itself.
        if "webview_ready" in dir(webview):
            threading.Thread(
                target=lambda: (webview.webview_ready(), load_idle())
            ).start()

        window = webview.create_window(
            title="Jellyfin MPV Shim Mirror", js_api=helpers, fullscreen=True
        )
        if window is not None:
            # It returned a Window object instead of blocking, we're running on 3.2 (or compatible)
            self.display_window = window
            self.webview = window

            # 3.2's .loaded event runs every time a new DOM is loaded as well, so not suitable for this purpose
            # However, 3.2's load_html waits for the DOM to be ready, so we can completely skip
            # waiting for that ourselves.
            threading.Thread(target=load_idle).start()

            webview.start()
예제 #2
0
    def get_cookies():
        timeout = 120

        def is_logged_in():
            return webview.evaluate_js(
                "document.querySelector('#logout-btn') !== null")

        while not webview.webview_ready() or not is_logged_in():
            time.sleep(1)
            timeout -= 1
            if timeout == 0:
                raise AuthenticationFailed("Can't login, timeout exceeded.")
            if not webview.window_exists():
                raise AuthenticationFailed(
                    "Webview window closed prematurely.")

        cookies = webview.evaluate_js("document.cookie")
        webview.destroy_window()
        return cookies
예제 #3
0
 def _no_resize(webview):
     assert webview.webview_ready(10)
     destroy_event.set()
예제 #4
0
def bg_color():
    child_window = webview.create_window('Window #2', background_color='#0000FF')
    assert child_window != 'MainWindow'
    webview.webview_ready()
    webview.destroy_window(child_window)
예제 #5
0
 def _bg_color(webview):
     child_window = webview.create_window('Window #2', background_color='#0000FF')
     webview.webview_ready()
     webview.destroy_window(child_window)
     destroy_event.set()
예제 #6
0
 def _fullscreen(webview):
     assert webview.webview_ready(10)
     destroy_event.set()
 def _localization(webview):
     assert webview.webview_ready(10)
     destroy_event.set()
예제 #8
0
 def _simple_browser(webview):
     assert webview.webview_ready(10)
     destroy_event.set()
예제 #9
0
def bg_color():
    child_window = webview.create_window('Window #2', background_color='#0000FF')
    assert child_window != 'MainWindow'
    webview.webview_ready()
    webview.destroy_window(child_window)