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

5
TODO
View File

@@ -24,6 +24,7 @@ TODO
✓ Context menu: Cache, Read, Edit database, delete, Mark read/unread
✓ Information dialog widget
✓ Allow editing of database data through the UI + for Bookmarks
Include (action) icons with the applications
Set focus to newly added file
Reading:
✓ Drop down for TOC
@@ -68,6 +69,7 @@ TODO
Exiting with Ctrl + Q does not save the cursor position INITIALLY
Secondary:
pdf support
Annotations
Graphical themes
Change focus rectangle dimensions
@@ -76,7 +78,7 @@ TODO
Goodreads API: Ratings, Read, Recommendations
Get ISBN using python-isbnlib
Pagination
Use embedded fonts
Use embedded fonts + CSS
Scrolling: Smooth / By Line
Spacebar should not cut off lines at the top
Shift to logging instead of print statements
@@ -91,5 +93,4 @@ TODO
Ignore a / the / numbers for sorting purposes
? Add only one file type if multiple are present
? Plugin system for parsers
? pdf support
? Create emblem per filetype

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>')