]> skyeroc.xyz Git - obs-ctl/commitdiff
mov OBSApp to its own file
authorsbkelley <sb24kelley@gmail.com>
Tue, 2 Dec 2025 18:03:04 +0000 (13:03 -0500)
committersbkelley <sb24kelley@gmail.com>
Tue, 2 Dec 2025 18:03:04 +0000 (13:03 -0500)
src/obs_ctl/__init__.py
src/obs_ctl/__main__.py
src/obs_ctl/app.py [new file with mode: 0644]
src/obs_ctl/data/__init__.py [new file with mode: 0644]
src/obs_ctl/interface/__init__.py
src/vscode_run_entrypoint.py

index 205d6cae02e44eb2fe3f48b44e26bd700f0b93fc..5aa63977a4c0ea95b3ce9d8328a2f79d4b276cf2 100644 (file)
@@ -1,107 +1,5 @@
-import importlib.resources
+from .app import OBSCtlApp
 
-from textual import on
-from textual.app import App
-from textual.containers import Vertical, Horizontal, ScrollableContainer
-from textual.widgets import Footer, Header, Placeholder, TabbedContent, TabPane
-
-from . import log, data
-from .interface import RecordControls, StatsDisplay, OBSSettingsPane, obs
-
-logger = log.getLogger(__name__)
-
-
-class OBSCtlApp(App):
-    CSS_PATH = importlib.resources.files(data).joinpath("layout.tcss")
-
-    def compose(self):
-        yield Header()
-        yield Footer()
-        yield obs.API(1, id="api")
-        logger.debug("Composing OBSCtlApp")
-        with ScrollableContainer(id="content_container"):
-            with Vertical(id="blocks_v_container", classes="blocks_containers"):
-                with Horizontal(id="blocks_h_container1", classes="blocks_h_containers"):
-                    yield RecordControls(id="record_controls")
-                    with TabbedContent(id="settings_container", classes="blocks"):
-                        with TabPane("OBS Settings", id="settings-tab"):
-                            yield OBSSettingsPane(id="settings-content")
-                        with TabPane("OBS Connection", id="connection-tab"):
-                            yield Placeholder("CONNECTION BLOCK", id="conection-plc")
-                        with TabPane("obs-ctl Settings", id="clients-tab"):
-                            yield Placeholder("CLIENT SETTINGS BLOCK", id="client-plc")
-                yield StatsDisplay(id="stats_display")
-
-
-    @on(obs.API.Report, "#api")
-    def on_api_report(self, message: obs.API.Report):
-        self.update_monitors(message.data)
-
-
-    @on(RecordControls.RecordStarted, "#record_controls")
-    def on_record_started(self, message: RecordControls.RecordStarted):
-        self._query_api("start_record")
-
-
-    @on(RecordControls.RecordStopped, "#record_controls")
-    def on_record_stopped(self, message: RecordControls.RecordStopped):
-        self._query_api("stop_record")
-
-
-    @on(RecordControls.StreamStarted, "#record_controls")
-    def on_stream_started(self, message: RecordControls.StreamStarted):
-        self._query_api("start_stream")
-
-
-    @on(RecordControls.StreamStopped, "#record_controls")
-    def on_stream_stopped(self, message: RecordControls.StreamStopped):
-        self._query_api("stop_stream")
-
-
-    @on(RecordControls.RecordPaused, "#record_controls")
-    def on_record_paused(self, message: RecordControls.RecordPaused):
-        self._query_api("start_pause")
-
-
-    @on(RecordControls.RecordUnpaused, "#record_controls")
-    def on_record_unpaused(self, message: RecordControls.RecordUnpaused):
-        self._query_api("stop_pause")
-
-
-    @on(RecordControls.OBSWSConnected, "#record_controls")
-    def on_obs_ws_connected(self, message: RecordControls.OBSWSConnected):
-        self._query_api("connect")
-    
-
-    @on(RecordControls.OBSWSDisconnected, "#record_controls")
-    def on_obs_ws_connected(self, message: RecordControls.OBSWSDisconnected):
-        self._query_api("disconnect")
-
-    
-    def _query_api(self, query: str, *args, **kwargs):
-        api: obs.API = self.query_exactly_one("#api")
-        getattr(api, query)(*args, **kwargs)
-
-
-    @on(OBSSettingsPane.RecordPathChanged, "#settings-content")
-    def on_settings_record_path_changed(self, message: OBSSettingsPane.RecordPathChanged):
-        api: obs.API = self.query_exactly_one("#api")
-        api.set_record_path(message.record_path)
-
-
-    def update_monitors(self, obs_stats: obs.OBSStats):
-        record_controls: RecordControls = self.query_exactly_one("#record_controls")
-        obs_settings: OBSSettingsPane = self.query_exactly_one("#settings-content")
-        stats_display: StatsDisplay = self.query_exactly_one("#stats_display")
-
-        record_controls.obsws_connected = obs_stats.obsws_connection_active
-        record_controls.streaming = obs_stats.stream_output_active
-        record_controls.recording = obs_stats.record_output_active
-        record_controls.paused = obs_stats.record_output_paused
-        obs_settings.record_path = obs_stats.record_directory
-        stats_display.update_text_readouts(obs_stats)
-
-
-def main():
+def run():
     app = OBSCtlApp()
     app.run()
\ No newline at end of file
index 878197ea700cc8243affc1e84c3bbcf11568a646..cd2562e77401309ce63163cc08cfd18b664de392 100644 (file)
@@ -1,4 +1,4 @@
-from . import main
+from . import run
 
 if __name__ == "__main__":
-    main()
\ No newline at end of file
+    run()
\ No newline at end of file
diff --git a/src/obs_ctl/app.py b/src/obs_ctl/app.py
new file mode 100644 (file)
index 0000000..5432ef7
--- /dev/null
@@ -0,0 +1,102 @@
+import importlib.resources
+
+from textual import on
+from textual.app import App
+from textual.containers import Vertical, Horizontal, ScrollableContainer
+from textual.widgets import Footer, Header, Placeholder, TabbedContent, TabPane
+
+from . import log, data
+from .interface import RecordControls, StatsDisplay, OBSSettingsPane, obs
+
+logger = log.getLogger(__name__)
+
+
+class OBSCtlApp(App):
+    CSS_PATH = importlib.resources.files(data).joinpath("layout.tcss")
+
+    def compose(self):
+        yield Header()
+        yield Footer()
+        yield obs.API(1, id="api")
+        logger.debug("Composing OBSCtlApp")
+        with ScrollableContainer(id="content_container"):
+            with Vertical(id="blocks_v_container", classes="blocks_containers"):
+                with Horizontal(id="blocks_h_container1", classes="blocks_h_containers"):
+                    yield RecordControls(id="record_controls")
+                    with TabbedContent(id="settings_container", classes="blocks"):
+                        with TabPane("OBS Settings", id="settings-tab"):
+                            yield OBSSettingsPane(id="settings-content")
+                        with TabPane("OBS Connection", id="connection-tab"):
+                            yield Placeholder("CONNECTION BLOCK", id="conection-plc")
+                        with TabPane("obs-ctl Settings", id="clients-tab"):
+                            yield Placeholder("CLIENT SETTINGS BLOCK", id="client-plc")
+                yield StatsDisplay(id="stats_display")
+
+
+    @on(obs.API.Report, "#api")
+    def on_api_report(self, message: obs.API.Report):
+        self.update_monitors(message.data)
+
+
+    @on(RecordControls.RecordStarted, "#record_controls")
+    def on_record_started(self, message: RecordControls.RecordStarted):
+        self._query_api("start_record")
+
+
+    @on(RecordControls.RecordStopped, "#record_controls")
+    def on_record_stopped(self, message: RecordControls.RecordStopped):
+        self._query_api("stop_record")
+
+
+    @on(RecordControls.StreamStarted, "#record_controls")
+    def on_stream_started(self, message: RecordControls.StreamStarted):
+        self._query_api("start_stream")
+
+
+    @on(RecordControls.StreamStopped, "#record_controls")
+    def on_stream_stopped(self, message: RecordControls.StreamStopped):
+        self._query_api("stop_stream")
+
+
+    @on(RecordControls.RecordPaused, "#record_controls")
+    def on_record_paused(self, message: RecordControls.RecordPaused):
+        self._query_api("start_pause")
+
+
+    @on(RecordControls.RecordUnpaused, "#record_controls")
+    def on_record_unpaused(self, message: RecordControls.RecordUnpaused):
+        self._query_api("stop_pause")
+
+
+    @on(RecordControls.OBSWSConnected, "#record_controls")
+    def on_obs_ws_connected(self, message: RecordControls.OBSWSConnected):
+        self._query_api("connect")
+    
+
+    @on(RecordControls.OBSWSDisconnected, "#record_controls")
+    def on_obs_ws_connected(self, message: RecordControls.OBSWSDisconnected):
+        self._query_api("disconnect")
+
+    
+    def _query_api(self, query: str, *args, **kwargs):
+        api: obs.API = self.query_exactly_one("#api")
+        getattr(api, query)(*args, **kwargs)
+
+
+    @on(OBSSettingsPane.RecordPathChanged, "#settings-content")
+    def on_settings_record_path_changed(self, message: OBSSettingsPane.RecordPathChanged):
+        api: obs.API = self.query_exactly_one("#api")
+        api.set_record_path(message.record_path)
+
+
+    def update_monitors(self, obs_stats: obs.OBSStats):
+        record_controls: RecordControls = self.query_exactly_one("#record_controls")
+        obs_settings: OBSSettingsPane = self.query_exactly_one("#settings-content")
+        stats_display: StatsDisplay = self.query_exactly_one("#stats_display")
+
+        record_controls.obsws_connected = obs_stats.obsws_connection_active
+        record_controls.streaming = obs_stats.stream_output_active
+        record_controls.recording = obs_stats.record_output_active
+        record_controls.paused = obs_stats.record_output_paused
+        obs_settings.record_path = obs_stats.record_directory
+        stats_display.update_text_readouts(obs_stats)
\ No newline at end of file
diff --git a/src/obs_ctl/data/__init__.py b/src/obs_ctl/data/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
index fc2366aa59d8ab36c07bbbbb9bb83e62e1f7cb63..0f114e1ae2ebd7d2c563710fcda75ded833581c4 100644 (file)
@@ -1,2 +1,3 @@
 """Provides RecordControls, OBSSettingsPane, and StatsDisplay to obs-ctl"""
-from .molecule import RecordControls, OBSSettingsPane, StatsDisplay
\ No newline at end of file
+from .molecule import RecordControls, OBSSettingsPane, StatsDisplay
+from . import obs
\ No newline at end of file
index e87038c8fcab39a583a8d20b2b0d5a30f20b9e0d..cbf11bab04f9f3cd6a5c5874a5b4f94f4a988d00 100644 (file)
@@ -1,3 +1,3 @@
 import obs_ctl
 
-obs_ctl.main()
\ No newline at end of file
+obs_ctl.run()
\ No newline at end of file