def script_update(settings): global Debug_Mode if Debug_Mode: print("Calling Update") global Enabled_Recording global Enabled_Streaming global Pause_Time global Recording_Start global Recording_Timer global Recording_End global Time_To_Record global Avoid_These_Days if obs.obs_data_get_bool(settings, "enabled") is not Enabled_Recording: if obs.obs_data_get_bool(settings, "enabled") is True: if Debug_Mode: print("Loading Timer") print("timer_check_recording(): [{}] vs [{}]".format( str(datetime.today().strftime("%a")), Avoid_These_Days)) Enabled_Recording = True obs.timer_add(timer_check_recording, 30000) else: if Debug_Mode: print("Unloading Timer") Enabled_Recording = False obs.timer_remove(timer_check_recording) if obs.obs_data_get_int(settings, "duration") == 0: Recording_Timer = 30 * 60 else: Recording_Timer = obs.obs_data_get_int(settings, "duration") * 60 Time_To_Record = time.time() + Recording_Timer if obs.obs_data_get_string( settings, "start_time") == "" or obs.obs_data_get_string( settings, "start_time") == "None" or obs.obs_data_get_string( settings, "start_time") == obs.obs_data_get_string( settings, "end_time"): Recording_Start = "None" obs.obs_data_set_bool(settings, "enabled_stream", False) Enabled_Streaming = False else: Recording_Start = obs.obs_data_get_string(settings, "start_time") if obs.obs_data_get_string(settings, "end_time") == "": Recording_Start = "None" obs.obs_data_set_bool(settings, "enabled_stream", False) Enabled_Streaming = False else: Recording_End = obs.obs_data_get_string(settings, "end_time") if obs.obs_data_get_string(settings, "avoid_days") == "": Avoid_These_Days = "Sat Sun" obs.obs_data_set_bool(settings, "enabled_stream", False) Enabled_Streaming = False else: Avoid_These_Days = obs.obs_data_get_string(settings, "avoid_days") Debug_Mode = obs.obs_data_get_bool(settings, "debug_mode") Enabled_Streaming = obs.obs_data_get_bool(settings, "enabled_stream")
def script_update(settings): global cal_url global interval global source_names global CLIENT_SECRET_FILE global max_events global images_path global image_sources cal_url = obs.obs_data_get_string(settings, "calendar_url") CLIENT_SECRET_FILE = obs.obs_data_get_string(settings, "client_secret_file") images_path = obs.obs_data_get_string(settings, "images_path") interval = obs.obs_data_get_int(settings, "interval") max_events = obs.obs_data_get_int(settings, "max_events") source_names = [None] * max_events for x in range(0, max_events): source_names[x] = obs.obs_data_get_string(settings, "source_{}".format(x)) image_sources = [None] * max_events for x in range(0, max_events): image_sources[x] = obs.obs_data_get_string(settings, "img_source_{}".format(x)) obs.timer_remove(update_text) if cal_url != "": #and source_name != "": obs.timer_add(update_text, interval * 1000)
def script_load(settings): obs.script_log(obs.LOG_DEBUG, "Loading script") hidesource() unsetfilename() #obs.timer_add(server_handle,100) start_server() obs.timer_add(play_task, 100)
def script_update(settings): global debug_mode if debug_mode: print("OBSBuffer Updated properties.") global enabled global display_text global check_frequency global source_presenter global source_time global json_filename global source_title global check_frequency if obs.obs_data_get_bool(settings, "enabled") is True: if (not enabled): if debug_mode: print("OBSBuffer Enabled buffer timer.") enabled = True obs.timer_add(update_content, check_frequency) else: if (enabled): if debug_mode: print("OBSBuffer Disabled buffer timer.") enabled = False obs.timer_remove(update_content) debug_mode = obs.obs_data_get_bool(settings, "debug_mode") source_presenter = obs.obs_data_get_string(settings, "source_presenter") source_title = obs.obs_data_get_string(settings, "source_title") source_time = obs.obs_data_get_string(settings, "source_time") check_frequency = obs.obs_data_get_int(settings, "check_frequency") json_filename = obs.obs_data_get_int(settings, "json_filename")
def script_update(settings): # see here to generate info needed below https://help.twitch.tv/customer/en/portal/articles/1302780-twitch-irc HOST = "irc.twitch.tv" # example "NICK ninjahipst3r :" NICK = "NICK "your_nickname"\r\n" PORT = 6667 #example PASS = "******"PASS oauth:"your_key"\r\n" # example "JOIN #ninjahipst3r :" JOIN= "JOIN #"your_channel_name" \r\n" #this makes the connection and sets it up to not block. Otherwise OBS will hangup s.connect((HOST, PORT)) s.send(PASS .encode()) s.send(NICK.encode()) s.send(JOIN.encode()) s.setblocking(0) sock_close = False obs.timer_remove(send_help) obs.timer_add(send_help, 1000 * 300) source_name = obs.obs_data_get_string(settings, "source") obs.timer_remove(update_text) obs.timer_add(update_text, 1) #bug here when first started, this can be taken out if needed obs.obs_frontend_set_current_scene(scenes[1])
def script_update(settings): global enabled global display_text global check_frequency global source_name global debug_mode debug("[CS] Updated properties.") if obs.obs_data_get_bool(settings, "enabled"): if not enabled: debug("[CS] Enabled song timer.") enabled = True obs.timer_add(get_song_info, check_frequency) else: if enabled: debug("[CS] Disabled song timer.") enabled = False obs.timer_remove(get_song_info) debug_mode = obs.obs_data_get_bool(settings, "debug_mode") display_text = obs.obs_data_get_string(settings, "display_text") source_name = obs.obs_data_get_string(settings, "source_name") check_frequency = obs.obs_data_get_int(settings, "check_frequency") for i in filter(lambda x: not x.startswith('_'), calcingfunc.keys()): globals()[i].state = obs.obs_data_get_bool(settings, globals()[i].id)
def script_update(settings): global enabled global display_text global check_frequency global source_name global debug_mode if debug_mode: print("[CS] 设置已更新。") if obs.obs_data_get_bool(settings, "enabled") is True: if not enabled: if debug_mode: print("[CS] Enabled song timer.") enabled = True obs.timer_add(get_song_info, check_frequency) else: if enabled: if debug_mode: print("[CS] Disabled song timer.") enabled = False obs.timer_remove(get_song_info) debug_mode = obs.obs_data_get_bool(settings, "debug_mode") display_text = obs.obs_data_get_string(settings, "display_text") source_name = obs.obs_data_get_string(settings, "source_name") check_frequency = obs.obs_data_get_int(settings, "check_frequency") customset['spotify'] = obs.obs_data_get_bool(settings, "spotify") customset['vlc'] = obs.obs_data_get_bool(settings, "vlc") customset['yt_firefox'] = obs.obs_data_get_bool(settings, "yt_firefox") customset['yt_chrome'] = obs.obs_data_get_bool(settings, "yt_chrome") customset['foobar2000'] = obs.obs_data_get_bool(settings, "foobar2000") customset['necloud'] = obs.obs_data_get_bool(settings, "necloud") customset['aimp'] = obs.obs_data_get_bool(settings, "aimp")
def script_update(settings): global debug_mode if debug_mode: print("Updated properties for Corvinus Now Playing") global enabled global display_text global alt_display_text global latency global source_name global output_buffer debug_mode = obspython.obs_data_get_bool(settings, "enabled") debug_mode = obspython.obs_data_get_bool(settings, "debug_mode") output_buffer = obspython.obs_data_get_int(settings, "output_buffer") display_text = obspython.obs_data_get_string(settings, "display_text") alt_display_text = obspython.obs_data_get_string(settings, "alt_display_text") latency = obspython.obs_data_get_int(settings, "latency") source_name = obspython.obs_data_get_string(settings, "source_name") if obspython.obs_data_get_bool(settings, "enabled") is True: if (not enabled): if debug_mode: print("Enabled song timer for Corvinus Now Playing") enabled = True obspython.timer_add(get_song_info, latency) else: if (enabled): if debug_mode: print("Disabled song timer for Corvinus Now Playing") enabled = False obspython.timer_remove(get_song_info)
def launcher(pressed): if pressed: if status.lock: obs.timer_add(status.update_all, status.interval) status.lock = False elif not status.lock: status.lock = True
def create_muted_callback(sn): global callback_name if sn is None or sn == callback_name: return False # source hasn't changed or callback is already set if callback_name is not None: remove_muted_callback(callback_name) source = obs.obs_get_source_by_name(sn) if source is None: if sources_loaded: # don't print if sources are still loading dprint("ERROR: Could not create callback for", sn) return False handler = obs.obs_source_get_signal_handler(source) obs.signal_handler_connect(handler, "mute", mute_callback) callback_name = sn # save name for future reference dprint("Added callback for \"{:s}\"".format( obs.obs_source_get_name(source))) if port: # if the serial port is open... obs.timer_add(send_initial_state, init_state_delay) # send the initial state obs.obs_source_release(source) return True
def validate_and_start(): global initial_load global idle_scene global playing_scene initial_load = True obs.timer_remove(validate_and_start) obs.timer_remove(check_status_and_toggle) # check if file exists if not os.path.isfile(status_file): raise FileNotFoundError(f"Could not find file '{status_file}'") obs.script_log(obs.LOG_INFO, f'{status_file} found!') # check if gameplay enter scene exists src = obs.obs_get_source_by_name(playing_scene) if src is None or obs.obs_source_get_type( src) != obs.OBS_SOURCE_TYPE_SCENE: obs.obs_source_release(src) raise FileNotFoundError(f" Could not find scene '{playing_scene}'") obs.obs_source_release(src) obs.script_log(obs.LOG_INFO, f"Scene '{playing_scene}' found!") # check if gameplay exit scene exists src = obs.obs_get_source_by_name(idle_scene) if src is None or obs.obs_source_get_type( src) != obs.OBS_SOURCE_TYPE_SCENE: obs.obs_source_release(src) raise FileNotFoundError(f" Could not find scene '{idle_scene}'") obs.obs_source_release(src) obs.script_log(obs.LOG_INFO, f"Scene '{idle_scene}' found!") obs.script_log(obs.LOG_INFO, 'Script is now active.') obs.timer_add(check_status_and_toggle, 500)
def fadeout(): global fadeout_timestamp global status status = DEFAULT_STATUS obs.timer_remove(fadeout_callback) fadeout_timestamp = time.time() obs.timer_add(fadeout_callback, 10)
def source_activated(calldata): source = obs.calldata_source(calldata, "source") if source is not None: name = obs.obs_source_get_name(source) if name == LATEST_SUBSCRIBER_SOURCE and not TRACKING_SUBSCRIBERS: update_latest_subscriber() obs.timer_add(update_latest_subscriber, UPDATE_INTERVAL * 1000)
def script_update(settings): eg.source_name = obs.obs_data_get_string(settings, "source") obs.timer_remove(eg.update_text) if eg.source_name != "": flag = obs.obs_data_get_bool(settings, "_obs_bool") print(flag) eg.update_text = partial(eg.update_text, flag_func=flag) obs.timer_add(eg.update_text, 1 * 1000)
def script_update(settings): """ Initialise the timer. """ timer() interval = obs.obs_data_get_int(settings, "interval") obs.timer_remove(timer) obs.timer_add(timer, interval * 1000)
def script_load(settings): global curRec global curStream obs.script_log(obs.LOG_DEBUG, "Loading script") curStream = obs.obs_frontend_streaming_active() curRec = obs.obs_frontend_recording_active() obs.timer_add(check_stream_state, 1000)
def script_update(settings): """ Called when the script’s settings (if any) have been changed by the user. """ obs.timer_remove(cycle) blink_rate = obs.obs_data_get_int(settings, "cycle_rate") obs.timer_add(cycle, blink_rate) # Change scene every cycle_rate ms
def hotkey_hook(self): """ trigger hotkey event""" self.duration = self.effect_duration interval = self.refresh_rate if self.lock: self.ticker = partial(self.ticker, text_effect=self.effect) obs.timer_add(self.ticker, interval) self.lock = False
def script_load(settings): obs.timer_add( source_loading, 10 ) # brute force - try to load sources every 10 ms until the callback is created obs.timer_add( flush_serial_input, 1000 ) # flush serial input buffer every second to prevent buffer overruns dprint("OBS Mute Indicator Script Loaded")
def script_update(settings): global source_name global g_time_fmt source_name = obs.obs_data_get_string(settings, "source") update_rate = obs.obs_data_get_int(settings, "update_rate") g_time_fmt = obs.obs_data_get_string(settings, "format") obs.timer_add(update_text, update_rate)
def script_update(settings): global is_active, scene_names, left_width, check_freq is_active = obs.obs_data_get_bool(settings, "is_active") scene_names[0] = obs.obs_data_get_string(settings, "scene_for_left_mon") scene_names[1] = obs.obs_data_get_string(settings, "scene_for_right_mon") left_width = obs.obs_data_get_int(settings, "left_width") check_freq = obs.obs_data_get_int(settings, "check_freq") obs.timer_remove(switch_scenes) if is_active: obs.timer_add(switch_scenes, check_freq)
def toggle_zoom(pressed): if pressed: if zoom.source_name != "" and zoom.flag: zoom.update_monitor_size() obs.timer_add(zoom.tick, zoom.refresh_rate) zoom.lock = True zoom.flag = False elif not zoom.flag: zoom.flag = True zoom.lock = False
def refresh(prop, props): """ refresh button""" scripted_text_driver.refresh_text() interval = scripted_text_driver.refresh_rate effect = scripted_text_driver.effect print(effect) if scripted_text_driver.preview: scripted_text_driver.ticker = partial(scripted_text_driver.ticker, text_effect=effect) obs.timer_add(scripted_text_driver.ticker, interval) scripted_text_driver.preview = False
def script_load(settings): global status_file global idle_scene global playing_scene status_file = obs.obs_data_get_string(settings, 'status_file') idle_scene = obs.obs_data_get_string(settings, 'idle_scene') playing_scene = obs.obs_data_get_string(settings, 'playing_scene') # Delay check valid source until OBS is fully loaded obs.script_log(obs.LOG_INFO, 'Starting in 10 seconds...') obs.timer_add(validate_and_start, 10000)
def script_update(settings): global refresh_interval global file_path # Remove existing refresh timer obs.timer_remove(refresh_all) # Start new refresh timer file_path = obs.obs_data_get_string(settings, 'file_path') if file_path is not None: obs.timer_add(refresh_all, refresh_interval)
def script_update(settings): global interval global source_name interval = obs.obs_data_get_int(settings, "interval") source_name = obs.obs_data_get_string(settings, "source") obs.timer_remove(update_text) if source_name != "": obs.timer_add(update_text, interval * 1)
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 script_update(settings): global time_input global source_name time_input = obs.obs_data_get_string(settings, "time_input") source_name = obs.obs_data_get_string(settings, "source") obs.timer_remove(update_text) if time_input != "" and source_name != "": obs.timer_add(update_text, 1000)
def script_update(settings): """ Called when the script’s settings (if any) have been changed by the user. """ global source_name source_name = obs.obs_data_get_string(settings, "source") obs.timer_remove(blink) blink_rate = obs.obs_data_get_int(settings, "blink_rate") # blink is actually toggle, do it every blink_rate ms obs.timer_add(blink, blink_rate)
def script_update(settings): global interval global source_name global file_path interval = obs.obs_data_get_int(settings, "interval") source_name = obs.obs_data_get_string(settings, "source") file_path = obs.obs_data_get_string(settings, "file") obs.timer_remove(update_text) if file_path != "" and source_name != "": obs.timer_add(update_text, interval * 1000)
def script_update(settings): global url global interval global source_name url = obs.obs_data_get_string(settings, "url") interval = obs.obs_data_get_int(settings, "interval") source_name = obs.obs_data_get_string(settings, "source") obs.timer_remove(update_text) if url != "" and source_name != "": obs.timer_add(update_text, interval * 1000)