from calibre.customize.conversion import OutputFormatPlugin
from calibre.customize.conversion import OptionRecommendation
class MOBIOutput(OutputFormatPlugin):
name = 'MOBI Output'
author = 'Marshall T. Vandegrift'
file_type = 'mobi'
options = set([
OptionRecommendation(name = 'rescale_images', recommended_value = False, help = _('Modify images to meet Palm device size limitations.')),
OptionRecommendation(name = 'prefer_author_sort', recommended_value = False, level = OptionRecommendation.LOW, help = _('When present, use author sort field as author.')),
OptionRecommendation(name = 'no_inline_toc', recommended_value = False, level = OptionRecommendation.LOW, help = _("Don't add Table of Contents to end of book. Useful if the book has its own table of contents.")),
OptionRecommendation(name = 'toc_title', recommended_value = None, help = _('Title for any generated in-line table of contents.')),
OptionRecommendation(name = 'dont_compress', recommended_value = False, level = OptionRecommendation.LOW, help = _('Disable compression of the file contents.')),
OptionRecommendation(name = 'personal_doc', recommended_value = '[PDOC]', help = _('Tag marking book to be filed with Personal Docs'))])
def check_for_periodical(self):
if self.oeb.metadata.publication_type and unicode(self.oeb.metadata.publication_type[0]).startswith('periodical:'):
self.periodicalize_toc()
self.check_for_masthead()
self.opts.mobi_periodical = True
else:
self.opts.mobi_periodical = False
def check_for_masthead(self):
found = 'masthead' in self.oeb.guide
if not found:
self.oeb.log.debug('No masthead found in manifest, generating default mastheadImage...')
try:
PILImage = Image
import PIL
PILImage
except ImportError:
import Image as PILImage
raw = open(P('content_server/calibre_banner.png'), 'rb')