epub converter: prettify

This commit is contained in:
shirshasa
2021-06-22 13:58:50 +03:00
parent f4e8eed13c
commit 22c841f191

View File

@@ -5,6 +5,7 @@ import re
from os.path import dirname, normpath, join from os.path import dirname, normpath, join
from collections import defaultdict from collections import defaultdict
from typing import Dict, Union from typing import Dict, Union
from itertools import chain
import ebooklib import ebooklib
from bs4 import BeautifulSoup from bs4 import BeautifulSoup
@@ -29,12 +30,8 @@ class EpubPostprocessor:
self.logger.log('Image processing.') self.logger.log('Image processing.')
self.href2img_bytes = {} self.href2img_bytes = {}
self.old_image_path2_aws_path = {} self.old_image_path2_aws_path = {}
for x in self.ebooklib_book.get_items_of_type(ebooklib.ITEM_IMAGE): for x in chain(self.ebooklib_book.get_items_of_type(ebooklib.ITEM_IMAGE),
file_name = x.file_name self.ebooklib_book.get_items_of_type(ebooklib.ITEM_COVER)):
content = x.content
# todo: check how file path is count in lib
self.href2img_bytes[file_name] = content
for x in self.ebooklib_book.get_items_of_type(ebooklib.ITEM_COVER):
file_name = x.file_name file_name = x.file_name
content = x.content content = x.content
self.href2img_bytes[file_name] = content self.href2img_bytes[file_name] = content