Account for no images in an epub

This commit is contained in:
BasioMeusPuga
2018-03-13 00:24:32 +05:30
parent ca3d747136
commit ce9ee4ccb2
2 changed files with 10 additions and 16 deletions

View File

@@ -234,13 +234,6 @@ class EPUB:
(fallback_title, chapter_data))
no_title_chapter += 1
cover_path = os.path.join(temp_dir, os.path.basename(self.filename)) + '- cover'
with open(cover_path, 'wb') as cover_temp:
cover_temp.write(self.book['cover'])
self.book['book_list'][0] = (
'Cover', f'<center><img src="{cover_path}" alt="Cover"></center>')
else:
# https://stackoverflow.com/questions/14444732/how-to-split-a-html-page-to-multiple-pages-using-python-and-beautiful-soup
markup = BeautifulSoup(chapter_data, 'xml')
@@ -267,10 +260,10 @@ class EPUB:
(fallback_title, this_chapter))
no_title_chapter += 1
def main():
book = EPUB(sys.argv[1])
book.read_epub()
book.parse_chapters()
cover_path = os.path.join(temp_dir, os.path.basename(self.filename)) + '- cover'
if self.book['cover']:
with open(cover_path, 'wb') as cover_temp:
cover_temp.write(self.book['cover'])
if __name__ == '__main__':
main()
self.book['book_list'][0] = (
'Cover', f'<center><img src="{cover_path}" alt="Cover"></center>')