Пример #1
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)
Пример #2
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}
def script_save(settings):
    hotkey_save_array = obs.obs_hotkey_save(zoom_id_tog)
    obs.obs_data_set_array(settings, ZOOM_NAME_TOG, hotkey_save_array)
    obs.obs_data_array_release(hotkey_save_array)

    hotkey_save_array = obs.obs_hotkey_save(follow_id_tog)
    obs.obs_data_set_array(settings, FOLLOW_NAME_TOG, hotkey_save_array)
    obs.obs_data_array_release(hotkey_save_array)
Пример #4
0
def script_load(settings):
    global hotkey_id_tog
    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)
Пример #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)
def script_save(settings):
    """
    Save state for script
    """

    _hotkey_save_array = obs.obs_hotkey_save(script_state.hotkey_id)
    obs.obs_data_set_array(settings, "reset_hotkey", _hotkey_save_array)
    obs.obs_data_array_release(_hotkey_save_array)
Пример #7
0
def script_save(settings):
  restore_sceneitem_after_shake()
  obs.obs_save_sources()

  # Hotkey save
  hotkey_save_array = obs.obs_hotkey_save(hotkey_id)
  obs.obs_data_set_array(settings, "shake_hotkey", hotkey_save_array)
  obs.obs_data_array_release(hotkey_save_array)
Пример #8
0
def script_save(settings):
    hotkey_save_array = obs.obs_hotkey_save(hotkey_id_tog)
    obs.obs_data_set_array(settings, HOTKEY_NAME_TOG, hotkey_save_array)
    obs.obs_data_array_release(hotkey_save_array)

    hotkey_save_array = obs.obs_hotkey_save(hotkey_id_freeze)
    obs.obs_data_set_array(settings, HOTKEY_NAME_FREEZE, hotkey_save_array)
    obs.obs_data_array_release(hotkey_save_array)
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 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')
Пример #11
0
def script_save(settings):
    #streamMsgDispNext
    hotkey_save_array = obs.obs_hotkey_save(config.dispNext_hotkey_id)
    obs.obs_data_set_array(settings, "streamMsgDispNext", hotkey_save_array)
    obs.obs_data_array_release(hotkey_save_array)
    #streamMsgDispPrev
    hotkey_save_array = obs.obs_hotkey_save(config.dispPrev_hotkey_id)
    obs.obs_data_set_array(settings, "streamMsgDispPrev", hotkey_save_array)
    obs.obs_data_array_release(hotkey_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)
Пример #13
0
def script_save(settings):
    global HOTKEY_ID_COUNT_UP
    global HOTKEY_ID_RESET
    hotkey_save_array_count_up = obs.obs_hotkey_save(HOTKEY_ID_COUNT_UP)
    hotkey_save_array_reset = obs.obs_hotkey_save(HOTKEY_ID_RESET)
    obs.obs_data_set_array(settings, "count_up_hotkey",
                           hotkey_save_array_count_up)
    obs.obs_data_set_array(settings, "reset_hotkey", hotkey_save_array_reset)
    obs.obs_data_array_release(hotkey_save_array_count_up)
    obs.obs_data_array_release(hotkey_save_array_reset)
Пример #14
0
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)
Пример #15
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)
Пример #16
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)
Пример #18
0
def script_save(settings):
    # save the hotkey info
    # increment hotkey
    increment_hotkey_save_array = obs.obs_hotkey_save(increment_hotkey_id)
    obs.obs_data_set_array(settings, counter_increment_hotkey,
                           increment_hotkey_save_array)
    obs.obs_data_array_release(increment_hotkey_save_array)

    # decrement hotkey
    decrement_hotkey_save_array = obs.obs_hotkey_save(decrement_hotkey_id)
    obs.obs_data_set_array(settings, counter_decrement_hotkey,
                           decrement_hotkey_save_array)
    obs.obs_data_array_release(decrement_hotkey_save_array)
Пример #19
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
Пример #20
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()
Пример #21
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)
Пример #22
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})
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)
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
Пример #26
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()
Пример #27
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)
Пример #28
0
def change_input():
    global globSettings
    url = obs.obs_data_get_string(globSettings, "url")
    source = obs.obs_data_get_string(globSettings, "source")
    qual = obs.obs_data_get_string(globSettings, "res")
    if url != None and source != None:
        sourceObj = obs.obs_get_source_by_name(source)
        try:
            streamUrl = ""
            stream = streamlink.streams(url)

            if qual in stream:
                streamUrl = stream[qual].url
            elif qual + "60" in stream:
                streamUrl = stream[qual + "60"].url
            elif qual + "_alt" in stream:
                streamUrl = stream[qual + "_alt"].url
            elif qual + "60_alt" in stream:
                streamUrl = stream[qual + "60_alt"].url
            elif "best" in stream:
                streamUrl = stream["best"].url

            if streamUrl != "" and sourceObj != None:
                source_id = obs.obs_source_get_id(sourceObj)
                settings = obs.obs_data_create()
                if source_id == "ffmpeg_source":
                    obs.obs_data_set_string(settings, "input", streamUrl)
                    obs.obs_data_set_bool(settings, "is_local_file", False)
                    obs.obs_source_update(sourceObj, settings)
                else:
                    array = obs.obs_data_array_create()
                    data = obs.obs_data_create()
                    obs.obs_data_set_string(data, "name", streamUrl)
                    obs.obs_data_set_string(data, "value", streamUrl)
                    obs.obs_data_array_push_back(array, data)
                    obs.obs_data_release(data)
                    obs.obs_data_set_array(settings, "playlist", array)
                    obs.obs_source_update(sourceObj, settings)
                    obs.obs_data_array_release(array)

                obs.obs_data_release(settings)
        except streamlink.StreamlinkError:
            pass
        obs.obs_source_release(sourceObj)
Пример #29
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)
Пример #30
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))