diff options
author | Evgeny Zinoviev <me@ch1p.io> | 2022-06-12 15:38:52 +0300 |
---|---|---|
committer | Evgeny Zinoviev <me@ch1p.io> | 2022-06-12 15:38:52 +0300 |
commit | c69ad683dc8f84b217ef532a580a82801f19e20d (patch) | |
tree | 160836121e7539e4572dad5154d24a60acd5cc49 /src/home/camera | |
parent | 2f8556eb459875f227ee8ce3e47a7935db989299 (diff) |
ipcam_server: add DVRScanInvalidTimecodes exception type, change handling logic
Diffstat (limited to 'src/home/camera')
-rw-r--r-- | src/home/camera/util.py | 10 |
1 files changed, 8 insertions, 2 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: |