From cb7356a04df08ad65fea9d15e5eeef3f20f0f195 Mon Sep 17 00:00:00 2001 From: Ozzie Isaacs Date: Thu, 4 May 2023 20:23:02 +0300 Subject: [PATCH] Fixes to word with new version of comicapi --- cps/comic.py | 21 ++++++++++++++------- requirements.txt | 3 +-- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/cps/comic.py b/cps/comic.py index 766b4584..907614c9 100644 --- a/cps/comic.py +++ b/cps/comic.py @@ -89,12 +89,14 @@ def _extract_cover(tmp_file_name, original_file_extension, rar_executable): cover_data = extension = None if use_comic_meta: archive = ComicArchive(tmp_file_name, rar_exe_path=rar_executable) - for index, name in enumerate(archive.getPageNameList()): + name_list = archive.getPageNameList if hasattr(archive, "getPageNameList") else archive.get_page_name_list + for index, name in enumerate(name_list()): ext = os.path.splitext(name) if len(ext) > 1: extension = ext[1].lower() if extension in cover.COVER_EXTENSIONS: - cover_data = archive.getPage(index) + get_page = archive.getPage if hasattr(archive, "getPageNameList") else archive.get_page + cover_data = get_page(index) break else: cover_data, extension = _extract_cover_from_archive(original_file_extension, tmp_file_name, rar_executable) @@ -104,16 +106,21 @@ def _extract_cover(tmp_file_name, original_file_extension, rar_executable): def get_comic_info(tmp_file_path, original_file_name, original_file_extension, rar_executable): if use_comic_meta: archive = ComicArchive(tmp_file_path, rar_exe_path=rar_executable) - if archive.seemsToBeAComicArchive(): - if archive.hasMetadata(MetaDataStyle.CIX): + if hasattr(archive, "seemsToBeAComicArchive"): + seems_archive = archive.seemsToBeAComicArchive + else: + seems_archive = archive.seems_to_be_a_comic_archive + if seems_archive(): + has_metadata = archive.hasMetadata if hasattr(archive, "hasMetadata") else archive.has_metadata + if has_metadata(MetaDataStyle.CIX): style = MetaDataStyle.CIX - elif archive.hasMetadata(MetaDataStyle.CBI): + elif has_metadata(MetaDataStyle.CBI): style = MetaDataStyle.CBI else: style = None - # if style is not None: - loaded_metadata = archive.readMetadata(style) + read_metadata = archive.readMetadata if hasattr(archive, "readMetadata") else archive.read_metadata + loaded_metadata = read_metadata(style) lang = loaded_metadata.language or "" loaded_metadata.language = isoLanguages.get_lang3(lang) diff --git a/requirements.txt b/requirements.txt index f0cd81c0..fef4bbf2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,10 +1,9 @@ APScheduler>=3.6.3,<3.11.0 -werkzeug<2.1.0 Babel>=1.3,<3.0 Flask-Babel>=0.11.1,<3.1.0 Flask-Login>=0.3.2,<0.6.3 Flask-Principal>=0.3.2,<0.5.1 -Flask>=1.0.2,<2.3.0 +Flask>=1.0.2,<2.4.0 iso-639>=0.4.5,<0.5.0 PyPDF>=3.0.0,<3.8.0 pytz>=2016.10