-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcodeRunner.py
More file actions
29 lines (26 loc) · 972 Bytes
/
Copy pathcodeRunner.py
File metadata and controls
29 lines (26 loc) · 972 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import os
import time
import subprocess
from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler
class FileHandler(FileSystemEventHandler):
def on_created(self, event):
if event.is_directory:
return
filename, extension = os.path.splitext(event.src_path)
if extension.lower() in ['.mp4', '.avi', '.mkv', '.mov']: # Adjust the list of supported video extensions as needed
print(f"New video file detected: {event.src_path}")
subprocess.run(["python", "both.py"])
if __name__ == "__main__":
folder_to_watch = "videos"
event_handler = FileHandler()
observer = Observer()
observer.schedule(event_handler, folder_to_watch, recursive=True)
observer.start()
print(f"Watching folder '{folder_to_watch}' for new video files...")
try:
while True:
time.sleep(1)
except KeyboardInterrupt:
observer.stop()
observer.join()