Skip to content

Commit 616ac14

Browse files
author
Gautam MG
committed
Initializing last_image_time to fix the bug
1 parent d0b328e commit 616ac14

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

external_plugins/image_detecting_plugin/image_detecting_plugin.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,17 +81,24 @@ class NewFileHandler(FileSystemEventHandler):
8181
on_create.
8282
"""
8383

84+
def __init__(self):
85+
super().__init__()
86+
self.last_image_time = 0
87+
8488
def extract_timestamp(self, file_path):
8589
basename = os.path.basename(file_path)
8690
try:
87-
# Expected format: 20250714-21:51:49-00.jpeg
91+
# Expected format: 20250714-21:51:49-00.jpg
8892
if "-" in basename and ":" in basename:
89-
# Splitting to get date and time parts
90-
date_part, time_part = basename.split("-")[0], basename.split("-")[1]
91-
datetime_str = date_part + time_part.replace(":", "")
92-
if len(datetime_str) == 14:
93-
ts = time.strptime(datetime_str, "%Y%m%d%H%M%S")
94-
return time.mktime(ts)
93+
# Splitting logic
94+
parts = basename.split("-")
95+
if len(parts) >= 2 and ":" in parts[1]:
96+
date_part = parts[0]
97+
time_part = parts[1].replace(":", "")
98+
datetime_str = date_part + time_part
99+
if len(datetime_str) == 14:
100+
ts = time.strptime(datetime_str, "%Y%m%d%H%M%S")
101+
return time.mktime(ts)
95102
except Exception as e:
96103
logging.warning(f"Filename parsing failed: {basename}{e}")
97104

0 commit comments

Comments
 (0)