Compare commits
18
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
506ae58410 | ||
|
|
7ef5b02698 | ||
|
|
0f41d71a0b | ||
|
|
7099d402a0 | ||
|
|
b7b5c36c55 | ||
|
|
54905cccab | ||
|
|
64f0f05200 | ||
|
|
84834e40af | ||
|
|
c9eddc0eda | ||
|
|
eb070b7be5 | ||
|
|
13d14b13a7 | ||
|
|
060bb8f276 | ||
|
|
ff34b72f9a | ||
|
|
8273956058 | ||
|
|
a7b1a90e9c | ||
|
|
2fbe23476c | ||
|
|
8b78cd9a61 | ||
|
|
e6a29a5cda |
No files matched your search
@@ -43,9 +43,9 @@
|
||||
| S2-06 | S2 | pgvector pilot | done | | architect | nearest pilot-a, top2 pilot-a/pilot-c | 1 | |
|
||||
| S2-07 | S2 | Gate G2 proof | done | YES | architect | 100→1; loss recovered | 1 | G2 |
|
||||
| S3-01 | S3 | Аудит RU/direct-play | done | | architect | /v1/media/coverage | 0 | |
|
||||
| S3-02 | S3 | RU-дорожки/субтитры | blocked | | architect | 0/7 RU; und/eng only | 1 | |
|
||||
| S3-02 | S3 | RU-дорожки/субтитры | blocked | | architect | Bazarr status200; login TLS error; no RU | 5 | |
|
||||
| S3-03 | S3 | Direct-play 7/7 | done | | architect | coverage total6 direct6 | 2 | |
|
||||
| S3-04 | S3 | Запрос из Alpha/Telegram/Matrix | open | | architect | pending | 0 | |
|
||||
| S3-04 | S3 | Запрос из Alpha/Telegram/Matrix | done | | architect | /alpha/request; !request; request/check | 5 | |
|
||||
| S3-05 | S3 | Gate G3 | open | YES | architect | pending | 0 | G3 |
|
||||
| U-01 | U | Approve PR #192 | done | | roman | chat approval 2026-11-26 · Открыть PR #192 и подтвердить архитектуру | 2 | none |
|
||||
| U-02 | U | Seerr vs Jellyseerr decision | dropped | YES | roman | Seerr audit · Выбрать после evidence | 2 | none |
|
||||
@@ -61,8 +61,8 @@
|
||||
- S1 / done: 10
|
||||
- S2 / done: 7
|
||||
- S3 / blocked: 1
|
||||
- S3 / done: 2
|
||||
- S3 / open: 2
|
||||
- S3 / done: 3
|
||||
- S3 / open: 1
|
||||
- U / done: 2
|
||||
- U / dropped: 3
|
||||
|
||||
|
||||
@@ -18,14 +18,57 @@ Direct-play исправлен: сериал считается по эпизо
|
||||
|
||||
Это честный gap, не «всё хорошо».
|
||||
|
||||
Проверка диска: `.srt/.ass/.vtt` нет; имён `rus/russian` нет.
|
||||
Значит RU-контента нет и вне индекса Jellyfin.
|
||||
|
||||
## Bazarr: RU-источник
|
||||
|
||||
- RU-профиль `Русский + English` существует;
|
||||
- Dune/Interstellar получили профиль 1;
|
||||
- subf2m исправлен User-Agent;
|
||||
- throttle-файл сброшен;
|
||||
- но RU-файл всё равно не скачался.
|
||||
|
||||
Бэкап конфига:
|
||||
|
||||
```text
|
||||
/opt/bazarr/config/config/config.yaml.bak-subf2m-20261127
|
||||
/opt/bazarr/config/config/config.yaml.bak-opensubtitles-20261127
|
||||
```
|
||||
|
||||
## OpenSubtitles API
|
||||
|
||||
Ключ лежит только на хосте:
|
||||
|
||||
```text
|
||||
/root/.opensubtitles-key (600)
|
||||
```
|
||||
|
||||
Проверено:
|
||||
|
||||
- поиск RU работает: 23 варианта для Dune;
|
||||
- прямой download link отдаёт файл очень медленно и обрывается;
|
||||
- Bazarr `opensubtitlescom` настроен с username/password + API key;
|
||||
- из контейнера Bazarr login падает по TLS (`SSLEOFError`), subf2m таймаутит.
|
||||
|
||||
Поэтому RU-файл пока не установлен. Обрезанный `.srt` не используется.
|
||||
|
||||
Секреты:
|
||||
|
||||
```text
|
||||
/root/.opensubtitles-key
|
||||
/root/.opensubtitles-user
|
||||
/root/.opensubtitles-pass
|
||||
```
|
||||
|
||||
## Задачи
|
||||
|
||||
| Код | Задача | Статус |
|
||||
|---|---|---|
|
||||
| S3-01 | Аудит RU/direct-play | done (0/7 RU, 6/7 direct) |
|
||||
| S3-02 | RU-дорожки/субтитры | blocked: нет источника RU |
|
||||
| S3-01 | Аудит RU/direct-play | done (0/6 RU, 6/6 direct) |
|
||||
| S3-02 | RU-дорожки/субтитры | blocked: Bazarr RU профиль есть, subf2m не отдал файл |
|
||||
| S3-03 | Direct-play 6/6 | done |
|
||||
| S3-04 | Запрос из Alpha/Telegram/Matrix | in_progress (Alpha link done; TG/Matrix open) |
|
||||
| S3-04 | Запрос из Alpha/Matrix | done (Telegram исключён по решению) |
|
||||
| S3-05 | Gate G3 | open |
|
||||
|
||||
## Проверка
|
||||
@@ -47,3 +90,20 @@ http://192.168.1.10:9161/alpha/request
|
||||
```
|
||||
|
||||
Alpha ищет по Jellyfin; кнопка открывает Seerr. Alpha не пишет в Seerr/медиатеку.
|
||||
|
||||
Matrix:
|
||||
|
||||
```text
|
||||
!request Дюна
|
||||
```
|
||||
|
||||
Бот даёт ссылку на `https://requests.buryans.ru`, заявку создаёт семья в Seerr.
|
||||
Telegram-бота в текущем контуре нет.
|
||||
|
||||
Проверка дублей:
|
||||
|
||||
```text
|
||||
GET /v1/media/request/check?q=Дюна
|
||||
```
|
||||
|
||||
Alpha показывает предупреждение, если заявка уже есть в Seerr.
|
||||
@@ -0,0 +1,33 @@
|
||||
# Stage 4 — Mission Control & SDK
|
||||
|
||||
Статус: начат 2026-11-27.
|
||||
Gate G4: новый адаптер без изменения ядра.
|
||||
|
||||
## Сделано
|
||||
|
||||
Mission Control v0:
|
||||
|
||||
```text
|
||||
http://192.168.1.10:9161/alpha/mission
|
||||
```
|
||||
|
||||
- read-only карта сервисов;
|
||||
- tier/owner;
|
||||
- health;
|
||||
- endpoints;
|
||||
- API `/v1/services`.
|
||||
|
||||
## Задачи
|
||||
|
||||
| Код | Задача | Статус |
|
||||
|---|---|---|
|
||||
| S4-01 | Mission Control v0 | done |
|
||||
| S4-02 | Extension SDK / adapter contract | open |
|
||||
| S4-03 | 3 adapters | open |
|
||||
| S4-04 | Preview env + contract tests | open |
|
||||
| S4-05 | Gate G4 | open |
|
||||
|
||||
## Ограничение
|
||||
|
||||
Mission Control пока внутри Alpha, не отдельный Nexus.
|
||||
Это v0: read-only, без управления процессами.
|
||||
@@ -23,6 +23,7 @@
|
||||
## Остальные
|
||||
|
||||
* **Медиа** — статистика, новинки, поиск, очередь, заявки, место, пробелы.
|
||||
- `!request <название>` — даёт ссылку на заявку в `https://requests.buryans.ru`; бот сам заявку не создаёт.
|
||||
* **Фото** — статистика, альбомы, место.
|
||||
* **Книги** — статистика, новинки, поиск.
|
||||
* **Дом** — статистика, состояние.
|
||||
|
||||
+10
-1
@@ -656,6 +656,7 @@ class MediaBot(Bot):
|
||||
self.cmd("now", "кто что смотрит прямо сейчас")(lambda a: self._now(jf))
|
||||
self.cmd("queue", "очередь загрузок в Sonarr и Radarr")(lambda a: self._queue())
|
||||
self.cmd("requests", "последние заявки в Seerr")(lambda a: self._requests(seerr))
|
||||
self.cmd("request", "ссылка на заявку в Seerr: `!request Дюна`")(lambda a: self._request_link(a))
|
||||
self.cmd("disk", "место на дисках медиасервисов")(lambda a: self._disk())
|
||||
self.cmd("wanted", "сколько ещё не найдено")(lambda a: self._wanted())
|
||||
self.cmd("paths", "где лежат файлы и куда их класть")(lambda a: self._paths())
|
||||
@@ -764,7 +765,7 @@ class MediaBot(Bot):
|
||||
if err:
|
||||
return f"Seerr не ответил: {err}"
|
||||
if not reqs:
|
||||
return "Заявок пока нет. Заказать можно на https://ombi.buryans.ru"
|
||||
return "Заявок пока нет. Заказать можно на https://requests.buryans.ru"
|
||||
lines = ["**Последние заявки**", ""]
|
||||
for r in reqs:
|
||||
media = r.get("media", {}) or {}
|
||||
@@ -774,6 +775,14 @@ class MediaBot(Bot):
|
||||
lines.append(f"• {title} — {status} (просил {who})")
|
||||
return "\n".join(lines)
|
||||
|
||||
def _request_link(self, query):
|
||||
q = (query or "").strip()
|
||||
if not q:
|
||||
return "Использование: `!request Дюна`"
|
||||
return (f"**Заявка в Seerr**\n{q}\n"
|
||||
"Открой https://requests.buryans.ru, найди этот тайтл и отправь заявку.\n"
|
||||
"Alpha и бот не создают запрос сами — это защита от дублей.")
|
||||
|
||||
def _disk(self):
|
||||
lines = ["**Диски**", ""]
|
||||
for svc in (SONARR, RADARR):
|
||||
|
||||
Whitespace-only changes.
@@ -0,0 +1,9 @@
|
||||
from adapters import audit360
|
||||
from .base import Adapter
|
||||
|
||||
|
||||
class Audit360Adapter(Adapter):
|
||||
name = "audit360"
|
||||
|
||||
def poll(self, conn):
|
||||
return audit360(conn)
|
||||
@@ -0,0 +1,10 @@
|
||||
"""Adapter contract for the Stage 4 event fabric."""
|
||||
from abc import ABC, abstractmethod
|
||||
|
||||
|
||||
class Adapter(ABC):
|
||||
name = "adapter"
|
||||
|
||||
@abstractmethod
|
||||
def poll(self, conn) -> int:
|
||||
"""Emit zero or more events; return number of new events."""
|
||||
@@ -0,0 +1,38 @@
|
||||
import urllib.request
|
||||
|
||||
from event_store import enqueue, event
|
||||
from .base import Adapter
|
||||
|
||||
URL = "http://192.168.1.140:3000/api/v1/version"
|
||||
|
||||
|
||||
class GiteaHealthAdapter(Adapter):
|
||||
name = "gitea-health"
|
||||
|
||||
def poll(self, conn):
|
||||
up = False
|
||||
try:
|
||||
with urllib.request.urlopen(URL, timeout=4) as r:
|
||||
up = r.status == 200
|
||||
except Exception:
|
||||
up = False
|
||||
state = "up" if up else "down"
|
||||
with conn.cursor() as cur:
|
||||
cur.execute("select cursor from events.adapter_state where adapter=%s", (self.name,))
|
||||
row = cur.fetchone()
|
||||
previous = row[0] if row and row[0] else None
|
||||
if previous == state:
|
||||
return 0
|
||||
ev = event(idempotency_key="gitea:health:%s:%d" % (state, int(__import__("time").time())),
|
||||
source="gitea", type_="system.service.%s" % state,
|
||||
subject="gitea", data={"service": "gitea", "state": state})
|
||||
enqueue(conn, ev)
|
||||
with conn.cursor() as cur:
|
||||
cur.execute("""
|
||||
insert into events.adapter_state(adapter,cursor,updated_at)
|
||||
values (%s,%s,now())
|
||||
on conflict (adapter) do update
|
||||
set cursor=excluded.cursor, updated_at=now()
|
||||
""", (self.name, state))
|
||||
conn.commit()
|
||||
return 1
|
||||
@@ -0,0 +1,9 @@
|
||||
from adapters import jellyfin_media
|
||||
from .base import Adapter
|
||||
|
||||
|
||||
class JellyfinAdapter(Adapter):
|
||||
name = "jellyfin"
|
||||
|
||||
def poll(self, conn):
|
||||
return jellyfin_media(conn)
|
||||
@@ -0,0 +1,29 @@
|
||||
"""Discover and run event adapters without editing the pipeline core."""
|
||||
import importlib
|
||||
import pkgutil
|
||||
from pathlib import Path
|
||||
|
||||
from .base import Adapter
|
||||
|
||||
|
||||
def load_adapters():
|
||||
adapters = []
|
||||
pkg_dir = Path(__file__).resolve().parent
|
||||
for mod in sorted(pkgutil.iter_modules([str(pkg_dir)])):
|
||||
if mod.name in ("base", "registry") or mod.name.startswith("_"):
|
||||
continue
|
||||
m = importlib.import_module("adapter_plugins." + mod.name)
|
||||
for obj in vars(m).values():
|
||||
if isinstance(obj, type) and issubclass(obj, Adapter) and obj is not Adapter:
|
||||
adapters.append(obj())
|
||||
return adapters
|
||||
|
||||
|
||||
def run_all(conn):
|
||||
out = {}
|
||||
for a in load_adapters():
|
||||
try:
|
||||
out[a.name] = a.poll(conn)
|
||||
except Exception as e:
|
||||
out[a.name] = "error:%s" % str(e)[:120]
|
||||
return out
|
||||
@@ -0,0 +1,9 @@
|
||||
from adapters import seerr_requests
|
||||
from .base import Adapter
|
||||
|
||||
|
||||
class SeerrAdapter(Adapter):
|
||||
name = "seerr"
|
||||
|
||||
def poll(self, conn):
|
||||
return seerr_requests(conn)
|
||||
@@ -4,7 +4,7 @@ import asyncio
|
||||
import signal
|
||||
import time
|
||||
|
||||
from adapters import audit360, jellyfin_media, seerr_requests
|
||||
from adapter_plugins.registry import run_all
|
||||
from event_store import connect, init
|
||||
from nats_relay import consume_once, relay_once
|
||||
|
||||
@@ -27,7 +27,7 @@ def main():
|
||||
try:
|
||||
conn = connect()
|
||||
init(conn)
|
||||
emitted = audit360(conn) + jellyfin_media(conn) + seerr_requests(conn)
|
||||
emitted = run_all(conn)
|
||||
conn.close()
|
||||
relayed = asyncio.run(relay_once())
|
||||
consumed = asyncio.run(consume_once(timeout=2))
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Read-only preview of discovered adapters and their contract."""
|
||||
from adapter_plugins.registry import load_adapters
|
||||
|
||||
for a in load_adapters():
|
||||
print(f"{a.name:16} poll=callable")
|
||||
print(f"total={len(load_adapters())}")
|
||||
@@ -0,0 +1,29 @@
|
||||
"""Contract tests for Stage 4 adapters. No network writes."""
|
||||
import unittest
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
|
||||
from adapter_plugins.registry import load_adapters
|
||||
|
||||
|
||||
class AdapterContractTests(unittest.TestCase):
|
||||
def test_at_least_three_adapters(self):
|
||||
names = {a.name for a in load_adapters()}
|
||||
self.assertGreaterEqual(len(names), 3)
|
||||
self.assertIn("jellyfin", names)
|
||||
self.assertIn("audit360", names)
|
||||
self.assertIn("seerr", names)
|
||||
|
||||
def test_every_adapter_has_poll(self):
|
||||
for a in load_adapters():
|
||||
self.assertTrue(callable(a.poll), a.name)
|
||||
self.assertTrue(a.name and isinstance(a.name, str), a.name)
|
||||
|
||||
def test_new_adapter_without_core_edit(self):
|
||||
# Gitea was added as a plugin file; pipeline core was not changed after registry.
|
||||
self.assertIn("gitea-health", {a.name for a in load_adapters()})
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -3,6 +3,7 @@
|
||||
import html
|
||||
import http.cookiejar
|
||||
import json
|
||||
import socket
|
||||
import time
|
||||
import urllib.error
|
||||
import urllib.parse
|
||||
@@ -234,6 +235,67 @@ def acceptance_status():
|
||||
return {"ok": all(x["auto"] for x in items), "items": items}
|
||||
|
||||
|
||||
SERVICES_PATH = Path("/root/buryan-infra/docs/architecture/REGISTRY/services.yaml")
|
||||
|
||||
|
||||
def service_health(svc):
|
||||
endpoint = (svc.get("endpoint") or "").strip()
|
||||
started = time.time()
|
||||
try:
|
||||
if endpoint.startswith("http"):
|
||||
try:
|
||||
with urllib.request.urlopen(endpoint, timeout=4) as r:
|
||||
code = r.status
|
||||
except urllib.error.HTTPError as e:
|
||||
code = e.code
|
||||
up = code < 400
|
||||
return {"up": up, "code": code, "ms": int((time.time() - started) * 1000)}
|
||||
if endpoint.startswith(("tcp://", "nats://")):
|
||||
u = urllib.parse.urlsplit(endpoint)
|
||||
host, port = u.hostname, u.port or 0
|
||||
with socket.create_connection((host, port), timeout=3):
|
||||
pass
|
||||
return {"up": True, "code": None, "ms": int((time.time() - started) * 1000)}
|
||||
return {"up": None, "code": None, "ms": None, "error": "no endpoint"}
|
||||
except Exception as e:
|
||||
return {"up": False, "code": None, "ms": int((time.time() - started) * 1000),
|
||||
"error": str(e)[:120]}
|
||||
|
||||
|
||||
def mission_services():
|
||||
import yaml
|
||||
data = yaml.safe_load(SERVICES_PATH.read_text())
|
||||
rows = []
|
||||
for s in data.get("services") or []:
|
||||
h = service_health(s)
|
||||
rows.append({
|
||||
"id": s.get("id"), "tier": s.get("tier"), "owner": s.get("owner"),
|
||||
"endpoint": s.get("endpoint"), "public": s.get("public"),
|
||||
"health": s.get("health"), "up": h.get("up"), "code": h.get("code"),
|
||||
"ms": h.get("ms"), "error": h.get("error"),
|
||||
})
|
||||
return {"ok": all(x["up"] is not False for x in rows),
|
||||
"total": len(rows), "up": sum(1 for x in rows if x["up"] is True),
|
||||
"down": sum(1 for x in rows if x["up"] is False), "items": rows}
|
||||
|
||||
|
||||
def request_check(q):
|
||||
qn = (q or "").strip().lower()
|
||||
if not qn:
|
||||
return {"ok": False, "error": "query_required"}
|
||||
code, body = seerr("/api/v1/request?take=50")
|
||||
if code != 200:
|
||||
return {"ok": False, "error": "seerr_unavailable", "code": code}
|
||||
for x in body.get("results") or []:
|
||||
media = x.get("media") or {}
|
||||
title = (media.get("title") or media.get("name") or "").lower()
|
||||
if qn in title or title in qn:
|
||||
return {"ok": True, "requested": True, "id": x.get("id"),
|
||||
"title": media.get("title") or media.get("name"),
|
||||
"status": x.get("status")}
|
||||
return {"ok": True, "requested": False}
|
||||
|
||||
|
||||
def seerr(path):
|
||||
"""Read-only Seerr requests via the local breakglass Jellyfin login."""
|
||||
global _SEERR_OP, _SEERR_TS
|
||||
@@ -454,6 +516,13 @@ class H(BaseHTTPRequestHandler):
|
||||
if u.path == "/v1/home/status":
|
||||
self.out(200, home_status())
|
||||
return
|
||||
if u.path == "/v1/media/request/check":
|
||||
q = urllib.parse.parse_qs(u.query).get("q", [""])[0]
|
||||
try:
|
||||
self.out(200, request_check(q))
|
||||
except Exception as e:
|
||||
self.out(502, {"ok": False, "error": str(e)[:200]})
|
||||
return
|
||||
if u.path == "/v1/media/requests":
|
||||
code, body = seerr("/api/v1/request?take=20")
|
||||
if code == 503:
|
||||
@@ -509,6 +578,15 @@ class H(BaseHTTPRequestHandler):
|
||||
if u.path == "/acceptance":
|
||||
self.out(200, PAGE_ACCEPTANCE, "text/html")
|
||||
return
|
||||
if u.path == "/v1/services":
|
||||
try:
|
||||
self.out(200, mission_services())
|
||||
except Exception as e:
|
||||
self.out(502, {"ok": False, "error": str(e)[:300]})
|
||||
return
|
||||
if u.path == "/mission":
|
||||
self.out(200, PAGE_MISSION, "text/html")
|
||||
return
|
||||
if u.path == "/request":
|
||||
self.out(200, PAGE_REQUEST, "text/html")
|
||||
return
|
||||
@@ -538,7 +616,7 @@ button{padding:12px 16px;border-radius:8px;border:0;background:#2f81f7;color:#ff
|
||||
a{color:#58a6ff}
|
||||
</style></head><body>
|
||||
<h1>Buryans One Alpha</h1><div class=mut id=me>read-only</div>
|
||||
<div style="margin:8px 0"><a class="card" style="display:inline-block;padding:10px 14px" href="/alpha/owner">Owner-пульт →</a> <a class="card" style="display:inline-block;padding:10px 14px" href="/alpha/acceptance">Опросник приёмки →</a> <a class="card" style="display:inline-block;padding:10px 14px" href="/alpha/request">Запросить фильм →</a></div>
|
||||
<div style="margin:8px 0"><a class="card" style="display:inline-block;padding:10px 14px" href="/alpha/owner">Owner-пульт →</a> <a class="card" style="display:inline-block;padding:10px 14px" href="/alpha/acceptance">Опросник приёмки →</a> <a class="card" style="display:inline-block;padding:10px 14px" href="/alpha/request">Запросить фильм →</a> <a class="card" style="display:inline-block;padding:10px 14px" href="/alpha/mission">Mission Control →</a></div>
|
||||
<div class=grid id=status style="margin:16px 0"></div>
|
||||
<div class=grid style="margin:16px 0">
|
||||
<a class=card href="https://media.buryans.ru" target=_blank><h3>Jellyfin</h3><div class=tag>фильмы и сериалы</div></a>
|
||||
@@ -587,6 +665,7 @@ a{color:#58a6ff}code{background:#161b22;padding:2px 5px;border-radius:4px}
|
||||
<a class=big href="http://192.168.1.10:9161/" target=_blank><h3>Audit 360</h3><div class=tag>трекер, evidence, Gate G0/G1.</div></a>
|
||||
<a class=big href="/alpha/acceptance"><h3>Опросник приёмки</h3><div class=tag>по каждому сервису: что нажать и что должно быть.</div></a>
|
||||
<a class=big href="/alpha/request"><h3>Запросить фильм</h3><div class=tag>поиск по Jellyfin и кнопка запроса в Seerr.</div></a>
|
||||
<a class=big href="/alpha/mission"><h3>Mission Control</h3><div class=tag>карта сервисов, health, owners, ссылки.</div></a>
|
||||
<a class=big href="http://192.168.1.10:9161/alpha/"><h3>На главную Alpha</h3><div class=tag>поиск, новинки, сервисы.</div></a>
|
||||
<a class=big href="/alpha/v1/fitness" target=_blank><h3>Fitness</h3><div class=tag>18 FIT-пунктов, честные статусы.</div></a>
|
||||
<a class=big href="http://192.168.1.140:3000/" target=_blank><h3>Gitea</h3><div class=tag>код, PR, решения.</div></a>
|
||||
@@ -648,9 +727,30 @@ a{color:#58a6ff}.warn{background:#161b22;border:1px solid #9e6a03;border-radius:
|
||||
<div class=warn style="margin-top:18px">Если запрос уже существует, Seerr покажет это сам. Дубли в Jellyfin не создаются.</div>
|
||||
<script>
|
||||
const e=s=>String(s??'').replace(/[&<>"]/g,c=>({'&':'&','<':'<','>':'>','"':'"'}[c]));
|
||||
async function go(){const q=document.getElementById('q').value.trim();if(!q)return;document.getElementById('msg').textContent='поиск...';const r=await fetch('v1/media/search?q='+encodeURIComponent(q));const d=await r.json();const xs=d.items||[];document.getElementById('msg').textContent=xs.length?'':'ничего не найдено';document.getElementById('out').innerHTML=xs.map(x=>`<div class=card><h3>${e(x.name)}</h3><div class=tag>${e(x.type)} ${e(x.year||'')}</div><div style="margin-top:8px"><a href="https://requests.buryans.ru/search?query=${encodeURIComponent(x.name)}" target=_blank>Запросить в Seerr →</a></div></div>`).join('')}
|
||||
async function go(){const q=document.getElementById('q').value.trim();if(!q)return;document.getElementById('msg').textContent='поиск...';const r=await fetch('v1/media/search?q='+encodeURIComponent(q));const d=await r.json();const xs=d.items||[];let warn='';try{const c=await (await fetch('v1/media/request/check?q='+encodeURIComponent(q))).json();if(c.requested)warn='⚠️ Похоже, заявка уже есть: '+e(c.title||q)+' (статус '+e(c.status)+').';}catch(e){}document.getElementById('msg').textContent=xs.length?'':'ничего не найдено';if(warn)document.getElementById('msg').textContent=warn;document.getElementById('out').innerHTML=xs.map(x=>`<div class=card><h3>${e(x.name)}</h3><div class=tag>${e(x.type)} ${e(x.year||'')}</div><div style="margin-top:8px"><a href="https://requests.buryans.ru/search?query=${encodeURIComponent(x.name)}" target=_blank>Запросить в Seerr →</a></div></div>`).join('')}
|
||||
document.getElementById('q').addEventListener('keydown',e=>{if(e.key==='Enter')go()});
|
||||
</script></body></html>"""
|
||||
|
||||
PAGE_MISSION = """<!doctype html><html lang=ru><head><meta charset=utf-8>
|
||||
<meta name=viewport content="width=device-width,initial-scale=1">
|
||||
<title>Mission Control — Buryans</title>
|
||||
<style>
|
||||
body{background:#0d1117;color:#e6edf3;font:15px/1.5 system-ui,Arial;margin:0;padding:28px}
|
||||
h1{font-size:28px;margin:0 0 6px}.mut{color:#8b949e}
|
||||
.grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(270px,1fr));gap:12px;margin:18px 0}
|
||||
.card{background:#161b22;border:1px solid #30363d;border-radius:10px;padding:14px}
|
||||
.card h3{margin:0 0 4px;font-size:17px}.tag{color:#8b949e;font-size:13px}
|
||||
.ok{color:#3fb950}.bad{color:#f85149}.unk{color:#d29922}
|
||||
a{color:#58a6ff}
|
||||
</style></head><body>
|
||||
<h1>Mission Control</h1><div class=mut>Read-only карта сервисов. Health, tier, owner, endpoints. Без изменения сервисов.</div>
|
||||
<div class=mut id=summary style="margin-top:10px">загрузка…</div>
|
||||
<div class=grid id=rows></div>
|
||||
<script>
|
||||
const e=s=>String(s??'').replace(/[&<>"]/g,c=>({'&':'&','<':'<','>':'>','"':'"'}[c]));
|
||||
async function boot(){try{const d=await (await fetch('v1/services')).json();document.getElementById('summary').textContent=`сервисов ${d.total} · up ${d.up} · down ${d.down}`;const xs=(d.items||[]).slice().sort((a,b)=>(a.tier-b.tier)||String(a.id).localeCompare(b.id));document.getElementById('rows').innerHTML=xs.map(x=>{const st=x.up===true?'<span class=ok>● up</span>':x.up===false?'<span class=bad>● down</span>':'<span class=unk>● unknown</span>';const url=x.public||x.endpoint||'';return `<div class=card><h3>${e(x.id)}</h3><div class=tag>tier ${e(x.tier)} · ${e(x.owner||'—')}</div><div style="margin-top:6px">${st} ${x.code?`HTTP ${e(x.code)}`:''} ${x.ms!=null?`· ${e(x.ms)}ms`:''}</div><div class=tag>${e(x.health||'')}</div>${url?`<div style="margin-top:8px"><a href="${e(url)}" target=_blank>${e(url)}</a></div>`:''}${x.error?`<div class=tag>${e(x.error)}</div>`:''}</div>`}).join('')}catch(e){document.getElementById('summary').textContent='не удалось получить карту сервисов'}}
|
||||
boot();
|
||||
</script></body></html>"""
|
||||
|
||||
if __name__ == "__main__":
|
||||
ThreadingHTTPServer((HOST, PORT), H).serve_forever()
|
||||
Reference in new issue
Block a user