mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Catalog generation: Handle invalid covers gracefully
This commit is contained in:
commit
5483bb6f94
@ -2861,25 +2861,17 @@ class EPUB_MOBI(CatalogPlugin):
|
|||||||
self.updateProgressMicroStep("Thumbnail %d of %d" % \
|
self.updateProgressMicroStep("Thumbnail %d of %d" % \
|
||||||
(i,len(self.booksByTitle)),
|
(i,len(self.booksByTitle)),
|
||||||
i/float(len(self.booksByTitle)))
|
i/float(len(self.booksByTitle)))
|
||||||
# Check to see if source file exists
|
|
||||||
if 'cover' in title and os.path.isfile(title['cover']):
|
|
||||||
# Add the thumb spec to thumbs[]
|
|
||||||
thumbs.append("thumbnail_%d.jpg" % int(title['id']))
|
|
||||||
|
|
||||||
# Check to see if thumbnail exists
|
|
||||||
thumb_fp = "%s/thumbnail_%d.jpg" % (image_dir,int(title['id']))
|
|
||||||
thumb_file = 'thumbnail_%d.jpg' % int(title['id'])
|
thumb_file = 'thumbnail_%d.jpg' % int(title['id'])
|
||||||
if os.path.isfile(thumb_fp):
|
thumb_generated = True
|
||||||
# Check to see if cover is newer than thumbnail
|
try:
|
||||||
# os.path.getmtime() = modified time
|
|
||||||
# os.path.ctime() = creation time
|
|
||||||
cover_timestamp = os.path.getmtime(title['cover'])
|
|
||||||
thumb_timestamp = os.path.getmtime(thumb_fp)
|
|
||||||
if thumb_timestamp < cover_timestamp:
|
|
||||||
self.generateThumbnail(title, image_dir, thumb_file)
|
self.generateThumbnail(title, image_dir, thumb_file)
|
||||||
else:
|
thumbs.append("thumbnail_%d.jpg" % int(title['id']))
|
||||||
self.generateThumbnail(title, image_dir, thumb_file)
|
except:
|
||||||
else:
|
thumb_generated = False
|
||||||
|
|
||||||
|
|
||||||
|
if not thumb_generated:
|
||||||
# Use default cover
|
# Use default cover
|
||||||
if False and self.verbose:
|
if False and self.verbose:
|
||||||
self.opts.log.warn(" using default cover for '%s'" % \
|
self.opts.log.warn(" using default cover for '%s'" % \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user