How ostapkonst/lanbookdownloader works
Project type and purpose
• LanBookDownloader is an open‑source, command‑line utility (batch + Python scripts) that downloads book pages from the “ЭБС Лань” web service in SVG format and converts them into a single PDF or DJVU file.
• Its goal is to work around browser memory limits by streaming and converting pages on disk.
File structure
• Top‑level items:
• run_all.bat / clean_all.bat: entry points to orchestrate the end‑to‑end workflow and cleanup
• header.json: configuration file (contains HTTP “Cookie” header)
• requirements.txt: Python dependencies
• scripts/: all Python and batch conversion scripts
• programs/: (likely a place for third‑party binaries or wrappers; check its README for details)
• The “scripts” directory reflects a linear pipeline of steps: downloading, converting, joining, final conversion, and inspection.
README for additional insights
• It enumerates each script’s role and the sequence in which they are called (run_all.bat glues them together).
• External tools invoked by batch files (e.g., Inkscape, PDFTK, djvulibre) are implied dependencies.
Main components and their interactions
a. CLI Layer
• run_all.bat: parses arguments (book_id, optional page range) and invokes each script in turn.
• clean_all.bat: removes intermediate files.
b. Configuration
• header.json: supplies authentication cookie to the downloader.
c. Downloader
• elan_downloader.py: HTTP client that pulls SVG pages from the web service and writes them to disk.
d. Conversion Pipeline
1) svg_to_pdf.bat: batch wrapper around an SVG‑to‑PDF converter (e.g., Inkscape CLI).
2) join_pdf.py: merges individual page PDFs into one document (e.g., via PyPDF2 or PDFTK).
3) pdf_to_djvu.bat: converts the merged PDF to DJVU (djvulibre CLI).
e. Inspection
• show_fixes.py: scans output PDFs for rasterized pages or anomalies and reports them.
f. External Dependencies
• Python 3 + pip modules (requests, PyPDF2, etc.)
• Inkscape / ImageMagick or other SVG → PDF tool
• PDFTK or equivalent for joining PDFs
• djvulibre for PDF → DJVU conversion
Architectural patterns and design principles
• Pipeline pattern: each script/component handles one stage, passing its output as input to the next.
• Configuration separation: HTTP header stored in header.json, keeping credentials out of code.
a. Components
• CLI / Orchestrator (run_all.bat)
• Downloader (elan_downloader.py)
• SVG→PDF converter (svg_to_pdf.bat)
• PDF joiner (join_pdf.py)
• PDF→DJVU converter (pdf_to_djvu.bat)
• Inspector (show_fixes.py)
• Configuration (header.json)
• External tools & libraries
b. Relationships & Data Flow
1) CLI → Downloader → disk (SVG files)
2) disk (SVG) → SVG→PDF → disk (one PDF/page)
3) disk (PDF pages) → PDF joiner → single PDF
4) single PDF → PDF→DJVU → DJVU file
5) single PDF → Inspector → report
c. Technologies & Frameworks
• Python interpreter hosting the .py scripts and pip dependencies.