diff options
-rw-r--r-- | src/home/camera/util.py | 10 | ||||
-rw-r--r-- | src/home/http/http.py | 2 | ||||
-rwxr-xr-x | src/ipcam_server.py | 5 |
3 files changed, 12 insertions, 5 deletions
diff --git a/src/home/camera/util.py b/src/home/camera/util.py index 5f18a1f..39bfcd3 100644 --- a/src/home/camera/util.py +++ b/src/home/camera/util.py @@ -63,9 +63,11 @@ async def ffmpeg_cut(input: str, def dvr_scan_timecodes(timecodes: str) -> list[tuple[int, int]]: + tc_backup = timecodes + timecodes = timecodes.split(',') if len(timecodes) % 2 != 0: - raise ValueError('invalid number of timecodes') + raise DVRScanInvalidTimecodes(f'invalid number of timecodes. input: {tc_backup}') timecodes = list(map(time2seconds, timecodes)) timecodes = list(chunks(timecodes, 2)) @@ -73,7 +75,7 @@ def dvr_scan_timecodes(timecodes: str) -> list[tuple[int, int]]: # sort out invalid fragments (dvr-scan returns them sometimes, idk why...) timecodes = list(filter(lambda f: f[0] < f[1], timecodes)) if not timecodes: - raise ValueError('no valid timecodes') + raise DVRScanInvalidTimecodes(f'no valid timecodes. input: {tc_backup}') # https://stackoverflow.com/a/43600953 timecodes.sort(key=lambda interval: interval[0]) @@ -88,6 +90,10 @@ def dvr_scan_timecodes(timecodes: str) -> list[tuple[int, int]]: return merged +class DVRScanInvalidTimecodes(Exception): + pass + + def has_handle(fpath): for proc in psutil.process_iter(): try: diff --git a/src/home/http/http.py b/src/home/http/http.py index 6ce16c4..8e9d3b2 100644 --- a/src/home/http/http.py +++ b/src/home/http/http.py @@ -93,4 +93,4 @@ class HTTPServer: event_loop.run_forever() def ok(self, data=None): - return ok(data) + return ok(data)
\ No newline at end of file diff --git a/src/ipcam_server.py b/src/ipcam_server.py index 9fc11c6..306f1c5 100755 --- a/src/ipcam_server.py +++ b/src/ipcam_server.py @@ -176,9 +176,10 @@ class IPCamWebServer(http.HTTPServer): db.set_timestamp(camera, TimeFilterType.MOTION, time) return self.ok() - except ValueError as e: + except camutil.DVRScanInvalidTimecodes as e: + db.add_motion_failure(camera, filename, str(e)) db.set_timestamp(camera, TimeFilterType.MOTION, time) - raise e + return self.ok('invalid timecodes') async def submit_motion_failure(self, req: http.Request): camera = int(req.match_info['name']) |