|
|
|
@@ -101,6 +101,37 @@ def fitness():
|
|
|
|
|
"items": [{"id": i, "name": n, "status": s} for i, n, s in items]}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def media_coverage():
|
|
|
|
|
qs = urllib.parse.urlencode({
|
|
|
|
|
"Recursive": "true", "IncludeItemTypes": "Movie,Series",
|
|
|
|
|
"Fields": "MediaStreams,MediaSources", "Limit": "200"})
|
|
|
|
|
data = jf("/Items?" + qs)
|
|
|
|
|
items = data.get("Items") or []
|
|
|
|
|
rus = {"ru", "rus", "russian", "русский"}
|
|
|
|
|
rows = []
|
|
|
|
|
for x in items:
|
|
|
|
|
streams = x.get("MediaStreams") or []
|
|
|
|
|
audio = [s for s in streams if s.get("Type") == "Audio"]
|
|
|
|
|
subs = [s for s in streams if s.get("Type") == "Subtitle" or s.get("IsTextSubtitleStream")]
|
|
|
|
|
has_ru_audio = any((s.get("Language") or "").lower() in rus or
|
|
|
|
|
any(w in (s.get("DisplayTitle") or "").lower() for w in ("russian", "русск"))
|
|
|
|
|
for s in audio)
|
|
|
|
|
has_ru_subs = any((s.get("Language") or "").lower() in rus or
|
|
|
|
|
any(w in (s.get("DisplayTitle") or "").lower() for w in ("russian", "русск"))
|
|
|
|
|
for s in subs)
|
|
|
|
|
sources = x.get("MediaSources") or []
|
|
|
|
|
direct = bool(sources) and all(
|
|
|
|
|
bool(s.get("SupportsDirectPlay") or s.get("SupportsDirectStream")) for s in sources)
|
|
|
|
|
rows.append({"id": x.get("Id"), "name": x.get("Name"), "type": x.get("Type"),
|
|
|
|
|
"ru_audio": has_ru_audio, "ru_subs": has_ru_subs, "direct_play": direct})
|
|
|
|
|
return {"ok": True, "total": len(rows),
|
|
|
|
|
"ru_audio": sum(1 for x in rows if x["ru_audio"]),
|
|
|
|
|
"ru_subs": sum(1 for x in rows if x["ru_subs"]),
|
|
|
|
|
"direct_play": sum(1 for x in rows if x["direct_play"]),
|
|
|
|
|
"missing_ru_audio": sum(1 for x in rows if not x["ru_audio"]),
|
|
|
|
|
"items": rows}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def audit_status():
|
|
|
|
|
try:
|
|
|
|
|
import psycopg2
|
|
|
|
@@ -134,6 +165,11 @@ def home_status():
|
|
|
|
|
out["audit"] = audit_status()
|
|
|
|
|
fs = fitness()
|
|
|
|
|
out["fitness"] = {"pass": fs["pass"], "total": fs["total"]}
|
|
|
|
|
try:
|
|
|
|
|
c = media_coverage()
|
|
|
|
|
out["coverage"] = {"total": c["total"], "ru_audio": c["ru_audio"], "ru_subs": c["ru_subs"]}
|
|
|
|
|
except Exception:
|
|
|
|
|
out["coverage"] = {"error": "unavailable"}
|
|
|
|
|
return out
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -171,6 +207,12 @@ def acceptance_status():
|
|
|
|
|
{"name": "Prism", "what": "очередь LLM (не трогать)",
|
|
|
|
|
"url": "/alpha/owner", "auto": "error" not in (h.get("prism") or {}),
|
|
|
|
|
"detail": f"pending={(h.get('prism') or {}).get('pending_tasks','—')} errors={(h.get('prism') or {}).get('error_tasks','—')}"},
|
|
|
|
|
{"name": "RU-озвучка", "what": "русская дорожка/субтитры",
|
|
|
|
|
"url": "/alpha/", "auto": (h.get("coverage") or {}).get("ru_audio", 0) > 0,
|
|
|
|
|
"detail": "RU audio %s/%s · subs %s" % (
|
|
|
|
|
(h.get("coverage") or {}).get("ru_audio", "—"),
|
|
|
|
|
(h.get("coverage") or {}).get("total", "—"),
|
|
|
|
|
(h.get("coverage") or {}).get("ru_subs", "—"))},
|
|
|
|
|
{"name": "Gitea", "what": "код и PR",
|
|
|
|
|
"url": "http://192.168.1.140:3000/", "auto": gitea_code == 200,
|
|
|
|
|
"detail": f"HTTP {gitea_code}"},
|
|
|
|
@@ -389,6 +431,12 @@ class H(BaseHTTPRequestHandler):
|
|
|
|
|
except Exception as e:
|
|
|
|
|
self.out(502, {"ok": False, "error": str(e)[:300]})
|
|
|
|
|
return
|
|
|
|
|
if u.path == "/v1/media/coverage":
|
|
|
|
|
try:
|
|
|
|
|
self.out(200, media_coverage())
|
|
|
|
|
except Exception as e:
|
|
|
|
|
self.out(502, {"ok": False, "error": str(e)[:300]})
|
|
|
|
|
return
|
|
|
|
|
if u.path == "/v1/fitness":
|
|
|
|
|
self.out(200, fitness())
|
|
|
|
|
return
|
|
|
|
@@ -499,6 +547,7 @@ async function boot(){try{const m=await (await fetch('v1/me')).json();document.g
|
|
|
|
|
<div class=card><h3>Prism</h3><div class=tag>pending ${p.pending_tasks??'—'} · running ${p.running_tasks??'—'} · errors ${p.error_tasks??'—'}</div></div>
|
|
|
|
|
<div class=card><h3>Audit 360</h3><div class=tag>done ${(s.audit||{}).done??'—'} · review ${(s.audit||{}).review_pending??'—'} · open ${(s.audit||{}).in_progress??'—'}</div><div class=tag><a href="http://192.168.1.10:9161/">открыть трекер</a></div></div>
|
|
|
|
|
<div class=card><h3>Fitness</h3><div class=tag>${(s.fitness||{}).pass??'—'}/${(s.fitness||{}).total??'—'} pass</div></div>
|
|
|
|
|
<div class=card><h3>RU-озвучка</h3><div class=tag>${(s.coverage||{}).ru_audio??'—'}/${(s.coverage||{}).total??'—'} · субтитры ${(s.coverage||{}).ru_subs??'—'}</div></div>
|
|
|
|
|
<div class=card><h3>Режим</h3><div class=tag>read-only · без записи</div></div>`}catch(e){}
|
|
|
|
|
try{const r=await (await fetch('v1/media/recent')).json();const xs=r.items||[];document.getElementById('recent').innerHTML=xs.map(x=>`<div class=card><h3>${e(x.name)}</h3><div class=tag>${e(x.type)} ${e(x.year||'')}</div><div class=mut style="margin-top:6px">${e(x.overview||'')}</div><div style="margin-top:8px"><a href="https://media.buryans.ru/web/index.html#!/details?id=${e(x.id)}" target=_blank>Открыть в Jellyfin →</a></div></div>`).join('')}catch(e){}}
|
|
|
|
|
document.getElementById('q').addEventListener('keydown',e=>{if(e.key==='Enter')go()});boot();
|
|
|
|
|