-
Notifications
You must be signed in to change notification settings - Fork 21
/
change-settings-multi.py
executable file
·68 lines (52 loc) · 2.22 KB
/
change-settings-multi.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env python3
# coding: utf-8
"""change-settings-multi.py - PyATEMMax demo script.
Part of the PyATEMMax library."""
import argparse
import sys
import time
import PyATEMMax
print(f"[{time.ctime()}] PyATEMMax demo script: change-settings-multi")
SWITCHERS = [
"192.168.1.110",
"192.168.1.111",
"192.168.1.112",
"192.168.1.113",
"192.168.1.114",
"192.168.1.115",
]
parser = argparse.ArgumentParser()
parser.add_argument('-v', '--mastervolume', help='master volume (dB)', type=float)
parser.add_argument('-w', '--preview', help='set preview video source', type=int)
parser.add_argument('-p', '--program', help='set program video source', type=int)
parser.add_argument('-m', '--mixeffect', help='select mix effect (0/1), default 0', type=int, default=0)
args = parser.parse_args()
if args.mastervolume is None and args.program is None and args.preview is None:
print(f"[{time.ctime()}] Please specify a value to change (see help)")
sys.exit(1)
print(f"[{time.ctime()}] Changing settings in all switchers")
if args.mastervolume is not None:
print(f"[{time.ctime()}] - Master volume: {args.mastervolume}db")
if args.program is not None:
print(f"[{time.ctime()}] - PGM Video source: {args.program} on m/e {args.mixeffect}")
if args.preview is not None:
print(f"[{time.ctime()}] - PVW Video source: {args.preview} on m/e {args.mixeffect}")
switcher = PyATEMMax.ATEMMax()
count = 0
print(f"[{time.ctime()}] Starting settings update")
for ip in SWITCHERS:
print(f"[{time.ctime()}] Connecting to {ip}", end="\r")
switcher.connect(ip)
if switcher.waitForConnection(infinite=False):
if args.mastervolume is not None:
switcher.setAudioMixerMasterVolume(args.mastervolume)
if args.program is not None:
switcher.setProgramInputVideoSource(args.mixeffect, args.program)
if args.preview is not None:
switcher.setPreviewInputVideoSource(args.mixeffect, args.preview)
print(f"[{time.ctime()}] Settings updated on {switcher.atemModel} at {ip}")
count += 1
else:
print(f"[{time.ctime()}] ERROR: no response from {ip}")
switcher.disconnect()
print(f"[{time.ctime()}] FINISHED: {count}/{len(SWITCHERS)} switchers updated.")