mirror of
https://github.com/calibrain/shelfmark.git
synced 2026-10-05 12:11:12 +01:00
make book language configurable (#1)
This commit is contained in:
+3
-3
@@ -7,7 +7,7 @@ from bs4 import BeautifulSoup
|
||||
from io import BytesIO
|
||||
|
||||
from logger import setup_logger
|
||||
from config import SUPPORTED_FORMATS
|
||||
from config import SUPPORTED_FORMATS, BOOK_LANGUAGE
|
||||
from models import BookInfo
|
||||
import network
|
||||
|
||||
@@ -28,8 +28,8 @@ def search_books(query: str) -> List[BookInfo]:
|
||||
query_html = quote(query)
|
||||
url = (
|
||||
f"https://annas-archive.org/search?index=&page=1&display=table"
|
||||
f"&acc=aa_download&acc=external_download&lang=en&sort="
|
||||
f"&ext={'&ext='.join(SUPPORTED_FORMATS)}&lang=en&q={query_html}"
|
||||
f"&acc=aa_download&acc=external_download&lang={BOOK_LANGUAGE}&sort="
|
||||
f"&ext={'&ext='.join(SUPPORTED_FORMATS)}&lang={BOOK_LANGUAGE}&q={query_html}"
|
||||
)
|
||||
|
||||
html = network.html_get_page(url)
|
||||
|
||||
@@ -29,6 +29,8 @@ CLOUDFLARE_PROXY = os.getenv("CLOUDFLARE_PROXY_URL", "http://localhost:8000")
|
||||
SUPPORTED_FORMATS = os.getenv("SUPPORTED_FORMATS", "epub,mobi,azw3,fb2,djvu,cbz,cbr")
|
||||
SUPPORTED_FORMATS = SUPPORTED_FORMATS.split(",")
|
||||
|
||||
BOOK_LANGUAGE = os.getenv("BOOK_LANGUAGE", "en")
|
||||
|
||||
# API settings
|
||||
FLASK_HOST = os.getenv("FLASK_HOST", "0.0.0.0")
|
||||
FLASK_PORT = int(os.getenv("FLASK_PORT", 5003))
|
||||
|
||||
@@ -6,6 +6,7 @@ services:
|
||||
FLASK_DEBUG: false
|
||||
CLOUDFLARE_PROXY_URL: http://cloudflarebypassforscraping:8000
|
||||
INGEST_DIR: /cwa-book-ingest
|
||||
BOOK_LANGUAGE: en
|
||||
ports:
|
||||
- "${FLASK_PORT:-8084}:${FLASK_PORT:-8084}"
|
||||
healthcheck:
|
||||
|
||||
@@ -60,6 +60,7 @@ An intuitive web interface for searching and requesting book downloads, designed
|
||||
| `DEFAULT_SLEEP` | Retry delay (seconds) | `5` |
|
||||
| `MAIN_LOOP_SLEEP_TIME` | Processing loop delay (seconds) | `5` |
|
||||
| `SUPPORTED_FORMATS` | Supported book formats | `epub,mobi,azw3,fb2,djvu,cbz,cbr` |
|
||||
| `BOOK_LANGUAGE` | Preferred language for books | `en` |
|
||||
|
||||
Note that PDF are NOT supported at the moment (they do not get ingested by CWA, but if you want to just dowload them loclaly, you can add `pdf` to the `SUPPORTED_FORMATS` env
|
||||
|
||||
|
||||
Reference in New Issue
Block a user