Răsfoiți Sursa

add two new script to go to the song next slide of the last switched to song

Noah Vogt 1 lună în urmă
părinte
comite
2603543af1
6 a modificat fișierele cu 110 adăugiri și 4 ștergeri
  1. 2 1
      input/__init__.py
  2. 13 1
      input/validate_config.py
  3. 33 0
      next_slide.py
  4. 33 0
      previous_slide.py
  5. 2 1
      song_switcher/__init__.py
  6. 27 1
      song_switcher/obs.py

+ 2 - 1
input/__init__.py

@@ -1,4 +1,4 @@
-# Copyright © 2024 Noah Vogt <noah@noahvogt.com>
+# Copyright © 2025 Noah Vogt <noah@noahvogt.com>
 
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -32,5 +32,6 @@ from .validate_config import (
     validate_cd_burn_config,
     validate_manual_filedrop_sermon_upload_config,
     validate_autoprint_infomail_config,
+    validate_obs_song_slides_switcher_config,
 )
 from .slide_selection_iterator import slide_selection_iterator

+ 13 - 1
input/validate_config.py

@@ -1,4 +1,4 @@
-# Copyright © 2024 Noah Vogt <noah@noahvogt.com>
+# Copyright © 2025 Noah Vogt <noah@noahvogt.com>
 
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -53,6 +53,18 @@ def validate_obs_song_scene_switcher_config() -> None:
     general_config_validator(needed_constants, gui_error_out=True)
 
 
+def validate_obs_song_slides_switcher_config() -> None:
+    needed_constants: dict = {
+        "NEXTSONG_CACHE_FILE": const.NEXTSONG_CACHE_FILE,
+        "SSYNC_SLIDESHOW_INPUT_NAMING": const.SSYNC_SLIDESHOW_INPUT_NAMING,
+        "OBS_WEBSOCKET_HOSTNAME": const.OBS_WEBSOCKET_HOSTNAME,
+        "OBS_WEBSOCKET_PORT": const.OBS_WEBSOCKET_PORT,
+        "OBS_SONG_SCENE_PREFIX": const.OBS_SONG_SCENE_PREFIX,
+    }
+
+    general_config_validator(needed_constants, gui_error_out=True)
+
+
 def validate_autoprint_infomail_config() -> None:
     needed_constants: dict = {
         "AUTOPRINT_INFOMAIL_CMD": const.AUTOPRINT_INFOMAIL_CMD,

+ 33 - 0
next_slide.py

@@ -0,0 +1,33 @@
+#!/usr/bin/env python3
+
+# Copyright © 2025 Noah Vogt <noah@noahvogt.com>
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+import colorama
+
+from song_switcher import change_to_next_song_slide
+from utils import make_sure_file_exists
+from input import (
+    validate_obs_song_slides_switcher_config,
+    get_cachefile_content,
+)
+import config as const
+
+if __name__ == "__main__":
+    colorama.init()
+    validate_obs_song_slides_switcher_config()
+    make_sure_file_exists(const.NEXTSONG_CACHE_FILE, gui_error_out=True)
+    cachefile_content = get_cachefile_content(const.NEXTSONG_CACHE_FILE)
+    change_to_next_song_slide(int(cachefile_content[1]))

+ 33 - 0
previous_slide.py

@@ -0,0 +1,33 @@
+#!/usr/bin/env python3
+
+# Copyright © 2025 Noah Vogt <noah@noahvogt.com>
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+import colorama
+
+from song_switcher import change_to_previous_song_slide
+from utils import make_sure_file_exists
+from input import (
+    validate_obs_song_slides_switcher_config,
+    get_cachefile_content,
+)
+import config as const
+
+if __name__ == "__main__":
+    colorama.init()
+    validate_obs_song_slides_switcher_config()
+    make_sure_file_exists(const.NEXTSONG_CACHE_FILE, gui_error_out=True)
+    cachefile_content = get_cachefile_content(const.NEXTSONG_CACHE_FILE)
+    change_to_previous_song_slide(int(cachefile_content[1]))

+ 2 - 1
song_switcher/__init__.py

@@ -1,4 +1,4 @@
-# Copyright © 2024 Noah Vogt <noah@noahvogt.com>
+# Copyright © 2025 Noah Vogt <noah@noahvogt.com>
 
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -14,3 +14,4 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 from .switch import SongDirection, cycle_to_song_direction, switch_to_song
+from .obs import change_to_next_song_slide, change_to_previous_song_slide

+ 27 - 1
song_switcher/obs.py

@@ -1,4 +1,4 @@
-# Copyright © 2024 Noah Vogt <noah@noahvogt.com>
+# Copyright © 2025 Noah Vogt <noah@noahvogt.com>
 
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -27,3 +27,29 @@ def change_to_song_scene(song_number: int) -> None:
         timeout=3,
     )
     cl.set_current_program_scene(f"{const.OBS_SONG_SCENE_PREFIX}{song_number}")
+
+
+def change_to_next_song_slide(song_number: int) -> None:
+    cl = obs.ReqClient(
+        host=const.OBS_WEBSOCKET_HOSTNAME,
+        port=const.OBS_WEBSOCKET_PORT,
+        password=const.OBS_WEBSOCKET_PASSWORD,
+        timeout=3,
+    )
+    cl.trigger_hotkey_by_name(
+        hotkeyName="SlideShow.NextSlide",
+        contextName=f"{const.SSYNC_SLIDESHOW_INPUT_NAMING}{song_number}",
+    )
+
+
+def change_to_previous_song_slide(song_number: int) -> None:
+    cl = obs.ReqClient(
+        host=const.OBS_WEBSOCKET_HOSTNAME,
+        port=const.OBS_WEBSOCKET_PORT,
+        password=const.OBS_WEBSOCKET_PASSWORD,
+        timeout=3,
+    )
+    cl.trigger_hotkey_by_name(
+        hotkeyName="SlideShow.PreviousSlide",
+        contextName=f"{const.SSYNC_SLIDESHOW_INPUT_NAMING}{song_number}",
+    )