Added environment variables
This commit is contained in:
21
main.py
21
main.py
@ -1,15 +1,26 @@
|
||||
"""
|
||||
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):
|
||||
@ -24,10 +35,16 @@ def onCameraEnabled(cam: Camera):
|
||||
with open('cameraOverrides.json', 'r', encoding='utf-8') as f:
|
||||
overrides = json.loads(f.read())
|
||||
|
||||
client = udp_client.SimpleUDPClient('127.0.0.1', 9000, timeout=2.5)
|
||||
clientIP = os.environ.get('VRCCO_OSCClientBind', '127.0.0.1')
|
||||
clientPort = 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 = os.environ.get('VRCCO_OSCServerPort', 9001)
|
||||
server = osc_server.ThreadingOSCUDPServer((serverIP, serverPort), dispatcher, timeout=2.5)
|
||||
|
||||
camera = Camera(dispatcher, client, onCameraEnabled)
|
||||
server = osc_server.ThreadingOSCUDPServer(('127.0.0.1', 9001), dispatcher, timeout=2.5)
|
||||
|
||||
try:
|
||||
server.serve_forever() # Serve, queen 💅
|
||||
|
||||
Reference in New Issue
Block a user