View Single Post
Old 08-21-2024, 09:37 PM   #534
JimmXinu
Plugin Developer
JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.
 
JimmXinu's Avatar
 
Posts: 7,017
Karma: 4604635
Join Date: Dec 2011
Location: Midwest USA
Device: Kobo Clara Colour running KOReader
First problem I found: PSCF9-24p086-106Helble.epub has a bad CRC. Log error:
Spoiler:
Code:
EpubMerge: PSCF9-24p086-106Helble Anthology
        EpubMerge: DEBUG: 2024-08-21 19:32:00,782: calibre_plugins.epubmerge.epubmerge.epubmerge(273): prep output:0.011002302169799805
        EpubMerge: DEBUG: 2024-08-21 19:32:00,786: calibre_plugins.epubmerge.epubmerge.epubmerge(451): write rootfile OEBPS/content.opf to 1/OEBPS/content.opf
        EpubMerge: DEBUG: 2024-08-21 19:32:00,790: calibre_plugins.epubmerge.epubmerge.epubmerge(488): write toc.ncx OEBPS/toc.ncx to 1/OEBPS/toc.ncx
        Traceback (most recent call last):
          File "runpy.py", line 198, in _run_module_as_main
          File "runpy.py", line 88, in _run_code
          File "site.py", line 83, in <module>
          File "site.py", line 78, in main
          File "site.py", line 50, in run_entry_point
          File "calibre\utils\ipc\worker.py", line 215, in main
          File "calibre\utils\ipc\worker.py", line 150, in arbitrary_n
          File "calibre_plugins.epubmerge.jobs", line 84, in do_merge_bg
          File "calibre_plugins.epubmerge.epubmerge.epubmerge", line 499, in doMerge
          File "zipfile.py", line 1511, in read
          File "zipfile.py", line 941, in read
          File "zipfile.py", line 1045, in _read1
          File "zipfile.py", line 973, in _update_crc
        zipfile.BadZipFile: Bad CRC-32 for file 'OEBPS/image/Figure 9 - Raindrop imp_fmt.png'
        ==================================================

        Beginning Merge...

        ==================================================

        Error occurred processing 'PSCF9-24p086-106Helble' by ['Unknown'].

Fixing it:

This one I fixed just by opening it and saving in Calibre's Edit book.

Second problem: Found this in all of the epubs; the embedded fonts are not encrypted correctly. Log:
Spoiler:
Code:
EpubMerge: PSCF9-24p086-106Helble Anthology
        EpubMerge: DEBUG: 2024-08-21 19:34:57,167: calibre_plugins.epubmerge.epubmerge.epubmerge(273): prep output:0.013002634048461914
        EpubMerge: DEBUG: 2024-08-21 19:34:57,170: calibre_plugins.epubmerge.epubmerge.epubmerge(451): write rootfile OEBPS/content.opf to 1/OEBPS/content.opf
        EpubMerge: DEBUG: 2024-08-21 19:34:57,175: calibre_plugins.epubmerge.epubmerge.epubmerge(488): write toc.ncx OEBPS/toc.ncx to 1/OEBPS/toc.ncx
        EpubMerge: INFO: 2024-08-21 19:34:57,450: calibre_plugins.epubmerge.epubmerge.epubmerge(501): Decrypting font file: font/Arial-BoldMT.ttf
        Traceback (most recent call last):
          File "runpy.py", line 198, in _run_module_as_main
          File "runpy.py", line 88, in _run_code
          File "site.py", line 83, in <module>
          File "site.py", line 78, in main
          File "site.py", line 50, in run_entry_point
          File "calibre\utils\ipc\worker.py", line 215, in main
          File "calibre\utils\ipc\worker.py", line 150, in arbitrary_n
          File "calibre_plugins.epubmerge.jobs", line 84, in do_merge_bg
          File "calibre_plugins.epubmerge.epubmerge.epubmerge", line 502, in doMerge
          File "calibre_plugins.epubmerge.epubmerge.epubmerge", line 161, in get_decrypted_font_data
          File "calibre_plugins.epubmerge.epubmerge.epubmerge", line 141, in get_idpf_key
          File "re\__init__.py", line 185, in sub
        TypeError: expected string or bytes-like object, got 'NoneType'
        ==================================================

        Beginning Merge...

        ==================================================

        Error occurred processing 'PSCF9-24p086-106Helble' by ['Unknown'].

(FYI, these messages were available in the background Jobs log and the debug log.)

This isn't just a problem with EpubMerge, Calibre's Edit book and Convert cannot decrypt the fonts in these epubs either. Which isn't too surprising, I lifted the decrypt code for EpubMerge from Calibre.

It's easy to see the corrupted font files by opening the epub in Calibre's Edit book and looking for the 'X on red' icon on each font file in the file browser.

In past, EpubMerge didn't handle encrypted fonts at all--the older version in fact broke all encrypted fonts by changing the uuid used as the encryption key.

Fixing it:

Ideally, you'd fix the embedded fonts in the input epubs. I can't help you with that.

If that's not an option, the quickest solution I found was to remove the embedded fonts using the Modify ePub 'Remove embedded fonts' option (second from top on the right column of options). Then the current EpubMerge works.

Or, of course, you could use the older version of EpubMerge and know you're sending it with broken fonts. The plugin intro thread documents how to manually install plugins.
JimmXinu is offline   Reply With Quote