forked from LiveCarta/BookConverter
37 lines
1.2 KiB
Python
37 lines
1.2 KiB
Python
from src.book_solver import BookSolver
|
|
from src.epub_converter.css_processor import CSSPreprocessor
|
|
from src.epub_converter.html_epub_processor import HtmlEpubPreprocessor
|
|
from src.epub_converter.epub_converter import EpubConverter
|
|
|
|
|
|
class EpubBook(BookSolver):
|
|
"""Class of .epub type book - child of BookSolver"""
|
|
|
|
def __init__(self, book_id=0, access=None, main_logger=None):
|
|
super().__init__(book_id, access, main_logger)
|
|
self.book_type = "epub"
|
|
|
|
def get_converted_book(self):
|
|
"""
|
|
Function
|
|
Steps
|
|
----------
|
|
1. Gets data from preset structure
|
|
2. Add preset to html preprocessor
|
|
3. Converts .epub to .html
|
|
4. Parses from line structure to nested structure
|
|
|
|
Returns
|
|
----------
|
|
content_dict
|
|
json for LiveCarta platform
|
|
|
|
"""
|
|
css_processor = CSSPreprocessor()
|
|
html_processor = HtmlEpubPreprocessor(self.preset_path, logger=self.logger_object)
|
|
json_converter = EpubConverter(
|
|
self.book_path, access=self.access, logger=self.logger_object,
|
|
css_processor=css_processor, html_processor=html_processor)
|
|
content_dict = json_converter.convert_to_dict()
|
|
return content_dict
|