-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathytembed.py
60 lines (52 loc) · 1.56 KB
/
ytembed.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import webview
import sys
import os
if "win" in sys.platform or os.name == "nt":
import ctypes
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(
"damusss.milimp_yt_embed.1.0"
)
link = sys.argv[1]
window = webview.create_window(
"MILIMP YT Embed",
link,
frameless=True,
on_top=True,
)
def update():
last = None
while True:
data = sys.stdin.readline().strip()
if data == "kill":
os.abort()
if not data:
continue
if data == last:
continue
last = data
if data == "show":
window.on_top = True
window.show()
window.restore()
elif data == "hide":
window.on_top = False
window.hide()
window.minimize()
elif data.startswith("newurl:"):
url = data.removeprefix("newurl:")
window.load_url(url)
elif data.startswith("html:"):
html = data.removeprefix("html:")
window.load_html(html)
elif data.startswith("nums"):
data = data.removeprefix("nums")
x, y, w, h = data.split(",")
x, y, w, h = [float(v) for v in (x, y, w, h)]
if w != window.width or h != window.height:
window.resize(int(w), int(h))
if x != window.x or h != window.y:
window.move(int(x), int(y))
webview.start(
update,
user_agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
)