mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 10:14:46 -04:00
Allow customization of comic metadata reader plugin
Allow customizing the comic metadata reader plugin via Preferences->Plugins to read the series index from either the volume or the issue number of the comic. Fixes #1211433 [comicinfo metada uses volume instead of issue](https://bugs.launchpad.net/calibre/+bug/1211433)
This commit is contained in:
parent
c8083b0995
commit
767bee56a2
@ -130,6 +130,9 @@ class ComicMetadataReader(MetadataReaderPlugin):
|
||||
file_types = set(['cbr', 'cbz'])
|
||||
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 hasattr(stream, 'seek') and hasattr(stream, 'tell'):
|
||||
pos = stream.tell()
|
||||
@ -151,8 +154,11 @@ class ComicMetadataReader(MetadataReaderPlugin):
|
||||
mi = MetaInformation(None, None)
|
||||
stream.seek(0)
|
||||
if ftype in {'cbr', 'cbz'}:
|
||||
series_index = self.site_customization
|
||||
if series_index not in {'volume', 'issue'}:
|
||||
series_index = 'volume'
|
||||
try:
|
||||
mi.smart_update(get_comic_metadata(stream, ftype))
|
||||
mi.smart_update(get_comic_metadata(stream, ftype, series_index=series_index))
|
||||
except:
|
||||
pass
|
||||
if ret is not None:
|
||||
|
@ -86,13 +86,16 @@ class ArchiveExtract(FileTypePlugin):
|
||||
of.write(zf.read(fname))
|
||||
return of.name
|
||||
|
||||
def get_comic_book_info(d, mi):
|
||||
def get_comic_book_info(d, mi, series_index='volume'):
|
||||
# See http://code.google.com/p/comicbookinfo/wiki/Example
|
||||
series = d.get('series', '')
|
||||
if series.strip():
|
||||
mi.series = series
|
||||
if d.get('volume', -1) > -1:
|
||||
mi.series_index = float(d['volume'])
|
||||
si = d.get(series_index, None)
|
||||
if si is None:
|
||||
si = d.get('issue' if series_index == 'volume' else 'volume', None)
|
||||
if si is not None:
|
||||
mi.series_index = float(si)
|
||||
if d.get('rating', -1) > -1:
|
||||
mi.rating = d['rating']
|
||||
for x in ('title', 'publisher'):
|
||||
@ -126,7 +129,7 @@ def get_comic_book_info(d, mi):
|
||||
except:
|
||||
pass
|
||||
|
||||
def get_comic_metadata(stream, stream_type):
|
||||
def get_comic_metadata(stream, stream_type, series_index='volume'):
|
||||
# See http://code.google.com/p/comicbookinfo/wiki/Example
|
||||
from calibre.ebooks.metadata import MetaInformation
|
||||
|
||||
@ -149,7 +152,7 @@ def get_comic_metadata(stream, stream_type):
|
||||
if hasattr(m, 'iterkeys'):
|
||||
for cat in m.iterkeys():
|
||||
if cat.startswith('ComicBookInfo'):
|
||||
get_comic_book_info(m[cat], mi)
|
||||
get_comic_book_info(m[cat], mi, series_index=series_index)
|
||||
break
|
||||
return mi
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user