mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 18:24:30 -04:00
Update espresso
images too large.
This commit is contained in:
parent
d5d0a97d37
commit
d6d5f356fd
@ -1,3 +1,4 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
'''
|
'''
|
||||||
https://www.economist.com/the-world-in-brief
|
https://www.economist.com/the-world-in-brief
|
||||||
'''
|
'''
|
||||||
@ -196,6 +197,12 @@ class Espresso(BasicNewsRecipe):
|
|||||||
ans.append({"title": title, "url": url})
|
ans.append({"title": title, "url": url})
|
||||||
return [('Espresso', ans)]
|
return [('Espresso', ans)]
|
||||||
|
|
||||||
|
def preprocess_html(self, soup):
|
||||||
|
for img in soup.findAll('img', src=True):
|
||||||
|
img['src'] = img['src'].replace('economist.com/',
|
||||||
|
'economist.com/cdn-cgi/image/width=600,quality=80,format=auto/')
|
||||||
|
return soup
|
||||||
|
|
||||||
def populate_article_metadata(self, article, soup, first):
|
def populate_article_metadata(self, article, soup, first):
|
||||||
article.url = soup.find('h1')['title']
|
article.url = soup.find('h1')['title']
|
||||||
|
|
||||||
|
@ -197,6 +197,14 @@ class Economist(BasicNewsRecipe):
|
|||||||
# downloaded with connection reset by peer (104) errors.
|
# downloaded with connection reset by peer (104) errors.
|
||||||
delay = 2
|
delay = 2
|
||||||
|
|
||||||
|
recipe_specific_options = {
|
||||||
|
'res': {
|
||||||
|
'short': 'For hi-res images, select a resolution from the\nfollowing options: 834, 960, 1096, 1280, 1424',
|
||||||
|
'long': 'This is useful for non e-ink devices, and for a lower file size\nthan the default, use from 480, 384, 360, 256.',
|
||||||
|
'default': '600'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
needs_subscription = False
|
needs_subscription = False
|
||||||
|
|
||||||
def get_browser(self, *args, **kwargs):
|
def get_browser(self, *args, **kwargs):
|
||||||
@ -269,9 +277,13 @@ class Economist(BasicNewsRecipe):
|
|||||||
article.url = soup.find('h1')['title']
|
article.url = soup.find('h1')['title']
|
||||||
|
|
||||||
def preprocess_html(self, soup):
|
def preprocess_html(self, soup):
|
||||||
|
width = '600'
|
||||||
|
w = self.recipe_specific_options.get('res')
|
||||||
|
if w and isinstance(w, str):
|
||||||
|
width = w
|
||||||
for img in soup.findAll('img', src=True):
|
for img in soup.findAll('img', src=True):
|
||||||
img['src'] = img['src'].replace('economist.com/',
|
qua = 'economist.com/cdn-cgi/image/width=' + width + ',quality=80,format=auto/'
|
||||||
'economist.com/cdn-cgi/image/width=600,quality=80,format=auto/')
|
img['src'] = img['src'].replace('economist.com/', qua)
|
||||||
return soup
|
return soup
|
||||||
|
|
||||||
else: # Load articles from individual article pages {{{
|
else: # Load articles from individual article pages {{{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user