Replies: 1 comment
-
sorry for the format |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
import time
from obswebsocket import obsws, requests
OBS WebSocket configuration
OBS_HOST = "localhost"
OBS_PORT = 4455
OBS_PASSWORD = "your_password" # Replace with your actual OBS password
Initialize OBS WebSocket
ws = obsws(OBS_HOST, OBS_PORT, OBS_PASSWORD)
Try connecting to OBS WebSocket
try:
ws.connect()
print("Connected to OBS WebSocket.")
except Exception as e:
print(f"Failed to connect: {e}")
exit()
Manually set the Super Chat amount (for testing purposes)
def get_latest_superchat():
# Simulate a Super Chat with a set amount (e.g., $5 or $10)
simulated_amount = 5 # You can change this to 10 for a $10 Super Chat test
return simulated_amount
def change_media_source(amount):
if amount == 5:
print("Switching to 5 dollar media...")
# Ensure the source name matches the one in your OBS scene
source_name = "audio" # Adjust this to the name of your media source
settings = {"file": "/home/khyalia/Desktop/gk/FUNK DO BOUNCE.mp3"} # Correct key is 'file' for media file
try:
ws.call(requests.SetSourceSettings(source_name, settings)) # Correct method and arguments
print(f"Media source changed to {settings['file']}")
except Exception as e:
print(f"Error changing media source: {e}")
Main loop (testing loop)
try:
while True:
superchat_amount = get_latest_superchat() # Get the simulated Super Chat amount
if superchat_amount:
print(f"Simulated Super Chat: ${superchat_amount}")
change_media_source(superchat_amount) # Change media source based on the amount
time.sleep(5) # Wait 5 seconds before checking again
except KeyboardInterrupt:
print("Stopping...")
finally:
ws.disconnect() # Disconnect from OBS WebSocket
print("Disconnected from OBS WebSocket.")
whis is the code i have got from chatGPT. I was trying to create an automated live stream and i was at the last step. I was trying to verify my code so i asked gpt. It gave me this code which is giving me the error
Simulated Super Chat: $5
Switching to 5 dollar media...
Traceback (most recent call last):
File "/home/khyalia/Desktop/gk/script/script.py", line 33, in
change_media_source(superchat_amount) # Change media source based on the amount
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/khyalia/Desktop/gk/script/script.py", line 22, in change_media_source
ws.call(requests.SetSourceSettings("audio", {"file": "/home/khyalia/Desktop/gk/FUNK DO BOUNCE.mp3"}))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Baserequests.init() takes 1 positional argument but 3 were given
Please help as i can't figureout how to solve this. I think gpt is not using the function "requests.SetSourceSettings" correctly.
Beta Was this translation helpful? Give feedback.
All reactions