Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Sigil > Plugins

Notices

Reply
 
Thread Tools Search this Thread
Old 09-02-2015, 04:18 PM   #1
CalibUser
Addict
CalibUser goes to eleven.CalibUser goes to eleven.CalibUser goes to eleven.CalibUser goes to eleven.CalibUser goes to eleven.CalibUser goes to eleven.CalibUser goes to eleven.CalibUser goes to eleven.CalibUser goes to eleven.CalibUser goes to eleven.CalibUser goes to eleven.
 
Posts: 201
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.
CalibUser is offline   Reply With Quote
Old 09-02-2015, 05:46 PM   #2
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 29,818
Karma: 54830978
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 )
theducks is offline   Reply With Quote
Old 09-02-2015, 07:05 PM   #3
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 7,657
Karma: 5433388
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:
Originally Posted by CalibUser View Post
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.
KevinH is offline   Reply With Quote
Old 09-02-2015, 07:06 PM   #4
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 27,553
Karma: 193191846
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!
DiapDealer is offline   Reply With Quote
Old 09-03-2015, 02:02 PM   #5
CalibUser
Addict
CalibUser goes to eleven.CalibUser goes to eleven.CalibUser goes to eleven.CalibUser goes to eleven.CalibUser goes to eleven.CalibUser goes to eleven.CalibUser goes to eleven.CalibUser goes to eleven.CalibUser goes to eleven.CalibUser goes to eleven.CalibUser goes to eleven.
 
Posts: 201
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.
CalibUser is offline   Reply With Quote
Old 09-03-2015, 06:49 PM   #6
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 7,657
Karma: 5433388
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
KevinH is offline   Reply With Quote
Old 09-05-2015, 10:45 AM   #7
CalibUser
Addict
CalibUser goes to eleven.CalibUser goes to eleven.CalibUser goes to eleven.CalibUser goes to eleven.CalibUser goes to eleven.CalibUser goes to eleven.CalibUser goes to eleven.CalibUser goes to eleven.CalibUser goes to eleven.CalibUser goes to eleven.CalibUser goes to eleven.
 
Posts: 201
Karma: 62362
Join Date: Jul 2015
Device: Sony
Thanks, that would be useful.
CalibUser is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Cleaning content.opf rubeus Plugins 5 09-04-2017 11:12 AM
erroneous content.opf rubeus Sigil 9 01-05-2015 04:30 PM
Change opf filename from content.opf to title.opf northstar7 Sigil 3 09-23-2013 12:44 PM
Sigil corrupting content.opf (0.4, 0.5) cyana Sigil 21 02-11-2012 05:25 PM
cleaning the content.opf file Adjust ePub 6 09-01-2010 05:54 PM


All times are GMT -4. The time now is 12:32 AM.


MobileRead.com is a privately owned, operated and funded community.