Пример #1
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")
Пример #2
0
def script_update(settings):
    global currentMidiPort
    global midiin
    global midiParams
    askedPort = obs.obs_data_get_string(settings, "midiDevice")
    if currentMidiPort != askedPort:
        if currentMidiPort != "":
            midiin.close_port()
            currentMidiPort = ""
        ok = True
        if askedPort != "":
            try:
                midiin, port_name = open_midiinput(askedPort)
                midiin.set_callback(MidiInputHandler(port_name))
            except (EOFError, KeyboardInterrupt):
                print("Meh :/")
                ok = False
            if ok:
                currentMidiPort = askedPort
    midiParams[0] = obs.obs_data_get_string(settings, "transitionMidiType")
    midiParams[1] = obs.obs_data_get_int(settings, "transitionMidiAddress")
    midiParams[2] = obs.obs_data_get_string(settings, "scenesMidiType")
    midiParams[3] = obs.obs_data_get_int(settings, "scenesMidiAddress")
    midiParams[4] = obs.obs_data_get_string(settings, "transitionsMidiType")
    midiParams[5] = obs.obs_data_get_int(settings, "transitionsMidiAddress")
    midiParams[6] = obs.obs_data_get_bool(settings, "logMidiInput")
Пример #3
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)
    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)
Пример #5
0
def script_update(settings):	
	global g
	g.settings = settings

	global slide_scene
	slide_scene = obs.obs_data_get_string(settings, "slide_scene")

	global monitors
	monitors = []
	for hMonitor, hdcMonitor, pyRect in win32api.EnumDisplayMonitors():
		monitors.append(Monitor(hMonitor, hdcMonitor, pyRect, win32api.GetMonitorInfo(hMonitor)["Device"])) 

	global monitor
	monitor = obs.obs_data_get_int(settings, "monitor")

	global screen_sourcename
	screen_sourcename = obs.obs_data_get_string(settings, "screen_sourcename")

	global slide_visible_duration
	slide_visible_duration = obs.obs_data_get_int(settings, "slide_visible_duration")

	global fadeout_duration
	fadeout_duration = obs.obs_data_get_double(settings, "fadeout_duration")

	global refresh_interval
	refresh_interval = obs.obs_data_get_double(settings, "refresh_interval")

	global camera_sourcename
	camera_sourcename = obs.obs_data_get_string(settings, "camera_sourcename")
Пример #6
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")
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)
Пример #8
0
 def fromSettings(cls, settings):
     return RecordingHandler(
         cmdType=obs.obs_data_get_string(settings, cls.Keys.cmdType),
         startChannel=obs.obs_data_get_int(settings, cls.Keys.startChannel),
         endChannel=obs.obs_data_get_int(settings, cls.Keys.endChannel),
         pauseChannel=obs.obs_data_get_int(settings, cls.Keys.pauseChannel),
         unpauseChannel=obs.obs_data_get_int(settings, cls.Keys.unpauseChannel)
     )
Пример #9
0
def script_update(updatedSettings):
    """
    Called when the script’s settings (if any) have been changed by the user.
    """
    global source_name
    global scene_item
    global animationCount
    global Server
    global Animations
    global settings
    global props

    print("Script Update Called")

    try:
        settings = updatedSettings

        source_name = obs.obs_data_get_string(settings, "source")
        animationCount = obs.obs_data_get_int(settings, "animationCount")
        Server.address = obs.obs_data_get_string(settings,
                                                 Server.addressStorage)
        Server.port = obs.obs_data_get_int(settings, Server.portStorage)

        restoreAnimations(settings)

        #only remove/add events if our server thread is failing.
        #serverThreadFound = False
        #main_thread = threading.current_thread()
        # for t in threading.enumerate():
        #     if t is main_thread or t.getName().startswith('Dummy'):
        #         print('Main/Dummy Thread with name %s, id %s' % (t.getName(), t.ident))
        #         continue
        #     print('Thread with name %s, id %s' % (t.getName(), t.ident))
        #     if t != None:
        #         Server.threadId = t.ident
        #         serverThreadFound = True
        #     break

        Server.run = False
        #Server.checkServer()

        Source.processingAnimation = False
        obs.timer_remove(adjustCameraTick)
        obs.timer_add(adjustCameraTick, UpdateRateMs)

        obs.timer_remove(check_Server)
        obs.timer_add(check_Server, 10000)

        obs.timer_remove(ping_Server)
        # # # Time is in ms.
        obs.timer_add(ping_Server, (Server.closeIfNoPingInXSeconds - 1) * 1000)

        obs.obs_frontend_remove_event_callback(frontend_event)
        obs.obs_frontend_add_event_callback(frontend_event)

    except Exception as e:
        print("Exception from script_update: %s" % (e))
Пример #10
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)
Пример #11
0
def script_update(settings):
    Settings.countdown_time = datetime.time(
        obs.obs_data_get_int(settings, "hour"),
        obs.obs_data_get_int(settings, "minute"),
        obs.obs_data_get_int(settings, "second"))

    Settings.source_name = obs.obs_data_get_string(settings, "source_name")
    Settings.stop_text = obs.obs_data_get_string(settings, "stop_text")

    start_timer()
Пример #12
0
def script_update(settings):

    global setting_offsetX
    global setting_offsetY
    global setting_offsetXMod
    global setting_offsetYMod

    setting_offsetX = obs.obs_data_get_int(settings, "offsetX")
    setting_offsetY = obs.obs_data_get_int(settings, "offsetY")
    setting_offsetXMod = obs.obs_data_get_int(settings, "offsetXMod")
    setting_offsetYMod = obs.obs_data_get_int(settings, "offsetYMod")
Пример #13
0
def script_update(settings):
    global initialized, PORT, WS_PORT, LIVE2D_FULL_PATH

    # print('script_update')

    PORT = obs.obs_data_get_int(settings, "port")
    WS_PORT = obs.obs_data_get_int(settings, "ws_port")
    LIVE2D_FULL_PATH = obs.obs_data_get_string(settings, "live2d_model")
    level = obs.obs_data_get_int(settings, "root_level")

    update_path(LIVE2D_FULL_PATH, level)

    if not initialized:
        initialized = True
        start_server()
Пример #14
0
def script_update(settings):
    global COLUMN_SIZE
    global LINE_SIZE
    global USERNAME_VALUE
    global CHANNEL_VALUE
    global OAUTH_KEY
    global TEXTSOURCE_VALUE
    COLUMN_SIZE = obs.obs_data_get_int(settings, "COLUMN_SIZE")
    LINE_SIZE = obs.obs_data_get_int(settings, "LINE_SIZE")
    USERNAME_VALUE = obs.obs_data_get_string(settings, "USERNAME_VALUE")
    USERNAME_VALUE = USERNAME_VALUE.lower()
    CHANNEL_VALUE = obs.obs_data_get_string(settings, "CHANNEL_VALUE")
    CHANNEL_VALUE = CHANNEL_VALUE.lower()
    OAUTH_KEY = obs.obs_data_get_string(settings, "OAUTH_VALUE")
    TEXTSOURCE_VALUE = obs.obs_data_get_string(settings, "TEXT_SOURCE")
Пример #15
0
    def update(self):
        global globSettings

        self.selection['menu'].delete(0, 'end')
        for choice in self.scenes:
            self.selection['menu'].add_command(label=choice,
                                               command=tk._setit(
                                                   self.scene, choice))
        stored = obs.obs_data_get_string(globSettings, "scene")
        if stored in self.scenes:
            self.scene.set(stored)
        else:
            self.scene.set(self.scenes[0])

        self.list.delete(0, self.list.index('end'))

        self.duration.set(obs.obs_data_get_int(globSettings, "duration"))

        templates = obs.obs_data_get_array(globSettings,
                                           "templates" + self.scene.get())
        if templates == None:
            template = obs.obs_data_array_create()
            obs.obs_data_set_array(globSettings,
                                   "templates" + self.scene.get(), template)
        length = obs.obs_data_array_count(templates)
        for i in range(length):
            item = obs.obs_data_array_item(templates, i)
            self.list.insert(
                'end',
                obs.obs_data_get_string(item, "id") + ". " +
                obs.obs_data_get_string(item, "name"))
            obs.obs_data_release(item)

        obs.obs_data_array_release(templates)
Пример #16
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")
def script_update(settings):
    global source_1_name
    global source_2_name
    global background_name
    global transition_time
    global host
    global port
    global password
    global autoconnect
    global thread_running

    source_1_name = obs.obs_data_get_string(settings, "source 1")
    create_colorcorrection_filter(source_1_name, COLOR_FILTER_NAME)
    source_2_name = obs.obs_data_get_string(settings, "source 2")
    create_colorcorrection_filter(source_2_name, COLOR_FILTER_NAME)
    background_name = obs.obs_data_get_string(settings, "background")
    create_colorcorrection_filter(background_name, COLOR_FILTER_NAME)

    transition_time = obs.obs_data_get_double(settings, "transition_time")

    host = obs.obs_data_get_string(settings, "host")
    port = obs.obs_data_get_int(settings, "port")
    password = obs.obs_data_get_string(settings, "password")

    tmpAutoconnect = obs.obs_data_get_bool(settings, "autoconnect")
    if not autoconnect and tmpAutoconnect:
        autoconnect = tmpAutoconnect
        if not thread_running:
            t = threading.Thread(target=connect)
            t.daemon = True
            t.start()
            q.put(0)
            thread_running = True
    else:
        autoconnect = tmpAutoconnect
Пример #18
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)
Пример #19
0
def script_update(settings):
    scripted_text_driver.source_name = obs.obs_data_get_string(
        settings, "source")

    scripted_text_driver.scripted_text = obs.obs_data_get_string(
        settings, "scripted_text")
    scripted_text_driver.refresh_rate = obs.obs_data_get_int(
        settings, "refresh_rate")

    scripted_text_driver.effect_duration = obs.obs_data_get_int(
        settings, "duration")
    scripted_text_driver.sound_source_name = obs.obs_data_get_string(
        settings, "playsound")
    scripted_text_driver.effect = obs.obs_data_get_string(
        settings, "text_effect")
    scripted_text_driver.stop_sound()
Пример #20
0
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")
    ircServer = obs.obs_data_get_string(settings, "IRC Server")
    ircChannel = obs.obs_data_get_string(settings, "IRC Channel")
    ircPort = obs.obs_data_get_int(settings, "IRC Port")
    ircNickname = obs.obs_data_get_string(settings, "IRC Nickname")
    ircPassword = obs.obs_data_get_string(settings, "IRC Password")
    config.commandPrefix = obs.obs_data_get_string(settings, "Command Prefix")
    config.commandResponse = obs.obs_data_get_string(settings,
                                                     "Command Response")
    config.irc = {
        "Enabled": True,
        "Servers": {
            ircServer: {
                "Channel": {
                    ircChannel: {
                        "Enabled": True
                    }
                },
                "Enabled": True,
                "Nickname": ircNickname,
                "Password": ircPassword,
                "Port": ircPort
            }
        }
    }
    config.obsSource = source_name
Пример #21
0
def script_update(settings):
    global xMaxSize
    global yMaxSize
    global followRate
    global zoomRate
    global keepAspectRatio
    global sourceName1
    global sourceName2
    xMaxSize = obs.obs_data_get_int(settings, "xMaxSize")
    yMaxSize = obs.obs_data_get_int(settings, "yMaxSize")
    followRate = obs.obs_data_get_int(settings, "followRate")
    zoomRate = obs.obs_data_get_int(settings, "zoomRate")
    keepAspectRatio = obs.obs_data_get_bool(settings, "keepAspectRatio")
    print(keepAspectRatio)
    sourceName1 = obs.obs_data_get_string(settings, "sourceName1")
    sourceName2 = obs.obs_data_get_string(settings, "sourceName2")
Пример #22
0
def tulosta(props, p):
    global settings

    nimi = obs.obs_data_get_string(settings, "valinta")
    source = obs.obs_get_source_by_name(nimi)
    data = obs.obs_source_get_settings(source)
    color = obs.obs_data_get_int(data, "color")
    print(color)
Пример #23
0
def script_load(settings):
    Data._format_ = obs.obs_data_get_string(settings, 'format')
    Data._timerDuration_ = obs.obs_data_get_int(settings, 'timer_duration')
    if not Data._format_:
        Data._format_ = Data._defaultFormat_

    obs.obs_data_set_string(settings, 'format', Data._format_)
    obs.obs_data_set_int(settings, 'timer_duration', Data._timerDuration_)
Пример #24
0
def script_update_coop_settings(settings, rtgg_obs: RacetimeObs):
    rtgg_obs.coop.enabled = obs.obs_data_get_bool(settings, "use_coop")
    rtgg_obs.coop.partner = obs.obs_data_get_string(settings, "coop_partner")
    rtgg_obs.coop.opponent1 = obs.obs_data_get_string(settings,
                                                      "coop_opponent1")
    rtgg_obs.coop.opponent2 = obs.obs_data_get_string(settings,
                                                      "coop_opponent2")
    rtgg_obs.coop.our_time_source = (obs.obs_data_get_string(
        settings, "coop_our_source"))
    rtgg_obs.coop.opponent_time_source = obs.obs_data_get_string(
        settings, "coop_opponent_source")
    rtgg_obs.coop.winner_color = obs.obs_data_get_int(settings,
                                                      "coop_winner_color")
    rtgg_obs.coop.loser_color = obs.obs_data_get_int(settings,
                                                     "coop_loser_color")
    rtgg_obs.coop.still_racing_color = obs.obs_data_get_int(
        settings, "coop_undetermined_color")
Пример #25
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)
Пример #26
0
 def _get(self, data):
     if self.type is float:
         v = _obs.obs_data_get_double(data, self.name)
     elif self.type is int:
         v = _obs.obs_data_get_int(data, self.name)
     else:
         v = _obs.obs_data_get_string(data, self.name)
     return {self.name: v}
Пример #27
0
 def durUpdate(self, *args):
     global globSettings
     if self.duration.get().isdigit():
         obs.obs_data_set_int(globSettings, "duration",
                              int(self.duration.get()))
     else:
         self.duration.set(
             str(obs.obs_data_get_int(globSettings, "duration")))
Пример #28
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
def script_update(settings):
    """
    Applies any changes made to the MQTT settings in the OBS Scripts GUI then
    reconnects the MQTT client.
    """
    # Apply the new settings
    global MQTT_HOST
    global MQTT_PORT
    global MQTT_CHANNEL
    global INTERVAL
    global TALLY_STATUS

    TALLY_STATUS = {}
    data_array = obs.obs_data_get_array(settings, "tally_sources")
    try:
        for i in range(obs.obs_data_array_count(data_array)):
            item = obs.obs_data_array_item(data_array, i)
            TALLY_STATUS[obs.obs_data_get_string(item, 'value')] = "000000"
    finally:
        obs.obs_data_array_release(data_array)

    mqtt_host = obs.obs_data_get_string(settings, "mqtt_host")
    if mqtt_host != MQTT_HOST:
        MQTT_HOST = mqtt_host
    mqtt_channel = obs.obs_data_get_string(settings, "mqtt_channel")
    if mqtt_channel != MQTT_CHANNEL:
        MQTT_CHANNEL = mqtt_channel
    mqtt_port = obs.obs_data_get_int(settings, "mqtt_port")
    if mqtt_port != MQTT_PORT:
        MQTT_PORT = mqtt_port
    INTERVAL = obs.obs_data_get_int(settings, "interval")

    # Disconnect (if connected) and reconnect the MQTT client
    CLIENT.disconnect()
    try:
        CLIENT.connect_async(MQTT_HOST, MQTT_PORT, 60)
        # Publish our initial state
        CLIENT.publish(MQTT_CHANNEL, json.dumps(STATUS))
    except (socket.gaierror, ConnectionRefusedError) as e:
        print("NOTE: Got a socket issue: %s" % e)
        pass  # Ignore it for now

    # Remove and replace the timer that publishes our status information
    obs.timer_remove(update_status)
    obs.timer_add(update_status, INTERVAL * 1000)
    CLIENT.loop_start()  # So we can know if we connected successfully
Пример #30
0
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)
Пример #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)