Lists all available processed books.
(request: Request)
| 36 | |
| 37 | @app.get("/", response_class=HTMLResponse) |
| 38 | async def library_view(request: Request): |
| 39 | """Lists all available processed books.""" |
| 40 | books = [] |
| 41 | |
| 42 | # Scan directory for folders ending in '_data' that have a book.pkl |
| 43 | if os.path.exists(BOOKS_DIR): |
| 44 | for item in os.listdir(BOOKS_DIR): |
| 45 | if item.endswith("_data") and os.path.isdir(item): |
| 46 | # Try to load it to get the title |
| 47 | book = load_book_cached(item) |
| 48 | if book: |
| 49 | books.append({ |
| 50 | "id": item, |
| 51 | "title": book.metadata.title, |
| 52 | "author": ", ".join(book.metadata.authors), |
| 53 | "chapters": len(book.spine) |
| 54 | }) |
| 55 | |
| 56 | return templates.TemplateResponse("library.html", {"request": request, "books": books}) |
| 57 | |
| 58 | @app.get("/read/{book_id}", response_class=HTMLResponse) |
| 59 | async def redirect_to_first_chapter(book_id: str): |
nothing calls this directly
no test coverage detected