Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't Open .epub Files #136

Open
Mindforms opened this issue Sep 8, 2020 · 1 comment
Open

Can't Open .epub Files #136

Mindforms opened this issue Sep 8, 2020 · 1 comment

Comments

@Mindforms
Copy link

Mindforms commented Sep 8, 2020

I run Kubuntu 19.10. Not only am I unable to open .pdf files as I can't install pymupdf (which isn't a big deal because I already have a good PDF reader), but most importantly, I can't open .epub files either.

Here's my log when I try opening one:

2020/09/08  15:41:07,896 lector.readers.read_epub WARNING toc.ncx not found in /home/aeonwaves/Downloads/~~~Reading~~~/eBooks - Selection/BOOK.epub
2020/09/08  15:41:07,900 lector.sorter ERROR Content generation error: /home/aeonwaves/Downloads/~~~Reading~~~/eBooks - Selection/BOOK.epub KeyError Arguments: ('ncx',)
Traceback (most recent call last):
  File "/home/aeonwaves/Downloads/~~~Software~~~/Lector/Lector/lector/sorter.py", line 290, in read_book
    book_breakdown = book_ref.generate_content()
  File "/home/aeonwaves/Downloads/~~~Software~~~/Lector/Lector/lector/parsers/epub.py", line 46, in generate_content
    self.book.generate_toc()
  File "/home/aeonwaves/Downloads/~~~Software~~~/Lector/Lector/lector/readers/read_epub.py", line 151, in generate_toc
    navpoints = toc_dict['ncx']['navMap']['navPoint']
KeyError: 'ncx'
2020/09/08  15:41:07,953 lector.main ERROR No parseable files found
@char101
Copy link

char101 commented Mar 1, 2022

BeautifulSoup cannot parse None so we need to handle the case

diff --git a/lector/readers/read_epub.py b/lector/readers/read_epub.py
index 124e8e5..55d9619 100644
--- a/lector/readers/read_epub.py
+++ b/lector/readers/read_epub.py
@@ -193,7 +193,7 @@ class EPUB:
             self.split_chapters[chapter_file] = {}

             chapter_content = self.get_chapter_content(chapter_file)
-            soup = BeautifulSoup(chapter_content, 'lxml')
+            soup = BeautifulSoup(chapter_content or '', 'lxml')

             split_anchors = i[1]
             for this_anchor in reversed(split_anchors):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants