Exemple #1
0
def get_audio_sources_from_scene(scene, source_dict=None):
    if source_dict is None:
        source_dict = OrderedDict()

    for sceneitem in obspython.obs_scene_enum_items(
            obspython.obs_scene_from_source(scene)):
        item_source = obspython.obs_sceneitem_get_source(sceneitem)
        name = obspython.obs_source_get_name(item_source)

        if obspython.obs_source_get_output_flags(
                item_source) & obspython.OBS_SOURCE_COMPOSITE:
            source_dict = get_audio_sources_from_scene(item_source,
                                                       source_dict)

        if obspython.obs_source_get_output_flags(
                item_source) & obspython.OBS_SOURCE_AUDIO:
            source_active = obspython.obs_source_active(item_source)
            audio_active = obspython.obs_source_audio_active(item_source)
            priv_settings = obspython.obs_source_get_private_settings(
                item_source)
            hidden = obspython.obs_data_get_bool(priv_settings, "mixer_hidden")
            if not source_active or not audio_active or hidden:
                continue

            source_dict[name] = item_source

    return source_dict
Exemple #2
0
def get_active_song():
    sources = obs.obs_enum_sources()
    if sources is not None:
        for source in sources:
            source_name = obs.obs_source_get_name(source)
            source_id = obs.obs_source_get_unversioned_id(source)
            active = obs.obs_source_active(source)
            if source_id == "ffmpeg_source" and active is True:
                return source
Exemple #3
0
def source_shown(stuff):
    source = obs.calldata_source(stuff, "source")
    print(obs.obs_source_get_name(source))
    if obs.obs_source_active(
            source
    ):  #should never happen unless handlers fire in a weird order
        print("TODO: set live tally")
    else:
        print("TODO: set preview tally")

    obs.obs_source_release(source)
def reset():
    """
    Reset the timer
    """

    activate(False)

    _source_name = script_state.get_value('text_source')
    _source = obs.obs_get_source_by_name(_source_name)

    if _source:
        _active = obs.obs_source_active(_source)
        obs.obs_source_release(_source)
        activate(_active)

    script_state.clock.reset()
    update_text()
def update_text():
    global username
    global format
    global interval
    global source_name
    global str_format

    source = obs.obs_get_source_by_name(source_name)
    if source is not None and obs.obs_source_active(source):
        try:
            opener = urllib.request.build_opener()
            opener.addheaders = [('User-Agent', 'ShowdownELOOBS/1.0')]
            r = opener.open(
                "http://play.pokemonshowdown.com/%7e%7eshowdown/action.php?act=ladderget&user="******"?" if len(obj) == 0 else str(obj[0]['gxe']) + '%'
            wins = 0 if len(obj) == 0 else int(obj[0]['w'])
            losses = 0 if len(obj) == 0 else int(obj[0]['l'])
            ties = 0 if len(obj) == 0 else int(obj[0]['t'])
            games = wins + losses + ties
            user = username if len(obj) == 0 else obj[0]['username']

            text = str_format.format(
                user=user, elo=f'{float(elo):.2f}', gxe=gxe, w=wins, l=losses, t=ties, g=games, elo_int=int(float(elo)))

            settings = obs.obs_data_create()
            obs.obs_data_set_string(
                settings, "text", text.replace('\\n', '\n'))
            obs.obs_source_update(source, settings)
            obs.obs_data_release(settings)

        except urllib.error.URLError as err:
            obs.script_log(obs.LOG_WARNING,
                           "Error opening URL: " + err.reason)
            obs.remove_current_callback()

        obs.obs_source_release(source)
Exemple #6
0
def source_activated(stuff):
    source = obs.calldata_source(stuff, "source")
    print(obs.obs_source_get_name(source))
    print("TODO: set live tally")

    if handler_name == "activate":
        print("TODO: set live tally")
    elif handler_name == "deactivate":
        if obs.obs_source_showing(source):
            print("TODO: set preview tally")
        else:
            print("TODO: clear tally")
    elif handler_name == "show":
        if obs.obs_source_active(
                source
        ):  #should never happen unless handlers fire in a weird order
            print("TODO: set live tally")
        else:
            print("TODO: set preview tally")
    elif handler_name == "hide":
        print("TODO: clear tally")
    else:
        print("TODO: clear tally")