Updated impls

This commit is contained in:
oitsjustjose 2024-12-11 18:24:08 -06:00
commit 8a7260e48e
5 changed files with 64 additions and 17 deletions

View file

@ -13,6 +13,7 @@ fastapi==0.115.6
fastapi-cli==0.0.6
h11==0.14.0
httpcore==1.0.7
httptools==0.6.4
httpx==0.28.1
idna==3.4
Jinja2==3.1.4
@ -20,11 +21,15 @@ markdown-it-py==3.0.0
MarkupSafe==3.0.2
mdurl==0.1.2
outcome==1.2.0
packaging==24.2
psutil==6.1.0
pycparser==2.21
pydantic==2.10.3
pydantic_core==2.27.1
Pygments==2.18.0
python-dateutil==2.8.2
python-dotenv==1.0.1
PyYAML==6.0.2
requests==2.28.1
rich==13.9.4
rich-toolkit==0.12.0
@ -39,5 +44,7 @@ typer==0.15.1
typing_extensions==4.12.2
urllib3==1.26.12
uvicorn==0.32.1
uvloop==0.21.0
watchfiles==1.0.3
websockets==14.1
wsproto==1.2.0

9
src/common/appstate.py Normal file
View file

@ -0,0 +1,9 @@
from enum import Enum
class AppState(Enum):
IDLE = 0
MEETING = 1
OBS_PAUSED = 2
OBS_RECORDING = 3
OBS_STREAMING = 4

12
src/desktop/main.py Normal file
View file

@ -0,0 +1,12 @@
from os import getenv
import psutil
def main() -> None:
backend_uri = getenv("TIDBYT_SERVER_URI", "http://172.16.1.6")
for p in psutil.process_iter():
print(p)
if __name__ == "__main__":
main()

31
src/desktop/obs_hooks.py Normal file
View file

@ -0,0 +1,31 @@
import urllib.request
from os import getenv
from common.appstate import AppState
def on_event(event):
state: AppState = AppState.IDLE
backend_uri = getenv("TIDBYT_SERVER_URI", "http://172.16.1.6")
if event == obspython.OBS_FRONTEND_EVENT_RECORDING_STARTED:
state = AppState.OBS_RECORDING
elif event == obspython.OBS_FRONTEND_EVENT_STREAMING_STARTED:
state = AppState.OBS_STREAMING
elif (
event == obspython.OBS_FRONTEND_EVENT_RECORDING_STOPPED
or event == obspython.OBS_FRONTEND_EVENT_STREAMING_STOPPED
):
state = AppState.OBS_PAUSED
urllib.request.urlopen(f"{backend_uri}?new_state={state.value}")
def script_load(_):
obspython.obs_frontend_add_event_callback(on_event)
def script_unload():
backend_uri = getenv("TIDBYT_SERVER_URI", "http://172.16.1.6")
urllib.request.urlopen(f"{backend_uri}?new_state={AppState.IDLE.value}")

View file

@ -1,4 +1,3 @@
from enum import Enum
from pathlib import Path
from threading import Thread
from time import sleep
@ -8,16 +7,7 @@ from pixlet import PixletHelper
from renderables import Renderable
from renderables.forgeserv import ForgeServ
class AppState(Enum):
IDLE = 0
MEETING = 1
OBS_PAUSED = 2
OBS_RECORDING = 3
OBS_STREAMING = 4
ROOT = Path("./")
from common.appstate import AppState
class StateManager:
@ -30,17 +20,15 @@ class StateManager:
self.state: AppState = AppState.IDLE
self.renderables: Dict[AppState, Renderable] = {
AppState.IDLE: ForgeServ(),
AppState.MEETING: Renderable(
ROOT.joinpath("templates/meeting.star").resolve()
),
AppState.MEETING: Renderable(Path("./templates/meeting.star").resolve()),
AppState.OBS_PAUSED: Renderable(
ROOT.joinpath("templates/obs/paused.star").resolve()
Path("./templates/obs/paused.star").resolve()
),
AppState.OBS_RECORDING: Renderable(
ROOT.joinpath("templates/obs/recording.star").resolve()
Path("./templates/obs/recording.star").resolve()
),
AppState.OBS_STREAMING: Renderable(
ROOT.joinpath("templates/obs/streaming.star").resolve()
Path("./templates/obs/streaming.star").resolve()
),
}
# Thread related activities & vars