From 1ac83da4014b7b4c88e54b905aeddcac608e9a00 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 30 Oct 2010 11:48:34 -0600 Subject: [PATCH] Only add SONY periodical code to downloaded news if output profile is set to one of the SONY reader profiles. This is needed because the ever delightful Stanza crashes and burns when an EPUB has the periodical code --- src/calibre/customize/profiles.py | 8 ++++++++ src/calibre/ebooks/epub/output.py | 7 ++++--- src/calibre/manual/plugins.rst | 3 ++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/calibre/customize/profiles.py b/src/calibre/customize/profiles.py index f8fe2a59b4..38f6d401f6 100644 --- a/src/calibre/customize/profiles.py +++ b/src/calibre/customize/profiles.py @@ -259,6 +259,9 @@ class OutputProfile(Plugin): #: Number of ems that the left margin of a blockquote is rendered as mobi_ems_per_blockquote = 1.0 + #: Special periodical formatting needed in EPUB + epub_periodical_format = None + @classmethod def tags_to_string(cls, tags): return escape(', '.join(tags)) @@ -439,6 +442,9 @@ class SonyReaderOutput(OutputProfile): fsizes = [7.5, 9, 10, 12, 15.5, 20, 22, 24] unsupported_unicode_chars = [u'\u201f', u'\u201b'] + epub_periodical_format = 'sony' + #periodical_date_in_title = False + class KoboReaderOutput(OutputProfile): @@ -561,6 +567,8 @@ class CybookOpusOutput(SonyReaderOutput): fbase = 16 fsizes = [12, 12, 14, 16, 18, 20, 22, 24] + epub_periodical_format = None + class KindleOutput(OutputProfile): name = 'Kindle' diff --git a/src/calibre/ebooks/epub/output.py b/src/calibre/ebooks/epub/output.py index 38820010a8..952559a9e2 100644 --- a/src/calibre/ebooks/epub/output.py +++ b/src/calibre/ebooks/epub/output.py @@ -187,9 +187,10 @@ class EPUBOutput(OutputFormatPlugin): metadata_xml = None extra_entries = [] if self.is_periodical: - from calibre.ebooks.epub.periodical import sony_metadata - metadata_xml, atom_xml = sony_metadata(oeb) - extra_entries = [('atom.xml', 'application/atom+xml', atom_xml)] + if self.opts.output_profile.epub_periodical_format == 'sony': + from calibre.ebooks.epub.periodical import sony_metadata + metadata_xml, atom_xml = sony_metadata(oeb) + extra_entries = [('atom.xml', 'application/atom+xml', atom_xml)] oeb_output = plugin_for_output_format('oeb') oeb_output.convert(oeb, tdir, input_plugin, opts, log) opf = [x for x in os.listdir(tdir) if x.endswith('.opf')][0] diff --git a/src/calibre/manual/plugins.rst b/src/calibre/manual/plugins.rst index 1b9b47ed3d..eb955aebee 100644 --- a/src/calibre/manual/plugins.rst +++ b/src/calibre/manual/plugins.rst @@ -36,6 +36,7 @@ FileTypePlugin .. _pluginsMetadataPlugin: + Metadata plugins ------------------- @@ -50,7 +51,6 @@ Metadata plugins :members: :member-order: bysource -.. _pluginsMetadataSource: Catalog plugins ---------------- @@ -60,6 +60,7 @@ Catalog plugins :members: :member-order: bysource +.. _pluginsMetadataSource: Metadata download plugins --------------------------