Mobileread
[Plugin] epub2 output
#1  Doitsu 08-14-2017, 05:40 PM
Updated: December 5, 2019
Current Version: "0.2.7"

This simple plugin will convert most valid commercial epub3 fiction books to valid epub2 books for use with older epub2 apps and readers. (Some post-editing might still be required.)

Note that this plugin is not a full-fledged epub3 converter; it handles only the most frequently used epub3 tags and attributes and won't work with enhanced epub3 books that contain JavaScript, MathML, audio, video or SMIL files.

This plugin does not support non-standard epubs. Select Tools > Restructure Epub to Sigil Norm before running this plugin with Sigil 1.0 and higher.


Installation:

1. Select Manage Plugins from the Plugins menu and select Use Bundled Python, if it isn't already selected.
2. Click Add Plugin and select ePub2_v0.2.7.zip. This will install the epub2 output plugin, which you can select via Plugins > Output > ePub2.

Settings:

The plugin doesn't come with a GUI, but a couple of settings can be changed via ePub2.json entries:

Code
{ "delete_epub_type": false, "output_dir": "C:\\Users\\User\\Desktop", "ncx_from_nav": false
}
delete_epub_type: Change this value to true, if you want the plugin to delete epub:type attributes. (By default, they'll be changed to class attributes.)

output_dir: Change this path, if you don't want the plugin to write epub2 files to the Desktop. (Note that on Windows machines, you'll need to use two backslashes in path names.)

ncx_from_nav: Change this value to true, if you want the plugin to always generate a new toc.ncx file from the Nav xhtml file.

License: GNU General Public License v3 (GPL-3)
[zip] ePub2_v0.2.7.zip (12.3 KB, 272 views)
Reply 

#2  DiapDealer 08-15-2017, 10:08 AM
Thanks! I'll get it added to the plugin index later today.
Reply 

#3  Heuswaar 12-01-2019, 03:59 AM
I get the following warning:

Status: failed

Processing content.opf...

ibooks: http://vocabulary.itunes.apple.com/rdf/ibooks/vocabulary-extensions-1.0/ package prefix attribute deleted.
Package updated.

Traceback (most recent call last):
File "D:\Program Files\Sigil\plugin_launchers\python\launcher.py", line 135, in launch
self.exitcode = target_script.run(container)
File "C:\Users\boeke\AppData\Local\sigil-ebook\sigil\plugins\ePub2\plugin.py", line 207, in run
timestamp.string = timestamp.string[0:10]
AttributeError: 'NoneType' object has no attribute 'string'
Error: 'NoneType' object has no attribute 'string'
Reply 

#4  Doitsu 12-01-2019, 04:19 AM
Please check all epub3 books with EpubCheck before running this plugin, because it might fail if the input file is invalid.

The plugin failed because there's no time stamp entry in the .opf file. (Time stamps are mandatory in epub3 files.)

Time stamps look like this:

Code
 <meta property="dcterms:modified">2019-12-01T10:06:19Z</meta>
To fix this issue, add and delete a space in an HTML file and save the epub with Sigil. This'll add the missing time stamp.
Reply 

#5  Heuswaar 12-05-2019, 04:28 AM
Thank You, it now works if i add de date.
Reply 

#6  Heuswaar 05-28-2020, 10:19 AM
I get the following warning:

Status: failed

Processing content.opf...

ibooks: http://vocabulary.itunes.apple.com/rdf/ibooks/vocabulary-extensions-1.0/ calibre: https://calibre-ebook.com package prefix attribute deleted.
Package updated.

Mapping refines...

"Krinar-kronieken 0,5 - De Krinar-onthulling" file:as refines title attribute mapped to calibre:title_sort attribute
"main" title-type refines property IGNORED.
"Zaires, Anna" file:as refines attribute mapped to opf:file-as attribute
"aut" role refines attribute mapped to opf:role attribute
"Ivers, Hettie" file:as refines attribute mapped to opf:file-as attribute
"aut" role refines attribute mapped to opf:role attribute
"series" collection-type refines property IGNORED.
"Krinar-kronieken" belongs-to-collection refines attribute mapped to calibre:series attribute
"0.5" group-position refines attribute mapped to calibre:series_index attribute
Traceback (most recent call last):
File "D:\Program Files\Sigil\plugin_launchers\python\launcher.py", line 136, in launch
self.exitcode = target_script.run(container)
File "C:\Users\boeke\AppData\Local\sigil-ebook\sigil\plugins\ePub2\plugin.py", line 215, in run
metadata.find(id=dc_id)['opf:role'] = refine.string
TypeError: 'NoneType' object does not support item assignment
Error: 'NoneType' object does not support item assignment

Date en Time are good.
Reply 

#7  Doitsu 05-28-2020, 12:07 PM
The book metadata section most likely contains invalid refine entries.
Check the book with my EPUBCheck plugin and fix all metadata errors.

If you don't get any error messages, try the following:

1. In Sigil, select Edit > Preferences > Open Preferences Location.

2. Go to plugins\ePub2 and open plugin.py with a text editor.

3. Change line 215 from:

Code
 if dc_property == 'role':
to

Code
 if dc_property == 'role' and dc_id is not None:
If it still doesn't work, do an epub to epub conversion with Calibre. This should convert your epub3 book to an epub2 book.
Reply 

#8  Heuswaar 05-29-2020, 05:59 AM
I have a on-line conversion done, and then all problems fixt.

Thank you
Reply 

Today's Posts | Search this Thread | Login | Register