Implemented basic html check and none check to avoid problems with html2text

This commit is contained in:
Sengian 2010-11-01 01:22:47 +01:00
parent dd522b051e
commit 9aefafc745

View File

@ -16,6 +16,8 @@ from calibre.ebooks.metadata.covers import check_for_cover
metadata_config = None metadata_config = None
html_check = re.compile("([\<])([^\>]{1,})*([\>])", re.I)
class MetadataSource(Plugin): # {{{ class MetadataSource(Plugin): # {{{
''' '''
Represents a source to query for metadata. Subclasses must implement Represents a source to query for metadata. Subclasses must implement
@ -78,10 +80,11 @@ class MetadataSource(Plugin): # {{{
mi.rating = None mi.rating = None
if not c.get('comments', True): if not c.get('comments', True):
mi.comments = None mi.comments = None
if c.get('textconvert', True) and mi.comments is not None \
and html_check.search(mi.comments) is not None:
mi.comments = html2text(mi.comments)
if not c.get('tags', True): if not c.get('tags', True):
mi.tags = [] mi.tags = []
if c.get('textconvert', True) and mi.comments is not None:
mi.comments = html2text(mi.comments)
except Exception, e: except Exception, e:
self.exception = e self.exception = e