forked from LiveCarta/BookConverter
Move main to epub_solver.py
This commit is contained in:
@@ -1,6 +1,4 @@
|
|||||||
import re
|
import re
|
||||||
import json
|
|
||||||
import codecs
|
|
||||||
import ebooklib
|
import ebooklib
|
||||||
from os import path
|
from os import path
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
@@ -605,20 +603,3 @@ class EpubConverter:
|
|||||||
"content": top_level_dict_chapters,
|
"content": top_level_dict_chapters,
|
||||||
"footnotes": self.footnotes_contents
|
"footnotes": self.footnotes_contents
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
epub_file_path = "../../books/epub/9780763774134.epub"
|
|
||||||
logger_object = BookLogger(
|
|
||||||
name="epub", book_id=epub_file_path.split("/")[-1])
|
|
||||||
|
|
||||||
css_processor = StylePreprocessor()
|
|
||||||
html_processor = HtmlEpubProcessor(
|
|
||||||
"../../presets/epub_presets.json", logger=logger_object)
|
|
||||||
|
|
||||||
json_converter = EpubConverter(epub_file_path, logger=logger_object,
|
|
||||||
style_processor=css_processor, html_processor=html_processor)
|
|
||||||
content_dict = json_converter.convert_to_dict()
|
|
||||||
|
|
||||||
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)
|
|
||||||
|
|||||||
@@ -1,6 +1,11 @@
|
|||||||
|
import json
|
||||||
|
import codecs
|
||||||
|
|
||||||
from src.book_solver import BookSolver
|
from src.book_solver import BookSolver
|
||||||
|
from src.util.helpers import BookLogger
|
||||||
|
from src.html_preprocessor import HtmlPreprocessor
|
||||||
from src.style_preprocessor import StylePreprocessor
|
from src.style_preprocessor import StylePreprocessor
|
||||||
from src.epub_converter.html_epub_processor import HtmlEpubProcessor
|
from src.epub_converter.html_epub_processor import HTMLEpubProcessor
|
||||||
from src.epub_converter.epub_converter import EpubConverter
|
from src.epub_converter.epub_converter import EpubConverter
|
||||||
|
|
||||||
|
|
||||||
@@ -33,3 +38,22 @@ class EpubBook(BookSolver):
|
|||||||
style_processor=style_processor, html_processor=html_processor)
|
style_processor=style_processor, html_processor=html_processor)
|
||||||
content_dict = json_converter.convert_to_dict()
|
content_dict = json_converter.convert_to_dict()
|
||||||
return content_dict
|
return content_dict
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
epub_file_path = "../../books/epub/9780763774134.epub"
|
||||||
|
logger_object = BookLogger(
|
||||||
|
name="epub", book_id=epub_file_path.split("/")[-1])
|
||||||
|
|
||||||
|
html_preprocessor = HtmlPreprocessor(
|
||||||
|
logger=logger_object, preset_path="../../presets/epub_presets.json")
|
||||||
|
style_preprocessor = StylePreprocessor()
|
||||||
|
html_processor = HTMLEpubProcessor(logger=logger_object,
|
||||||
|
html_preprocessor=html_preprocessor)
|
||||||
|
|
||||||
|
json_converter = EpubConverter(epub_file_path, logger=logger_object,
|
||||||
|
style_processor=style_preprocessor, html_processor=html_processor)
|
||||||
|
content_dict = json_converter.convert_to_dict()
|
||||||
|
|
||||||
|
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)
|
||||||
|
|||||||
Reference in New Issue
Block a user