mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Implemented basic html check and none check to avoid problems with html2text
This commit is contained in:
parent
dd522b051e
commit
9aefafc745
@ -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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user