replaced online image with local asset

This commit is contained in:
Hazel Noack 2025-06-10 15:27:22 +02:00
parent 82bb899a0d
commit 165c03ca07
2 changed files with 11 additions and 2 deletions

View File

@ -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()

View File

@ -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,10 +248,12 @@ 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 = []
self.tags = []
@ -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