Skip to content

Commit

Permalink
Update optional requirements
Browse files Browse the repository at this point in the history
Update to be compatible with comicapi 3.2
  • Loading branch information
Ozzie Isaacs committed Jun 25, 2023
1 parent 709a4e5 commit 63b7d70
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
17 changes: 15 additions & 2 deletions cps/comic.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@
from comicapi import __version__ as comic_version
except ImportError:
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:
log.debug('Cannot import comicapi, extracting comic metadata will not work: %s', e)
import zipfile
Expand Down Expand Up @@ -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):
cover_data = extension = None
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
for index, name in enumerate(name_list()):
ext = os.path.splitext(name)
Expand All @@ -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):
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"):
seems_archive = archive.seemsToBeAComicArchive
else:
Expand Down
8 changes: 4 additions & 4 deletions cps/uploader.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
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)
extension_upper = original_file_extension.upper()
try:
Expand All @@ -83,7 +83,7 @@ def process(tmp_file_path, original_file_name, original_file_extension, rarExecu
meta = comic.get_comic_info(tmp_file_path,
original_file_name,
original_file_extension,
rarExecutable)
rar_executable)
except Exception as ex:
log.warning('cannot parse metadata, using default: %s', ex)

Expand Down Expand Up @@ -248,7 +248,7 @@ def get_magick_version():
return ret


def upload(uploadfile, rarExcecutable):
def upload(uploadfile, rar_excecutable):
tmp_dir = os.path.join(gettempdir(), 'calibre_web')

if not os.path.isdir(tmp_dir):
Expand All @@ -260,4 +260,4 @@ def upload(uploadfile, rarExcecutable):
tmp_file_path = os.path.join(tmp_dir, md5)
log.debug("Temporary file: %s", 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)
2 changes: 1 addition & 1 deletion optional-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ faust-cchardet>=2.1.18

# Comics
natsort>=2.2.0,<8.4.0
comicapi>=2.2.0,<2.3.0
comicapi>=2.2.0,<3.3.0

# Kobo integration
jsonschema>=3.2.0,<4.18.0

0 comments on commit 63b7d70

Please sign in to comment.