extract pages from cbr/cbz
This commit is contained in:
parent
9ef5c01235
commit
148b41087f
1 changed files with 21 additions and 1 deletions
|
@ -66,10 +66,30 @@ def cover_cbz(path):
|
|||
data = None
|
||||
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):
|
||||
data = {}
|
||||
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
|
||||
|
||||
|
|
Loading…
Reference in a new issue