OBSPlugin/main.py

78 lines
2.5 KiB
Python
Raw Normal View History

2023-11-25 13:49:41 +00:00
from src.backend.PluginManager.ActionBase import ActionBase
from src.backend.PluginManager.PluginBase import PluginBase
from src.backend.PluginManager.ActionHolder import ActionHolder
2023-11-25 13:49:41 +00:00
# Import gtk modules
import gi
gi.require_version("Gtk", "4.0")
gi.require_version("Adw", "1")
from gi.repository import Gtk, Adw, Gdk
import sys
import os
import threading
from datetime import timedelta
from loguru import logger as log
# Add plugin to sys.paths
sys.path.append(os.path.dirname(__file__))
from OBSActionBase import OBSActionBase
2024-01-14 10:50:34 +00:00
from actions.ToggleRecord.ToggleRecord import ToggleRecord
from actions.RecPlayPause.RecPlayPause import RecPlayPause
2024-03-26 14:30:17 +00:00
from actions.SwitchScene.SwitchScene import SwitchScene
2023-11-25 13:49:41 +00:00
class OBS(PluginBase):
def __init__(self):
super().__init__()
2024-01-14 10:50:34 +00:00
# Launch backend
print("launch backend")
2024-03-27 09:06:28 +00:00
self.launch_backend(os.path.join(self.PATH, "backend", "backend.py"), os.path.join(self.PATH, "backend", ".venv"), open_in_terminal=False)
print("backend launched")
self.lm = self.locale_manager
self.lm.set_to_os_default()
self.register(
plugin_name=self.lm.get("plugin.name"),
2024-03-09 12:50:43 +00:00
github_repo="https://github.com/StreamController/OBSPlugin",
plugin_version="1.0.0",
app_version="1.0.0-alpha",
)
toggle_record_action_holder = ActionHolder(
plugin_base=self,
action_base=ToggleRecord,
2024-03-26 14:33:54 +00:00
action_id="com_core447_OBSPlugin::ToggleRecord",
action_name=self.lm.get("actions.toggle-record.name")
)
self.add_action_holder(toggle_record_action_holder)
rec_play_pause_action_holder = ActionHolder(
plugin_base=self,
action_base=RecPlayPause,
2024-03-26 14:33:54 +00:00
action_id="com_core447_OBSPlugin::RecPlayPause",
action_name=self.lm.get("actions.rec-play-pause.name")
)
self.add_action_holder(rec_play_pause_action_holder)
2023-11-25 13:49:41 +00:00
2024-03-26 14:30:17 +00:00
switch_scene_action_holder = ActionHolder(
plugin_base=self,
action_base=SwitchScene,
2024-03-26 14:33:54 +00:00
action_id="com_core447_OBSPlugin::SwitchScene",
2024-03-26 14:30:17 +00:00
action_name=self.lm.get("actions.switch-scene.name")
)
self.add_action_holder(switch_scene_action_holder)
2023-11-25 13:49:41 +00:00
# Load custom css
2024-04-20 07:02:00 +00:00
self.add_css_stylesheet(os.path.join(self.PATH, "style.css"))
def get_connected(self):
try:
return self.backend.get_connected()
except Exception as e:
log.error(e)
return False