def update_crop(self):
        """
        Create 2 display captures.
        Create crop filter with this name: cropXY.
        Check relative.
        Set Width and Height to relatively small numbers e.g : 64x64 .
        Image mask blend + color correction might be an option too.
        Run script,select this source as cursor source , check Update crop, click start.
        """
        source = obs.obs_get_source_by_name(self.source_name)
        crop = obs.obs_source_get_filter_by_name(source, "cropXY")
        filter_settings = obs.obs_source_get_settings(crop)

        _x, _y = get_position()
        # https://github.com/obsproject/obs-studio/blob/79981889c6d87d6e371e9dc8fcaad36f06eb9c9e/plugins/obs-filters/crop-filter.c#L87-L93
        w = obs.obs_data_get_int(filter_settings, "cx")
        h = obs.obs_data_get_int(filter_settings, "cy")
        h, w = int(h / 2), int(w / 2)
        obs.obs_data_set_int(filter_settings, "left", _x - h)
        obs.obs_data_set_int(filter_settings, "top", _y - w)

        obs.obs_source_update(crop, filter_settings)

        obs.obs_data_release(filter_settings)
        obs.obs_source_release(source)
        obs.obs_source_release(crop)
Beispiel #2
0
    def update_text(self, force=False, updateTime=True):
        source = obs.obs_get_source_by_name(self.source_name)
        if source is not None:
            if updateTime:
                self.secondsLive += 1

                if (self.secondsLive >= 60):
                    self.minutesLive += 1
                    self.secondsLive = 0
                    if (self.minutesLive >= 60):
                        self.hoursLive += 1
                        self.minutesLive = 0

            if (Data._visible_ and not Data._timerRunning_):
                timeLive = ""
            else:
                timeLive = self.get_formatted_time()

            #prevent more work being done than necessary
            if (timeLive == self.lastTimeLive and not force):
                return

            self.lastTimeLive = timeLive
            settings = obs.obs_data_create()
            obs.obs_data_set_string(settings, "text", timeLive)
            obs.obs_source_update(source, settings)
            obs.obs_data_release(settings)
            obs.obs_source_release(source)
Beispiel #3
0
def update_sprite_sources(source_name, team_slot):
    """Updates the settings values

    Gets called by update_team.

    Given the source name list, it updates the path for the sprite sources
    """
    # If the dex number is zero or null, then give it the empty GIF file so
    # they can set sizing
    if (not team_slot["dexnumber"]) or (team_slot["dexnumber"] == 0):
        location = f"{script_path()}empty.gif"
    else:
        sprite = get_sprite_location(sprite_map['sprites'], team_slot['shiny'],
                                     team_slot["dexnumber"], None)
        location = cache_image(sprite, team_slot['shiny'],
                               sprite_map['cache_location'], "sprites")

    source = obs.obs_get_source_by_name(source_name)
    if source is not None:
        # Set the text element as being the local cached version of the file
        settings = obs.obs_data_create()
        obs.obs_data_set_string(settings, "file", location)
        obs.obs_source_update(source, settings)
        obs.obs_data_release(settings)

        # Release the source
        obs.obs_source_release(source)
def update_text():
    """Updates text sources for the scoreboard"""

    global scoreboard_source_names, rate_vs, rate_nc, rate_tr

    scoreboard_source_names['RATE_VS'] = rate_vs
    scoreboard_source_names['RATE_NC'] = rate_nc
    scoreboard_source_names['RATE_TR'] = rate_tr

    for name in scoreboard_source_names:  # Iterate through list and update sources in OBS
        source = obs.obs_get_source_by_name(name)
        if source is not None:
            try:
                settings = obs.obs_data_create()
                obs.obs_data_set_string(settings, "text",
                                        scoreboard_source_names[name])
                obs.obs_source_update(source, settings)
                obs.obs_data_release(settings)
            except:
                obs.script_log(
                    obs.LOG_WARNING,
                    f'[{datetime.datetime.now()}][TRACKER] Encountered error updating '
                    f'scoreboard source')
                obs.remove_current_callback()

        obs.obs_source_release(
            source)  # Releases source and prevents memory leak
def update_text():
    global interval
    global source_name
    global strftime
    global prefix
    global suffix
    global time_offset

    time_stamp = time.time() + (time_offset * 60 * 60)

    source = obs.obs_get_source_by_name(source_name)
    if source is not None:
        time_obj = datetime.datetime.fromtimestamp(time_stamp)
        settings = obs.obs_data_create()
        time_str = "格式错误"
        try:
            time_str = "{}{}{}".format(prefix, time_obj.strftime(strftime), suffix)
        except ValueError:
            pass

        obs.obs_data_set_string(settings, "text", time_str)

        obs.obs_source_update(source, settings)
        obs.obs_data_release(settings)
        obs.obs_source_release(source)
Beispiel #6
0
def update_text():
    global source_name
    source = obs.obs_get_source_by_name(source_name)

    if source is not None:
        # Get the time from the computer OBS runs on
        if clock_24hr is True:
            time_now = datetime.now().strftime("%H:%M")
        else:
            time_now = datetime.now().strftime("%I:%M %p").lstrip("0")

        # Add timezone text beneath clock
        if timezone_text != "":
            clock_entry = f"{time_now}\n{timezone_text}"
        else:
            clock_entry = time_now

        # Updating the OBS source data
        settings = obs.obs_data_create()
        obs.obs_data_set_string(settings, "text", clock_entry)
        obs.obs_source_update(source, settings)
        obs.obs_data_release(settings)
        obs.obs_source_release(source)

        set_timer_interval()
Beispiel #7
0
 def update_text(self):
     source = obs.obs_get_source_by_name(self.source_name)
     if source is not None:
         data = str(next(datacycle))
         settings = obs.obs_data_create()
         obs.obs_data_set_string(settings, "text", data)
         obs.obs_source_update(source, settings)
Beispiel #8
0
def playsound(filename, volume, speed):
    obs.script_log(obs.LOG_DEBUG,
                   "Trying to play " + filename + " to source " + sourcename)

    scenesource = obs.obs_frontend_get_current_scene()
    scene = obs.obs_scene_from_source(scenesource)
    #obs.script_log(obs.LOG_DEBUG,"Scene "+str(scene))

    sceneitem = obs.obs_scene_find_source(scene, sourcename)
    #obs.script_log(obs.LOG_DEBUG,"Scene item "+str(sceneitem))

    source = obs.obs_sceneitem_get_source(sceneitem)

    obs.obs_source_set_volume(source, volume)
    set_source_speed(source, speed)

    obs.obs_sceneitem_set_visible(sceneitem, False)

    settings = obs.obs_source_get_settings(source)
    #obs.script_log(obs.LOG_DEBUG,str(obs.obs_data_get_json(settings)))
    obs.obs_data_set_string(settings, "local_file", audiofolder + filename)
    #obs.script_log(obs.LOG_DEBUG,str(obs.obs_data_get_json(settings)))

    obs.obs_source_update(source, settings)

    obs.obs_sceneitem_set_visible(sceneitem, True)

    obs.obs_data_release(settings)
    obs.obs_source_release(scenesource)
def update_text():
    """
    Update the text with the passed time string
    """

    _hide_zero_units = script_state.properties['hide_zero_units'].cur_value
    _format = script_state.properties['format'].cur_value
    _round_up = script_state.properties['round_up'].cur_value
    _time = script_state.clock.get_time(_format, _hide_zero_units, _round_up)

    _source = script_state.get_value('text_source')

    if not _source:
        return

    _text = _time.string

    if _time.seconds == 0:
        obs.remove_current_callback()
        _text = script_state.get_value('end_text')

    _settings = obs.obs_data_create()
    _source = obs.obs_get_source_by_name(_source)

    obs.obs_data_set_string(_settings, 'text', _text)
    obs.obs_source_update(_source, _settings)
    obs.obs_data_release(_settings)
    obs.obs_source_release(_source)
Beispiel #10
0
 def update_text(self):
     with source_auto_release(self.source_name) as source:
         if source is not None:
             data = str(next(datacycle))
             with data_auto_release() as settings:
                 obs.obs_data_set_string(settings, "text", data)
                 obs.obs_source_update(source, settings)
Beispiel #11
0
 def _obs_filter_set_property_values(self, filter_name, owner_name, values):
     with self._filter_by_name(owner_name, filter_name) as s:
         d = _obs.obs_data_create()
         try:
             _data.set_data(d, values.items())
             _obs.obs_source_update(s, d)
         finally:
             _obs.obs_data_release(d)
 def update_text(self):
     source = obs.obs_get_source_by_name(self.source_name)
     if source is not None:
         settings = obs.obs_data_create()
         obs.obs_data_set_string(settings, "text", self.data)
         obs.obs_source_update(source, settings)
         obs.obs_data_release(settings)
         obs.obs_source_release(source)
 def update_text(self, scripted_text, color=None):
     """takes scripted_text , sets its value in obs  """
     with source_ar(self.source_name) as source, data_ar() as settings:
         self.text_string = scripted_text
         if color:
             obs.obs_data_set_int(settings, "color", color)  # colored text
         obs.obs_data_set_string(settings, "text", self.text_string)
         obs.obs_source_update(source, settings)
def set_text_source(text):
    source = obs.obs_get_source_by_name(text_source)
    if source != None:
        settings = obs.obs_data_create()
        obs.obs_data_set_string(settings, "text", text)
        obs.obs_source_update(source, settings)
        obs.obs_data_release(settings)
        obs.obs_source_release(source)
 async def updateSource(self):
     source = obs.obs_get_source_by_name(config.obsSource)
     text = config.streamList.displayNext()
     if source is not None:
         settings = obs.obs_data_create()
         obs.obs_data_set_string(settings, "text", text)
         obs.obs_source_update(source, settings)
         obs.obs_data_release(settings)
         obs.obs_source_release(source)
Beispiel #16
0
def update_text(text):  #updates
    global source_name
    source = obs.obs_get_source_by_name(source_name)
    if source is not None:
        settings = obs.obs_data_create()
        obs.obs_data_set_string(settings, "text", text)
        obs.obs_source_update(source, settings)
        obs.obs_data_release(settings)
        obs.obs_source_release(source)
def update_match_video():
    global last_video_path

    print('update_match_video')

    # TODO: actually set the video starting at the start of the game, rather
    # than the slot. Also involves ensuring that our timings are in step with
    # the compbox.

    path = video_path.get()
    if last_video_path == path:
        print(f"{path!r} has already played")
        return

    # TODO: can we pull the current video from the source? I tried this but
    # couldn't work out how.
    last_video_path = path
    print(f"Updating to {path!r}")

    source = obs.obs_get_source_by_name(source_name)
    if source != None:
        print('got source')

        settings = obs.obs_data_create()
        source_id = obs.obs_source_get_id(source)
        if source_id == "ffmpeg_source":

            obs.obs_data_set_string(settings, "local_file", path)
            obs.obs_data_set_bool(settings, "is_local_file", True)

            # updating will automatically cause the source to
            # refresh if the source is currently active
            obs.obs_source_update(source, settings)

            # TODO: this ends up resetting the size of the video within OBS. Can
            # we inspect the source beforehand and preserve the apparent size?
            # Might be moot if all our videos are the same size and we're
            # showing them at 100% scale, but would be good to sort properly.

        elif source_id == "vlc_source":
            # "playlist"
            array = obs.obs_data_array_create()
            item = obs.obs_data_create()
            obs.obs_data_set_string(item, "value", path)
            obs.obs_data_array_push_back(array, item)
            obs.obs_data_set_array(settings, "playlist", array)

            # updating will automatically cause the source to
            # refresh if the source is currently active
            obs.obs_source_update(source, settings)
            obs.obs_data_release(item)
            obs.obs_data_array_release(array)

        obs.obs_data_release(settings)
        obs.obs_source_release(source)

    print('update_match_video done')
Beispiel #18
0
def update_bar():
    source = obs.obs_get_source_by_name(source_name)
    if source is not None:
        text = title() + "                                      Maker: " + maker() + "      Likes: " + likes() + "  Plays: " + plays() + "      " + id()
        
        settings = obs.obs_data_create()
        obs.obs_data_set_string(settings, "text", text)
        obs.obs_source_update(source, settings)
        obs.obs_data_release(settings)
    obs.obs_source_release(source)
Beispiel #19
0
def update_song():
    global debug_mode
    global now_playing

    settings = obspython.obs_data_create()
    obspython.obs_data_set_string(settings, "text", now_playing)
    source = obspython.obs_get_source_by_name(source_name)
    obspython.obs_source_update(source, settings)
    obspython.obs_data_release(settings)
    obspython.obs_source_release(source)
Beispiel #20
0
def set_logo(blue_config, orange_config): #reused for logo later
    default_logo = os.path.join(files_path, 'logo.png')

    blue_config_bun = get_bot_config_bundle(blue_config)

    orange_config_bun = get_bot_config_bundle(orange_config)

    blue_logo = blue_config_bun.get_logo_file()
    if blue_logo is None:
        blue_logo = default_logo
    orange_logo = orange_config_bun.get_logo_file()
    if orange_logo is None:
        orange_logo = default_logo

    default_logo_scale = 0.25
    default_logo_size = [400*default_logo_scale, 300*default_logo_scale]

    blue_logo_size = list(Image.open(blue_logo).size)
    blue_scale = default_logo_size[0]/blue_logo_size[0]
    orange_logo_size = list(Image.open(orange_logo).size)
    orange_scale = default_logo_size[0]/orange_logo_size[0]

    scenes = obs.obs_frontend_get_scenes()
    if scenes is not None:
        for scene in scenes:
            if obs.obs_source_get_name(scene) == 'RLBot - AutoLeague':
                scene = obs.obs_scene_from_source(scene)
                items = obs.obs_scene_enum_items(scene)
                for item in items:
                    if item is not None:
                        source_t = obs.obs_sceneitem_get_source(item)
                        if obs.obs_source_get_name(source_t) == "Logo-0":
                            source = source_t
                            settings = obs.obs_data_create()
                            obs.obs_data_set_string(settings, "file", blue_logo)
                            obs.obs_source_update(source, settings)
                            obs.obs_data_release(settings)

                            vec = obs.vec2()
                            obs.vec2_set(vec, blue_scale, blue_scale)
                            obs.obs_sceneitem_set_scale(item, vec)

                        if obs.obs_source_get_name(source_t) == "Logo-1":
                            source = source_t
                            settings = obs.obs_data_create()
                            obs.obs_data_set_string(settings, "file", orange_logo)
                            obs.obs_source_update(source, settings)
                            obs.obs_data_release(settings)

                            vec = obs.vec2()
                            obs.vec2_set(vec, orange_scale, orange_scale)
                            obs.obs_sceneitem_set_scale(item, vec)

                obs.source_list_release(scenes)
                obs.sceneitem_list_release(items)
Beispiel #21
0
 def update_text(self, counter_text, counter_value=0):
     source = obs.obs_get_source_by_name(self.source_name)
     settings = obs.obs_data_create()
     self.counter += 1
     if counter_value < 0:
         self.counter = 0
     self.text_string = f"{counter_text}{self.counter}"
     obs.obs_data_set_string(settings, "text", self.text_string)
     obs.obs_source_update(source, settings)
     obs.obs_data_release(settings)
     obs.obs_source_release(source)
    def on_left(self):
        self.menu_item_select = True
        self.action_item_active = False
        self.submenu_item_select = False
        self.selection = self.submenus[self.index]

        for i, _ in enumerate(self.submenus):
            with source_ar(
                    f"menu_{i}_status") as source, data_ar() as settings:
                obs.obs_data_set_string(settings, "text", " ")
                obs.obs_source_update(source, settings)
Beispiel #23
0
 def update_text(self, scripted_text, color=None):
     """takes scripted_text , sets its value in obs  """
     source = obs.obs_get_source_by_name(self.source_name)
     settings = obs.obs_data_create()
     self.text_string = scripted_text
     if color:
         obs.obs_data_set_int(settings, "color", color)  # colored text
     obs.obs_data_set_string(settings, "text", self.text_string)
     obs.obs_source_update(source, settings)
     obs.obs_data_release(settings)
     obs.obs_source_release(source)
Beispiel #24
0
def media_source_ar(media_path: str, monitoring_type: int):
    media_source = obs.obs_source_create_private("ffmpeg_source",
                                                 "Global Media Source", None)
    with data_ar() as settings:
        obs.obs_data_set_string(settings, "local_file", media_path)
        obs.obs_source_update(media_source, settings)
        obs.obs_source_set_monitoring_type(media_source, monitoring_type)
        try:
            yield media_source
        finally:
            obs.obs_source_release(media_source)
Beispiel #25
0
def render_textSource(source):
    textData = ""
    for lineCounter in range(0, len(TEXTSOURCE_BUFFER)):
        textData = textData + TEXTSOURCE_BUFFER[lineCounter]
        if (lineCounter != (len(TEXTSOURCE_BUFFER) - 1)):
            textData = textData + "\n"

    settings = obs.obs_data_create()
    obs.obs_data_set_string(settings, "text", textData)
    obs.obs_source_update(source, settings)
    obs.obs_data_release(settings)
def update_text():
    global source_name

    source = obs.obs_get_source_by_name(source_name)
    text = "Hello World"
    if source is not None:
        settings = obs.obs_data_create()
        obs.obs_data_set_string(settings, "text", text)
        obs.obs_source_update(source, settings)
        obs.obs_data_release(settings)
        obs.obs_source_release(source)
Beispiel #27
0
def update_text():
    song = get_active_song()
    song_name = obs.obs_source_get_name(song)
    settings = obs.obs_data_create()
    text_source = obs.obs_get_source_by_name(text_source_name)
    if text_source is not None:
        settings = obs.obs_data_create()
        obs.obs_data_set_string(settings, "text", song_name)
        obs.obs_source_update(text_source, settings)
        obs.obs_data_release(settings)
        obs.obs_source_release(text_source)
Beispiel #28
0
def update_text():
    global source_name

	#Changes source text to clipped text
    source = obs.obs_get_source_by_name(source_name)
    text = transcript
    if source is not None:
        settings = obs.obs_data_create()
        obs.obs_data_set_string(settings, "text", text)
        obs.obs_source_update(source, settings)
        obs.obs_data_release(settings)
        obs.obs_source_release(source)
Beispiel #29
0
def play_sound():
    mediaSource = S.obs_source_create_private("ffmpeg_source",
                                              "Global Media Source", None)
    s = S.obs_data_create()
    S.obs_data_set_string(s, "local_file", script_path() + "alert.mp3")
    S.obs_source_update(mediaSource, s)
    S.obs_source_set_monitoring_type(mediaSource,
                                     S.OBS_MONITORING_TYPE_MONITOR_AND_OUTPUT)
    S.obs_data_release(s)

    S.obs_set_output_source(outputIndex, mediaSource)
    return mediaSource
Beispiel #30
0
def update_text():
    global source_name

    source = obs.obs_get_source_by_name(source_name)
    text = ""
    if source is not None:
        settings = obs.obs_data_create()
        text = datetime.datetime.now().strftime(g_time_fmt)
        obs.obs_data_set_string(settings, "text", text)
        obs.obs_source_update(source, settings)
        obs.obs_data_release(settings)
        obs.obs_source_release(source)
Beispiel #31
0
def update_text():
	global url
	global interval
	global source_name

	source = obs.obs_get_source_by_name(source_name)
	if source is not None:
		try:
			with urllib.request.urlopen(url) as response:
				data = response.read()
				text = data.decode('utf-8')

				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 urllib.error.URLError as err:
			obs.script_log(obs.LOG_WARNING, "Error opening URL '" + url + "': " + err.reason)
			obs.remove_current_callback()

		obs.obs_source_release(source)