From 61e191fabfe9621c607b8c4ad48a488c50ccc3a2 Mon Sep 17 00:00:00 2001 From: "Astra (rpi)" Date: Sun, 11 Oct 2026 19:04:36 +0300 Subject: [PATCH] =?UTF-8?q?rpi:=20=D1=83=D0=B2=D0=B5=D0=B4=D0=BE=D0=BC?= =?UTF-8?q?=D0=BB=D1=8F=D1=82=D1=8C=20=D0=B2=D0=BB=D0=B0=D0=B4=D0=B5=D0=BB?= =?UTF-8?q?=D1=8C=D1=86=D0=B0=20=D0=BE=20=D1=81=D0=BA=D0=B0=D1=87=D0=B8?= =?UTF-8?q?=D0=B2=D0=B0=D0=BD=D0=B8=D0=B8=20=D0=A7=D0=B5=D1=80=D0=BD=D0=BE?= =?UTF-8?q?=D0=B1=D1=8B=D0=BB=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- servers/rpi.md | 2 + stacks/rpi-media/scripts/notify-chernobyl.py | 44 ++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 stacks/rpi-media/scripts/notify-chernobyl.py diff --git a/servers/rpi.md b/servers/rpi.md index fd5c571..4e65c19 100644 --- a/servers/rpi.md +++ b/servers/rpi.md @@ -181,3 +181,5 @@ Docker CE 29.9 + Compose v5.6 из репо download.docker.com (в Debian ст - Медиацентр: проброс 6881 tcp/udp на роутере (раздача/скорость); пароль SFTP роутера слабый (только LAN) — сменить; Kinozal и OpenSubtitles — аккаунты пользователя; решить про автообновление образов. - Ложный алерт PushMetricsStale для backup_servers разобран 2026-10-11: live Result=success, завершение 15:14:12, ExecStopPost завершён 15:14:15, локальный backup_servers.success есть; SMART и router-watch успешно пушат, health fr1 видит свежие метрики. Ошибка в правиле fr1: общий порог 3 ч применялся к дневному бэкапу. В infra подготовлено ограничение PushMetricsStale на job=smart; BackupStale/BackupNeverReported сохранены. Применение/reload выполняет агент fr1; сами бэкапы не перезапускались. + +- 2026-10-11 по просьбе владельца включено Telegram-уведомление Sonarr после импорта серий Chernobyl (HBO, 2019, TVDB 360893) в чат владельца 607015. Ранее уведомления о загрузках не были настроены. Connect `Telegram: Chernobyl owner`, только onDownload, ограничение тегом `notify-owner-chernobyl`; другие сериалы не затрагиваются. Повторяемая настройка — `stacks/rpi-media/scripts/notify-chernobyl.py`, запуск root; токен берётся из `/etc/astra-bot.env`, хранится также в локальной БД Sonarr, в git отсутствует. ⚠️ Уведомление означает импорт отдельной серии, не подтверждает английские субтитры или готовность всего сезона; подходящая раздача при настройке пока не найдена. Настройка проверена чтением API, фактическая доставка будет проверена при импорте. diff --git a/stacks/rpi-media/scripts/notify-chernobyl.py b/stacks/rpi-media/scripts/notify-chernobyl.py new file mode 100644 index 0000000..940687f --- /dev/null +++ b/stacks/rpi-media/scripts/notify-chernobyl.py @@ -0,0 +1,44 @@ +#!/usr/bin/env python3 +"""Enable owner Telegram notifications for Chernobyl imports; run as root.""" +import json +import urllib.request + +def env(path): + return dict(line.strip().split('=', 1) for line in open(path) + if '=' in line and not line.startswith('#')) + +key = env('/etc/media.env')['SONARR_KEY'] + +def api(path, data=None, method=None): + req = urllib.request.Request('http://127.0.0.1:8989/api/v3/' + path, + data=None if data is None else json.dumps(data).encode(), + headers={'X-Api-Key': key, 'Content-Type': 'application/json'}, + method=method or ('GET' if data is None else 'POST')) + with urllib.request.urlopen(req, timeout=30) as response: + return json.load(response) + +series = next(s for s in api('series') if s['tvdbId'] == 360893) +tags = api('tag') +tag = next((t for t in tags if t['label'] == 'notify-owner-chernobyl'), None) +if tag is None: + tag = api('tag', {'label': 'notify-owner-chernobyl'}) +if tag['id'] not in series['tags']: + series['tags'].append(tag['id']) + api('series/' + str(series['id']), series, 'PUT') +name = 'Telegram: Chernobyl owner' +existing = next((n for n in api('notification') if n['name'] == name), None) +notification = existing or next(n for n in api('notification/schema') if n['implementation'] == 'Telegram') +for field in notification['fields']: + values = {'botToken': env('/etc/astra-bot.env')['TG_TOKEN'], 'chatId': '607015', + 'sendSilently': False, 'includeAppNameInTitle': True} + if field['name'] in values: + field['value'] = values[field['name']] +for event in list(notification): + if event.startswith('on') and isinstance(notification[event], bool): + notification[event] = False +notification.update(name=name, tags=[tag['id']], onDownload=True) +api('notification/' + str(existing['id']) if existing else 'notification', notification, + 'PUT' if existing else 'POST') +check = next(n for n in api('notification') if n['name'] == name) +assert check['onDownload'] and check['tags'] == [tag['id']] +print('Configured: Telegram notifications for Chernobyl episode imports, owner chat 607015.')