def check_status_and_toggle():
    global status_file
    global idle_scene
    global playing_scene
    global previous_status

    # read status file contents
    if not os.path.isfile(status_file):
        obs.timer_remove(check_status_and_toggle)
        raise FileNotFoundError("Could not find file '{status_file}'")
    with open(status_file, 'r') as f:
        status = f.readlines()
    if status == []:
        return
    status = status[0].strip()
    if status == previous_status:  # status has not changed
        return

    # Switch scene according to game status
    if status == 'Playing':
        src = obs.obs_get_source_by_name(playing_scene)
    else:
        src = obs.obs_get_source_by_name(idle_scene)
    obs.obs_frontend_set_current_scene(src)
    obs.obs_source_release(src)

    previous_status = status
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 source_deactivated(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 TRACKING_SUBSCRIBERS:
            obs.timer_remove(update_latest_subscriber)
Example #4
0
def timer_start_recording():
    global Debug_Mode
    if Debug_Mode: print("Timer Event: timer_start_recording")

    if obs.obs_frontend_recording_active() is False:
        obs.obs_frontend_recording_start()
        obs.timer_remove(timer_start_recording)
def source_deactivated(calldata):
    source = obs.calldata_source(calldata, "source")

    if source is not None:
        name = obs.obs_source_get_name(source)
        if name == LATEST_FOLLOWER_SOURCE and TRACKING_FOLLOWERS:
            obs.timer_remove(update_latest_follower)
Example #6
0
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")
Example #7
0
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 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)
Example #9
0
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")
Example #10
0
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)
Example #11
0
def new_race_selected(props, prop, settings):
    set_locale()
    rtgg_obs.race_changed = True
    obs.timer_remove(update_sources)

    rtgg_obs.selected_race = obs.obs_data_get_string(settings, "race")
    if rtgg_obs.selected_race == sp.none_races:
        rtgg_obs.race = None
    if rtgg_obs.selected_race == sp.alttpr_ladder:
        rtgg_obs.race = None
        ladder_timer.enabled = True
    else:
        ladder_timer.enabled = False
    r = racetime_client.get_race_by_name(rtgg_obs.selected_race)
    if r is not None:
        rtgg_obs.race = r
        rtgg_obs.coop.update_coop_text(rtgg_obs.race, rtgg_obs.full_name)
        rtgg_obs.qualifier.update_qualifier_text(rtgg_obs.race,
                                                 rtgg_obs.full_name)
        rtgg_obs.media_player.race_updated(rtgg_obs.race, rtgg_obs.full_name)
        rtgg_obs.logger.info(f"new race selected: {rtgg_obs.race}")
        obs.obs_data_set_default_string(settings, "race_info", r.info)
        coop_scripting.fill_coop_entrant_lists(props, rtgg_obs)
        rtgg_obs.timer.enabled = True
        obs.timer_add(update_sources, 100)
    elif ladder_timer.enabled:
        obs.timer_add(update_sources, 100)
    elif rtgg_obs.preview_mode:
        obs.timer_add(update_sources, 100)
    else:
        obs.obs_data_set_default_string(settings, "race_info",
                                        _("Race not found"))
    return True
Example #12
0
def update():
    file = open(get_file_path(), "w+")

    # Write a bunch of spaces to the file so that it is wide text
    # then it can fill the whole width of the screen, and we can use the center alignment
    # to ensure that the rest of the text is centered
    file.write(
        "                                                                           \r\n"
    )

    difference = (datetime - datetime.now())

    if (difference.total_seconds() > 0):
        timeStr = create_time_string(difference)
        toWrite = text.replace("%s", timeStr)

        file.write(toWrite)
        debug_write(f"Wrote '{toWrite}' to file")
    else:
        toWrite = expiredtext
        file.write(toWrite)
        debug_write(f"Wrote '{toWrite}' to file")
        obs.timer_remove(update)

    file.close()
Example #13
0
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")
Example #14
0
def frontend_event_callback(event):
    if (event == obs.OBS_FRONTEND_EVENT_EXIT and ser is not None):
        obs.timer_remove(update)
        debug_write(
            f"Shutting down. Writing off value ({offvalue}) to COM port.")
        write_value(offvalue)
        ser.close()
Example #15
0
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)
Example #16
0
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)
Example #17
0
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
Example #18
0
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 timer_start_recording():
    global Debug_Mode
    if Debug_Mode: print("Entrando en timer_start_recording")

    # obs_frontend_recording_active: TRUE si la grabación está activa, False en caso contrario.
    if obs.obs_frontend_recording_active() is False:
        obs.obs_frontend_recording_start()  # Inicia la grabación.
        obs.timer_remove(timer_start_recording)
Example #20
0
def start_recording():
    global is_stopped
    if is_stopped:
        if not obs.obs_frontend_recording_active():
            obs.obs_frontend_recording_start()
            print("Start recording...")
        else:
            obs.timer_remove(start_recording)
Example #21
0
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)
Example #22
0
def stop_recording():
    global is_stopped

    if obs.obs_frontend_recording_active():
        obs.obs_frontend_recording_stop()
        print("Stop recording...")
        is_stopped = False
    else:
        obs.timer_remove(stop_recording)
        is_stopped = True
Example #23
0
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 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)
Example #25
0
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)
Example #26
0
def update_text():
    global source_name
    global num
    global video
    ret, frame = video.read()
    print(type(frame))
    num += 1
    print(num)
    if num == 2:
        obs.timer_remove(update_text)
        video.release()
Example #27
0
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)
Example #28
0
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)
Example #29
0
def script_update(settings):
    global interval
    global interval_bak
    obs.timer_remove(decrease_interval)
    if obs.obs_data_get_bool(settings, "enabled"):
        interval = obs.obs_data_get_int(settings, "interval") - 1
        interval_bak = interval
        print("activated [" + str(interval + 1) + "min]")
        if interval > 0:
            obs.timer_add(decrease_interval, 1000 * 60)
    else:
        print("deactivated")
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)
Example #31
0
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)