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:
Kovid Goyal 2010-01-14 21:32:12 -07:00
parent 5030402995
commit c74de78b0d
3 changed files with 22 additions and 11 deletions

View File

@ -29,7 +29,8 @@ class GlobeAndMail(BasicNewsRecipe):
remove_tags_before = dict(id="article-top")
remove_tags = [
{'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'] },
dict(name='div', attrs={'id':'lead-photo'}),
dict(name='div', attrs={'class':'right'}),
@ -68,3 +69,8 @@ class GlobeAndMail(BasicNewsRecipe):
(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

View File

@ -264,13 +264,21 @@ class EPUBOutput(OutputFormatPlugin):
if body:
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'):
# 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):
if br.getparent() is None:
continue

View File

@ -145,10 +145,7 @@ class DBAdder(Thread):
else:
self.names.append(name)
self.paths.append(formats[0])
self.infos.append({'title':mi.title,
'authors':', '.join(mi.authors),
'cover':None,
'tags':mi.tags if mi.tags else []})
self.infos.append(mi)
return mi.title
def add_formats(self, id, formats):