diff --git a/index.html b/index.html index ef7a317..991a1a3 100644 --- a/index.html +++ b/index.html @@ -136,6 +136,8 @@

C41 Archive

+ +
@@ -707,6 +709,21 @@ dateSelect.addEventListener("change", () => loadDate(dateSelect.value)); addEventListener("resize", drawTimeline); + + // rescan: button + silent auto-poll for new dates + const rescanBtn = document.querySelector("#rescan-btn"); + async function rescan(notify) { + try { + const r = await fetch("/api/rescan", {method: "POST"}); + const d = await r.json(); + if (notify) setStatus(`${d.days} day${d.days !== 1 ? "s" : ""}, ${d.clips} clip${d.clips !== 1 ? "s" : ""} indexed`); + loadDate(dateSelect.value || ""); + return d; + } catch { return null; } + } + rescanBtn.addEventListener("click", () => rescan(true)); + setInterval(() => { if (!queue.some(e => e.state === "busy")) rescan(false); }, 30000); + loadDate("").catch(() => {}); updateEncodeStatus(); diff --git a/server.py b/server.py index 8ca1551..d241c22 100644 --- a/server.py +++ b/server.py @@ -111,6 +111,11 @@ class PlayerHandler(BaseHTTPRequestHandler): def do_POST(self): path = urlparse(self.path).path + if path == "/api/rescan": + self.server.recordings = scan_recordings(self.server.output_root) + self.server.system_highlights = scan_system_highlights(self.server.source_root) + count = sum(map(len, self.server.recordings.values())) + return self.send_json({"ok": True, "days": len(self.server.recordings), "clips": count}) if path == "/api/upload": return self.handle_upload() if path == "/api/encode":