Work with cbz files with subdirectories
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Simon Bruder 2020-02-10 12:19:45 +00:00
parent 202a6f8bdf
commit 2dbe0416de
No known key found for this signature in database
GPG key ID: 6F03E0000CC5B62F

View file

@ -29,6 +29,10 @@ def dict_factory(cursor, row):
return d
def filter_zip_filelist(filelist):
return [file for file in filelist if not file.is_dir()]
class BaseDB:
def __init__(self, webp_quality, webp_method, webp_size):
# lossy: 0-100 (used as quality)
@ -251,7 +255,8 @@ class CalibreDB(BaseDB):
def get_volume_page_number(self, volume_id):
path = self.get_volume_filepath(volume_id)
with ZipFile(path, 'r') as volume:
return len(volume.filelist)
filelist = filter_zip_filelist(volume.filelist)
return len(filelist)
def get_volume_page(self, volume_id, page_number, original=False):
if page_number < 1:
@ -259,7 +264,8 @@ class CalibreDB(BaseDB):
path = self.get_volume_filepath(volume_id)
with ZipFile(path, 'r') as volume:
try:
zip_info = volume.filelist[page_number - 1]
filelist = filter_zip_filelist(volume.filelist)
zip_info = filelist[page_number - 1]
except IndexError:
raise exceptions.NotFound()
return None