#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ twitch-irl-docker Copyright (C) 2022 gpkvt This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero 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 Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . """ import obs_settings import cgi, cgitb from obswebsocket import obsws, requests from pprint import pprint if obs_settings.debug: cgitb.enable() print("HTTP/1.0 200 OK") print("Content-type:text/html;charset=utf-8\r\n") form = cgi.FieldStorage() action = form.getvalue('action') param = form.getvalue('param') host = obs_settings.host port = obs_settings.port password = obs_settings.password dayflat = obs_settings.dayflat extdata = obs_settings.extdata liveu = obs_settings.liveu offline_scene = obs_settings.offline_scene channel = obs_settings.channel chat_height = obs_settings.chat_height if not chat_height: chat_height = int(500) connected = False ws = obsws(host, port, password) try: ws.connect() connected = True except: connected = False if connected: scenes = ws.call(requests.GetSceneList()) sources = ws.call(requests.GetSourcesList()) print(''' OBS Remote ''') if connected: print('') print('') print('
') if connected: print('
') print('
N/A
') if liveu: print('
N/A
') if extdata: print('
N/A') if channel: print('
') print(' '.format(str(channel))) print('
Show/Hide chat
') print('
') print('
') print('
') if dayflat: print('
') else: print('
') print('
') print('
') print('
') print('
') for s in scenes.getScenes(): id = str(s['name']) print('
'.format(id)) print('
') print('
') print('
') print('
') for s in sources.getSources(): if s['typeId'] == "vlc_source": id = str(s['name']) print('
'.format(id)) print('
') filters = ws.call(requests.GetSourceFilters(s['name'])) for f in filters.getFilters(): id = str(s['name'])+'|'+str(f['name']) filter = str(s['name'])+'|'+str(f['name']) print(' '.format(id, filter)) print('
') print('
') print('
') print('
') print('
') for s in sources.getSources(): id = str(s['name']) if s['typeId'] == 'ffmpeg_source' or s['typeId'] == 'wasapi_input_capture' or s['typeId'] == 'wasapi_output_capture': print('
'.format(id)) print('
') print('
') else: print('

FATAL: Could not connect to OBS.

') print('
') print('''
There was an error fetching the current state, will retry...

Stream might be in BRB scene but we are unable to check, right now.

Please note that it might take some seconds until the proper state will be displayed after this error is gone.
Connecting to OBS...
The bitrate is low, stream is on hold...
''') if obs_settings.extdata: print(''' ''') print('') print('')