|
|
|
@@ -234,6 +234,23 @@ def acceptance_status():
|
|
|
|
|
return {"ok": all(x["auto"] for x in items), "items": items}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 +471,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:
|
|
|
|
@@ -648,7 +672,7 @@ 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>"""
|
|
|
|
|
|
|
|
|
|