From 3b145786c9356e7bb5b9e65f36605e7805179030 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 30 Mar 2022 15:27:00 +0530 Subject: [PATCH] Read covers from CBC comic files. Fixes #1967028 [Calibre doesn't load first page of CBC file as cover](https://bugs.launchpad.net/calibre/+bug/1967028) --- src/calibre/customize/builtins.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/calibre/customize/builtins.py b/src/calibre/customize/builtins.py index 349c187bda..dbba022538 100644 --- a/src/calibre/customize/builtins.py +++ b/src/calibre/customize/builtins.py @@ -101,13 +101,21 @@ plugins += [HTML2ZIP, PML2PMLZ, TXT2TXTZ, ArchiveExtract, KPFExtract] class ComicMetadataReader(MetadataReaderPlugin): name = 'Read comic metadata' - file_types = {'cbr', 'cbz', 'cb7'} + file_types = {'cbr', 'cbz', 'cb7', 'cbc'} description = _('Extract cover from comic files') def customization_help(self, gui=False): return 'Read series number from volume or issue number. Default is volume, set this to issue to use issue number instead.' def get_metadata(self, stream, ftype): + if ftype == 'cbc': + from zipfile import ZipFile + zf = ZipFile(stream) + fcn = zf.open('comics.txt').read().decode('utf-8').splitlines()[0] + oname = getattr(stream, 'name', None) + stream = zf.open(fcn) + if oname: + stream.name = oname if hasattr(stream, 'seek') and hasattr(stream, 'tell'): pos = stream.tell() id_ = stream.read(3)