mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Merge from trunk
This commit is contained in:
commit
6259647329
@ -13,6 +13,7 @@ from calibre.utils.titlecase import titlecase
|
||||
from calibre.utils.html2text import html2text
|
||||
from calibre.customize import Plugin
|
||||
from calibre.ebooks.metadata.covers import check_for_cover
|
||||
from calibre.utils.html2text import html2text
|
||||
|
||||
metadata_config = None
|
||||
|
||||
@ -51,6 +52,11 @@ class MetadataSource(Plugin): # {{{
|
||||
#: member.
|
||||
string_customization_help = None
|
||||
|
||||
#: Set this to true if your plugin returns HTML markup in comments.
|
||||
#: Then if the user disables HTML, calibre will automagically convert
|
||||
#: the HTML to Markdown.
|
||||
has_html_comments = False
|
||||
|
||||
type = _('Metadata download')
|
||||
|
||||
def __call__(self, title, author, publisher, isbn, verbose, log=None,
|
||||
@ -85,6 +91,13 @@ class MetadataSource(Plugin): # {{{
|
||||
mi.comments = html2text(mi.comments)
|
||||
if not c.get('tags', True):
|
||||
mi.tags = []
|
||||
if self.has_html_comments and mi.comments and \
|
||||
c.get('textcomments', False):
|
||||
try:
|
||||
mi.comments = html2text(mi.comments)
|
||||
except:
|
||||
traceback.print_exc()
|
||||
mi.comments = None
|
||||
|
||||
except Exception, e:
|
||||
self.exception = e
|
||||
@ -138,17 +151,17 @@ class MetadataSource(Plugin): # {{{
|
||||
setattr(w, '_'+x, cb)
|
||||
cb.setChecked(c.get(x, True))
|
||||
w._layout.addWidget(cb)
|
||||
#textconvert for comments
|
||||
cb = QCheckBox(_('Convert comments from %s to text')%(self.name))
|
||||
setattr(w, '_textconvert', cb)
|
||||
cb.setChecked(c.get('textconvert', False))
|
||||
|
||||
cb = QCheckBox(_('Convert comments downloaded from %s to plain text')%(self.name))
|
||||
setattr(w, '_textcomments', cb)
|
||||
cb.setChecked(c.get('textcomments', False))
|
||||
w._layout.addWidget(cb)
|
||||
|
||||
return w
|
||||
|
||||
def save_settings(self, w):
|
||||
dl_settings = {}
|
||||
for x in ('rating', 'tags', 'comments', 'textconvert'):
|
||||
for x in ('rating', 'tags', 'comments', 'textcomments'):
|
||||
dl_settings[x] = getattr(w, '_'+x).isChecked()
|
||||
c = self.config_store()
|
||||
c.set(self.name, dl_settings)
|
||||
@ -222,6 +235,8 @@ class Amazon(MetadataSource): # {{{
|
||||
metadata_type = 'social'
|
||||
description = _('Downloads social metadata from amazon.com')
|
||||
|
||||
has_html_comments = True
|
||||
|
||||
def fetch(self):
|
||||
if not self.isbn:
|
||||
return
|
||||
|
Loading…
x
Reference in New Issue
Block a user