benchen71 / epub-metadata-editor

Edit the metadata of EPUB files
192 stars 11 forks source link

Lack of support for multiple 'Identifer' fields #44

Closed Cyberbeing closed 5 years ago

Cyberbeing commented 5 years ago

Currently only the first 'Identifier' field is loaded and able to be displayed in both the GUI and Console application.

Optimally I'd like to be able to see and edit all epub 'Identifier' fields in a future version, or otherwise always prioritize what I'd consider the primary Identifier which is the UUID dc:identifier id="uuid_id" opf:scheme="uuid", and allow adding that field if missing.

If the program could auto-generate a new UUID for that field on demand similar to Uuidgen.exe from the Microsoft SDK, that would be even more convenient.

For my use-case, the current behavior is an issue since I frequently run into user published epubs which have identical UUID values, while my epub reader uses the UUID for duplicate detection and only allows a single instance of each UUID to exist. For the past few years, I'd been using Epub Metadata Editor to add new UUIDs to these files with the help of uuidgen.exe, but today I ran into a few epub files where the 'calibre' Identifier field somehow ended up first rather than the UUID. Hence my request to always prioritize the UUID Identifer field, or add support for multiple Identifier fields so I can view and edit whichever needed.

Edit: Another issue I'm noticing now upon checking, is when the UUID is changed with Epub Metadata Editor, it only changes the value in content.opf, but and doesn't change the same UUID meta content name="dtb:uid value in toc.ncx which it seems like it probably should so they are in sync.

benchen71 commented 5 years ago

I've got something working for EPUB2 files, but I'm not sure what to do with EPUB3 files which have a far more complicated Identifier system. I'll try and get the update out tomorrow...

benchen71 commented 5 years ago

And by "working" I mean that the program now preferences UUID identifiers and also updates toc.ncx if the UUID content changes. To allow for editing of multiple identifiers will overly complicate the interface. And anyway, it is already possible to edit them by editing the opf file using the button in the "Advanced tasks" panel.

Cyberbeing commented 5 years ago

To allow for editing of multiple identifiers will overly complicate the interface.

I see two possible alternatives:

  1. Show the number of Identifiers which exist, with a tooltip which lists the scheme types and/or values

  2. Add a button next to the Identifier field for Edit .ofp which is grayed out except in cases when multiple Identifiers are detected. Add a warning to the Console application if there are multiple Identifiers

Related to all this was also an issue that if you use Edit Identifier's Scheme Type to change an identifier which is something else to uuid it didn't actually set the field to the standard value dc:identifier id="uuid_id" opf:scheme="uuid". I believe it ignored setting dc:identifier id, no idea if you want to add another button for that or just set it automatically.

Though with your update that always prioritizes UUID, this should no longer be necessary except in cases where the UUID is entirely missing and you're adding the Identifier field from scratch.

benchen71 commented 5 years ago

OK, so the up-coming version will inform you if multiple identifiers are present with a label (and if you mouseover the label it will instruct you to open the Advanced Tasks panel and click the Edit .opf file button). If there is a uuid identifier, even if it is not first in the opf file, it will always be displayed. If one is not present, the first identifier will be displayed. If the current (non-uuid) identifier is changed into a uuid one, the identifier's id will also be changed. (This should also work if there are no identifiers currently and you add a uuid one.)

This might be the best I can do at this stage...

Cyberbeing commented 5 years ago

Sounds good. Thanks for the hard work.

benchen71 commented 5 years ago

Added to version 1.7.2.

haudek commented 5 years ago

I found other problem with multiple identifiers. Get sample file, make any change in metadata and try save.

test_1.7.2.epub.zip

benchen71 commented 5 years ago

Thanks for that. The issue is caused by the all caps UUID in the identifier's scheme. I've added a fix that will come out in 1.7.3, but I might not release it just yet and wait for some more bugs!