examples refactored

This commit is contained in:
2023-07-19 15:13:26 +01:00
parent 153f35e742
commit 73ae24eb4b
9 changed files with 66 additions and 50 deletions

View File

@@ -5,5 +5,3 @@ source "https://rubygems.org"
# gem "rails"
gem "obsws", path: "../.."
gem "perfect_toml", "~> 0.9.0"

View File

@@ -1,7 +1,7 @@
PATH
remote: ../..
specs:
obsws (0.1.0)
obsws (0.1.3)
observer (~> 0.1.1)
waitutil (~> 0.2.1)
websocket-driver (~> 0.7.5)
@@ -10,7 +10,6 @@ GEM
remote: https://rubygems.org/
specs:
observer (0.1.1)
perfect_toml (0.9.0)
waitutil (0.2.1)
websocket-driver (0.7.5)
websocket-extensions (>= 0.1.0)
@@ -21,7 +20,6 @@ PLATFORMS
DEPENDENCIES
obsws!
perfect_toml (~> 0.9.0)
BUNDLED WITH
2.3.22

View File

@@ -1,19 +1,18 @@
require "obsws"
require "perfect_toml"
require "yaml"
OBSWS::LOGGER.info!
def conn_from_toml
PerfectTOML.load_file("obs.toml", symbolize_names: true)[:connection]
def conn_from_yaml
YAML.load_file("obs.yml", symbolize_names: true)[:connection]
end
def main
r_client = OBSWS::Requests::Client.new(**conn_from_toml)
r_client.run do
resp = r_client.get_scene_list
resp.scenes.reverse.each do |s|
puts "Switching to scene #{s[:sceneName]}"
r_client.set_current_program_scene(s[:sceneName])
OBSWS::Requests::Client.new(**conn_from_yaml).run do |client|
resp = client.get_scene_list
resp.scenes.reverse_each do |scene|
puts "Switching to scene #{scene[:sceneName]}"
client.set_current_program_scene(scene[:sceneName])
sleep(0.5)
end
end