diff --git a/calibre-plugin/plugin-defaults.ini b/calibre-plugin/plugin-defaults.ini
index 0816e5d3..58aed7b9 100644
--- a/calibre-plugin/plugin-defaults.ini
+++ b/calibre-plugin/plugin-defaults.ini
@@ -778,6 +778,13 @@ nook_img_fix:true
## with this.
#internalize_text_links:false
+## Some ebook readers (Moon+ Reader was reported) read and
+## for series info. This is not epub standard, but not an
+## unreasonable thing for FanFicFare to emulate. This is primarily
+## useful for CLI and web service--the calibre plugin doesn't need it.
+#calibre_series_meta:false
+
[mobi]
## mobi TOC cannot be turned off right now.
#include_tocpage: true
diff --git a/fanficfare/configurable.py b/fanficfare/configurable.py
index dcc2b018..e86e2c60 100644
--- a/fanficfare/configurable.py
+++ b/fanficfare/configurable.py
@@ -224,6 +224,8 @@ def get_valid_set_options():
'include_logpage':(None,['epub'],boollist+['smart']),
'logpage_at_end':(None,['epub'],boollist),
+ 'calibre_series_meta':(None,['epub'],boollist),
+
'windows_eol':(None,['txt'],boollist),
'include_images':(None,['epub','html'],boollist),
@@ -346,6 +348,7 @@ def get_valid_keywords():
'include_images',
'include_logpage',
'logpage_at_end',
+ 'calibre_series_meta',
'include_subject_tags',
'include_titlepage',
'include_tocpage',
diff --git a/fanficfare/defaults.ini b/fanficfare/defaults.ini
index a3c526cf..963e8fc7 100644
--- a/fanficfare/defaults.ini
+++ b/fanficfare/defaults.ini
@@ -827,6 +827,13 @@ nook_img_fix:true
## with this.
#internalize_text_links:false
+## Some ebook readers (Moon+ Reader was reported) read and
+## for series info. This is not epub standard, but not an
+## unreasonable thing for FanFicFare to emulate. This is primarily
+## useful for CLI and web service--the calibre plugin doesn't need it.
+#calibre_series_meta:false
+
[mobi]
## mobi TOC cannot be turned off right now.
#include_tocpage: true
diff --git a/fanficfare/writers/writer_epub.py b/fanficfare/writers/writer_epub.py
index 0bd8b155..8db5d83c 100644
--- a/fanficfare/writers/writer_epub.py
+++ b/fanficfare/writers/writer_epub.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2011 Fanficdownloader team, 2016 FanFicFare team
+# Copyright 2011 Fanficdownloader team, 2017 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -399,6 +399,28 @@ div { margin: 0pt; padding: 0pt; }
attrs={"name":"calibre:timestamp",
"content":self.story.getMetadataRaw('dateUpdated').strftime("%Y-%m-%dT%H:%M:%S")}))
+ series = self.story.getMetadataRaw('series')
+ if series and self.getConfig('calibre_series_meta'):
+ series_index = "0.0"
+ if '[' in series:
+ logger.debug(series)
+ ## assumed "series [series_index]"
+ series_index = series[series.index(' [')+2:-1]
+ series = series[:series.index(' [')]
+
+ ## calibre always outputs a series_index and it's
+ ## always a float with 1 or 2 decimals. FFF usually
+ ## has either an integer or no index. (injected
+ ## calibre series is the only float at this time)
+ series_index = "%.2f" % float(series_index)
+
+ metadata.appendChild(newTag(contentdom,"meta",
+ attrs={"name":"calibre:series",
+ "content":series}))
+ metadata.appendChild(newTag(contentdom,"meta",
+ attrs={"name":"calibre:series_index",
+ "content":series_index}))
+
if self.getMetadata('description'):
metadata.appendChild(newTag(contentdom,"dc:description",text=
self.getMetadata('description')))