[ARCH] Buryans One Alpha: recent items and current SSO user
lint / hygiene (push) Failing after 17s
lint / hygiene (pull_request) Failing after 18s
standard / check (pull_request) Successful in 11s

This commit is contained in:
architect committed 2026-11-26 23:24:13 +03:00
1 parent 7f4f82140d
commit d90341430e
1 file changed
+31 -2
+31 -2
View File
@@ -23,6 +23,23 @@ def jf(path):
return json.load(r)
def recent():
params = urllib.parse.urlencode({
"SortBy": "DateCreated", "SortOrder": "Descending",
"IncludeItemTypes": "Movie,Series", "Recursive": "true",
"Limit": "6", "Fields": "ProductionYear,Overview,ImageTags",
})
data = jf("/Items?" + params)
out = []
for item in data.get("Items") or []:
out.append({
"id": item.get("Id"), "name": item.get("Name"),
"year": item.get("ProductionYear"), "type": item.get("Type"),
"overview": (item.get("Overview") or "")[:200],
})
return out
def search(q):
if not q.strip():
return []
@@ -75,6 +92,15 @@ class H(BaseHTTPRequestHandler):
except Exception as e:
self.out(503, {"ok": False, "error": str(e)[:200]})
return
if u.path == "/v1/media/recent":
try:
self.out(200, {"ok": True, "items": recent()})
except Exception as e:
self.out(502, {"ok": False, "error": str(e)[:300]})
return
if u.path == "/v1/me":
self.out(200, {"ok": True, "email": self.headers.get("X-Audit-User") or "local", "read_only": True})
return
if u.path == "/v1/media/search":
q = urllib.parse.parse_qs(u.query).get("q", [""])[0]
try:
@@ -104,7 +130,7 @@ button{padding:12px 16px;border-radius:8px;border:0;background:#2f81f7;color:#ff
.card h3{margin:0 0 4px;font-size:16px}.tag{color:#8b949e;font-size:12px}
a{color:#58a6ff}
</style></head><body>
<h1>Buryans One Alpha</h1><div class=mut>Read-only вход. Поиск по Jellyfin; сервисы открываются в native-приложениях.</div>
<h1>Buryans One Alpha</h1><div class=mut id=me>read-only</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>
<a class=card href="https://requests.buryans.ru" target=_blank><h3>Seerr</h3><div class=tag>заявки</div></a>
@@ -113,13 +139,16 @@ a{color:#58a6ff}
<a class=card href="http://192.168.1.10:9161/" target=_blank><h3>Audit 360</h3><div class=tag>аудит</div></a>
<a class=card href="http://192.168.1.140:3000/" target=_blank><h3>Gitea</h3><div class=tag>код и решения</div></a>
</div>
<h2 style="font-size:18px;margin:24px 0 8px">Недавно добавлено</h2><div id=recent class=grid></div>
<div style="margin:18px 0"><input id=q placeholder="Фильм или сериал..." autofocus> <button onclick="go()">Найти</button></div>
<div id=msg class=mut></div><div id=out class=grid></div>
<div class=mut style="margin-top:18px">Alpha read-only. Запросы и изменения — только после Gate G1.</div>
<script>
const e=s=>String(s??'').replace(/[&<>"]/g,c=>({'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;'}[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();if(!d.ok){document.getElementById('msg').textContent=d.error||'ошибка';return}document.getElementById('msg').textContent=d.items.length?'':'ничего не найдено';document.getElementById('out').innerHTML=d.items.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>`).join('')}
document.getElementById('q').addEventListener('keydown',e=>{if(e.key==='Enter')go()});
async function boot(){try{const m=await (await fetch('v1/me')).json();document.getElementById('me').textContent='read-only · '+(m.email||'local')}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>`).join('')}catch(e){}}
document.getElementById('q').addEventListener('keydown',e=>{if(e.key==='Enter')go()});boot();
</script></body></html>"""
if __name__ == "__main__":