mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix adding books directly to device (broken by send to device template functionality). EPUB Output: Remove <img> tags without src attributes as older versions of ADE apparently choke on them. Remove video articles from Globe and Mail recipe.
This commit is contained in:
parent
5030402995
commit
c74de78b0d
@ -29,7 +29,8 @@ class GlobeAndMail(BasicNewsRecipe):
|
|||||||
remove_tags_before = dict(id="article-top")
|
remove_tags_before = dict(id="article-top")
|
||||||
remove_tags = [
|
remove_tags = [
|
||||||
{'id':['util', 'article-tabs', 'comments', 'article-relations',
|
{'id':['util', 'article-tabs', 'comments', 'article-relations',
|
||||||
'gallery-controls', 'video', 'galleryLoading','deck','header'] },
|
'gallery-controls', 'video', 'galleryLoading','deck','header',
|
||||||
|
'toolsBottom'] },
|
||||||
{'class':['credit','inline-img-caption','tab-pointer'] },
|
{'class':['credit','inline-img-caption','tab-pointer'] },
|
||||||
dict(name='div', attrs={'id':'lead-photo'}),
|
dict(name='div', attrs={'id':'lead-photo'}),
|
||||||
dict(name='div', attrs={'class':'right'}),
|
dict(name='div', attrs={'class':'right'}),
|
||||||
@ -68,3 +69,8 @@ class GlobeAndMail(BasicNewsRecipe):
|
|||||||
(u'Auto', u'http://www.theglobeandmail.com/auto/?service=rss')
|
(u'Auto', u'http://www.theglobeandmail.com/auto/?service=rss')
|
||||||
]
|
]
|
||||||
|
|
||||||
|
def get_article_url(self, article):
|
||||||
|
url = BasicNewsRecipe.get_article_url(self, article)
|
||||||
|
if '/video/' not in url:
|
||||||
|
return url
|
||||||
|
|
||||||
|
@ -264,13 +264,21 @@ class EPUBOutput(OutputFormatPlugin):
|
|||||||
if body:
|
if body:
|
||||||
body = body[0]
|
body = body[0]
|
||||||
|
|
||||||
# Add id attribute to <a> tags that have name
|
|
||||||
for x in XPath('//h:a[@name]')(body):
|
|
||||||
if not x.get('id', False):
|
|
||||||
x.set('id', x.get('name'))
|
|
||||||
|
|
||||||
# Replace <br> that are children of <body> as ADE doesn't handle them
|
|
||||||
if hasattr(body, 'xpath'):
|
if hasattr(body, 'xpath'):
|
||||||
|
# remove <img> tags with empty src elements
|
||||||
|
bad = []
|
||||||
|
for x in XPath('//h:img')(body):
|
||||||
|
if not x.get('src', '').strip():
|
||||||
|
bad.append(x)
|
||||||
|
for img in bad:
|
||||||
|
img.getparent().remove(img)
|
||||||
|
|
||||||
|
# Add id attribute to <a> tags that have name
|
||||||
|
for x in XPath('//h:a[@name]')(body):
|
||||||
|
if not x.get('id', False):
|
||||||
|
x.set('id', x.get('name'))
|
||||||
|
|
||||||
|
# Replace <br> that are children of <body> as ADE doesn't handle them
|
||||||
for br in XPath('./h:br')(body):
|
for br in XPath('./h:br')(body):
|
||||||
if br.getparent() is None:
|
if br.getparent() is None:
|
||||||
continue
|
continue
|
||||||
|
@ -145,10 +145,7 @@ class DBAdder(Thread):
|
|||||||
else:
|
else:
|
||||||
self.names.append(name)
|
self.names.append(name)
|
||||||
self.paths.append(formats[0])
|
self.paths.append(formats[0])
|
||||||
self.infos.append({'title':mi.title,
|
self.infos.append(mi)
|
||||||
'authors':', '.join(mi.authors),
|
|
||||||
'cover':None,
|
|
||||||
'tags':mi.tags if mi.tags else []})
|
|
||||||
return mi.title
|
return mi.title
|
||||||
|
|
||||||
def add_formats(self, id, formats):
|
def add_formats(self, id, formats):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user