diff --git a/README.md b/README.md index 9e45e01..e69de29 100644 --- a/README.md +++ b/README.md @@ -1,5 +0,0 @@ -Q: but adam, I thought you utterly despised "organizing" by file type - -A: yes, but this particular repo is "misc". if it needs *any* more organization, make it a repo. it's not hard. - - diff --git a/obstwitch/q and a.html b/obstwitch/q and a.html new file mode 100644 index 0000000..ccf5bf8 --- /dev/null +++ b/obstwitch/q and a.html @@ -0,0 +1,65 @@ + + + + + + +
+ + +
+ + diff --git a/obstwitch/record-control-anchor.lua b/obstwitch/record-control-anchor.lua new file mode 100644 index 0000000..2f85ab2 --- /dev/null +++ b/obstwitch/record-control-anchor.lua @@ -0,0 +1,63 @@ +obs = obslua +stop_target = "" +start_target = "" +pause_target = "" + +function source_activated(cd) + local source = obs.calldata_source(cd, "source") + if source ~= nil then + local name = obs.obs_source_get_name(source) + if pause_target == name then + obs.obs_frontend_recording_pause(true) + elseif stop_target == name then + obs.obs_frontend_recording_stop() + elseif start_target == name then + obs.obs_frontend_recording_start() + end + end +end +function source_deactivated(cd) + local source = obs.calldata_source(cd, "source") + if source ~= nil then + local name = obs.obs_source_get_name(source) + if pause_target == name then + obs.obs_frontend_recording_pause(false) + end + end +end + +function script_properties() + local props = obs.obs_properties_create() + + local pStart = obs.obs_properties_add_list(props, "start_target", "start target", obs.OBS_COMBO_TYPE_EDITABLE, obs.OBS_COMBO_FORMAT_STRING) + local pStop = obs.obs_properties_add_list(props, "stop_target", "stop target", obs.OBS_COMBO_TYPE_EDITABLE, obs.OBS_COMBO_FORMAT_STRING) + local pPause = obs.obs_properties_add_list(props, "pause_target", "pause target", obs.OBS_COMBO_TYPE_EDITABLE, obs.OBS_COMBO_FORMAT_STRING) + local sources = obs.obs_enum_sources() + if sources ~= nil then + for _, source in ipairs(sources) do + local name = obs.obs_source_get_name(source) + obs.obs_property_list_add_string(pStart, name, name) + obs.obs_property_list_add_string(pStop, name, name) + obs.obs_property_list_add_string(pPause, name, name) + end + end + obs.source_list_release(sources) + + return props +end + +function script_description() + return "start/stop recording when specified source is in active scene" +end + +function script_update(settings) + stop_target = obs.obs_data_get_string(settings, "stop_target") + start_target = obs.obs_data_get_string(settings, "start_target") + pause_target = obs.obs_data_get_string(settings, "pause_target") +end + +function script_load(settings) + local sh = obs.obs_get_signal_handler() + obs.signal_handler_connect(sh, "source_activate", source_activated) + obs.signal_handler_connect(sh, "source_deactivate", source_deactivated) +end diff --git a/obstwitch/trivia.html b/obstwitch/trivia.html new file mode 100644 index 0000000..142157f --- /dev/null +++ b/obstwitch/trivia.html @@ -0,0 +1,43 @@ + + + + + + +
+
+ + \ No newline at end of file diff --git a/obstwitch/webhook on live.py b/obstwitch/webhook on live.py new file mode 100644 index 0000000..aac18b9 --- /dev/null +++ b/obstwitch/webhook on live.py @@ -0,0 +1,59 @@ +import obspython as obs +import urllib.request +import urllib.error +from urllib import request, parse +import json + +url = "" +body = "" + +# ------------------------------------------------------------ + + +def call_hook(): + global url + global body + + try: + data = json.dumps({"content": body}) + data = str(data) + data = data.encode() + req = request.Request(url, data=data,method="POST",headers = {'Content-Type': 'application/json', 'User-Agent': 'curl/7.54.1'}) + resp = request.urlopen(req) + + except urllib.error.URLError as err: + obs.script_log(obs.LOG_WARNING, "Error opening URL '" + url + "': " + err.reason) + obs.remove_current_callback() + +def testbutton_pressed(props, prop): + call_hook() +# ------------------------------------------------------------ + +def on_event(event): + if event == obs.OBS_FRONTEND_EVENT_STREAMING_STARTED: + call_hook() + +def script_description(): + return "posts basic text to a discord webhook when you go live\n\nBy AdamRGrey" + +def script_load(settings): + obs.obs_frontend_add_event_callback(on_event) + +def script_defaults(settings): + obs.obs_data_set_default_string(settings, "body", "hey I'm live! https://twitch.tv") + +def script_update(settings): + global url + global body + + url = obs.obs_data_get_string(settings, "url") + body = obs.obs_data_get_string(settings, "body") + +def script_properties(): + props = obs.obs_properties_create() + + obs.obs_properties_add_text(props, "url", "URL", obs.OBS_TEXT_DEFAULT) + obs.obs_properties_add_text(props, "body", "body", obs.OBS_TEXT_DEFAULT) + + obs.obs_properties_add_button(props, "button", "test", testbutton_pressed) + return props