Fixed #4
This commit is contained in:
20
camera.py
20
camera.py
@ -41,16 +41,7 @@ class NewPictureHandler(watchdog.events.FileSystemEventHandler):
|
|||||||
if not isinstance(event, watchdog.events.FileCreatedEvent):
|
if not isinstance(event, watchdog.events.FileCreatedEvent):
|
||||||
return
|
return
|
||||||
|
|
||||||
# Ignore multi layer images
|
# Update last closed (can't use on_closed(), see #4).
|
||||||
for layer in ['_Environment', '_Player', '_UI']:
|
|
||||||
if layer in os.path.basename(event.src_path):
|
|
||||||
return
|
|
||||||
|
|
||||||
timeGap = time.perf_counter() - self._lastPicture
|
|
||||||
Thread(target=self._callback, args=(event.src_path, timeGap)).start()
|
|
||||||
self._lastPicture = time.perf_counter()
|
|
||||||
|
|
||||||
def on_closed(self, event: watchdog.events.FileSystemEvent) -> None:
|
|
||||||
exExt = '.'.join(event.src_path.split('.')[:-1])
|
exExt = '.'.join(event.src_path.split('.')[:-1])
|
||||||
|
|
||||||
if exExt.endswith('_Environment'):
|
if exExt.endswith('_Environment'):
|
||||||
@ -64,6 +55,15 @@ class NewPictureHandler(watchdog.events.FileSystemEventHandler):
|
|||||||
|
|
||||||
self.lastClosedTime = time.perf_counter()
|
self.lastClosedTime = time.perf_counter()
|
||||||
|
|
||||||
|
# Ignore multi layer images
|
||||||
|
for layer in ['_Environment', '_Player', '_UI']:
|
||||||
|
if layer in os.path.basename(event.src_path):
|
||||||
|
return
|
||||||
|
|
||||||
|
timeGap = time.perf_counter() - self._lastPicture
|
||||||
|
Thread(target=self._callback, args=(event.src_path, timeGap)).start()
|
||||||
|
self._lastPicture = time.perf_counter()
|
||||||
|
|
||||||
def createNewPictureObserver(callback: callable) -> Observer:
|
def createNewPictureObserver(callback: callable) -> Observer:
|
||||||
"""
|
"""
|
||||||
Creates an Observer that watches the VRChat pictures folder and calls callback
|
Creates an Observer that watches the VRChat pictures folder and calls callback
|
||||||
|
|||||||
Reference in New Issue
Block a user