mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
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)
This commit is contained in:
parent
d9c61d48b9
commit
3b145786c9
@ -101,13 +101,21 @@ plugins += [HTML2ZIP, PML2PMLZ, TXT2TXTZ, ArchiveExtract, KPFExtract]
|
|||||||
class ComicMetadataReader(MetadataReaderPlugin):
|
class ComicMetadataReader(MetadataReaderPlugin):
|
||||||
|
|
||||||
name = 'Read comic metadata'
|
name = 'Read comic metadata'
|
||||||
file_types = {'cbr', 'cbz', 'cb7'}
|
file_types = {'cbr', 'cbz', 'cb7', 'cbc'}
|
||||||
description = _('Extract cover from comic files')
|
description = _('Extract cover from comic files')
|
||||||
|
|
||||||
def customization_help(self, gui=False):
|
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.'
|
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):
|
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'):
|
if hasattr(stream, 'seek') and hasattr(stream, 'tell'):
|
||||||
pos = stream.tell()
|
pos = stream.tell()
|
||||||
id_ = stream.read(3)
|
id_ = stream.read(3)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user