check for doubles
This commit is contained in:
@@ -216,10 +216,25 @@ async def delete_book_api(book_id: int):
|
|||||||
|
|
||||||
@app.get("/api/debug/calibre_books")
|
@app.get("/api/debug/calibre_books")
|
||||||
async def 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()
|
cfg = config.load()
|
||||||
books = fetch_all_books(cfg.calibre)
|
from uploader import CalibreClient
|
||||||
return {"total": len(books), "sample": books[:5]}
|
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 ---
|
# --- Data reset ---
|
||||||
|
|||||||
Reference in New Issue
Block a user