Fix #7851 (some meta tags failed since V0.7.25)

This commit is contained in:
Kovid Goyal 2010-12-12 12:55:53 -07:00
parent e56e2c7f45
commit 86ee4489d4
2 changed files with 23 additions and 9 deletions

View File

@ -314,6 +314,8 @@ class HTMLInput(InputFormatPlugin):
rewrite_links, urlnormalize, urldefrag, BINARY_MIME, OEB_STYLES, \ rewrite_links, urlnormalize, urldefrag, BINARY_MIME, OEB_STYLES, \
xpath xpath
from calibre import guess_type from calibre import guess_type
from calibre.ebooks.oeb.transforms.metadata import \
meta_info_to_oeb_metadata
import cssutils import cssutils
self.OEB_STYLES = OEB_STYLES self.OEB_STYLES = OEB_STYLES
oeb = create_oebbook(log, None, opts, self, oeb = create_oebbook(log, None, opts, self,
@ -321,15 +323,7 @@ class HTMLInput(InputFormatPlugin):
self.oeb = oeb self.oeb = oeb
metadata = oeb.metadata metadata = oeb.metadata
if mi.title: meta_info_to_oeb_metadata(mi, metadata, log)
metadata.add('title', mi.title)
if mi.authors:
for a in mi.authors:
metadata.add('creator', a, attrib={'role':'aut'})
if mi.publisher:
metadata.add('publisher', mi.publisher)
if mi.isbn:
metadata.add('identifier', mi.isbn, attrib={'scheme':'ISBN'})
if not metadata.language: if not metadata.language:
oeb.logger.warn(u'Language not specified') oeb.logger.warn(u'Language not specified')
metadata.add('language', get_lang().replace('_', '-')) metadata.add('language', get_lang().replace('_', '-'))

View File

@ -170,7 +170,27 @@ def get_metadata_(src, encoding=None):
if match: if match:
series = match.group(1) series = match.group(1)
if series: if series:
pat = re.compile(r'\[([.0-9]+)\]')
match = pat.search(series)
series_index = None
if match is not None:
try:
series_index = float(match.group(1))
except:
pass
series = series.replace(match.group(), '').strip()
mi.series = ent_pat.sub(entity_to_unicode, series) mi.series = ent_pat.sub(entity_to_unicode, series)
if series_index is None:
pat = get_meta_regexp_("Seriesnumber")
match = pat.search(src)
if match:
try:
series_index = float(match.group(1))
except:
pass
if series_index is not None:
mi.series_index = series_index
# RATING # RATING
rating = None rating = None