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

epub2txt.py produces incorrect results for many epubs #26

Open
shawwn opened this issue Sep 1, 2020 · 1 comment
Open

epub2txt.py produces incorrect results for many epubs #26

shawwn opened this issue Sep 1, 2020 · 1 comment

Comments

@shawwn
Copy link

shawwn commented Sep 1, 2020

Specifically this line:

html = file.read(ops + t.content.split("#")[0])

image

When I tried to convert a book on Tensorflow to text using this script, I noticed chapter 1 was being repeated multiple times.

The reason is that the Table of Contents looks similar to this:

ch1.html#section1
ch1.html#section2
ch1.html#section3
...
ch2.html#section1
ch2.html#section2
...

The epub2txt script iterates over this table of contents, splits "ch1.html#section1" to "ch1.html", then converts that to text. Then repeats for "ch1.html#section2", which converts the same chapter into text.

I have a fixed version here: https://github.com/shawwn/scrap/blob/afb699ee9c8181b3728b81fc410a31b66311f0d8/epub2txt#L158-L206

@soskek
Copy link
Owner

soskek commented Sep 5, 2020

Thank you! I'll fix it!

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