From f317e0ee068fd8f018868a1eaa6e8c1b6f604cd9 Mon Sep 17 00:00:00 2001 From: Sophie Schiller Date: Mon, 1 May 2023 14:44:11 +0200 Subject: rename inputs on startup --- config.toml | 19 ++++--------------- switcher.py | 13 ++++++------- 2 files changed, 10 insertions(+), 22 deletions(-) diff --git a/config.toml b/config.toml index 8256646..7d5bfea 100644 --- a/config.toml +++ b/config.toml @@ -3,21 +3,10 @@ ip = "10.73.4.40" video_mode = "1080p25" [atem.settings.inputs] -1 = "Laptop" -2 = "Kamera" -3 = "VGA" -4 = "Infobeamer" -# 5 ... 40 further HDMI/SDI Inputs -# 1000 = 'colorBars' -# 2001 = 'color1' -# 2002 = 'color2' -# 3010 = 'mediaPlayer1' -# 3011 = 'mediaPlayer1Key' -# 3020 .. 3040 further media players -# 3021 .. 3041 further media plaer keys -# 4010 = 'key1Mask' -# ... and a gazillion more inputs - +input1 = "Laptop" +input3 = "Kamera" +input2 = "VGA" +input4 = "Infobeamer" [gtk-settings] gtk-application-prefer-dark-theme = true diff --git a/switcher.py b/switcher.py index 31b5933..4262846 100644 --- a/switcher.py +++ b/switcher.py @@ -2,7 +2,7 @@ import logging import PyATEMMax from PyATEMMax.ATEMProtocolEnums import ATEMVideoModeFormats, ATEMTransitionStyles -from rich import inspect + VIDEO_FORMATS = { f[1:] for f in dir(ATEMVideoModeFormats) @@ -74,12 +74,11 @@ class PyATEMSwitcher: self.atem.setVideoModeFormat(video_mode) if conf.get('inputs', None): - for inp in self.atem.atem.videoSources: - if conf['inputs'].get(inp.value, None): - new_name = conf['inputs'][inp.value] - self.log.debug(f"setting input {inp.value} to name '{new_name}'") - self.atem.setInputLongName(inp.value, new_name) - self.atem.setInputShortName(inp.value, new_name[0:3]) + for key, name in conf['inputs'].items(): + input_number = getattr(self.atem.atem.videoSources, key) + self.log.debug(f"setting input {input_number} to name '{name}'") + self.atem.setInputLongName(input_number, name) + self.atem.setInputShortName(input_number, name[0:3]) def _validate_config(self): if 'ip' not in self.config: -- cgit v1.2.3