diff options
author | Evgeny Zinoviev <me@ch1p.io> | 2022-06-12 02:19:38 +0300 |
---|---|---|
committer | Evgeny Zinoviev <me@ch1p.io> | 2022-06-12 02:19:38 +0300 |
commit | bf45c8a28203eafa75cb080b9265be164ab6230f (patch) | |
tree | 2110fddf1dd7ff22c903a3cf5f944838d469b079 | |
parent | 03b2d0a2ae7c529c29e8f4b81ed8705dc82e0452 (diff) |
ipcam_server: fix telegram notifications
-rwxr-xr-x | src/ipcam_server.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/ipcam_server.py b/src/ipcam_server.py index a9218c6..9fc11c6 100755 --- a/src/ipcam_server.py +++ b/src/ipcam_server.py @@ -345,6 +345,12 @@ async def motion_notify_tg(camera: int, text += _tg_links(TelegramLinkType.ORIGINAL_FILE, camera, filename) for start, end in fragments: + start -= config['motion']['padding'] + end += config['motion']['padding'] + + if start < 0: + start = 0 + duration = end - start if duration < 0: duration = 0 @@ -352,7 +358,7 @@ async def motion_notify_tg(camera: int, dt1 = dt_file + timedelta(seconds=start) dt2 = dt_file + timedelta(seconds=end) - text += f'\nFragment: <b>{duration}s</b>, {dt1.strftime(fmt)} - {dt2.strftime(fmt)} ' + text += f'\nFragment: <b>{duration}s</b>, {dt1.strftime(fmt)}-{dt2.strftime(fmt)} ' text += _tg_links(TelegramLinkType.FRAGMENT, camera, f'{dt1.strftime(datetime_format)}__{dt2.strftime(datetime_format)}.mp4') await send_telegram_aio(text) |