diff --git a/src/calibre/ebooks/fb2/fb2ml.py b/src/calibre/ebooks/fb2/fb2ml.py
index 2c937fd357..d86a83e9b0 100644
--- a/src/calibre/ebooks/fb2/fb2ml.py
+++ b/src/calibre/ebooks/fb2/fb2ml.py
@@ -101,9 +101,6 @@ class FB2MLizer(object):
def fb2_header(self):
metadata = {}
- metadata['author_first'] = u''
- metadata['author_middle'] = u''
- metadata['author_last'] = u''
metadata['title'] = self.oeb_book.metadata.title[0].value
metadata['appname'] = __appname__
metadata['version'] = __version__
@@ -115,16 +112,36 @@ class FB2MLizer(object):
metadata['id'] = None
metadata['cover'] = self.get_cover()
- author_parts = self.oeb_book.metadata.creator[0].value.split(' ')
- if len(author_parts) == 1:
- metadata['author_last'] = author_parts[0]
- elif len(author_parts) == 2:
- metadata['author_first'] = author_parts[0]
- metadata['author_last'] = author_parts[1]
- else:
- metadata['author_first'] = author_parts[0]
- metadata['author_middle'] = ' '.join(author_parts[1:-2])
- metadata['author_last'] = author_parts[-1]
+ metadata['author'] = u''
+ for auth in self.oeb_book.metadata.creator:
+ author_first = u''
+ author_middle = u''
+ author_last = u''
+ author_parts = auth.value.split(' ')
+ if len(author_parts) == 1:
+ author_last = author_parts[0]
+ elif len(author_parts) == 2:
+ author_first = author_parts[0]
+ author_last = author_parts[1]
+ else:
+ author_first = author_parts[0]
+ author_middle = ' '.join(author_parts[1:-1])
+ author_last = author_parts[-1]
+ metadata['author'] += ''
+ metadata['author'] += '%s' % prepare_string_for_xml(author_first)
+ if author_middle:
+ metadata['author'] += '%s' % prepare_string_for_xml(author_middle)
+ metadata['author'] += '%s' % prepare_string_for_xml(author_last)
+ metadata['author'] += ''
+ if not metadata['author']:
+ metadata['author'] = u''
+
+ metadata['sequence'] = u''
+ if self.oeb_book.metadata.series:
+ index = '1'
+ if self.oeb_book.metadata.series_index:
+ index = self.oeb_book.metadata.series_index[0]
+ metadata['sequence'] = u'' % (prepare_string_for_xml(u'%s' % self.oeb_book.metadata.series[0]), index)
identifiers = self.oeb_book.metadata['identifier']
for x in identifiers:
@@ -136,28 +153,21 @@ class FB2MLizer(object):
metadata['id'] = str(uuid.uuid4())
for key, value in metadata.items():
- if not key == 'cover':
+ if key not in ('author', 'cover', 'sequence'):
metadata[key] = prepare_string_for_xml(value)
return u'' \
'' \
'' \
'antique' \
- '' \
- '%(author_first)s' \
- '%(author_middle)s' \
- '%(author_last)s' \
- '' \
+ '%(author)s' \
'%(title)s' \
'%(cover)s' \
'%(lang)s' \
+ '%(sequence)s' \
'' \
'' \
- '' \
- '' \
- '' \
- '' \
- '' \
+ '%(author)s' \
'%(appname)s %(version)s' \
'%(date)s' \
'%(id)s' \