Add support for app version 0.1.1-alpha
This commit is contained in:
parent
a504a3f9af
commit
e0823734c9
|
@ -1,5 +1,8 @@
|
||||||
from src.backend.PluginManager.ActionBase import ActionBase
|
from src.backend.PluginManager.ActionBase import ActionBase
|
||||||
from src.backend.PluginManager.PluginBase import PluginBase
|
from src.backend.PluginManager.PluginBase import PluginBase
|
||||||
|
from src.backend.DeckManagement.DeckController import DeckController
|
||||||
|
from src.backend.PageManagement.Page import Page
|
||||||
|
from src.backend.PluginManager.PluginBase import PluginBase
|
||||||
|
|
||||||
# Import gtk modules
|
# Import gtk modules
|
||||||
import gi
|
import gi
|
||||||
|
@ -8,16 +11,18 @@ gi.require_version("Adw", "1")
|
||||||
from gi.repository import Gtk, Adw
|
from gi.repository import Gtk, Adw
|
||||||
|
|
||||||
class OBSActionBase(ActionBase):
|
class OBSActionBase(ActionBase):
|
||||||
def __init__(self, deck_controller, page, coords):
|
def __init__(self, action_id: str, action_name: str,
|
||||||
super().__init__(deck_controller=deck_controller, page=page, coords=coords)
|
deck_controller: "DeckController", page: Page, coords: str, plugin_base: PluginBase):
|
||||||
|
super().__init__(action_id=action_id, action_name=action_name,
|
||||||
|
deck_controller=deck_controller, page=page, coords=coords, plugin_base=plugin_base)
|
||||||
|
|
||||||
self.status_label = Gtk.Label(label="Couldn't connect to OBS", css_classes=["bold", "red"])
|
self.status_label = Gtk.Label(label=self.plugin_base.lm.get("actions.base.status.no-connection"), css_classes=["bold", "red"])
|
||||||
|
|
||||||
def get_config_rows(self) -> list:
|
def get_config_rows(self) -> list:
|
||||||
self.ip_entry = Adw.EntryRow(title="IP Address")
|
self.ip_entry = Adw.EntryRow(title=self.plugin_base.lm.get("actions.base.ip.label"))
|
||||||
self.port_spinner = Adw.SpinRow.new_with_range(0, 65535, 1)
|
self.port_spinner = Adw.SpinRow.new_with_range(0, 65535, 1)
|
||||||
self.port_spinner.set_title("Port:")
|
self.port_spinner.set_title(self.plugin_base.lm.get("actions.base.port.label"))
|
||||||
self.password_entry = Adw.PasswordEntryRow(title="Password")
|
self.password_entry = Adw.PasswordEntryRow(title=self.plugin_base.lm.get("actions.base.password.label"))
|
||||||
|
|
||||||
self.load_config_defaults()
|
self.load_config_defaults()
|
||||||
|
|
||||||
|
@ -29,7 +34,7 @@ class OBSActionBase(ActionBase):
|
||||||
return [self.ip_entry, self.port_spinner, self.password_entry]
|
return [self.ip_entry, self.port_spinner, self.password_entry]
|
||||||
|
|
||||||
def load_config_defaults(self):
|
def load_config_defaults(self):
|
||||||
settings = self.PLUGIN_BASE.get_settings()
|
settings = self.plugin_base.get_settings()
|
||||||
ip = settings.setdefault("ip", "localhost")
|
ip = settings.setdefault("ip", "localhost")
|
||||||
port = settings.setdefault("port", 4455)
|
port = settings.setdefault("port", 4455)
|
||||||
password = settings.setdefault("password", "")
|
password = settings.setdefault("password", "")
|
||||||
|
@ -39,39 +44,43 @@ class OBSActionBase(ActionBase):
|
||||||
self.port_spinner.set_value(port)
|
self.port_spinner.set_value(port)
|
||||||
self.password_entry.set_text(password)
|
self.password_entry.set_text(password)
|
||||||
|
|
||||||
self.PLUGIN_BASE.set_settings(settings)
|
self.plugin_base.set_settings(settings)
|
||||||
|
|
||||||
def on_change_ip(self, entry, *args):
|
def on_change_ip(self, entry, *args):
|
||||||
settings = self.PLUGIN_BASE.get_settings()
|
settings = self.plugin_base.get_settings()
|
||||||
settings["ip"] = entry.get_text()
|
settings["ip"] = entry.get_text()
|
||||||
self.PLUGIN_BASE.set_settings(settings)
|
self.plugin_base.set_settings(settings)
|
||||||
|
|
||||||
self.reconnect_obs()
|
self.reconnect_obs()
|
||||||
|
|
||||||
def on_change_port(self, spinner, *args):
|
def on_change_port(self, spinner, *args):
|
||||||
settings = self.PLUGIN_BASE.get_settings()
|
settings = self.plugin_base.get_settings()
|
||||||
settings["port"] = int(spinner.get_value())
|
settings["port"] = int(spinner.get_value())
|
||||||
self.PLUGIN_BASE.set_settings(settings)
|
self.plugin_base.set_settings(settings)
|
||||||
|
|
||||||
self.reconnect_obs()
|
self.reconnect_obs()
|
||||||
|
|
||||||
def on_change_password(self, entry, *args):
|
def on_change_password(self, entry, *args):
|
||||||
settings = self.PLUGIN_BASE.get_settings()
|
settings = self.plugin_base.get_settings()
|
||||||
settings["password"] = entry.get_text()
|
settings["password"] = entry.get_text()
|
||||||
self.PLUGIN_BASE.set_settings(settings)
|
self.plugin_base.set_settings(settings)
|
||||||
|
|
||||||
self.reconnect_obs()
|
self.reconnect_obs()
|
||||||
|
|
||||||
def reconnect_obs(self):
|
def reconnect_obs(self):
|
||||||
print("reconnecing obs")
|
print("reconnecing obs")
|
||||||
self.PLUGIN_BASE.backend.connect_to(host=self.PLUGIN_BASE.get_settings()["ip"], port=self.PLUGIN_BASE.get_settings()["port"], password=self.PLUGIN_BASE.get_settings()["password"], timeout=3, legacy=False)
|
self.plugin_base.backend.connect_to(
|
||||||
|
host=self.plugin_base.get_settings().get("ip"),
|
||||||
|
port=self.plugin_base.get_settings().get("port"),
|
||||||
|
password=self.plugin_base.get_settings().get("password"),
|
||||||
|
timeout=3, legacy=False)
|
||||||
|
|
||||||
if self.PLUGIN_BASE.backend.get_connected():
|
if self.plugin_base.backend.get_connected():
|
||||||
self.status_label.set_label("Successfully connected to OBS")
|
self.status_label.set_label(self.plugin_base.lm.get("actions.base.status.connected"))
|
||||||
self.status_label.remove_css_class("red")
|
self.status_label.remove_css_class("red")
|
||||||
self.status_label.add_css_class("green")
|
self.status_label.add_css_class("green")
|
||||||
else:
|
else:
|
||||||
self.status_label.set_label("Couldn't connect to OBS")
|
self.status_label.set_label(self.plugin_base.lm.get("actions.base.status.no-connection"))
|
||||||
self.status_label.remove_css_class("green")
|
self.status_label.remove_css_class("green")
|
||||||
self.status_label.add_css_class("red")
|
self.status_label.add_css_class("red")
|
||||||
|
|
||||||
|
|
|
@ -3,4 +3,4 @@ from os.path import join, abspath, dirname
|
||||||
|
|
||||||
print("installing")
|
print("installing")
|
||||||
toplevel = dirname(abspath(__file__))
|
toplevel = dirname(abspath(__file__))
|
||||||
create_venv(join(toplevel, ".venv"), join(toplevel, "backend/requirements.txt"))
|
create_venv(join(toplevel, ".venv"), join(toplevel, "backend", "requirements.txt"))
|
|
@ -1,29 +1,32 @@
|
||||||
from plugins.dev_core447_OBSPlugin.OBSActionBase import OBSActionBase
|
from plugins.dev_core447_OBSPlugin.OBSActionBase import OBSActionBase
|
||||||
|
from src.backend.DeckManagement.DeckController import DeckController
|
||||||
|
from src.backend.PageManagement.Page import Page
|
||||||
|
from src.backend.PluginManager.PluginBase import PluginBase
|
||||||
import os
|
import os
|
||||||
|
|
||||||
class RecPlayPause(OBSActionBase):
|
class RecPlayPause(OBSActionBase):
|
||||||
ACTION_NAME = "Recording Play/Pause"
|
def __init__(self, action_id: str, action_name: str,
|
||||||
CONTROLS_KEY_IMAGE = True
|
deck_controller: "DeckController", page: Page, coords: str, plugin_base: PluginBase):
|
||||||
def __init__(self, deck_controller, page, coords):
|
super().__init__(action_id=action_id, action_name=action_name,
|
||||||
|
deck_controller=deck_controller, page=page, coords=coords, plugin_base=plugin_base)
|
||||||
self.current_state = -1
|
self.current_state = -1
|
||||||
super().__init__(deck_controller=deck_controller, page=page, coords=coords)
|
|
||||||
|
|
||||||
def on_ready(self):
|
def on_ready(self):
|
||||||
# Connect to obs if not connected
|
# Connect to obs if not connected
|
||||||
if not self.PLUGIN_BASE.backend.get_connected():
|
if not self.plugin_base.backend.get_connected():
|
||||||
# self.PLUGIN_BASE.obs.connect_to(host="localhost", port=4444, timeout=3, legacy=False)
|
# self.plugin_base.obs.connect_to(host="localhost", port=4444, timeout=3, legacy=False)
|
||||||
self.reconnect_obs()
|
self.reconnect_obs()
|
||||||
|
|
||||||
# Show current rec status
|
# Show current rec status
|
||||||
self.show_current_rec_status()
|
self.show_current_rec_status()
|
||||||
|
|
||||||
def show_current_rec_status(self, new_paused = False):
|
def show_current_rec_status(self, new_paused = False):
|
||||||
if not self.PLUGIN_BASE.backend.get_connected():
|
if not self.plugin_base.backend.get_connected():
|
||||||
self.set_key(media_path=os.path.join(self.PLUGIN_BASE.PATH, "assets", "error.png"))
|
self.set_key(media_path=os.path.join(self.plugin_base.PATH, "assets", "error.png"))
|
||||||
return
|
return
|
||||||
status = self.PLUGIN_BASE.backend.get_record_status()
|
status = self.plugin_base.backend.get_record_status()
|
||||||
if status is None:
|
if status is None:
|
||||||
self.set_key(media_path=os.path.join(self.PLUGIN_BASE.PATH, "assets", "error.png"))
|
self.set_key(media_path=os.path.join(self.plugin_base.PATH, "assets", "error.png"))
|
||||||
return
|
return
|
||||||
if status["active"] and not status["paused"]:
|
if status["active"] and not status["paused"]:
|
||||||
self.show_for_state(1)
|
self.show_for_state(1)
|
||||||
|
@ -52,12 +55,12 @@ class RecPlayPause(OBSActionBase):
|
||||||
else:
|
else:
|
||||||
self.set_bottom_label(None)
|
self.set_bottom_label(None)
|
||||||
|
|
||||||
self.set_key(media_path=os.path.join(self.PLUGIN_BASE.PATH, "assets", image))
|
self.set_key(media_path=os.path.join(self.plugin_base.PATH, "assets", image))
|
||||||
|
|
||||||
def on_key_down(self):
|
def on_key_down(self):
|
||||||
if not self.PLUGIN_BASE.backend.get_connected():
|
if not self.plugin_base.backend.get_connected():
|
||||||
return
|
return
|
||||||
self.PLUGIN_BASE.backend.toggle_record_pause()
|
self.plugin_base.backend.toggle_record_pause()
|
||||||
|
|
||||||
def on_tick(self):
|
def on_tick(self):
|
||||||
self.show_current_rec_status()
|
self.show_current_rec_status()
|
|
@ -1,29 +1,32 @@
|
||||||
# from ...OBSActionBase import OBSActionBase
|
# from ...OBSActionBase import OBSActionBase
|
||||||
from plugins.dev_core447_OBSPlugin.OBSActionBase import OBSActionBase
|
from plugins.dev_core447_OBSPlugin.OBSActionBase import OBSActionBase
|
||||||
|
from src.backend.DeckManagement.DeckController import DeckController
|
||||||
|
from src.backend.PageManagement.Page import Page
|
||||||
|
from src.backend.PluginManager.PluginBase import PluginBase
|
||||||
|
|
||||||
import os
|
import os
|
||||||
class ToggleRecord(OBSActionBase):
|
class ToggleRecord(OBSActionBase):
|
||||||
ACTION_NAME = "Toggle Record"
|
def __init__(self, action_id: str, action_name: str,
|
||||||
CONTROLS_KEY_IMAGE = True
|
deck_controller: "DeckController", page: Page, coords: str, plugin_base: PluginBase):
|
||||||
def __init__(self, deck_controller, page, coords):
|
super().__init__(action_id=action_id, action_name=action_name,
|
||||||
|
deck_controller=deck_controller, page=page, coords=coords, plugin_base=plugin_base)
|
||||||
self.current_state = -1
|
self.current_state = -1
|
||||||
super().__init__(deck_controller=deck_controller, page=page, coords=coords)
|
|
||||||
|
|
||||||
def on_ready(self):
|
def on_ready(self):
|
||||||
# Connect to obs if not connected
|
# Connect to obs if not connected
|
||||||
if not self.PLUGIN_BASE.backend.get_connected(): # self.PLUGIN_BASE.obs.connect_to(host="localhost", port=4444, timeout=3, legacy=False)
|
if not self.plugin_base.backend.get_connected(): # self.plugin_base.obs.connect_to(host="localhost", port=4444, timeout=3, legacy=False)
|
||||||
self.reconnect_obs()
|
self.reconnect_obs()
|
||||||
|
|
||||||
# Show current rec status
|
# Show current rec status
|
||||||
self.show_current_rec_status()
|
self.show_current_rec_status()
|
||||||
|
|
||||||
def show_current_rec_status(self, new_paused = False):
|
def show_current_rec_status(self, new_paused = False):
|
||||||
if not self.PLUGIN_BASE.backend.get_connected():
|
if not self.plugin_base.backend.get_connected():
|
||||||
self.set_key(media_path=os.path.join(self.PLUGIN_BASE.PATH, "assets", "error.png"))
|
self.set_key(media_path=os.path.join(self.plugin_base.PATH, "assets", "error.png"))
|
||||||
return
|
return
|
||||||
status = self.PLUGIN_BASE.backend.get_record_status()
|
status = self.plugin_base.backend.get_record_status()
|
||||||
if status is None:
|
if status is None:
|
||||||
self.set_key(media_path=os.path.join(self.PLUGIN_BASE.PATH, "assets", "error.png"))
|
self.set_key(media_path=os.path.join(self.plugin_base.PATH, "assets", "error.png"))
|
||||||
return
|
return
|
||||||
if status["paused"]:
|
if status["paused"]:
|
||||||
self.show_for_state(2)
|
self.show_for_state(2)
|
||||||
|
@ -54,23 +57,23 @@ class ToggleRecord(OBSActionBase):
|
||||||
self.show_rec_time()
|
self.show_rec_time()
|
||||||
image = "record_resume.png"
|
image = "record_resume.png"
|
||||||
|
|
||||||
self.set_key(media_path=os.path.join(self.PLUGIN_BASE.PATH, "assets", image))
|
self.set_key(media_path=os.path.join(self.plugin_base.PATH, "assets", image))
|
||||||
|
|
||||||
def on_key_down(self):
|
def on_key_down(self):
|
||||||
if not self.PLUGIN_BASE.backend.get_connected():
|
if not self.plugin_base.backend.get_connected():
|
||||||
return
|
return
|
||||||
self.PLUGIN_BASE.backend.toggle_record()
|
self.plugin_base.backend.toggle_record()
|
||||||
|
|
||||||
def on_tick(self):
|
def on_tick(self):
|
||||||
self.show_current_rec_status()
|
self.show_current_rec_status()
|
||||||
|
|
||||||
def show_rec_time(self):
|
def show_rec_time(self):
|
||||||
if not self.PLUGIN_BASE.backend.get_connected():
|
if not self.plugin_base.backend.get_connected():
|
||||||
self.set_key(media_path=os.path.join(self.PLUGIN_BASE.PATH, "assets", "error.png"))
|
self.set_key(media_path=os.path.join(self.plugin_base.PATH, "assets", "error.png"))
|
||||||
return
|
return
|
||||||
status = self.PLUGIN_BASE.backend.get_record_status()
|
status = self.plugin_base.backend.get_record_status()
|
||||||
if status is None:
|
if status is None:
|
||||||
self.set_key(media_path=os.path.join(self.PLUGIN_BASE.PATH, "assets", "error.png"))
|
self.set_key(media_path=os.path.join(self.plugin_base.PATH, "assets", "error.png"))
|
||||||
return
|
return
|
||||||
if not status["active"]:
|
if not status["active"]:
|
||||||
self.set_bottom_label(None)
|
self.set_bottom_label(None)
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
{
|
||||||
|
"plugin.name": "OBS",
|
||||||
|
"actions.toggle-record.name": "Aufnahme pausieren",
|
||||||
|
"actions.rec-play-pause.name": "Play/Pause Aufnahme",
|
||||||
|
"actions.base.status.no-connection": "Es konnte keine Verbindung zu OBS hergestellt werden.",
|
||||||
|
"actions.base.ip.label": "IP:",
|
||||||
|
"actions.base.port.label": "Port:",
|
||||||
|
"actions.base.password.label": "Passwort:"
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"plugin.name": "OBS",
|
||||||
|
"actions.toggle-record.name": "Toggle Recording",
|
||||||
|
"actions.rec-play-pause.name": "Play/Pause Recording",
|
||||||
|
"actions.base.status.no-connection": "Could not connect to OBS.",
|
||||||
|
"actions.base.status.connected": "Successfully connected to OBS.",
|
||||||
|
"actions.base.ip.label": "IP:",
|
||||||
|
"actions.base.port.label": "Port:",
|
||||||
|
"actions.base.password.label": "Password:"
|
||||||
|
}
|
34
main.py
34
main.py
|
@ -1,5 +1,6 @@
|
||||||
from src.backend.PluginManager.ActionBase import ActionBase
|
from src.backend.PluginManager.ActionBase import ActionBase
|
||||||
from src.backend.PluginManager.PluginBase import PluginBase
|
from src.backend.PluginManager.PluginBase import PluginBase
|
||||||
|
from src.backend.PluginManager.ActionHolder import ActionHolder
|
||||||
|
|
||||||
# Import gtk modules
|
# Import gtk modules
|
||||||
import gi
|
import gi
|
||||||
|
@ -23,15 +24,40 @@ from actions.RecPlayPause.RecPlayPause import RecPlayPause
|
||||||
|
|
||||||
class OBS(PluginBase):
|
class OBS(PluginBase):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.PLUGIN_NAME = "OBS"
|
|
||||||
self.GITHUB_REPO = "https://github.com/your-github-repo"
|
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
# Launch backend
|
# Launch backend
|
||||||
|
print("launch backend")
|
||||||
self.launch_backend(os.path.join(self.PATH, "backend", "backend.py"), os.path.join(self.PATH, ".venv"))
|
self.launch_backend(os.path.join(self.PATH, "backend", "backend.py"), os.path.join(self.PATH, ".venv"))
|
||||||
|
print("backend launched")
|
||||||
|
|
||||||
self.add_action(ToggleRecord)
|
self.lm = self.locale_manager
|
||||||
self.add_action(RecPlayPause)
|
self.lm.set_to_os_default()
|
||||||
|
|
||||||
|
|
||||||
|
self.register(
|
||||||
|
plugin_name=self.lm.get("plugin.name"),
|
||||||
|
github_repo="https://github.com/Core447/OBSPlugin",
|
||||||
|
plugin_version="0.1",
|
||||||
|
app_version="0.1.1-alpha",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
toggle_record_action_holder = ActionHolder(
|
||||||
|
plugin_base=self,
|
||||||
|
action_base=ToggleRecord,
|
||||||
|
action_id="dev_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,
|
||||||
|
action_id="dev_core447_OBSPlugin::RecPlayPause",
|
||||||
|
action_name=self.lm.get("actions.rec-play-pause.name")
|
||||||
|
)
|
||||||
|
self.add_action_holder(rec_play_pause_action_holder)
|
||||||
|
|
||||||
# Load custom css
|
# Load custom css
|
||||||
self.add_css_stylesheet(os.path.join(self.PATH, "style.css"))
|
self.add_css_stylesheet(os.path.join(self.PATH, "style.css"))
|
Loading…
Reference in New Issue