Add object detection, tracking, mobile notifications, and search to any security camera.
works with hours maybe
roryclear5319e17a8237
diff --git a/clearcam/ViewController.m b/clearcam/ViewController.mindex 038eb9e..5dc5e16 100644--- a/clearcam/ViewController.m+++ b/clearcam/ViewController.m@@ -322,7 +322,7 @@ NSMutableDictionary *classColorMap;NSString *segmentsFilePath = [segmentsDirectory stringByAppendingPathComponent:@"segments.txt"];NSCalendar *calendar = [NSCalendar currentCalendar];- NSDateComponents *components = [calendar components:NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay | NSCalendarUnitHour fromDate:self.current_file_timestamp];+ NSDateComponents *components = [calendar components:NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay | NSCalendarUnitHour fromDate:self.last_file_timestamp];NSDate *midnight = [calendar dateFromComponents:components];NSString *dateKey = [NSString stringWithFormat:@"%04ld-%02ld-%02ld_%02ld", (long)components.year, (long)components.month, (long)components.day, (long)components.hour];@@ -344,7 +344,6 @@ NSMutableDictionary *classColorMap;}];NSMutableArray *segmentsForDate = self.fileServer.segmentsDict[dateKey];- // If this is the first entry of the day, store a timestamp relative to midnightif (segmentsForDate.count == 0) {NSTimeInterval timeStamp = [self.last_file_timestamp timeIntervalSinceDate:midnight];segmentEntry[@"timeStamp"] = @(timeStamp);diff --git a/clearcam/player.html b/clearcam/player.htmlindex d76034c..b6331ee 100644--- a/clearcam/player.html+++ b/clearcam/player.html@@ -268,6 +268,7 @@}});+ let lastFetchedHour = null;async function fetchSegments() {try {const startParam = segments.length;@@ -280,6 +281,13 @@const hour = String(now.getHours()).padStart(2, '0');const currentDate = `${year}-${month}-${day}_${hour}`;+ // Check if the hour has changed+ if (lastFetchedHour !== hour) {+ segments = []; // Reset segments if the hour has changed+ totalDuration = 0; // Reset totalDuration+ lastFetchedHour = hour;+ }+const response = await fetch(`/get-segments?date=${currentDate}&start=${startParam}`);if (response.ok) {const newSegments = await response.json();@@ -308,7 +316,7 @@preloadNextSegments();// TODO: Improve autoplay logic- if (currentVideo.currentTime + segments[currentSegment].cumulativeStart == 0 ||+ if (currentVideo.currentTime + segments[currentSegment].cumulativeStart === 0 ||(isPlaying && isWaitingForNextSegment && segments.length < currentSegment + 1)) {playSegment();}@@ -324,6 +332,7 @@}}+function formatTime(seconds) {const hours = Math.floor(seconds / 3600).toString().padStart(2, '0');const minutes = Math.floor((seconds % 3600) / 60).toString().padStart(2, '0');