extract pages from cbr/cbz

This commit is contained in:
j 2019-02-01 19:24:34 +05:30
parent 9ef5c01235
commit 148b41087f

View file

@ -66,10 +66,30 @@ def cover_cbz(path):
data = None data = None
return data return data
def get_pages(path):
files = []
format = detect_format(path)
if format == 'cbz':
try:
z = zipfile.ZipFile(path)
except zipfile.BadZipFile:
logger.debug('invalid cbz file %s', path)
return data
files = [f.filename for f in z.filelist]
elif format == 'cbr':
try:
from unrar import rarfile
rar = rarfile.RarFile(path)
files = rar.namelist()
except:
pass
files = filter_images(files)
return len(files)
def info(path): def info(path):
data = {} data = {}
data['title'] = os.path.splitext(os.path.basename(path))[0] data['title'] = os.path.splitext(os.path.basename(path))[0]
#data['pages'] = fixme read rar to count pages data['pages'] = get_pages(path)
return data return data