Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2024
400
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.50 KB | None | 0 0
  1. import obspython as obs
  2. from shutil import move
  3. import os
  4. import time
  5.  
  6. # Output paths and search strings
  7. output_paths = {
  8. "anythingelse": "D:/vods/anything-else",
  9. "bridges": "D:/vods/bridges",
  10. "destinystudio": "D:/vods/destiny-stream",
  11. "saturdaymorning": "D:/vods/saturday-morning"
  12. }
  13.  
  14. # Description of the script for OBS
  15. def script_description():
  16. """Return the plugin description."""
  17. return "This plugin moves the recorded file to a specified folder after recording stops, based on keywords in the filename."
  18.  
  19. # Hook to connect recording stop signal
  20. def script_load(settings):
  21. """Hook stop recording signal on plugin load."""
  22. signal_handler = obs.obs_output_get_signal_handler(
  23. obs.obs_frontend_get_recording_output()
  24. )
  25. obs.signal_handler_connect(signal_handler, "stop", signal_handler_function)
  26.  
  27. # Update function to set output paths and search strings dynamically
  28. def script_update(settings):
  29. """Called when script settings are updated."""
  30. global output_paths
  31. output_paths = {
  32. "anythingelse": obs.obs_data_get_string(settings, "search_string1"),
  33. "bridges": obs.obs_data_get_string(settings, "search_string2"),
  34. "destinystudio": obs.obs_data_get_string(settings, "search_string3"),
  35. "saturdaymorning": obs.obs_data_get_string(settings, "search_string4")
  36. }
  37.  
  38. # Property panel for OBS interface configuration
  39. def script_properties():
  40. """Define properties for OBS interface configuration."""
  41. props = obs.obs_properties_create()
  42.  
  43. obs.obs_properties_add_text(props, "search_string1", "Keyword for Output 1", obs.OBS_TEXT_DEFAULT)
  44. obs.obs_properties_add_path(props, "output_path1", "Output Folder 1", obs.OBS_PATH_DIRECTORY, "", "")
  45.  
  46. obs.obs_properties_add_text(props, "search_string2", "Keyword for Output 2", obs.OBS_TEXT_DEFAULT)
  47. obs.obs_properties_add_path(props, "output_path2", "Output Folder 2", obs.OBS_PATH_DIRECTORY, "", "")
  48.  
  49. obs.obs_properties_add_text(props, "search_string3", "Keyword for Output 3", obs.OBS_TEXT_DEFAULT)
  50. obs.obs_properties_add_path(props, "output_path3", "Output Folder 3", obs.OBS_PATH_DIRECTORY, "", "")
  51.  
  52. obs.obs_properties_add_text(props, "search_string4", "Keyword for Output 4", obs.OBS_TEXT_DEFAULT)
  53. obs.obs_properties_add_path(props, "output_path4", "Output Folder 4", obs.OBS_PATH_DIRECTORY, "", "")
  54.  
  55. return props
  56.  
  57. # Signal handler for recording stop
  58. def signal_handler_function(calldata):
  59. """Handle the recording stop signal and move the file accordingly."""
  60. try:
  61. last_recording = obs.obs_frontend_get_last_recording()
  62.  
  63. # Wait for the file to be fully available
  64. time.sleep(3)
  65.  
  66. if not last_recording or not os.path.exists(last_recording):
  67. print(f"Recording file not found: {last_recording}")
  68. return
  69.  
  70. # Move the file based on matching keyword
  71. for keyword, output_path in output_paths.items():
  72. if keyword.lower() in last_recording.lower():
  73. if os.path.exists(output_path):
  74. move(last_recording, output_path)
  75. print(f"Moved file to: {output_path}")
  76. else:
  77. print(f"Output path does not exist: {output_path}")
  78. break
  79. else:
  80. print(f"No keyword match found for recording: {last_recording}")
  81.  
  82. except Exception as e:
  83. print(f"Error occurred during file move: {e}")
  84.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement