When checking if a zip/rar file is a comic or contains a single ebook to be auto-extracted, ignore thumbs.db files inside the archive

This commit is contained in:
Kovid Goyal 2013-04-26 09:16:17 +05:30
parent 31fc648f78
commit 0cc0771147

View File

@ -13,7 +13,8 @@ from calibre.customize import FileTypePlugin
from calibre.utils.zipfile import ZipFile, stringFileHeader
def is_comic(list_of_names):
extensions = set([x.rpartition('.')[-1].lower() for x in list_of_names])
extensions = set([x.rpartition('.')[-1].lower() for x in list_of_names
if '.' in x and x.lower().rpartition('/')[-1] != 'thumbs.db'])
comic_extensions = set(['jpg', 'jpeg', 'png'])
return len(extensions - comic_extensions) == 0
@ -58,7 +59,7 @@ class ArchiveExtract(FileTypePlugin):
else:
fnames = zf.namelist()
fnames = [x for x in fnames if '.' in x]
fnames = [x for x in fnames if '.' in x and x.lower().rpartition('/')[-1] != 'thumbs.db']
if is_comic(fnames):
ext = '.cbr' if is_rar else '.cbz'
of = self.temporary_file('_archive_extract'+ext)