09-02-2015, 05:18 PM | #1 |
Addict
Posts: 202
Karma: 62362
Join Date: Jul 2015
Device: Sony
|
Writing to the content.opf
I want to correct errors that sometimes occur in the content.opf file. I can read this file using bk.readotherfile("OEBPS/content.opf"). However, I cannot write to this file using bk.writeotherfile("OEBPS/content.opf", opf2) where opf2 is the updated file to write back to the ePub.
Is it possible to amend the content.opf file without having to unzip the ePub, amend the unzipped file, and then zip it back up again? Thanks. |
09-02-2015, 06:46 PM | #2 |
Well trained by Cats
Posts: 30,443
Karma: 58055868
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Dou you need to do this from a PI?
Content.opf is selectable from the file browser list and opens just like any other file. Caution, there are no bullet proof vests while editing. WYSIWYD (what you did ) |
Advert | |
|
09-02-2015, 08:05 PM | #3 | |
Sigil Developer
Posts: 8,158
Karma: 5450818
Join Date: Nov 2009
Device: many
|
Hi,
As designed, the content.opf is properly changed and maintained by all of the other calls in the bookcontainer interface. So if you could explain exactly what you are trying to change in the opf, I can explain how you might go about it with interface calls. If what you want to do is not possible via the interface, you can get total control by unzipping a copy. See the epub_utils code available on this site for some utility routines if you end up having to do that, KevinH Quote:
|
|
09-02-2015, 08:06 PM | #4 |
Grand Sorcerer
Posts: 28,040
Karma: 199464182
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
The content of the opf file is not directly editable through the plugin interface. This is by design. I'm not going to say this will never change, but that's the way it is right now.
The opf file is always rebuilt by the plugin interface to automatically incorporate all the changes to the various files that a plugin may have made. Depending on what changes you need to make, there are workarounds to accomplish some things. For instance deleting a manifested file and recreating a new one (from saved data) will allow you to "rename" a manifested file. EDIT: Scooped by 60 seconds! |
09-03-2015, 03:02 PM | #5 |
Addict
Posts: 202
Karma: 62362
Join Date: Jul 2015
Device: Sony
|
The media files in the content .opf file should be media-type="application/xhtml+xml". However, sometimes my PDF converter produces ePub files that are of type "text/html" and this generates an error. I wanted to add something to the plugin that I am developing (see https://www.mobileread.com/forums/sho...d.php?t=264378) so that I can do a search and replace for these errors.
|
Advert | |
|
09-03-2015, 07:49 PM | #6 |
Sigil Developer
Posts: 8,158
Karma: 5450818
Join Date: Nov 2009
Device: many
|
Hi,
That is not easy to do in the current plugin interface without deleting and re-adding the file specifying the correct media-type. That said, text/html is not a valid media-type in an epub so, it may be possible to change the launcher code to auto-correct that type of failure. Your plugin might be something better done as an input plugin that fixes things it needs to on the way into Sigil. Let me think about it. We have already added spell checking via hunspell to the plugin interface for the next release so adding even more should not be an issue. Kevin |
09-05-2015, 11:45 AM | #7 |
Addict
Posts: 202
Karma: 62362
Join Date: Jul 2015
Device: Sony
|
Thanks, that would be useful.
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Cleaning content.opf | rubeus | Plugins | 5 | 09-04-2017 12:12 PM |
erroneous content.opf | rubeus | Sigil | 9 | 01-05-2015 05:30 PM |
Change opf filename from content.opf to title.opf | northstar7 | Sigil | 3 | 09-23-2013 01:44 PM |
Sigil corrupting content.opf (0.4, 0.5) | cyana | Sigil | 21 | 02-11-2012 06:25 PM |
cleaning the content.opf file | Adjust | ePub | 6 | 09-01-2010 06:54 PM |