This repository has been archived on 2026-04-06. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
BookConverter/test.py
2025-04-25 14:39:55 +03:00

32 lines
1.3 KiB
Python

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)