Exemplo n.º 1
0
def populate_scene_lists(lists):
    scene_names = obs.obs_frontend_get_scene_names()
    for l in lists:
        obs.obs_property_list_clear(l)
        obs.obs_property_list_add_string(l, "", "")
        for name in scene_names:
            obs.obs_property_list_add_string(l, name, name)
Exemplo n.º 2
0
def fill_entrant_list(race, entrant_list):
    obs.obs_property_list_clear(entrant_list)
    obs.obs_property_list_add_string(entrant_list, "", "")
    if race is not None:
        for entrant in race.entrants:
            obs.obs_property_list_add_string(entrant_list,
                                             entrant.user.full_name,
                                             entrant.user.full_name)
Exemplo n.º 3
0
def populate_list_property_with_source_names(list_property):
  sources = obs.obs_enum_sources()
  obs.obs_property_list_clear(list_property)
  obs.obs_property_list_add_string(list_property, "", "")
  for source in sources:
    name = obs.obs_source_get_name(source)
    obs.obs_property_list_add_string(list_property, name, name)
  obs.source_list_release(sources)
Exemplo n.º 4
0
def populate_channels(props, p=None, _settings=None):
    p = obs.obs_properties_get(props, 'voice_channel')
    obs.obs_property_list_clear(p)
    for guild in sorted(client.guilds, key=lambda x: x.name.lower()):
        for channel in sorted(guild.channels, key=lambda x: x.position):
            if isinstance(channel, discord.VoiceChannel):
                obs.obs_property_list_add_string(
                    p, guild.name + ' -> ' + channel.name, str(channel.id))
    return True
Exemplo n.º 5
0
def fill_source_list(p):
    obs.obs_property_list_clear(p)
    obs.obs_property_list_add_string(p, "", "")
    with source_list_ar() as sources:
        if sources is not None:
            for source in sources:
                source_id = obs.obs_source_get_unversioned_id(source)
                if (source_id == "text_gdiplus"
                        or source_id == "text_ft2_source"):
                    name = obs.obs_source_get_name(source)
                    obs.obs_property_list_add_string(p, name, name)
def event_start_list_modified(props, property, settings):
    event_start_list = obs.obs_properties_get(props, "preshow_duration")
    obs.obs_property_list_clear(event_start_list)
    for i in range(0, 4):
        seconds = i * 60 * 5
        obs.obs_property_list_add_int(
            event_start_list,
            time(hour=math.floor((event_start - seconds) / 60 / 60),
                 minute=int(
                     (event_start - seconds) / 60 % 60)).strftime("%I:%M %p"),
            seconds)
    return True
Exemplo n.º 7
0
def populate_sources(props, p=None, _settings=None):
    p = obs.obs_properties_get(props, 'discord_source')
    obs.obs_property_list_clear(p)
    obs.obs_property_list_add_string(p, '(none)', '')
    sources = obs.obs_enum_sources()
    labels = {}
    for src in sources:
        n = obs.obs_source_get_name(src)
        labels[n] = n + ' (' + obs.obs_source_get_display_name(
            obs.obs_source_get_id(src)) + ')'
    obs.source_list_release(sources)
    for n in sorted(labels, key=lambda x: x.lower()):
        obs.obs_property_list_add_string(p, labels[n], n)
    return True
Exemplo n.º 8
0
 def _do_update(cls, data, item_prop, name, item_name):
     s1 = _obs.obs_data_get_string(data, name)
     s2 = _obs.obs_data_get_string(data, item_name)
     _obs.obs_property_list_clear(item_prop)
     _obs.obs_property_list_add_string(item_prop, "(None)", None)
     if not s1:
         return True  # still need to update
     try:
         items = _helper.get_scene_item_names(s1)
     except LookupError as ex:
         _obs.obs_property_list_add_string(item_prop, s2, s2)
         return True
     for n, k in items:
         _obs.obs_property_list_add_string(item_prop, n, n)
     return True
Exemplo n.º 9
0
def fill_race_list(rtgg_obs: RacetimeObs, race_list, category_list):
    lang = gettext.translation("racetime-obs",
                               localedir=os.environ['LOCALEDIR'])
    _ = lang.gettext
    obs.obs_property_list_clear(race_list)
    obs.obs_property_list_clear(category_list)
    obs.obs_property_list_add_string(category_list, _("All"), sp.all_category)

    obs.obs_property_list_add_string(race_list, _("None"), "None")
    races = racetime_client.get_races()
    if races is not None:
        fill_category_list(category_list, races)
        if (rtgg_obs.category == sp.alttpr_category
                or rtgg_obs.category == sp.all_category):
            obs.obs_property_list_add_string(race_list, sp.alttpr_ladder,
                                             sp.alttpr_ladder)
        for race in filter_races_by_category(rtgg_obs, races):
            obs.obs_property_list_add_string(race_list, race.name, race.name)
Exemplo n.º 10
0
def populate_participants(props, p=None, _settings=None):
    if not client.channel:
        return False
    values = []
    for nick, name, disc, uid in (
        (x.nick, x.name, x.discriminator, x.id)
            for x in sorted(client.channel.guild.members,
                            key=lambda x: x.display_name.lower() + '!')
            if x != client.user):
        label = (nick or name) + ' ('
        if nick:
            label += name + ' '
        label += f'#{disc})'
        values.append((label, uid))
    for name in ['myself'] + [f'participant{i}' for i in range(SLOTS)]:
        p = obs.obs_properties_get(props, name)
        obs.obs_property_list_clear(p)
        obs.obs_property_list_add_string(p, '(none)', '')
        for label, uid in values:
            obs.obs_property_list_add_string(p, label, str(uid))
    return True
def script_properties():
    props = obs.obs_properties_create()

    p = obs.obs_properties_add_bool(props, "manage_streaming",
                                    "Manage Streaming")
    obs.obs_property_set_modified_callback(p, on_property_modified)
    p = obs.obs_properties_add_bool(props, "manage_recording",
                                    "Manage Recording")
    obs.obs_property_set_modified_callback(p, on_property_modified)

    auto_start_group = obs.obs_properties_create()
    obs.obs_properties_add_group(props, "auto_start_group", "Auto Start",
                                 obs.OBS_GROUP_NORMAL, auto_start_group)

    p = obs.obs_properties_add_list(auto_start_group, "start_scene",
                                    "Start Scene", obs.OBS_COMBO_TYPE_LIST,
                                    obs.OBS_COMBO_FORMAT_STRING)
    obs.obs_property_set_enabled(p, manage_streaming or manage_recording)
    obs.obs_property_set_modified_callback(p, on_property_modified)
    obs.obs_property_list_add_string(p, "--Disabled--", "")
    scene_names = obs.obs_frontend_get_scene_names()
    if scene_names != None:
        for scene_name in scene_names:
            obs.obs_property_list_add_string(p, scene_name, scene_name)

    schedule_group = obs.obs_properties_create()
    obs.obs_properties_add_group(auto_start_group, "schedule_group",
                                 "Schedule", obs.OBS_GROUP_NORMAL,
                                 schedule_group)

    p = obs.obs_properties_add_list(schedule_group, "weekday", "Day of Week",
                                    obs.OBS_COMBO_TYPE_LIST,
                                    obs.OBS_COMBO_FORMAT_INT)
    obs.obs_property_set_enabled(p, (manage_streaming or manage_recording)
                                 and start_scene != "")
    for i, day_of_week in enumerate(days_of_week):
        obs.obs_property_list_add_int(p, day_of_week, i)

    p = obs.obs_properties_add_list(schedule_group, "preshow_duration",
                                    "Livestream Start",
                                    obs.OBS_COMBO_TYPE_LIST,
                                    obs.OBS_COMBO_FORMAT_INT)
    obs.obs_property_set_enabled(p, (manage_streaming or manage_recording)
                                 and start_scene != "")
    obs.obs_property_list_clear(p)
    for i in range(4):
        seconds = i * 60 * 5
        obs.obs_property_list_add_int(
            p,
            time(hour=math.floor((event_start - seconds) / 60 / 60),
                 minute=int(
                     (event_start - seconds) / 60 % 60)).strftime("%I:%M %p"),
            seconds)

    p = obs.obs_properties_add_list(schedule_group, "event_start",
                                    "Event Start", obs.OBS_COMBO_TYPE_LIST,
                                    obs.OBS_COMBO_FORMAT_INT)
    obs.obs_property_set_enabled(p, (manage_streaming or manage_recording)
                                 and start_scene != "")
    obs.obs_property_set_modified_callback(p, event_start_list_modified)
    for i in range(288):
        obs.obs_property_list_add_int(
            p,
            time(hour=math.floor(i / 12),
                 minute=(i % 12) * 5).strftime("%I:%M %p"),
            int((i / 12) * 60 * 60))

    text_source_list = obs.obs_properties_add_list(auto_start_group,
                                                   "text_source",
                                                   "Text Source",
                                                   obs.OBS_COMBO_TYPE_LIST,
                                                   obs.OBS_COMBO_FORMAT_STRING)
    obs.obs_property_set_enabled(text_source_list,
                                 (manage_streaming or manage_recording)
                                 and start_scene != "")
    obs.obs_property_set_modified_callback(text_source_list,
                                           on_property_modified)
    obs.obs_property_list_add_string(text_source_list, "--Disabled--", "")

    sources = obs.obs_enum_sources()
    if sources != None:
        for source in sources:
            source_id = obs.obs_source_get_unversioned_id(source)
            if source_id == "text_gdiplus" or source_id == "text_ft2_source":
                name = obs.obs_source_get_name(source)
                obs.obs_property_list_add_string(text_source_list, name, name)
    obs.source_list_release(sources)

    p = obs.obs_properties_add_text(auto_start_group, "countdown_final_text",
                                    "Countdown Final Text",
                                    obs.OBS_TEXT_DEFAULT)
    obs.obs_property_set_enabled(p, (manage_streaming or manage_recording)
                                 and text_source != "" and start_scene != "")

    auto_stop_group = obs.obs_properties_create()
    obs.obs_properties_add_group(props, "auto_stop_group", "Auto Stop",
                                 obs.OBS_GROUP_NORMAL, auto_stop_group)

    p = obs.obs_properties_add_list(auto_stop_group, "closing_scene",
                                    "Closing Scene", obs.OBS_COMBO_TYPE_LIST,
                                    obs.OBS_COMBO_FORMAT_STRING)
    obs.obs_property_set_enabled(p, manage_streaming or manage_recording)
    obs.obs_property_set_modified_callback(p, closing_scene_modified)
    obs.obs_property_list_add_string(p, "--Disabled--", "")
    scene_names = obs.obs_frontend_get_scene_names()
    if scene_names != None:
        for scene_name in scene_names:
            obs.obs_property_list_add_string(p, scene_name, scene_name)

    p = obs.obs_properties_add_int(auto_stop_group, "stop_streaming_delay",
                                   "Streaming Delay", 0, 300, 15)
    obs.obs_property_set_enabled(p, manage_streaming and closing_scene != "")
    p = obs.obs_properties_add_int(auto_stop_group, "stop_recording_delay",
                                   "Recording Delay", 0, 120, 5)
    obs.obs_property_set_enabled(p, manage_recording and closing_scene != "")

    return props