MobileRead Forums

MobileRead Forums (https://www.mobileread.com/forums/index.php)
-   Plugins (https://www.mobileread.com/forums/forumdisplay.php?f=268)
-   -   [Plugin] Epub2LegacyMetaData - legacy epub2 metadata editor (https://www.mobileread.com/forums/showthread.php?t=294335)

Doitsu 01-29-2018 08:25 AM

[Plugin] Epub2LegacyMetaData - legacy epub2 metadata editor
 
2 Attachment(s)
Last updated: January 28, 2020
Current Version: "0.1.2"

This plugin recreates the table-based epub2 metadata editor that was used in older Sigil versions. There are some minor differences, though:
  • You can no longer change the order of the metadata entries, however, all metadata entries will be automatically grouped by type.
  • You can use semicolons in values only to add multiple <dc:creator>/<dc:contributor> and <dc:subject> entries.

    For example, if you create a new author role entry and enter Peter Venkman;Raymond Stantz;Egon Spengler as the value, the plugin will actually write the following three entries to the metadata section:

    Code:

    <dc:contributor opf:role="aut">Peter Venkman</dc:contributor>
     <dc:contributor opf:role="aut">Raymond Stantz</dc:contributor>
     <dc:contributor opf:role="aut">Egon Spengler</dc:contributor>

  • The plugin will display all <meta> tags, for example, Calibre metadata entries.

There are also some new features:
  • The book description is displayed in its own text box.
  • If you enter the name of an author in the Author text box (or click an existing author name) and press the Tab key, the plugin will add an author sort order suggestion to the File-as text box, if it's empty.
  • If you know the ASIN number of a Kindle book, you can manually add a MOBI-ASIN identifier via Add Basic. (This custom metadata entry is used by Calibre and some plugins.) You can also add calibre:title_sort, calibre:series and calibre:series_index metadata entries via Add Basic.
  • Advanced users can customize languages and MARC roles by editing the Epub2LegacyMetaData.json preferences file. For example, the following entries will limit the languages to English, French, Italian, German and Spanish and the MARC roles to author, book producer, translator and editor:

    Code:

    {
      "roles": "aut, bkp, trl, edt",
      "languages": "en, fr, it, de, es"
    }


Credits: The plugin uses code originally written by Florian Strzelecki for the Python-Epub 0.5.2 package. It also uses the original Sigil .ui files and metadata descriptions. The plugin icon for Sigil 0.9.9.1 and higher was created by BeckyEbook. DiapDealer created the Darkmode support code.

System requirements:

This plugin requires Sigil 0.9.8 or higher and only works with epub2 books.

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 Epub2LegacyMetaData_v0.1.2.zip. This will install the Epub2LegacyMetaData plugin, which you can select via Plugins > Edit > Epub2LegacyMetaData.

Known issues:

Very long metadata entries are sometimes not correctly resized or shown as blank cells. To fix this issue simply resize the Epub2LegacyMetaData dialog box.
You might get a "The metadata might have been modified..." message, when you click the Cancel button, even if you didn't change anything.
This message is usually displayed, if the ebook didn't contain a language metadata entry or the existing language metadata entry is wrong.
If this happens, move the Epub2LegacyMetaData dialog box to the side, click Details to open the Plugin Runner dialog box and check the original metadata section in the Plugin Runner dialog box.
(Advanced users could also change the plugin.xml <autoclose>true</autoclose> entry to <autoclose>false</autoclose>.)

License: GNU General Public License v3 (GPL-3)

DiapDealer 01-29-2018 06:25 PM

Very nice! It has the added benefit of showing people how to get translations working for Qt plugins.

I've added it to the plugin index. Thanks for the contribution to Sigil!

Maui 01-30-2018 10:24 AM

Cool!

:thanks:

What about inserting a button "Series" adding

<meta content="..." name="calibre:series" />
<meta content="1" name="calibre:series_index" />

to the metadata? They are not official, but there is at least no replacement for them and some e-readers/softreaders are interpreting them.

M

KevinH 01-30-2018 11:10 AM

If you do, please do not forget to add the calibre xml namespace info to the metadata tag itself.

Maui 01-30-2018 11:27 AM

Practically seen neither FlightCrew nor Epubcheck are complaining if the name space is missing. At least mantano reader is accepting them without namespace as well.

Theoretically you're right, no question.

Doitsu 01-30-2018 12:08 PM

Quote:

Originally Posted by Maui (Post 3649676)
What about inserting a button "Series" adding

<meta content="..." name="calibre:series" />
<meta content="1" name="calibre:series_index" />

to the metadata?

Added in version 0.1.1.

Turtle91 01-31-2018 10:16 AM

Quote:

Originally Posted by Maui (Post 3649676)
Cool!

:thanks:

What about inserting a button "Series" adding

<meta content="..." name="calibre:series" />
<meta content="1" name="calibre:series_index" />

to the metadata? They are not official, but there is at least no replacement for them and some e-readers/softreaders are interpreting them.

M

I simply saved this as a "clip". Go to your .opf, hit the button, and it's inserted. Then just edit the info as needed.

It would be nice though, if TPTB ever agree on a standard meta for series/# for that to be added to the meta editor in Sigil.

KevinH 01-31-2018 10:27 AM

Currently, Sigil meets the 3.01 spec. The IDPF has disolved and merged with W3C. They have no spec. They are planning a completely new packaged web content spec for epub4 which does not even use an opf, or zip, or ...

An epub community within w3c has decided epub 3.1 is dead on arrival. They are trying to salvage an epub 3.2 or epub 3.0.2 that does not support any series meta either.

Once the calibre namespace prefix is added to the metadata tag, using calibre: metadata is completely legal for xml and use in an opf. The issue is adoption by readers but since there is no other viable solution ....

So do not hold your breath. Simply add the calibre namespace to the metadata tag in the opf and use your clip as the epub format is in for a very rocky future.

ie. Inside the metadata tag, my guess is adding the following attribute will do the trick, unless calibre has a more specific url that describes its metadata.

Code:

xmlns:calibre="http://calibre-ebook.com"
What does Calibre itself put in the metadata tag?

KevinH

Quote:

Originally Posted by Turtle91 (Post 3650194)
I simply saved this as a "clip". Go to your .opf, hit the button, and it's inserted. Then just edit the info as needed.

It would be nice though, if TPTB ever agree on a standard meta for series/# for that to be added to the meta editor in Sigil.


kovidgoyal 02-01-2018 03:45 AM

The XML namespace calibre uses is

xmlns:calibre="http://calibre.kovidgoyal.net/2009/metadata"


However, this is not actually needed for <meta> tags. That is because the calibre: prefix in the meta tag is *inside* an attribute value and as such is not an actual XML namespace.

KevinH 02-01-2018 08:33 AM

I thought attributes could have namespaces as well. Don’t they need to be defined as well?

kovidgoyal 02-01-2018 11:01 AM

This is a namespace isnide the attribute value not the attribute name.

So

calibre:name="series"

is a namespaced attribute

name="calibre:series"

is not.

KevinH 02-01-2018 11:06 AM

Well you do learn something every day! So if a user just wanted to only use calibre series metadata, they would not need to do anything other than use the epub2 meta tag with the appropriate name and content. No namespace additions needed at all.


The equivalent in epub3 would then be:

<meta property="calibre:series">Series Name here</meta>
<meta property="calibre:series_index">1</meta>

So you would then not need any refines or use dcterms isPartOf.

Is that correct?

kovidgoyal 02-01-2018 11:11 AM

That is correct. However, for epub 3 calibre uses the technique defined in the spec for series (belongs-to-collection). It also supports the meta tag approach so you can use either as far as calibre is concerned, but for wider interoperability better to use the standard approach despite it being far less elegant.

KevinH 02-01-2018 11:16 AM

Okay so to be most correct when converting an epub2 to an epub3, ePub3-itizer should then recognize and convert calibre:series and calibre:series_index inside epub2 style meta entries to:

Code:

  <meta id="num" property="belongs-to-collection">Series Name Here</meta>
  <meta refines="#num" property="collection-type">series</meta>
  <meta refines="#num" property="group-position">1</meta>

I will add support for that.

ps: I have now created fixes for this which I will push tomorrow to support recognition of calibre:series and calibre:series_index in both the ePub3-itizer plugin and inside Sigil itself inside Sigil's Metadata Editor GUI when used on an epub2.

pps: Sigil master now has support for calibre:series and calibre:series_index in the epub2 Metadata Editor.

jcsalomon 02-01-2018 02:17 PM

Quote:

Originally Posted by KevinH (Post 3650199)
Currently, Sigil meets the 3.01 spec. The IDPF has disolved and merged with W3C. They have no spec. They are planning a completely new packaged web content spec for epub4 which does not even use an opf, or zip, or ...

An epub community within w3c has decided epub 3.1 is dead on arrival. They are trying to salvage an epub 3.2 or epub 3.0.2 that does not support any series meta either.

(emphasis added)

I’m not sure that’s right. My reading was, it was 3.1 which removed series metadata, and since 3.2 (AKA 3.0.2) is returning to 3.0.1-compatibility (warts and all) it’ll have the series metadata from 3.0.1 too.

(It’ll be “deprecated”, but since there won’t be another 3.x version, and since EPUB4 will have a completely different model anyway, I don’t see that deprecation will have any effect at all.)

KevinH 02-01-2018 02:22 PM

Agreed. Just not the dedicated "series" ones we hoped for in 3.1, so back to the refines for 3.0 and calibre:series and calibre:series_index for epub2

Doitsu 02-04-2018 05:13 AM

Since KevinH added calibre:title_sort, calibre:series and calibre:series_index support to the code for Sigil 0.9.9.1 and the ePub3-itizer plugin I added the same options to the Add Basic dialog box.

Leonatus 01-27-2020 01:15 PM

Version of Plugin: 0.1.1. Sigil Version: 1.0.0.
Windows 10, 64 bit.
Recently, I get this information when running the plugin: "Ergebnis-XML-Datei-Analyse-Fehler: Öffnendes Element erwartet." Thus, the plugin does not work.
The change in my usual work is that I now no longer use Toxaris' ebub creation tool, but the "Docx-input-plugin" of Sigil. Is there a solution?
Thanks in advance!

Doitsu 01-27-2020 01:53 PM

Quote:

Originally Posted by Leonatus (Post 3946284)
Recently, I get this information when running the plugin: "Ergebnis-XML-Datei-Analyse-Fehler: Öffnendes Element erwartet."

The plugin works fine with Sigil 1.0.0 on my 64bit Windows machine.

The original English error message is "Error Parsing Result XML: Start tag expected" and it's usually only displayed when a user clicks the Cancel button while a plugin is running.

Are you getting the same plugin error message when you open one of your older MR epubs or are you only getting the error message for newer epubs?

If you're only getting the error message for newer epubs, please copy and paste the complete <metadata>...</metadata> section.

If the newer epubs don't have the default Sigil folder structure (Text, Styles etc.), try selecting Tools > Restructure Epub to Sigil Norm (Werkzeuge > EPUB-Datei in Standard-Sigil-EPUB-Datei umwandeln), before running the plugin.

Leonatus 01-27-2020 02:55 PM

Quote:

Originally Posted by Doitsu (Post 3946297)
Are you getting the same plugin error message when you open one of your older MR epubs or are you only getting the error message for newer epubs?

It's only in the newer ones.
Quote:

If you're only getting the error message for newer epubs, please copy and paste the complete <metadata>...</metadata> section.
Here is the metadata section:
Code:

<metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf">
    <dc:language>de</dc:language>
    <dc:title>Ein Baum im Odenwald</dc:title>
    <dc:date opf:event="modification">2020-01-27</dc:date>
    <meta name="Sigil version" content="1.0.0" />
    <dc:identifier id="BookId" opf:scheme="UUID">urn:uuid:835bd7ec-3a04-43db-86f7-b83d6f72dc8f</dc:identifier>
    <meta name="cover" content="Cover.jpg" />
  </metadata>

Quote:

If the newer epubs don't have the default Sigil folder structure (Text, Styles etc.), try selecting Tools > Restructure Epub to Sigil Norm (Werkzeuge > EPUB-Datei in Standard-Sigil-EPUB-Datei umwandeln), before running the plugin.
I tried this, but then, my formattings are at least partly removed (font assignments).

Doitsu 01-27-2020 03:09 PM

Quote:

Originally Posted by Leonatus (Post 3946334)
Here is the metadata section:

The metadata section looks OK.

Quote:

Originally Posted by Doitsu (Post 3946297)
If the newer epubs don't have the default Sigil folder structure (Text, Styles etc.), try selecting Tools > Restructure Epub to Sigil Norm

Quote:

Originally Posted by Leonatus (Post 3946334)
I tried this, but then, my formattings are at least partly removed (font assignments).


This shouldn't happen, because restructuring epubs should update all folder paths. If it doesn't, you might want to bring this issue to the attention of KevinH and DiapDealer. (Post before and after code examples.)

Since I can't reproduce your problems on my machine, please PM me a download link for one of the newer epubs that you can't use with this plugin.

Leonatus 01-27-2020 03:43 PM

I just saved the erpub once more, applied the Restructure tool, and everything was allright. Also the Plugin runs as it should.
Strange was only that initially - I had corrected this immediately - the language was assigned as english, and in the metadata appeared neither author nor title. This seems to be a problem of the docx-import plugin.
Thank you for your help, though! I don't know what it was, but as everything is working well again, I'm truely satisfied!

Doitsu 01-28-2020 11:19 AM

Quote:

Originally Posted by Leonatus (Post 3946365)
I just saved the erpub once more, applied the Restructure tool, and everything was alright.

I've just found out that I hadn't uploaded the latest plugin version with Sigil 1.x support to MR.

The lack of Sigil 1.x support might explain the problem that you've encountered.

If you download the latest version, you should no longer have to select Tools > Restructure Epub to Sigil Norm when working with non-standard epubs generated by the docx input plugin.

(DiapDealer also kindly added Darkmode support to the code.)

AlanHK 07-21-2021 02:54 AM

I found that if I paste formatted text into the "Description" box (e.g., copied from a webpage in the browser) it will show italics and bold, and produce encoded html markup:

&lt;em&gt;New York Times&lt;/em&gt; bestselling

However, there is no way to change text formatting in the plugin window. Typing in codes just gets the < and > encoded. Typing in & makes &amp;. So I have to edit the OPF directly.

So would be nice if buttons for italic and bold could be added to do that.

And would also be nice if it could do epub3. Just ignore the tags it doesn't understand as long as it works on those in common with epub2.

Doitsu 07-21-2021 06:59 AM

Quote:

Originally Posted by AlanHK (Post 4140420)
So would be nice if buttons for italic and bold could be added to do that.

That's a good idea, but implementing it is beyond my skill set. Maybe KevinH could add those buttons to the built-in metadata editor.

Quote:

Originally Posted by AlanHK (Post 4140420)
And would also be nice if it could do epub3. Just ignore the tags it doesn't understand as long as it works on those in common with epub2.

I don't have plans for adding epub3 support, because that would require major code changes.


All times are GMT -4. The time now is 08:50 PM.

Powered by: vBulletin
Copyright ©2000 - 3.8.5, Jelsoft Enterprises Ltd.
MobileRead.com is a privately owned, operated and funded community.