You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
kmftools/bookscraper/scraper/services/scrape_engine.py

34 lines
1.1 KiB

# ============================================================
# 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,
}