Work with cbz files with subdirectories
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
202a6f8bdf
commit
2dbe0416de
10
backend.py
10
backend.py
|
@ -29,6 +29,10 @@ def dict_factory(cursor, row):
|
||||||
return d
|
return d
|
||||||
|
|
||||||
|
|
||||||
|
def filter_zip_filelist(filelist):
|
||||||
|
return [file for file in filelist if not file.is_dir()]
|
||||||
|
|
||||||
|
|
||||||
class BaseDB:
|
class BaseDB:
|
||||||
def __init__(self, webp_quality, webp_method, webp_size):
|
def __init__(self, webp_quality, webp_method, webp_size):
|
||||||
# lossy: 0-100 (used as quality)
|
# lossy: 0-100 (used as quality)
|
||||||
|
@ -251,7 +255,8 @@ class CalibreDB(BaseDB):
|
||||||
def get_volume_page_number(self, volume_id):
|
def get_volume_page_number(self, volume_id):
|
||||||
path = self.get_volume_filepath(volume_id)
|
path = self.get_volume_filepath(volume_id)
|
||||||
with ZipFile(path, 'r') as volume:
|
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):
|
def get_volume_page(self, volume_id, page_number, original=False):
|
||||||
if page_number < 1:
|
if page_number < 1:
|
||||||
|
@ -259,7 +264,8 @@ class CalibreDB(BaseDB):
|
||||||
path = self.get_volume_filepath(volume_id)
|
path = self.get_volume_filepath(volume_id)
|
||||||
with ZipFile(path, 'r') as volume:
|
with ZipFile(path, 'r') as volume:
|
||||||
try:
|
try:
|
||||||
zip_info = volume.filelist[page_number - 1]
|
filelist = filter_zip_filelist(volume.filelist)
|
||||||
|
zip_info = filelist[page_number - 1]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
raise exceptions.NotFound()
|
raise exceptions.NotFound()
|
||||||
return None
|
return None
|
||||||
|
|
Reference in a new issue