Created
June 18, 2021 02:59
-
-
Save dustractor/6635db478595f35500e920770014dcc9 to your computer and use it in GitHub Desktop.
OBS Studio python plugin: select last recorded mkv [windows only]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import obspython as obs | |
import datetime | |
import pathlib | |
import subprocess | |
class Data: | |
OutputDir = None | |
def frontend_event_handler(data): | |
if data == obs.OBS_FRONTEND_EVENT_RECORDING_STOPPED: | |
path = pathlib.Path(Data.OutputDir) | |
if path.exists(): | |
now_ts = datetime.datetime.now() | |
df = None | |
for df in sorted([((now_ts - datetime.datetime.fromtimestamp(_.stat().st_mtime)).total_seconds(),_) for _ in path.iterdir()]): | |
break | |
if df: | |
subprocess.run('explorer /select,"%s"'%str(df[1])) | |
return True | |
def script_update(settings): | |
Data.OutputDir = obs.obs_data_get_string(settings,"outputdir") | |
def script_description(): | |
return "you have to set the output folder manually" | |
def script_properties(): | |
props = obs.obs_properties_create() | |
obs.obs_properties_add_text( | |
props,"outputdir","the output folder",obs.OBS_TEXT_DEFAULT) | |
return props | |
obs.obs_frontend_add_event_callback(frontend_event_handler) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment