Add notif flyout js for Big Lda

This commit is contained in:
lda
2026-05-13 21:41:23 +07:00 Verified
parent e7e92eb111
commit c22b4f6952
3 changed files with 44 additions and 7 deletions
+26 -5
View File
@@ -1,12 +1,19 @@
from pathlib import Path
import random
import time
from typing import TYPE_CHECKING, cast
from playwright.sync_api import (
sync_playwright,
TimeoutError as PlaywrightTimeoutError,
Error as PlaywrightError,
)
from plyer import notification # type: ignore
if TYPE_CHECKING:
from plyer.facades import Notification
notification: Notification
CHROME_DATA_DIR = Path(__file__).parent / "chrome-data-dir"
CHROME_DATA_DIR.mkdir(exist_ok=True)
@@ -21,6 +28,18 @@ def launch_context(p, *, headless: bool):
)
def print_and_notif(msg: str, title: str = "Endfield Login"):
print(f"{title}: {msg}")
notification.notify(
title=title,
message=msg,
app_name="lda's Endfield Login", # this shit doesnt work! always "python"
ticker=msg,
timeout=5,
)
def main():
with sync_playwright() as p:
context = launch_context(p, headless=True)
@@ -36,7 +55,9 @@ def main():
while time.time() < deadline:
# need manual login
if login_form.first.is_visible():
print("Please log in manually, then close the browser window.")
print_and_notif(
"Please log in manually, then close the browser window."
)
context.close()
@@ -51,10 +72,10 @@ def main():
timeout=LOGIN_TIMEOUT_MS,
)
print("Browser closed. Please rerun the script.")
print_and_notif("Browser closed. Please rerun the script.")
except PlaywrightTimeoutError:
print("Login timeout reached.")
print_and_notif("Login timeout reached.")
headful.close()
break
@@ -67,7 +88,7 @@ def main():
delay=random.randint(100, 300),
)
print("clicked")
print_and_notif("Login successful.")
break
except (PlaywrightTimeoutError, PlaywrightError) as e:
@@ -77,7 +98,7 @@ def main():
"intercepts pointer events" in msg
and "completed-overlay" in msg
):
print("Work already completed elsewhere.")
print_and_notif("Work already completed elsewhere.")
break
raise # re-raise other exceptions
+4 -1
View File
@@ -4,7 +4,10 @@ version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.14"
dependencies = ["playwright>=1.59.0"]
dependencies = [
"playwright>=1.59.0",
"plyer>=2.1.0",
]
[tool.uv]
package = true
Generated
+14 -1
View File
@@ -54,10 +54,23 @@ version = "0.1.0"
source = { editable = "." }
dependencies = [
{ name = "playwright" },
{ name = "plyer" },
]
[package.metadata]
requires-dist = [{ name = "playwright", specifier = ">=1.59.0" }]
requires-dist = [
{ name = "playwright", specifier = ">=1.59.0" },
{ name = "plyer", specifier = ">=2.1.0" },
]
[[package]]
name = "plyer"
version = "2.1.0"
source = { registry = "https://pypi.org/simple" }
sdist = { url = "https://files.pythonhosted.org/packages/20/85/f61425aa9be1f9108eec1c13861c1e11c9a04eb786eb4832a8f7188317df/plyer-2.1.0.tar.gz", hash = "sha256:65b7dfb7e11e07af37a8487eb2aa69524276ef70dad500b07228ce64736baa61", size = 121371, upload-time = "2022-11-12T13:36:48.978Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/d3/89/a41c2643fc8eabeb84791acb9d0e4d139b1e4b53473cc4dae947b5fa33ed/plyer-2.1.0-py2.py3-none-any.whl", hash = "sha256:1b1772060df8b3045ed4f08231690ec8f7de30f5a004aa1724665a9074eed113", size = 142266, upload-time = "2022-11-12T13:36:47.181Z" },
]
[[package]]
name = "pyee"