From 33979626b11f3cedb4c64f7f4be06bacfef3295e Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 29 Apr 2013 07:28:02 +0530 Subject: [PATCH] FB2 Output: Include tags in metadata as . Fixes #1174047 (keywords tag not created on FB2 creation) --- src/calibre/ebooks/fb2/fb2ml.py | 45 +++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/src/calibre/ebooks/fb2/fb2ml.py b/src/calibre/ebooks/fb2/fb2ml.py index 35ebb601fd..75c03aedc2 100644 --- a/src/calibre/ebooks/fb2/fb2ml.py +++ b/src/calibre/ebooks/fb2/fb2ml.py @@ -139,6 +139,12 @@ class FB2MLizer(object): if not metadata['author']: metadata['author'] = u'' + metadata['keywords'] = u'' + tags = list(map(unicode, self.oeb_book.metadata.subject)) + if tags: + tags = ', '.join(prepare_string_for_xml(x) for x in tags) + metadata['keywords'] = '%s'%tags + metadata['sequence'] = u'' if self.oeb_book.metadata.series: index = '1' @@ -156,27 +162,28 @@ class FB2MLizer(object): metadata['id'] = str(uuid.uuid4()) for key, value in metadata.items(): - if key not in ('author', 'cover', 'sequence'): + if key not in ('author', 'cover', 'sequence', 'keywords'): metadata[key] = prepare_string_for_xml(value) - return u'' \ - '' \ - '' \ - '%(genre)s' \ - '%(author)s' \ - '%(title)s' \ - '%(cover)s' \ - '%(lang)s' \ - '%(sequence)s' \ - '' \ - '' \ - '%(author)s' \ - '%(appname)s %(version)s' \ - '%(date)s' \ - '%(id)s' \ - '1.0' \ - '' \ - '' % metadata + return (u'' + '' + '' + '%(genre)s' + '%(author)s' + '%(title)s' + '%(cover)s' + '%(lang)s' + '%(keywords)s' + '%(sequence)s' + '' + '' + '%(author)s' + '%(appname)s %(version)s' + '%(date)s' + '%(id)s' + '1.0' + '' + '') % metadata def fb2_footer(self): return u''