View Single Post
Old 04-30-2014, 10:56 PM   #1
Saioko
Member
Saioko began at the beginning.
 
Posts: 23
Karma: 10
Join Date: Apr 2013
Device: Digma s602
Converting to fb2 - adding annotation.

What code should I use to add <annotation> to fb2 file header?

I tried using this:
Code:
        annotationtext = u''
        annotationtext = self.oeb_book.metadata['description'][0].value
Plus some replacing, which gives me in "annotationtext" something like "<p>Blah-blah-blah</p>".

But when I try to add it to fb2 header with this:
Code:
                        <book-title>%(title)s</book-title>
                        <annotation>%(annotationtext)s</annotation>
I get an error message.
Quote:
File "/home/katya/calibre/src/calibre/ebooks/fb2/fb2ml.py", line 56, in extract_content
return self.fb2mlize_spine()
File "/home/katya/calibre/src/calibre/ebooks/fb2/fb2ml.py", line 59, in fb2mlize_spine
output = [self.fb2_header()]
File "/home/katya/calibre/src/calibre/ebooks/fb2/fb2ml.py", line 253, in fb2_header
</description>\n''') % metadata
KeyError: u'annotationtext'

P.S. I know it is possible, because in past I had "Update metadata" option turned on during save-to-disk and those files had annotation. But they also messed up my author edits.

Last edited by Saioko; 04-30-2014 at 10:58 PM.
Saioko is offline   Reply With Quote