summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeny Zinoviev <me@ch1p.io>2022-06-12 02:19:38 +0300
committerEvgeny Zinoviev <me@ch1p.io>2022-06-12 02:19:38 +0300
commitbf45c8a28203eafa75cb080b9265be164ab6230f (patch)
tree2110fddf1dd7ff22c903a3cf5f944838d469b079
parent03b2d0a2ae7c529c29e8f4b81ed8705dc82e0452 (diff)
ipcam_server: fix telegram notifications
-rwxr-xr-xsrc/ipcam_server.py8
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)