#!/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 tts = obs_settings.tts tts_url = obs_settings.tts_url twitch_parent = obs_settings.twitch_parent if not chat_height: chat_height = int(500) connected = False ws = obsws(host, port, password) try: ws.connect() connected = True except: connected = False print('Not Connected') 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), str(twitch_parent))) print('
Show/Hide chat
') print('
') if tts: print('
') print(' '.format(str(tts_url))) print('
Show/Hide TTS
') 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('')