rupor-github / fb2mobi

[DEPRECATED] fb2mobi - derived from fb2conv 1.5.4
http://www.the-ebook.org/forum/viewtopic.php?t=30380
MIT License
103 stars 13 forks source link

AttributeError: 'EpubProc' object has no attribute 'header' #11

Closed JulyMorning closed 7 years ago

JulyMorning commented 7 years ago

Please, help. Having this problem. Different books, ebup -> mobi conversion. Win10/64, v3.3.4.

M:\Books>for /R "M:\Books\mathesay\" %a in ("*.epub") do "G:\Soft\Kindle\fb2mobi\fb2mobi.exe" "%~a"

M:\Books>"G:\Soft\Kindle\fb2mobi\fb2mobi.exe" "M:\Books\mathesay\mathe-2016.epub"
INFO: Converting "mathe-2016.epub"...
INFO: Using profile "default".
INFO: Unpacking epub...
INFO: Processing epub...
Traceback (most recent call last):
  File "d:\python\python35\lib\site-packages\cx_freeze-5.0-py3.5-win-amd64.egg\cx_Freeze\initscripts\Console.py", line 21, in <module>
  File "fb2mobi.py", line 611, in <module>
  File "fb2mobi.py", line 514, in process
  File "fb2mobi.py", line 215, in process_file
  File "E:\builds_lib\fb2mobi\modules\epub.py", line 109, in process
  File "E:\builds_lib\fb2mobi\modules\epub.py", line 48, in insert_hyphenation
AttributeError: 'EpubProc' object has no attribute 'header'
rupor-github commented 7 years ago

July, epub processing is not main function of by fb2 to mobi converter :) It is rather rudimentary and stupid. You could simply run kindlegen.exe directly on your epubs using command line very similar to yours. However, please see if using command line switch (or config parameter) to turn off hyphenation will help with the problem. Meantime (if you are willing to share your book) I could take a look at the code.

JulyMorning commented 7 years ago

Alright, seems fair, but I've used this feature for a while with your great converter and it was pretty comfy to get all the books converted by the couple of commands with the same application – not just fb2, but some epubs too. Should I really consider to run kindlegen with the same command line? Does it support it natively? However,

when the hyphens is set to False we have this:

M:\Books>"G:\Soft\Kindle\fb2mobi\fb2mobi.exe" "M:\Books\mathesay\mathe-2016.epub"
Traceback (most recent call last):
  File "d:\python\python35\lib\site-packages\cx_freeze-5.0-py3.5-win-amd64.egg\cx_Freeze\initscripts\Console.py", line 21, in <module>
  File "fb2mobi.py", line 611, in <module>
  File "fb2mobi.py", line 407, in process
  File "E:\builds_lib\fb2mobi\modules\config.py", line 92, in __init__
  File "E:\builds_lib\fb2mobi\modules\config.py", line 95, in _load
  File "src\lxml\lxml.etree.pyx", line 3427, in lxml.etree.parse (src\lxml\lxml.etree.c:78731)
  File "src\lxml\parser.pxi", line 1782, in lxml.etree._parseDocument (src\lxml\lxml.etree.c:114432)
  File "src\lxml\parser.pxi", line 1808, in lxml.etree._parseDocumentFromURL (src\lxml\lxml.etree.c:114779)
  File "src\lxml\parser.pxi", line 1712, in lxml.etree._parseDocFromFile (src\lxml\lxml.etree.c:113691)
  File "src\lxml\parser.pxi", line 1115, in lxml.etree._BaseParser._parseDocFromFile (src\lxml\lxml.etree.c:108438)
  File "src\lxml\parser.pxi", line 573, in lxml.etree._ParserContext._handleParseResultDoc (src\lxml\lxml.etree.c:101974)
  File "src\lxml\parser.pxi", line 683, in lxml.etree._handleParseResult (src\lxml\lxml.etree.c:103624)
  File "src\lxml\parser.pxi", line 613, in lxml.etree._raiseParseError (src\lxml\lxml.etree.c:102536)
lxml.etree.XMLSyntaxError: Input is not proper UTF-8, indicate encoding !
Bytes: 0x85 0x30 0x31 0x32, line 9, column 26

If you really can take a look at the book and test it, it would be really great. In the matter of fact, it isn't the first time when I get the error «'EpubProc' object has no attribute 'header'» with epubs, so it possilbly can solve lots of familiar cases. By the way, I know that there's a mobi-version on the tracker, but it's not the point really)

Also, I don't know, I just cannot convert these fb2 books with the app, although all the other books seems to convert alright.

Thanks for your reply, really great work on this useful util. I appreciate it a lot.

rupor-github commented 7 years ago
  1. When hyphenation turned off properly epub conversion just works (as expected):
.\fb2mobi.py --no-hyphenate "Поскитт К.-Математика для взрослых.Лайфхаки для повседневных вычислений-2016.epub"
INFO: Converting "Поскитт К.-Математика для взрослых.Лайфхаки для повседневных вычислений-2016.epub"...
INFO: Using profile "default".
INFO: Unpacking epub...
INFO: Processing epub...
INFO: Processing took 1.6 sec.
INFO: Running kindlegen...
INFO: Optimizing resulting file...
INFO: Book conversion completed in 26.91 sec.

This is not to say that it should not work with hyphenation on, but...

  1. Your fb2 books do not convert because they are not properly formatted, all of them have description block empty:
<description>
    <title-info>
        <genre></genre>
        <author>
            <first-name></first-name>
            <middle-name></middle-name>
            <last-name></last-name>
        </author>
        <book-title></book-title>
    </title-info>
</description>

and as a result fb2mobi generates such xhtml that kindlegen just silently fails.

  1. I tried to correct (or rather compensate for) all of the above in new version 3.3.5 - please, download and try it (although you may not like what you would get without correcting your fb2 files)