""" VRCCC (VRChat Custom Camera) is a simple Python script to override camera options in VRChat using OSC. Environment variables: VRCCO_OSCServerBind: The IP address for the OSC server to bind to, default is '127.0.0.1'. VRCCO_OSCServerPort: The port the OSC server listenes on, default is 9001. VRCCO_OSCClientBind: The IP address of VRChat's OSC server, default is '127.0.0.1'. VRCCO_OSCClientPort: The port of VRChat's OSC server, default is 9000. VRCCO_PICTURES_DIR: A manual override for where your VRChat pictures are stored. """ import json import os from pythonosc import udp_client, osc_server from pythonosc.dispatcher import Dispatcher from dotenv import load_dotenv from camera import Camera load_dotenv() overrides = {} def onCameraEnabled(cam: Camera): """ Camera enabled callback. This will load the overrides. """ for address, value in overrides.items(): cam.oscClient.send_message(address, value) with open('cameraOverrides.json', 'r', encoding='utf-8') as f: overrides = json.loads(f.read()) clientIP = os.environ.get('VRCCO_OSCClientBind', '127.0.0.1') clientPort = int(os.environ.get('VRCCO_OSCClientPort', 9000)) client = udp_client.SimpleUDPClient(clientIP, clientPort, timeout=2.5) dispatcher = Dispatcher() serverIP = os.environ.get('VRCCO_OSCServerBind', '127.0.0.1') serverPort = int(os.environ.get('VRCCO_OSCServerPort', 9001)) server = osc_server.ThreadingOSCUDPServer((serverIP, serverPort), dispatcher, timeout=2.5) camera = Camera(dispatcher, client, onCameraEnabled) try: server.serve_forever() # Serve, queen 💅 except KeyboardInterrupt: pass camera.close() server.server_close() client.close()