add converter local launch

This commit is contained in:
Svitin Egor
2025-04-25 14:39:55 +03:00
parent 9be0a46162
commit 43f65f9712
4 changed files with 98 additions and 0 deletions

31
test.py Normal file
View File

@@ -0,0 +1,31 @@
import json
import codecs
import logging
from src.book_solver import BookSolver
from src.util.helpers import BookLogger
from src.html_presets_processor import HtmlPresetsProcessor
from src.style_reader import StyleReader
from src.epub_converter.html_epub_processor import HtmlEpubProcessor
from src.epub_converter.epub_converter import EpubConverter
if __name__ == "__main__":
#epub_file_path = f"/app/books/epub/9781284289473.epub"
epub_file_path = f"/app/books/epub/9781284296693.epub"
print("Start")
logger_object = BookLogger(name="epub")
logger_object.configure_book_logger(book_id=epub_file_path.split("/")[-1])
html_preset_processor = HtmlPresetsProcessor(
logger=logger_object, preset_path="/app/preset/default_preset.json")
style_preprocessor = StyleReader()
html_processor = HtmlEpubProcessor(logger=logger_object,
html_preprocessor=html_preset_processor)
json_converter = EpubConverter(epub_file_path, logger=logger_object,
style_processor=style_preprocessor, html_processor=html_processor)
content_dict = json_converter.convert_to_dict()
print(epub_file_path.replace("epub", "json"))
with codecs.open(epub_file_path.replace("epub", "json"), "w", encoding="utf-8") as f_json:
json.dump(content_dict, f_json, ensure_ascii=False)