Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import obspython as obs
- from shutil import move
- import os
- import time
- # Output paths and search strings
- output_paths = {
- "anythingelse": "D:/vods/anything-else",
- "bridges": "D:/vods/bridges",
- "destinystudio": "D:/vods/destiny-stream",
- "saturdaymorning": "D:/vods/saturday-morning"
- }
- # Description of the script for OBS
- def script_description():
- """Return the plugin description."""
- return "This plugin moves the recorded file to a specified folder after recording stops, based on keywords in the filename."
- # Hook to connect recording stop signal
- def script_load(settings):
- """Hook stop recording signal on plugin load."""
- signal_handler = obs.obs_output_get_signal_handler(
- obs.obs_frontend_get_recording_output()
- )
- obs.signal_handler_connect(signal_handler, "stop", signal_handler_function)
- # Update function to set output paths and search strings dynamically
- def script_update(settings):
- """Called when script settings are updated."""
- global output_paths
- output_paths = {
- "anythingelse": obs.obs_data_get_string(settings, "search_string1"),
- "bridges": obs.obs_data_get_string(settings, "search_string2"),
- "destinystudio": obs.obs_data_get_string(settings, "search_string3"),
- "saturdaymorning": obs.obs_data_get_string(settings, "search_string4")
- }
- # Property panel for OBS interface configuration
- def script_properties():
- """Define properties for OBS interface configuration."""
- props = obs.obs_properties_create()
- obs.obs_properties_add_text(props, "search_string1", "Keyword for Output 1", obs.OBS_TEXT_DEFAULT)
- obs.obs_properties_add_path(props, "output_path1", "Output Folder 1", obs.OBS_PATH_DIRECTORY, "", "")
- obs.obs_properties_add_text(props, "search_string2", "Keyword for Output 2", obs.OBS_TEXT_DEFAULT)
- obs.obs_properties_add_path(props, "output_path2", "Output Folder 2", obs.OBS_PATH_DIRECTORY, "", "")
- obs.obs_properties_add_text(props, "search_string3", "Keyword for Output 3", obs.OBS_TEXT_DEFAULT)
- obs.obs_properties_add_path(props, "output_path3", "Output Folder 3", obs.OBS_PATH_DIRECTORY, "", "")
- obs.obs_properties_add_text(props, "search_string4", "Keyword for Output 4", obs.OBS_TEXT_DEFAULT)
- obs.obs_properties_add_path(props, "output_path4", "Output Folder 4", obs.OBS_PATH_DIRECTORY, "", "")
- return props
- # Signal handler for recording stop
- def signal_handler_function(calldata):
- """Handle the recording stop signal and move the file accordingly."""
- try:
- last_recording = obs.obs_frontend_get_last_recording()
- # Wait for the file to be fully available
- time.sleep(3)
- if not last_recording or not os.path.exists(last_recording):
- print(f"Recording file not found: {last_recording}")
- return
- # Move the file based on matching keyword
- for keyword, output_path in output_paths.items():
- if keyword.lower() in last_recording.lower():
- if os.path.exists(output_path):
- move(last_recording, output_path)
- print(f"Moved file to: {output_path}")
- else:
- print(f"Output path does not exist: {output_path}")
- break
- else:
- print(f"No keyword match found for recording: {last_recording}")
- except Exception as e:
- print(f"Error occurred during file move: {e}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement