def dispatch_obs_streaming(self, parts, args): if self.check_arg_one(args): if len(parts) == 4: if parts[3] == "start": # /obs/streaming/start obs.obs_frontend_streaming_start() if parts[3] == "stop": # /obs/streaming/stop obs.obs_frontend_streaming_stop()
def script_tick(seconds): #print(time.time()) global currentSecond global oldSecond global currentMinute global oldMinute global currentHour global oldHour global stopSecondToCheck global startSecondToCheck global minuteToCheck global hourToCheckAm global hourToCheckPm currentSecond = datetime.datetime.utcnow().second currentMinute = datetime.datetime.utcnow().minute currentHour = datetime.datetime.utcnow().hour if oldSecond != currentSecond: #print(currentSecond) # The block below ends the stream at 11:59:30 or 23:59:30 if currentSecond == stopSecondToCheck: #print(datetime.datetime.utcnow().isoformat() + " Second is now " + str(stopSecondToCheck) + ", this is where we should stop the stream (" + str(currentSecond) + ")") if currentMinute == minuteToCheck: #print(datetime.datetime.utcnow().isoformat() + " Minute is now " + str(minuteToCheck) + " (" + str(currentMinute) + ")") if currentHour == hourToCheckAm or currentHour == hourToCheckPm: #print(datetime.datetime.utcnow().isoformat() + " Hour is now " + str(hourToCheckAm) + " or " + str(hourToCheckPm) + " (" + str(currentHour) + ")") if obs.obs_frontend_streaming_active() == True: print(datetime.datetime.utcnow().isoformat() + " OBS is streaming") obs.obs_frontend_streaming_stop() print(datetime.datetime.utcnow().isoformat() + " Stream should have ended now") if obs.obs_frontend_streaming_active() == False: print(datetime.datetime.utcnow().isoformat() + " OBS is NOT streaming, don't do anything") # The block below starts the stream at 11:59:40 or 23:59:40 if currentSecond == startSecondToCheck: #print(datetime.datetime.utcnow().isoformat() + " Second is now " + str(startSecondToCheck) + ", this is where we should start the stream (" + str(currentSecond) + ")") if currentMinute == minuteToCheck: #print(datetime.datetime.utcnow().isoformat() + " Minute is now " + str(minuteToCheck) + " (" + str(currentMinute) + ")") if currentHour == hourToCheckAm or currentHour == hourToCheckPm: #print(datetime.datetime.utcnow().isoformat() + " Hour is now " + str(hourToCheckAm) + " or " + str(hourToCheckPm) + " (" + str(currentHour) + ")") if obs.obs_frontend_streaming_active() == False: print(datetime.datetime.utcnow().isoformat() + " OBS is NOT streaming") obs.obs_frontend_streaming_start() print(datetime.datetime.utcnow().isoformat() + " Stream should have started now") if obs.obs_frontend_streaming_active() == True: print(datetime.datetime.utcnow().isoformat() + " OBS is streaming, don't do anything") oldSecond = currentSecond oldMinute = currentMinute oldHour = currentHour
def timer_check_recording(): global Debug_Mode if Debug_Mode: print("Timer Event: timer_check_recording") global Enabled_Recording global Enabled_Streaming global Pause_Time global Recording_Start global Recording_Timer global Recording_End global Time_To_Record Recording_Active = False if Enabled_Recording and Recording_Start is not "None": if int(Recording_Start[:2]) <= int(Recording_End[:2]): if Debug_Mode: print("Normal Time") print("timer_check_recording(): [{}] vs [{}]".format( str(datetime.today().strftime("%a")), Avoid_These_Days)) Recording_Active = time.strftime( "%H:%M") >= Recording_Start and time.strftime( "%H:%M") <= Recording_End and str(datetime.today( ).strftime("%a")) not in Avoid_These_Days else: if Debug_Mode: print("Backwards Time") Recording_Active = not (time.strftime("%H:%M") <= Recording_Start and time.strftime("%H:%M") >= Recording_End) if Recording_Active: if obs.obs_frontend_recording_active(): if time.time() >= Time_To_Record and str( datetime.today().strftime("%a")) in Avoid_These_Days: if Debug_Mode: print("I'm going to stop recording now") obs.obs_frontend_recording_stop() obs.timer_add(timer_start_recording, Pause_Time) Time_To_Record = time.time() + Recording_Timer else: obs.obs_frontend_recording_start() if obs.obs_frontend_streaming_active( ) is False and Enabled_Streaming is True: obs.obs_frontend_streaming_start() else: if obs.obs_frontend_recording_active(): obs.obs_frontend_recording_stop() else: if Debug_Mode: print("Sleeping Waiting for timer ", Recording_Start) if obs.obs_frontend_streaming_active( ) and Enabled_Streaming is True: obs.obs_frontend_streaming_stop()
def stopwatch(): global source_name global timer source = obs.obs_get_source_by_name(source_name) diff = time.time() - start if stop_stream and diff >= stop_stream_time: timer = False if obs.obs_frontend_streaming_active(): obs.obs_frontend_streaming_stop() print('Stopwatch - Stream stopped!') if obs.obs_frontend_recording_active(): obs.obs_frontend_recording_stop() print('Stopwatch - Recording stopped!') obs.timer_remove(stopwatch) obs.remove_current_callback() text = str(timed(int(diff))) try: settings = obs.obs_data_create() obs.obs_data_set_string(settings, "text", text) obs.obs_source_update(source, settings) obs.obs_data_release(settings) except UnboundLocalError: pass
def start(): print(c_ipA) print(c_port) # Open Port? """ #open Port if (c_port != ""): cmd = 'netsh advfirewall firewall add rule name= \"Open Port ' + str(c_port) + '\" dir=in action=allow protocol=TCP localport='+str(c_port) #os.system('cmd /k ' + cmd) subprocess.call(['runas', '/user:Administrator', cmd]) else: #cmd = "echo Hello"#"netsh advfirewall firewall add rule name= \"Open Port \" dir=in action=allow protocol=TCP localport=80" #os.system('cmd /k ' + cmd) pass """ with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: s.settimeout(5) if c_ipA != "" and c_port != "": print("Connecting with custom ip adress and port...") s.bind((c_ipA, int(c_port))) elif c_ipA == "" and c_port != "": print("Connecting with custom port...") s.bind((getIP(), int(c_port))) elif c_ipA != "" and c_port == "": print("Connecting with custom ip adress...") s.bind((c_ipA, PORT)) else: print("Connecting with default values...") s.bind(ADDR) s.listen() print("Server Started...") global runServer global stopServer while runServer: print("Server Running...") try: conn, addr = s.accept() conn.settimeout(5) with conn: print("connected by", addr) connected = True while connected: try: msg = conn.recv(1024) if not msg: break msg = msg.decode(FORMAT) if "scene" in msg: try: scene = int(msg[5:]) scenes = obs.obs_frontend_get_scenes() if len(scenes) >= (scene + 1): obs.obs_frontend_set_current_scene( scenes[scene]) except: pass elif "s_mute" in msg: try: msource = str(msg[6:]) source = obs.obs_get_source_by_name( msource) if source is not None: obs.obs_source_set_muted(source, True) except: pass elif "s_unmute" in msg: try: umsource = str(msg[8:]) source = obs.obs_get_source_by_name( umsource) if source is not None: obs.obs_source_set_muted(source, False) except: pass elif "s_hide" in msg: try: hsource = str(msg[6:]) source = obs.obs_get_source_by_name( hsource) if source is not None: obs.obs_source_set_enabled( source, False) except: pass elif "s_unhide" in msg: try: uhsource = str(msg[8:]) source = obs.obs_get_source_by_name( uhsource) if source is not None: obs.obs_source_set_enabled( source, True) except: pass elif "st_start" in msg: try: obs.obs_frontend_streaming_start() except: pass elif "st_stop" in msg: try: obs.obs_frontend_streaming_stop() except: pass elif "re_start" in msg: try: obs.obs_frontend_recording_start() except: pass elif "re_stop" in msg: try: obs.obs_frontend_recording_stop() except: pass elif "re_pause" in msg: try: if obs.obs_frontend_recording_paused(): obs.obs_frontend_recording_pause(False) else: obs.obs_frontend_recording_pause(True) except: pass if "server_stop" in msg: connected = False runServer = False stopServer = False except: if runServer == False: connected = False print("Closing Connection") conn.close() print("Server Stopped...") sys.exit() except: pass print("Server Stopped...") sys.exit()
def stopStream(): obs.obs_frontend_streaming_stop() print("stopped streaming")
def stop_streaming(): if manage_streaming and obs.obs_frontend_streaming_active( ) and get_current_scene_name() == closing_scene: obs.obs_frontend_streaming_stop() obs.timer_remove(stop_streaming)
def update_text(): global cal_url global interval global source_names global CLIENT_SECRET_FILE global max_events global images_path global image_sources # Gets stored credentials (taken from Calendar API quickstart) credentials = get_credentials() http = credentials.authorize(httplib2.Http()) service = discovery.build('calendar', 'v3', http=http) # Time objects using datetime dt_now = datetime.datetime.utcnow() now = datetime.datetime.utcnow().isoformat( ) + 'Z' # 'Z' indicates UTC time # Gets events currently happending by setting bounds to events happening within a second of current datetime events = service.events().list( calendarId=cal_url, timeMin=now, timeMax=(dt_now + datetime.timedelta(0, 1)).isoformat() + 'Z', maxResults=max_events, singleEvents=True, orderBy='startTime').execute() # Logs the events to console for event in events['items']: print(event['summary']) # Updates the text for each event count = 0 stream_event_happening = False record_event_happening = False for event in events['items']: if (count >= max_events): break text = event['summary'] settings = obs.obs_data_create() obs.obs_data_set_string(settings, "text", text) source = obs.obs_get_source_by_name(source_names[count]) obs.obs_source_update(source, settings) obs.obs_data_release(settings) obs.obs_source_release(source) settings2 = obs.obs_data_create() obs.obs_data_set_string(settings2, "file", "{}/{}.jpg".format(images_path, text)) source2 = obs.obs_get_source_by_name(image_sources[count]) obs.obs_source_update(source2, settings2) obs.obs_data_release(settings2) obs.obs_source_release(source2) count += 1 # Checks for the "Stream" event and starts streaming if not doing so already if text == "Stream": stream_event_happening = True if ~obs.obs_frontend_streaming_active(): obs.obs_frontend_streaming_start() # Likewise, checks for "Record" event elif text == "Record": record_event_happening = True if ~obs.obs_frontend_recording_active(): obs.obs_frontend_recording_start() # Stops the stream/recording if the Google Calendar event is no longer occuring if obs.obs_frontend_streaming_active() and not (stream_event_happening): obs.obs_frontend_streaming_stop() if obs.obs_frontend_recording_active() and not (record_event_happening): obs.obs_frontend_recording_stop() # Sets any specified sources to blank if here is no event for x in range(count, max_events): text = "" settings = obs.obs_data_create() obs.obs_data_set_string(settings, "text", text) source = obs.obs_get_source_by_name(source_names[x]) obs.obs_source_update(source, settings) obs.obs_data_release(settings) obs.obs_source_release(source) settings2 = obs.obs_data_create() obs.obs_data_set_string(settings2, "file", text) source2 = obs.obs_get_source_by_name(image_sources[x]) obs.obs_source_update(source2, settings2) obs.obs_data_release(settings2) obs.obs_source_release(source2)