summary refs log tree commit diff
path: root/bin
diff options
context:
space:
mode:
authorRobert Günzler <r@gnzler.io>2022-11-18 18:16:59 +0100
committerRobert Günzler <r@gnzler.io>2022-11-18 18:38:22 +0100
commit9d75f7330ad7743defd8f2b0284f85299fcd8156 (patch)
tree3e5a408d4972f3a38419c17afde0b8bc0a181f89 /bin
parenta89c547131ce4c8673b322a3707f72b27a5cbeb0 (diff)
drop bin/obsctl
Diffstat (limited to 'bin')
-rwxr-xr-xbin/obsctl121
1 files changed, 0 insertions, 121 deletions
diff --git a/bin/obsctl b/bin/obsctl
deleted file mode 100755
index d964f6b..0000000
--- a/bin/obsctl
+++ /dev/null
@@ -1,121 +0,0 @@
-#!/bin/env python3
-# -*- coding: utf-8 -*-
-
-import argparse
-import logging
-import sys
-
-from obswebsocket import obsws, requests
-
-
-def __call(ws, req, cb=None):
-    r = ws.call(req)
-    if r.status:
-        logging.debug('Success calling %s' % req)
-        if cb:
-            try:
-                return cb(r)
-            except Exception as e:
-                raise(e)
-    else:
-        raise Exception(r)
-
-
-def listActions(*_):
-    for a in actions:
-        print(a)
-
-
-def startRecording(ws, _):
-    __call(ws, requests.StartRecording())
-
-
-def stopRecording(ws, _):
-    __call(ws, requests.StopRecording())
-    __call(ws, requests.GetRecordingFolder(),
-           lambda r: print('Saved recording at: %s' % r.getRecFolder()))
-
-
-def startStreaming(ws, _):
-    __call(ws, requests.StartStreaming())
-
-
-def stopStreaming(ws, _):
-    __call(ws, requests.StopStreaming())
-
-
-def listScenes(ws, _):
-    def cb(r):
-        current_scene = r.getCurrentScene()
-        for scene in r.getScenes():
-            scene = scene['name']
-            print('%s %s' % (('*' if current_scene == scene else ' '), scene))
-
-    __call(ws, requests.GetSceneList(), cb)
-
-
-def switchScene(ws, args):
-    def cb(r):
-        return list(map(lambda s: s['name'], r.getScenes()))
-
-    scenes = __call(ws, requests.GetSceneList(), cb)
-
-    if len(args) != 1:
-        raise Exception('need exactly 1 argument')
-
-    if args[0] in scenes:
-        __call(ws, requests.SetCurrentScene(args[0]))
-
-
-sys.path.append('../')
-
-actions = {
-    'list-actions': listActions,
-    'start-recording': startRecording,
-    'stop-recording': stopRecording,
-    'start-streaming': startStreaming,
-    'stop-streaming': stopStreaming,
-    'list-scenes': listScenes,
-    'switch-scene': switchScene,
-}
-
-if __name__ == '__main__':
-    try:
-        app = argparse.ArgumentParser(
-            description=__doc__,
-            formatter_class=argparse.ArgumentDefaultsHelpFormatter)
-
-        app.add_argument('-d', '--debug',
-                         action='store_true',
-                         help='show debug logs')
-        app.add_argument('-H', '--host', type=str,
-                         default='localhost',
-                         help='obs-websocket host')
-        app.add_argument('-P', '--port', type=int,
-                         default=4444,
-                         help='obs-websocket port')
-        app.add_argument('-p', '--password', type=str,
-                         help='obs-websocket password')
-        app.add_argument('action', type=str,
-                         choices=actions.keys(),
-                         help='the command to run')
-        app.add_argument('args',
-                         nargs=argparse.REMAINDER,
-                         help='optional action argument')
-        args = app.parse_args()
-
-        if args.debug:
-            logging.basicConfig(level=logging.DEBUG)
-
-        ws = obsws(args.host, args.port, args.password)
-        ws.connect()
-
-        actions[args.action](ws, args.args)
-
-        ws.disconnect()
-        exit(0)
-
-    except KeyboardInterrupt:
-        pass
-    except Exception as e:
-        logging.error(e)