Initial commit
This commit is contained in:
commit
afda90bb0e
16 changed files with 396 additions and 0 deletions
7
.gitignore
vendored
Normal file
7
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
__pycache__
|
||||
device_id
|
||||
status
|
||||
start.bat
|
||||
status
|
||||
test.py
|
||||
geckodriver.log
|
||||
5
.vscode/settings.json
vendored
Normal file
5
.vscode/settings.json
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"files.associations": {
|
||||
"*.star": "python"
|
||||
}
|
||||
}
|
||||
58
dynamic_star.py
Normal file
58
dynamic_star.py
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
import os
|
||||
import subprocess
|
||||
|
||||
STARTUP_INFO = subprocess.STARTUPINFO()
|
||||
STARTUP_INFO.dwFlags |= subprocess.STARTF_USESHOWWINDOW
|
||||
|
||||
TEMPLATE = '''
|
||||
load("render.star", "render")
|
||||
load("encoding/base64.star", "base64")
|
||||
|
||||
def main():
|
||||
return render.Root(
|
||||
max_age=60,
|
||||
delay=125,
|
||||
child=render.Marquee(
|
||||
height=32,
|
||||
offset_start = 32,
|
||||
offset_end = 32,
|
||||
scroll_direction="vertical",
|
||||
child=render.WrappedText("""<TEMP>""", width=60)
|
||||
)
|
||||
)
|
||||
'''
|
||||
|
||||
|
||||
def _abp(path: str) -> str:
|
||||
path_root = os.path.realpath(__file__).replace("dynamic_star.py", "")
|
||||
return f"{path_root}\\{path}"
|
||||
|
||||
|
||||
def _render():
|
||||
subprocess.Popen(
|
||||
[_abp("pixlet.exe"), "render", _abp("splatoon_dynamic.star")],
|
||||
startupinfo=STARTUP_INFO,
|
||||
).wait()
|
||||
|
||||
|
||||
def _display():
|
||||
with open(_abp("device_id"), "r", encoding="utf-8") as file_handle:
|
||||
device_id = file_handle.read()
|
||||
subprocess.Popen(
|
||||
[
|
||||
_abp("pixlet.exe"),
|
||||
"push",
|
||||
"--installation-id",
|
||||
"SalmonRun",
|
||||
device_id,
|
||||
_abp("splatoon_dynamic.webp"),
|
||||
],
|
||||
startupinfo=STARTUP_INFO,
|
||||
).wait()
|
||||
|
||||
|
||||
def show_text(text: str) -> None:
|
||||
with open(_abp("splatoon_dynamic.star"), "w", encoding="utf-8") as file_handle:
|
||||
file_handle.write(TEMPLATE.replace("<TEMP>", text))
|
||||
_render()
|
||||
_display()
|
||||
139
main.py
Normal file
139
main.py
Normal file
|
|
@ -0,0 +1,139 @@
|
|||
import json
|
||||
import os
|
||||
import subprocess
|
||||
from dynamic_star import show_text
|
||||
from time import sleep
|
||||
from typing import List
|
||||
from dataclasses import dataclass
|
||||
from bs4 import BeautifulSoup
|
||||
from pywinauto import Desktop
|
||||
from selenium import webdriver
|
||||
from selenium.webdriver.firefox.options import Options
|
||||
|
||||
path_root = os.path.realpath(__file__).replace("main.py", "")
|
||||
|
||||
|
||||
@dataclass
|
||||
class SalmonRunEvent:
|
||||
date: str
|
||||
stage_name: str
|
||||
loadout: str
|
||||
rewards: str
|
||||
|
||||
|
||||
def abp(path: str) -> str:
|
||||
return f"{path_root}\\{path}"
|
||||
|
||||
|
||||
def display(file_name: str):
|
||||
with open(abp("device_id"), "r", encoding="utf-8") as file_handle:
|
||||
device_id = file_handle.read()
|
||||
startupinfo = subprocess.STARTUPINFO()
|
||||
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
|
||||
subprocess.Popen(
|
||||
[abp("pixlet.exe"), "push", device_id, abp(file_name)], startupinfo=startupinfo
|
||||
).wait()
|
||||
|
||||
|
||||
def get_salmon_run_data() -> List[SalmonRunEvent]:
|
||||
"""Scrapes salmon run data"""
|
||||
options = Options()
|
||||
options.add_argument("--headless")
|
||||
|
||||
driver = webdriver.Firefox(options=options)
|
||||
driver.get("https://splatoon.oatmealdome.me/three/salmon-run")
|
||||
|
||||
page_source = driver.page_source
|
||||
page_source = BeautifulSoup(page_source, features="html.parser")
|
||||
main_entry = page_source.body.find("main", attrs={"role": "main"}).find(
|
||||
"div", attrs={"class": "d-grid gap-3"}
|
||||
)
|
||||
|
||||
# The row where the datetime is shown when the evt. will occur
|
||||
times = [
|
||||
x.text.strip()
|
||||
for x in main_entry.find_all("div", attrs={"class": "d-flex flex-row"})
|
||||
]
|
||||
# The row where the actual Salmon Run loadout & reward is
|
||||
events: List[BeautifulSoup] = main_entry.find_all(
|
||||
"div", attrs={"class": "bg-salmon-run"}
|
||||
)
|
||||
|
||||
data = []
|
||||
|
||||
for idx, evt in enumerate(events):
|
||||
time = times[idx]
|
||||
stage_name = evt.find("span", attrs={"class": "text-stage-name"}).text
|
||||
|
||||
event_root = evt.find("div", attrs={"class": "col d-flex flex-column"})
|
||||
|
||||
# Get the photos of the loadout, then lean on the `title` attr
|
||||
loadout_pic_els = event_root.find("div", attrs={"class": "row gx-2"}).find_all(
|
||||
"picture"
|
||||
)
|
||||
loadout = [x.find("img").attrs["title"] for x in loadout_pic_els]
|
||||
|
||||
# Get the photos of the reward, then lean on the `title` attr
|
||||
reward_pic_els = event_root.find(
|
||||
"div", attrs={"class": "row mt-3 gx-2"}
|
||||
).find_all("picture")
|
||||
rewards = [x.find("img").attrs["title"] for x in reward_pic_els]
|
||||
|
||||
data.append(
|
||||
SalmonRunEvent(time, stage_name, ", ".join(loadout), ", ".join(rewards))
|
||||
)
|
||||
|
||||
driver.close()
|
||||
return data
|
||||
|
||||
|
||||
def main():
|
||||
desktop = Desktop()
|
||||
|
||||
salmon_runs = get_salmon_run_data()
|
||||
text = []
|
||||
for event in salmon_runs:
|
||||
# Display the event for a bit, then sleep
|
||||
text.append(
|
||||
f"""{event.date}\n\nSTAGE:\n{event.stage_name}\n\nLOADOUT:\n{event.loadout}\n\nREWARD(S):\n{event.rewards}"""
|
||||
)
|
||||
# show_text(
|
||||
# f"{event.date}: {event.stage_name}",
|
||||
# f"Loadout: {event.loadout} | Rewards: {event.rewards}",
|
||||
# )
|
||||
# sleep(60)
|
||||
|
||||
show_text("\n-------\n\n".join(text))
|
||||
return
|
||||
|
||||
# print(json.dumps(get_salmon_run_data(), indent=2))
|
||||
# return
|
||||
while True:
|
||||
try:
|
||||
windows = list(
|
||||
filter(lambda x: x, [w.window_text() for w in desktop.windows()])
|
||||
)
|
||||
|
||||
if "Zoom Meeting" in windows:
|
||||
display("zoom/meeting.webp")
|
||||
sleep(16)
|
||||
elif "obs64" in windows:
|
||||
with open(abp("status"), "r", encoding="utf-8") as file_handle:
|
||||
data = json.loads(file_handle.read())
|
||||
if data["STREAMING"]:
|
||||
display("streaming/active.webp")
|
||||
sleep(10)
|
||||
elif data["RECORDING"]:
|
||||
display("recording/active.webp")
|
||||
sleep(12)
|
||||
else:
|
||||
display("recording/paused.webp")
|
||||
sleep(10)
|
||||
else:
|
||||
sleep(1)
|
||||
except KeyboardInterrupt:
|
||||
print("Quitting...")
|
||||
break
|
||||
|
||||
|
||||
main()
|
||||
28
obs_hook.py
Normal file
28
obs_hook.py
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import json
|
||||
|
||||
status = {"STREAMING": False, "RECORDING": False}
|
||||
|
||||
|
||||
def on_event(event):
|
||||
if event == obspython.OBS_FRONTEND_EVENT_RECORDING_STARTED:
|
||||
status["RECORDING"] = True
|
||||
__write()
|
||||
if event == obspython.OBS_FRONTEND_EVENT_RECORDING_STOPPED:
|
||||
status["RECORDING"] = False
|
||||
__write()
|
||||
if event == obspython.OBS_FRONTEND_EVENT_STREAMING_STARTED:
|
||||
status["STREAMING"] = True
|
||||
__write()
|
||||
if event == obspython.OBS_FRONTEND_EVENT_STREAMING_STOPPED:
|
||||
status["STREAMING"] = False
|
||||
__write()
|
||||
|
||||
|
||||
def __write():
|
||||
with open("C:\\Users\\Jose\\Documents\\Tidbyt\\status", "w") as fh:
|
||||
fh.write(json.dumps(status))
|
||||
|
||||
|
||||
def script_load(settings):
|
||||
__write()
|
||||
obspython.obs_frontend_add_event_callback(on_event)
|
||||
BIN
pixlet.exe
Normal file
BIN
pixlet.exe
Normal file
Binary file not shown.
21
recording/active.star
Normal file
21
recording/active.star
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
load("render.star", "render")
|
||||
load("encoding/base64.star", "base64")
|
||||
|
||||
|
||||
ICON = base64.decode(
|
||||
"UklGRl4AAABXRUJQVlA4TFEAAAAvD8ADEBcgEEhy2p9tDYFAkr/LjAsEkpz2Z3v+A/4VMGojyVFrnwNl+GxEsyT2Hy4X0MMQ0f/QNAnUIUywt13+puHEyP+bhr/t8gnWIQikaQIA"
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
return render.Root(
|
||||
child=render.Column(
|
||||
expanded=True,
|
||||
main_align="space_around",
|
||||
cross_align="center",
|
||||
children=[
|
||||
render.Image(src=ICON),
|
||||
render.Marquee(width=64, child=render.Text("Now Recording :)")),
|
||||
],
|
||||
)
|
||||
)
|
||||
BIN
recording/active.webp
Normal file
BIN
recording/active.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 13 KiB |
23
recording/paused.star
Normal file
23
recording/paused.star
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
load("render.star", "render")
|
||||
load("encoding/base64.star", "base64")
|
||||
|
||||
|
||||
ICON = base64.decode(
|
||||
"UklGRlQAAABXRUJQVlA4TEcAAAAvD8ADEBcgEEhy2p9tDYFAkr/LjAsEkpz2Z3v+A/4VqIkkRdoiRAoqUbExITU279EQ0f/QpARqiIFcuw42/7XrDGRDCKRJAQA="
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
return render.Root(
|
||||
child=render.Column(
|
||||
expanded=True,
|
||||
main_align="space_around",
|
||||
cross_align="center",
|
||||
children=[
|
||||
render.Image(src=ICON),
|
||||
render.Marquee(
|
||||
width=64, child=render.Text("Taking a break between recordings (?)")
|
||||
),
|
||||
],
|
||||
)
|
||||
)
|
||||
BIN
recording/paused.webp
Normal file
BIN
recording/paused.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 25 KiB |
73
splatoon_dynamic.star
Normal file
73
splatoon_dynamic.star
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
|
||||
load("render.star", "render")
|
||||
load("encoding/base64.star", "base64")
|
||||
|
||||
def main():
|
||||
return render.Root(
|
||||
max_age=60,
|
||||
delay=125,
|
||||
child=render.Marquee(
|
||||
height=32,
|
||||
offset_start = 32,
|
||||
offset_end = 32,
|
||||
scroll_direction="vertical",
|
||||
child=render.WrappedText("""Nov 5, 2022, 11:00 AM - Nov 7, 2022, 2:00 AM
|
||||
|
||||
STAGE:
|
||||
Spawning Grounds
|
||||
|
||||
LOADOUT:
|
||||
Sploosh-o-matic, Luna Blaster, Undercover Brella, Splat Charger
|
||||
|
||||
REWARD(S):
|
||||
Brain Strainer
|
||||
-------
|
||||
|
||||
Nov 7, 2022, 2:00 AM - Nov 8, 2022, 6:00 PM
|
||||
|
||||
STAGE:
|
||||
Sockeye Station
|
||||
|
||||
LOADOUT:
|
||||
Splat Roller, Dualie Squelchers, Nautilus 47, Heavy Splatling
|
||||
|
||||
REWARD(S):
|
||||
Brain Strainer
|
||||
-------
|
||||
|
||||
Nov 8, 2022, 6:00 PM - Nov 10, 2022, 10:00 AM
|
||||
|
||||
STAGE:
|
||||
Gone Fission Hydroplant
|
||||
|
||||
LOADOUT:
|
||||
Tri-Slosher, L-3 Nozzlenose, Splat Brella, .96 Gal
|
||||
|
||||
REWARD(S):
|
||||
Brain Strainer
|
||||
-------
|
||||
|
||||
Nov 10, 2022, 10:00 AM - Nov 12, 2022, 2:00 AM
|
||||
|
||||
STAGE:
|
||||
Spawning Grounds
|
||||
|
||||
LOADOUT:
|
||||
Splattershot Jr., Sloshing Machine, Range Blaster, Goo Tuber
|
||||
|
||||
REWARD(S):
|
||||
Brain Strainer
|
||||
-------
|
||||
|
||||
Nov 12, 2022, 2:00 AM - Nov 13, 2022, 6:00 PM
|
||||
|
||||
STAGE:
|
||||
Sockeye Station
|
||||
|
||||
LOADOUT:
|
||||
Splat Dualies, Carbon Roller, Splattershot Pro, Splat Charger
|
||||
|
||||
REWARD(S):
|
||||
Brain Strainer""", width=60)
|
||||
)
|
||||
)
|
||||
BIN
splatoon_dynamic.webp
Normal file
BIN
splatoon_dynamic.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 91 KiB |
21
streaming/active.star
Normal file
21
streaming/active.star
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
load("render.star", "render")
|
||||
load("encoding/base64.star", "base64")
|
||||
|
||||
|
||||
ICON = base64.decode(
|
||||
"UklGRlgAAABXRUJQVlA4TEsAAAAvD8ADEBcgEEiy259oDSFBwv/oYed//gP+AmoiWa3eUCIFP/n28REdqSiZ0xkREf0PpUugC5bgBVGtBa3BWX9rVGtRm8iHXzCBlC4A"
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
return render.Root(
|
||||
child=render.Column(
|
||||
expanded=True,
|
||||
main_align="space_around",
|
||||
cross_align="center",
|
||||
children=[
|
||||
render.Image(src=ICON),
|
||||
render.Marquee(width=64, child=render.Text("Now Streaming")),
|
||||
],
|
||||
)
|
||||
)
|
||||
BIN
streaming/active.webp
Normal file
BIN
streaming/active.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 184 B |
21
zoom/meeting.star
Normal file
21
zoom/meeting.star
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
load("render.star", "render")
|
||||
load("encoding/base64.star", "base64")
|
||||
|
||||
|
||||
ICON = base64.decode(
|
||||
"UklGRmAAAABXRUJQVlA4TFMAAAAvD8ADEBcgEEiC33sNgUCS2f5UCwkS/g+2Ov8B/woYtY0kqTTPhtJ8isNoUAyJ/s/eu+G5HCL6H1ohgSa0BfFCdl85XN+wf/W9rnwhF8SEJpBWCAA="
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
return render.Root(
|
||||
child=render.Column(
|
||||
expanded=True,
|
||||
main_align="space_around",
|
||||
cross_align="center",
|
||||
children=[
|
||||
render.Image(src=ICON),
|
||||
render.Marquee(width=64, child=render.Text("In a Zoom Meeting")),
|
||||
],
|
||||
)
|
||||
)
|
||||
BIN
zoom/meeting.webp
Normal file
BIN
zoom/meeting.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
Loading…
Reference in a new issue