From 165c03ca07c4f4d5ba5a3531a244ec951e971b34 Mon Sep 17 00:00:00 2001 From: Hazel Noack Date: Tue, 10 Jun 2025 15:27:22 +0200 Subject: [PATCH] replaced online image with local asset --- scribble_to_epub/__main__.py | 2 +- scribble_to_epub/scribblehub.py | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/scribble_to_epub/__main__.py b/scribble_to_epub/__main__.py index 1188786..6a48df3 100644 --- a/scribble_to_epub/__main__.py +++ b/scribble_to_epub/__main__.py @@ -18,7 +18,7 @@ def cli(): print(f"Running scribble_to_epub for URL: {args.url}") - scribble_book = ScribbleBook(args.url) + scribble_book = ScribbleBook(args.url, disable_author_quotes=True) scribble_book.load(limit_chapters=1) scribble_book.build() diff --git a/scribble_to_epub/scribblehub.py b/scribble_to_epub/scribblehub.py index 6eb79a1..f726afd 100644 --- a/scribble_to_epub/scribblehub.py +++ b/scribble_to_epub/scribblehub.py @@ -144,6 +144,10 @@ class ScribbleChapter: resp = self.session.get(self.source_url, headers=headers) soup = BeautifulSoup(resp.text, "lxml") + if self.parent.disable_author_quotes: + for tag in soup.select('.wi_authornotes'): + tag.decompose() + for tag in soup.find_all(lambda x: x.has_attr("lang")): if tag["lang"] not in self.parent.languages: log.debug(f'Found language {tag["lang"]}') @@ -244,9 +248,11 @@ class ScribbleBook: def file_name(self) -> str: return f"{self.author} - {self.title}.epub" - def __init__(self, url: str, file_name: Optional[str] = None): + def __init__(self, url: str, file_name: Optional[str] = None, disable_author_quotes: bool = False): self.source_url = url self.assets: Dict[str, Asset] = {} + + self.disable_author_quotes = disable_author_quotes self.languages = [] self.genres = [] @@ -255,6 +261,9 @@ class ScribbleBook: self.chapters: List[ScribbleChapter] = [] self.session = cloudscraper.create_scraper() + if file_name is not None: + self.file_name = file_name + def add_asset(self, url: str) -> Optional[Asset]: if url is None: return