mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
...
This commit is contained in:
parent
f6185b2e55
commit
aae88fa07e
@ -34,6 +34,7 @@ class NewYorker(BasicNewsRecipe):
|
||||
timefmt = ' [%b %d]'
|
||||
encoding = 'utf-8'
|
||||
extra_css = '''
|
||||
img { display:block; margin:0 auto; }
|
||||
.byline { font-size:smaller; font-weight: bold;}
|
||||
h3 { margin-bottom: 6px; }
|
||||
.caption { font-size: smaller; font-style: italic; font-weight: normal; }
|
||||
@ -72,6 +73,21 @@ class NewYorker(BasicNewsRecipe):
|
||||
self.log.warn('Kindle Output profile being used, reducing image quality to keep file size below amazon email threshold')
|
||||
|
||||
def preprocess_html(self, soup):
|
||||
w = '/w_320' # use '/w_640' for highres
|
||||
for img in soup.findAll('img'):
|
||||
if img.has_attr('srcset'):
|
||||
for x in img['srcset'].split():
|
||||
if w in x:
|
||||
img['src'] = x
|
||||
elif img.find_previous_sibling('source', attrs={'srcset':True}):
|
||||
srcset = img.find_previous_sibling('source', attrs={'srcset':True})
|
||||
for x in srcset['srcset'].split():
|
||||
if w in x:
|
||||
img['src'] = x
|
||||
elif '/w_560' in x:
|
||||
img['src'] = x
|
||||
for src in soup.findAll('source'):
|
||||
src.decompose()
|
||||
for noscript in soup.findAll('noscript'):
|
||||
noscript.name = 'div'
|
||||
return soup
|
||||
|
Loading…
x
Reference in New Issue
Block a user