Check for masthead image when generating MOBI periodicals

This commit is contained in:
Kovid Goyal 2009-07-06 08:56:34 -06:00
parent 6ac637a9de
commit 45366b0df5

View File

@ -386,8 +386,16 @@ class MobiWriter(object):
def _map_image_names(self): def _map_image_names(self):
index = 1 index = 1
self._images = images = {} self._images = images = {}
mh_href = None
if 'masthead' in self._oeb.guide:
mh_href = self._oeb.guide['masthead'].href
images[mh_href] = 1
index += 1
for item in self._oeb.manifest.values(): for item in self._oeb.manifest.values():
if item.media_type in OEB_RASTER_IMAGES: if item.media_type in OEB_RASTER_IMAGES:
if item.href == mh_href: continue
images[item.href] = index images[item.href] = index
index += 1 index += 1
@ -1195,6 +1203,13 @@ class MobiWriter(object):
self._oeb.logger.info('metadata missing timestamp needed for periodical') self._oeb.logger.info('metadata missing timestamp needed for periodical')
return False return False
# Periodicals also need a mastheadImage in the manifest
has_mastheadImage = 'masthead' in self._oeb.guide
if not has_mastheadImage :
self._oeb.logger.info('mastheadImage missing from manifest, aborting periodical indexing')
return False
self._oeb.logger.info('TOC structure and pubdate verified') self._oeb.logger.info('TOC structure and pubdate verified')
return True return True