# ============================================================ # File: scraper/services/scrape_engine.py # Purpose: # Provide unified scraping methods for INIT-flow. # Reuses BookScraper internally with ZERO duplication. # ============================================================ from scraper.book_scraper import BookScraper class ScrapeEngine: """ Adapter layer around BookScraper. Allows INIT-flow to fetch ONLY metadata (no chapters). """ @staticmethod def fetch_metadata_only(site, url: str) -> dict: """ Execute BookScraper but return ONLY metadata. Chapters are intentionally removed. """ scraper = BookScraper(site, url) result = scraper.execute() # returns full metadata + chapters # Strip chapterlist — INIT-flow should not fetch them return { "title": result.get("title"), "author": result.get("author"), "description": result.get("description"), "cover_url": result.get("cover_url"), "book_url": url, }