def script_load(settings):
    global zoom_id_tog
    zoom_id_tog = obs.obs_hotkey_register_frontend(ZOOM_NAME_TOG,
                                                   ZOOM_DESC_TOG, toggle_zoom)
    hotkey_save_array = obs.obs_data_get_array(settings, ZOOM_NAME_TOG)
    obs.obs_hotkey_load(zoom_id_tog, hotkey_save_array)
    obs.obs_data_array_release(hotkey_save_array)

    global follow_id_tog
    follow_id_tog = obs.obs_hotkey_register_frontend(FOLLOW_NAME_TOG,
                                                     FOLLOW_DESC_TOG,
                                                     toggle_follow)
    hotkey_save_array = obs.obs_data_get_array(settings, FOLLOW_NAME_TOG)
    obs.obs_hotkey_load(follow_id_tog, hotkey_save_array)
    obs.obs_data_array_release(hotkey_save_array)
Пример #2
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)
Пример #3
0
def script_load(settings):
    global hotkey_id_tog
    global hotkey_id_freeze

    hotkey_id_tog = obs.obs_hotkey_register_frontend(HOTKEY_NAME_TOG,
                                                     HOTKEY_DESC_TOG,
                                                     toggle_zoom_follow)
    hotkey_save_array = obs.obs_data_get_array(settings, HOTKEY_NAME_TOG)
    obs.obs_hotkey_load(hotkey_id_tog, hotkey_save_array)
    obs.obs_data_array_release(hotkey_save_array)

    hotkey_id_freeze = obs.obs_hotkey_register_frontend(
        HOTKEY_NAME_FREEZE, HOTKEY_DESC_FREEZE, toggle_zoom_freeze)
    hotkey_save_array = obs.obs_data_get_array(settings, HOTKEY_NAME_FREEZE)
    obs.obs_hotkey_load(hotkey_id_freeze, hotkey_save_array)
    obs.obs_data_array_release(hotkey_save_array)
Пример #4
0
 def _get(self, data):
     o = _obs.obs_data_get_array(data, self.name)
     try:
         values = [v.get("value") for v in _helper.read_data_array(o)]
     finally:
         _obs.obs_data_array_release(o)
     return {self.name: values}
Пример #5
0
def script_load(settings):
	global hotkey
	hotkey = obs.obs_hotkey_register_frontend("SlideDisplay.hotkey.show", "Show Slide-Display (hold)", hotkey_callback)
	hotkey_save_array = obs.obs_data_get_array(settings, "SlideDisplay.hotkey.show")
	obs.obs_hotkey_load(hotkey, hotkey_save_array)
	obs.obs_data_array_release(hotkey_save_array)

	obs.obs_frontend_add_event_callback(on_event)
Пример #6
0
def script_load(settings):
    config.streamList = streamList.streamList()
    #streamMsgDispNext
    config.dispNext_hotkey_id = obs.obs_hotkey_register_frontend(
        "streamMsgDispNext", "Stream Msg Increment", displayNextHotkey)
    hotkey_save_array = obs.obs_data_get_array(settings, "streamMsgDispNext")
    obs.obs_hotkey_load(config.dispNext_hotkey_id, hotkey_save_array)
    obs.obs_data_array_release(hotkey_save_array)
    #streamMsgDispPrev
    config.dispPrev_hotkey_id = obs.obs_hotkey_register_frontend(
        "streamMsgDispPrev", "Stream Msg Decrement", displayPrevHotkey)
    hotkey_save_array = obs.obs_data_get_array(settings, "streamMsgDispPrev")
    obs.obs_hotkey_load(config.dispPrev_hotkey_id, hotkey_save_array)
    obs.obs_data_array_release(hotkey_save_array)

    #loads all the initial configs from obs for the tool
    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

    config.secondaryThread = main()
    config.secondaryThread.start()
def script_load(settings):
    s = S.obs_data_create_from_json(JSON_DATA)

    a = S.obs_data_get_array(s, ID)
    h = S.obs_hotkey_register_frontend(ID, ID, on_obs_key_1)
    S.obs_hotkey_load(h, a)

    S.obs_data_array_release(a)
    S.obs_data_release(s)
def script_load(settings):
    #Load hotkeys
    for hotkeyId in hotkeyDict:
        hk = obs.obs_hotkey_register_frontend(
            hotkeyId, hotkeyDict[hotkeyId]["description"],
            hotkeyDict[hotkeyId]["function"])
        hotkeyDict[hotkeyId]["id"] = hk
        save_array = obs.obs_data_get_array(settings, hotkeyId)
        obs.obs_hotkey_load(hk, save_array)
        obs.obs_data_array_release(save_array)
def hook(obs_htk_id, htk_id, callback):
    json_data = '{"%s":[{"key":"%s"}]}' % (htk_id, obs_htk_id)
    s = S.obs_data_create_from_json(json_data)

    a = S.obs_data_get_array(s, htk_id)
    h = S.obs_hotkey_register_frontend(htk_id, obs_htk_id, callback)
    S.obs_hotkey_load(h, a)

    S.obs_data_array_release(a)
    S.obs_data_release(s)
Пример #10
0
 def switch(self):
     global globSettings
     selection = self.list.curselection()
     if selection != "":
         templates = obs.obs_data_get_array(globSettings,
                                            "templates" + self.scene.get())
         item = obs.obs_data_array_item(templates, selection[0])
         loc = obs.obs_data_get_string(item, "loc")
         obs.obs_data_release(item)
         obs.obs_data_array_release(templates)
         start_animation(loc)
Пример #11
0
def script_load(settings):
    def callback_up(pressed):
        if pressed:
            return scripted_text_driver.hotkey_hook()

    hotkey_id_scripted_text = obs.obs_hotkey_register_frontend(
        "Trigger sripted text", "Trigger sripted text", callback_up)
    hotkey_save_array_scripted_text = obs.obs_data_get_array(
        settings, "scripted_text_hotkey")
    obs.obs_hotkey_load(hotkey_id_scripted_text,
                        hotkey_save_array_scripted_text)
    obs.obs_data_array_release(hotkey_save_array_scripted_text)
def script_load(settings):
    global HOTKEY_ID

    def callback(pressed):
        if pressed:
            return eg.update_text()

    HOTKEY_ID = S.obs_hotkey_register_frontend("htk_id", "Example hotkey",
                                               callback)
    hotkey_save_array_htk = S.obs_data_get_array(settings, "htk_hotkey")
    S.obs_hotkey_load(HOTKEY_ID, hotkey_save_array_htk)
    S.obs_data_array_release(hotkey_save_array_htk)
Пример #13
0
 def remove(self):
     global globSettings
     selection = self.list.curselection()
     if selection != "":
         templates = obs.obs_data_get_array(globSettings,
                                            "templates" + self.scene.get())
         obs.obs_data_array_erase(templates, selection[0])
         length = obs.obs_data_array_count(templates)
         for i in range(selection[0], length):
             item = obs.obs_data_array_item(templates, i)
             obs.obs_data_set_string(item, "id", str(i + 1))
             obs.obs_data_release(item)
         obs.obs_data_array_release(templates)
     self.update()
Пример #14
0
def script_load(settings):
    global HOTKEY_ID_COUNT_UP
    global HOTKEY_ID_RESET

    def callback_up(pressed):
        if pressed:
            return hotkeys_counter.hotkey_up()

    def callback_reset(pressed):
        if pressed:
            return hotkeys_counter.hotkey_reset()

    HOTKEY_ID_COUNT_UP = obs.obs_hotkey_register_frontend(
        "counter up !", "Count up ", callback_up)
    HOTKEY_ID_RESET = obs.obs_hotkey_register_frontend("reset !", "Reset ",
                                                       callback_reset)
    hotkey_save_array_count_up = obs.obs_data_get_array(
        settings, "count_up_hotkey")
    hotkey_save_array_reset = obs.obs_data_get_array(settings, "reset_hotkey")
    obs.obs_hotkey_load(HOTKEY_ID_COUNT_UP, hotkey_save_array_count_up)
    obs.obs_hotkey_load(HOTKEY_ID_RESET, hotkey_save_array_reset)
    obs.obs_data_array_release(hotkey_save_array_count_up)
    obs.obs_data_array_release(hotkey_save_array_reset)
Пример #15
0
def _register_hot_keys(settings):
	global scenes

	scenes = obs.obs_frontend_get_scenes()
	for i in range(len(scenes)):
		scene = scenes[i]
		scene_id = obs.obs_source_get_name(scene)
		callback = _handle_key(scene, scene_id)
		name = 'toggle.' + scene_id
		hot_key_id = obs.obs_hotkey_register_frontend(name, "Toggle '" + scene_id + "'", callback)
		save_array = obs.obs_data_get_array(settings, name)
		obs.obs_hotkey_load(hot_key_id, save_array)
		obs.obs_data_array_release(save_array)
		hot_keys.append({'callback': callback, 'scene_id': hot_key_id, 'name': name})
Пример #16
0
def script_load(settings):
    global keeptime

    # grab the hotkey info from OBS
    global hotkey_id
    hotkey_id = obs.obs_hotkey_register_frontend(script_path(), "PSTimestamp",
                                                 on_timestamp_hotkey)
    hotkey_save_array = obs.obs_data_get_array(settings, "timestamp_hotkey")
    obs.obs_hotkey_load(hotkey_id, hotkey_save_array)
    obs.obs_data_array_release(hotkey_save_array)

    # register events callback
    obs.obs_frontend_add_event_callback(on_event)
    keeptime = False
Пример #17
0
def script_load(settings):
    global HOTKEY_ID

    def callback_up(pressed):
        if pressed:
            return scripted_text_driver.hotkey_hook()

    HOTKEY_ID = obs.obs_hotkey_register_frontend("scripted_text_hotkey",
                                                 "Trigger sripted text",
                                                 callback_up)
    hotkey_save_array = obs.obs_data_get_array(settings,
                                               "scripted_text_hotkey")
    obs.obs_hotkey_load(HOTKEY_ID, hotkey_save_array)
    obs.obs_data_array_release(hotkey_save_array)
    def script_load(settings_):
        global settings

        settings = settings_

        reset_match_info()

        # run child reaper every second
        obs.timer_add(check_children, 1000)

        # get saved hotkey data
        hotkey_start = obs.obs_data_get_array(settings, 'hotkey_start')
        hotkey_stop = obs.obs_data_get_array(settings, 'hotkey_stop')
        hotkey_cancel = obs.obs_data_get_array(settings, 'hotkey_cancel')

        # register hotkeys
        hotkeys['start'] = obs.obs_hotkey_register_frontend(
            'ftc-match-uploader_start', '(FTC) Start recording a match',
            start_recording)
        hotkeys['stop'] = obs.obs_hotkey_register_frontend(
            'ftc-match-uploader_stop',
            '(FTC) Stop recording a match and upload to YouTube',
            stop_recording_and_upload)
        hotkeys['cancel'] = obs.obs_hotkey_register_frontend(
            'ftc-match-uploader_cancel',
            '(FTC) Stop recording a match but cancel uploading to YouTube',
            stop_recording_and_cancel)

        # load saved hotkey data
        obs.obs_hotkey_load(hotkeys['start'], hotkey_start)
        obs.obs_hotkey_load(hotkeys['stop'], hotkey_stop)
        obs.obs_hotkey_load(hotkeys['cancel'], hotkey_cancel)

        # release data references
        obs.obs_data_array_release(hotkey_start)
        obs.obs_data_array_release(hotkey_stop)
        obs.obs_data_array_release(hotkey_cancel)
Пример #19
0
def script_load(settings):
    # create hotkey settings in OBS
    global increment_hotkey_id, decrement_hotkey_id, counter_filepath

    # increment hotkey
    increment_hotkey_id = obs.obs_hotkey_register_frontend(
        script_path(), "PSCounter Up", on_increment_hotkey)
    increment_hotkey_save_array = obs.obs_data_get_array(
        settings, counter_increment_hotkey)
    obs.obs_hotkey_load(increment_hotkey_id, increment_hotkey_save_array)
    obs.obs_data_array_release(increment_hotkey_save_array)

    # decrement hotkey
    decrement_hotkey_id = obs.obs_hotkey_register_frontend(
        script_path(), "PSCounter Down", on_decrement_hotkey)
    decrement_hotkey_save_array = obs.obs_data_get_array(
        settings, counter_decrement_hotkey)
    obs.obs_hotkey_load(decrement_hotkey_id, decrement_hotkey_save_array)
    obs.obs_data_array_release(decrement_hotkey_save_array)

    # create counter file if it doesn't exist
    counter_filepath = obs.obs_data_get_string(settings, file_path_setting)
    create_count_file()
    print("*** PSCounter loaded! ***")
def script_load(settings):
    """
    Connect hotkey and activation/deactivation signal callbacks
    """

    _sh = obs.obs_get_signal_handler()
    obs.signal_handler_connect(_sh, "source_activate", source_activated)
    obs.signal_handler_connect(_sh, "source_deactivate", source_deactivated)

    _hotkey_id = obs.obs_hotkey_register_frontend("reset_timer_thingy",
                                                  "Reset Timer", reset)

    _hotkey_save_array = obs.obs_data_get_array(settings, "reset_hotkey")
    obs.obs_hotkey_load(_hotkey_id, _hotkey_save_array)
    obs.obs_data_array_release(_hotkey_save_array)
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
Пример #22
0
    def find_obs_device_pipeline(self):
        gst_raw_list = obs.obs_data_get_array(self.plugin_settings, "list")
        num_gst_raw = obs.obs_data_array_count(gst_raw_list)

        self.devices = {}
        for i in range(num_gst_raw):  # Convert C array to Python list
            gst_raw_object = obs.obs_data_array_item(gst_raw_list, i)
            device_id,pipeline = obs.obs_data_get_string(gst_raw_object, "value").split("~")
            self.devices[device_id]=pipeline

        for device_id,pipeline in self.devices.items():
                print("{device_id}: {pipeline}".format(device_id=device_id,pipeline=pipeline))
        if self.device_supplied_id in  self.devices:
            obs.script_log(obs.LOG_INFO,"Device entry found for {device_id}".format(device_id=self.device_supplied_id))
            self.pipeline = self.devices[self.device_supplied_id] +" matroskamux name=mux ! queue ! tcpclientsink host={obs_ip_address} port={port}".format(port=self.video_port,obs_ip_address=self.obs_ip_address)
        else:
            obs.script_log(obs.LOG_INFO,"No device entry for {device_id}".format(device_id=self.device_supplied_id))
        return
Пример #23
0
def monitor_source(source):
    ignored = obs.obs_data_get_array(settings, 'ignored')

    for idx in range(obs.obs_data_array_count(ignored)):
        ignored_source_data = obs.obs_data_array_item(ignored, idx)
        ignored_source = str(
            obs.obs_data_get_string(ignored_source_data, 'value'))
        obs.obs_data_release(ignored_source_data)

        if ignored_source.strip() == obs.obs_source_get_name(source).strip():
            print(f'Ignoring "{obs.obs_source_get_name(source)}"')
            break
    else:
        print(f'Monitoring "{obs.obs_source_get_name(source)}"')
        obs.obs_source_set_monitoring_type(
            source, obs.OBS_MONITORING_TYPE_MONITOR_AND_OUTPUT)

    obs.obs_data_array_release(ignored)
Пример #24
0
def script_update(settings):
    twitch.channel = obs.obs_data_get_string(settings, "channel").lower()
    twitch.nickname = obs.obs_data_get_string(settings, "user").lower()

    new_oauth = obs.obs_data_get_string(settings, "oauth").lower()
    if new_oauth != twitch.password:
        twitch.disconnect()  # Disconnect old oauth connection, if it exists
        twitch.password = new_oauth

    obs_messages = obs.obs_data_get_array(settings, "messages")
    num_messages = obs.obs_data_array_count(obs_messages)

    messages = []
    for i in range(num_messages):  # Convert C array to Python list
        message_object = obs.obs_data_array_item(obs_messages, i)
        messages.append(obs.obs_data_get_string(message_object, "value"))

    ChatMessage.check_messages(messages, settings)
    obs.obs_data_array_release(obs_messages)
Пример #25
0
 def add(self):
     global globSettings
     loc = filedialog.askopenfilename(filetypes=[("JSON", "*.json")],
                                      title="Open Template File")
     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)
     new = obs.obs_data_create()
     length = obs.obs_data_array_count(templates) + 1
     obs.obs_data_set_string(new, "id", str(length))
     obs.obs_data_set_string(new, "name", os.path.basename(loc))
     obs.obs_data_set_string(new, "loc", loc)
     obs.obs_data_array_push_back(templates, new)
     obs.obs_data_release(new)
     obs.obs_data_array_release(templates)
     self.list.insert('end', str(length) + ". " + os.path.basename(loc))
Пример #26
0
 def load_hotkey(self):
     self.hotkey_saved_key = obs.obs_data_get_array(
         self.obs_data, "htk_id" + str(self._id))
     obs.obs_data_array_release(self.hotkey_saved_key)
Пример #27
0
 def load_hotkey(self):
     self.hotkey_saved_key = obs.obs_data_get_array(
         self.obs_data, "chat_hotkey_" + str(self.position))
Пример #28
0
def script_load(settings):
  global hotkey_id
  hotkey_id = obs.obs_hotkey_register_frontend(script_path(), "Source Shake", on_shake_hotkey)
  hotkey_save_array = obs.obs_data_get_array(settings, "shake_hotkey")
  obs.obs_hotkey_load(hotkey_id, hotkey_save_array)
  obs.obs_data_array_release(hotkey_save_array)