forked from LiveCarta/BookConverter
Add preset processing from backend
This commit is contained in:
@@ -13,7 +13,6 @@ from typing import Dict, Union, List
|
||||
from bs4 import BeautifulSoup, NavigableString, Tag
|
||||
|
||||
from src.util.helpers import BookLogger
|
||||
from src.preset_processor import PresetProcessor
|
||||
from src.epub_converter.css_processor import CSSPreprocessor
|
||||
from src.epub_converter.html_epub_processor import HtmlEpubPreprocessor
|
||||
from src.livecarta_config import LiveCartaConfig
|
||||
@@ -24,11 +23,11 @@ from src.epub_converter.tag_inline_style_processor import TagInlineStyleProcesso
|
||||
|
||||
|
||||
class EpubConverter:
|
||||
def __init__(self, file_path, access=None, logger=None, css_processor=None, html_processor=None):
|
||||
self.file_path = file_path
|
||||
def __init__(self, book_path, access=None, logger=None, css_processor=None, html_processor=None):
|
||||
self.book_path = book_path
|
||||
self.access = access
|
||||
self.logger: BookLogger = logger
|
||||
self.ebooklib_book = epub.read_epub(file_path)
|
||||
self.ebooklib_book = epub.read_epub(book_path)
|
||||
self.css_processor = css_processor
|
||||
self.html_processor = html_processor
|
||||
|
||||
@@ -603,7 +602,7 @@ class EpubConverter:
|
||||
path_to_html=nav_point.href,
|
||||
access=self.access,
|
||||
path2aws_path=self.book_image_src_path2aws_path,
|
||||
book_id=Path(self.file_path).stem)
|
||||
book_id=Path(self.book_path).stem)
|
||||
sub_nodes = []
|
||||
# warning! not EpubHtmlItems won't be added to chapter
|
||||
# if it doesn't have subchapters
|
||||
@@ -638,11 +637,8 @@ if __name__ == "__main__":
|
||||
logger_object = BookLogger(
|
||||
name="epub", book_id=epub_file_path.split("/")[-1])
|
||||
|
||||
preset = PresetProcessor(preset_path="../../config/presets.json", logger=logger_object)\
|
||||
.get_preset_json()
|
||||
css_processor = CSSPreprocessor()
|
||||
html_processor = HtmlEpubPreprocessor(
|
||||
preset=preset, logger=logger_object)
|
||||
html_processor = HtmlEpubPreprocessor("../../presets/presets.json", logger=logger_object)
|
||||
|
||||
json_converter = EpubConverter(epub_file_path, logger=logger_object,
|
||||
css_processor=css_processor, html_processor=html_processor)
|
||||
|
||||
Reference in New Issue
Block a user