From 4915139cc40ea8c27d7bdeb09dcdbaff160e7b3e Mon Sep 17 00:00:00 2001 From: grymphen Date: Sun, 10 May 2026 22:52:18 +0200 Subject: [PATCH] check for doubles --- main.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index b244771..c6c0d93 100644 --- a/main.py +++ b/main.py @@ -216,10 +216,25 @@ async def delete_book_api(book_id: int): @app.get("/api/debug/calibre_books") async def debug_calibre_books(): - """Return raw listbooks sample so we can verify field names and structure.""" + """Show raw Calibre-Web listbooks response shape so we can identify field names.""" cfg = config.load() - books = fetch_all_books(cfg.calibre) - return {"total": len(books), "sample": books[:5]} + from uploader import CalibreClient + client = CalibreClient(cfg.calibre) + client._ensure_auth() + resp = client._session.get( + f"{cfg.calibre.url}/ajax/listbooks", + params={"draw": 1, "start": 0, "length": 5, "sort": "title", "order": "asc"}, + timeout=30, + ) + data = resp.json() + non_list = {k: v for k, v in data.items() if not isinstance(v, list)} + list_keys = {k: len(v) for k, v in data.items() if isinstance(v, list)} + return { + "http_status": resp.status_code, + "top_level_keys": list(data.keys()), + "non_list_fields": non_list, + "list_fields_lengths": list_keys, + } # --- Data reset ---