Update optional requirements

Update to be compatible with comicapi 3.2
This commit is contained in:
Ozzie Isaacs 2023-06-25 14:39:45 +02:00
parent 709a4e51ba
commit 63b7d70f33
3 changed files with 20 additions and 7 deletions

View File

@ -36,6 +36,12 @@ try:
from comicapi import __version__ as comic_version from comicapi import __version__ as comic_version
except ImportError: except ImportError:
comic_version = '' comic_version = ''
try:
from comicapi.comicarchive import load_archive_plugins
import comicapi.utils
comicapi.utils.add_rar_paths()
except ImportError:
load_archive_plugins = None
except (ImportError, LookupError) as e: except (ImportError, LookupError) as e:
log.debug('Cannot import comicapi, extracting comic metadata will not work: %s', e) log.debug('Cannot import comicapi, extracting comic metadata will not work: %s', e)
import zipfile import zipfile
@ -88,7 +94,10 @@ def _extract_cover_from_archive(original_file_extension, tmp_file_name, rar_exec
def _extract_cover(tmp_file_name, original_file_extension, rar_executable): def _extract_cover(tmp_file_name, original_file_extension, rar_executable):
cover_data = extension = None cover_data = extension = None
if use_comic_meta: if use_comic_meta:
archive = ComicArchive(tmp_file_name, rar_exe_path=rar_executable) try:
archive = ComicArchive(tmp_file_name, rar_exe_path=rar_executable)
except TypeError:
archive = ComicArchive(tmp_file_name)
name_list = archive.getPageNameList if hasattr(archive, "getPageNameList") else archive.get_page_name_list name_list = archive.getPageNameList if hasattr(archive, "getPageNameList") else archive.get_page_name_list
for index, name in enumerate(name_list()): for index, name in enumerate(name_list()):
ext = os.path.splitext(name) ext = os.path.splitext(name)
@ -105,7 +114,11 @@ 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): def get_comic_info(tmp_file_path, original_file_name, original_file_extension, rar_executable):
if use_comic_meta: if use_comic_meta:
archive = ComicArchive(tmp_file_path, rar_exe_path=rar_executable) try:
archive = ComicArchive(tmp_file_path, rar_exe_path=rar_executable)
except TypeError:
load_archive_plugins(force=True, rar=rar_executable)
archive = ComicArchive(tmp_file_path)
if hasattr(archive, "seemsToBeAComicArchive"): if hasattr(archive, "seemsToBeAComicArchive"):
seems_archive = archive.seemsToBeAComicArchive seems_archive = archive.seemsToBeAComicArchive
else: else:

View File

@ -69,7 +69,7 @@ except ImportError as e:
use_fb2_meta = False use_fb2_meta = False
def process(tmp_file_path, original_file_name, original_file_extension, rarExecutable): def process(tmp_file_path, original_file_name, original_file_extension, rar_executable):
meta = default_meta(tmp_file_path, original_file_name, original_file_extension) meta = default_meta(tmp_file_path, original_file_name, original_file_extension)
extension_upper = original_file_extension.upper() extension_upper = original_file_extension.upper()
try: try:
@ -83,7 +83,7 @@ def process(tmp_file_path, original_file_name, original_file_extension, rarExecu
meta = comic.get_comic_info(tmp_file_path, meta = comic.get_comic_info(tmp_file_path,
original_file_name, original_file_name,
original_file_extension, original_file_extension,
rarExecutable) rar_executable)
except Exception as ex: except Exception as ex:
log.warning('cannot parse metadata, using default: %s', ex) log.warning('cannot parse metadata, using default: %s', ex)
@ -248,7 +248,7 @@ def get_magick_version():
return ret return ret
def upload(uploadfile, rarExcecutable): def upload(uploadfile, rar_excecutable):
tmp_dir = os.path.join(gettempdir(), 'calibre_web') tmp_dir = os.path.join(gettempdir(), 'calibre_web')
if not os.path.isdir(tmp_dir): if not os.path.isdir(tmp_dir):
@ -260,4 +260,4 @@ def upload(uploadfile, rarExcecutable):
tmp_file_path = os.path.join(tmp_dir, md5) tmp_file_path = os.path.join(tmp_dir, md5)
log.debug("Temporary file: %s", tmp_file_path) log.debug("Temporary file: %s", tmp_file_path)
uploadfile.save(tmp_file_path) uploadfile.save(tmp_file_path)
return process(tmp_file_path, filename_root, file_extension, rarExcecutable) return process(tmp_file_path, filename_root, file_extension, rar_excecutable)

View File

@ -38,7 +38,7 @@ faust-cchardet>=2.1.18
# Comics # Comics
natsort>=2.2.0,<8.4.0 natsort>=2.2.0,<8.4.0
comicapi>=2.2.0,<2.3.0 comicapi>=2.2.0,<3.3.0
# Kobo integration # Kobo integration
jsonschema>=3.2.0,<4.18.0 jsonschema>=3.2.0,<4.18.0