get size from zip

This commit is contained in:
j 2016-01-16 09:19:22 +05:30
parent b66e76c01a
commit 08e9472d2a

View file

@ -19,6 +19,7 @@ from utils import find_isbns, get_language, to_isbn13
import logging
logger = logging.getLogger(__name__)
def get_ratio(data):
try:
img = Image.open(BytesIO(data))
@ -42,7 +43,7 @@ def cover(path):
if r < 0.3 or r > 2:
return None
return data
files = []
for f in z.filelist:
if f.filename == 'calibre-logo.png':
@ -78,12 +79,10 @@ def cover(path):
filename = unquote(e.attrib['href'])
filename = os.path.normpath(os.path.join(os.path.dirname(opf[0]), filename))
if filename in files:
image_data.append((filename, z.read(filename)))
image_data.append(filename)
if image_data:
image_data.sort(key=lambda i: len(i[1]))
data = image_data[-1][1]
logger.debug('using %s', image_data[-1][0])
return data
image_data.sort(key=lambda name: z.getinfo(name).file_size)
return use(image_data[-1])
for e in manifest.getchildren():
if 'html' in e.attrib['media-type']:
filename = unquote(e.attrib['href'])