zk4 / epub2html

Fast epub reader with simple idea

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

open epub file returns "FileNotFoundError"

ilcpm opened this issue · comments

commented

using command epub2html.exe .\SuperMemo.epub to view a epub file, it shows an error:

PS C:\Users\Ruossipha\Desktop> epub2html.exe .\SuperMemo.epub
self.ncx_a_path C:\Users\RUOSSI~1\AppData\Local\Temp\SuperMemo\toc.ncx
Traceback (most recent call last):
  File "c:\dev\python37\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\dev\python37\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Dev\Python37\Scripts\epub2html.exe\__main__.py", line 7, in <module>
  File "c:\dev\python37\lib\site-packages\epub2html\epub2html.py", line 228, in entry_point
    main(mainArgs)
  File "c:\dev\python37\lib\site-packages\epub2html\epub2html.py", line 215, in main
    e.gen()
  File "c:\dev\python37\lib\site-packages\epub2html\epub2html.py", line 190, in gen
    menu, full_content = self.gen_menu_content()
  File "c:\dev\python37\lib\site-packages\epub2html\epub2html.py", line 139, in gen_menu_content
    self._gen_menu_content(c,menus,contents,0)
  File "c:\dev\python37\lib\site-packages\epub2html\epub2html.py", line 128, in _gen_menu_content
    self._gen_menu_content(d,menus,contents,depth+1)
  File "c:\dev\python37\lib\site-packages\epub2html\epub2html.py", line 120, in _gen_menu_content
    washed_content = self.gen_content(join(dirname(self.ncx_a_path),no_hash_name))
  File "c:\dev\python37\lib\site-packages\epub2html\epub2html.py", line 151, in gen_content
    raw_text_content = Path(path).read_bytes()
  File "c:\dev\python37\lib\pathlib.py", line 1214, in read_bytes
    with self.open(mode='rb') as f:
  File "c:\dev\python37\lib\pathlib.py", line 1208, in open
    opener=self._opener)
  File "c:\dev\python37\lib\pathlib.py", line 1063, in _opener
    return self._accessor.open(self, flags, mode)
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\RUOSSI~1\\AppData\\Local\\Temp\\SuperMemo\\Gao%20Zhong%20Sheng%20Shi%20Jiao.html'

I checked the epub file, found the file here. Maybe the error is caused by the "space" in file name?

image

commented

@ilcpm file in OneDriver is pdf.

commented

sorry, I've corrected the link above.

commented

I found the problem, the file path in "index.html" has been url encoded
image

so the path should be url decode.


here's the fix:

in file "epub2html\epub2html.py" line 154
change "Path(path).read_bytes()" into "Path(urllib.parse.unquote(path)).read_bytes()"
then it works fine in my system

I'm not familiar about making a pr with github, so maybe you have to fix it yourself, sorry for that 😂

commented

@ilcpm already fixed in 6825d2e