From 09b3c95ac9d6498da46a9446afe0f5095e061c60 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 11 Jun 2021 08:06:05 +0530 Subject: [PATCH] Use larger images in Hindu Also remove tags since browsers tend to use them in preference to --- recipes/hindu.recipe | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/recipes/hindu.recipe b/recipes/hindu.recipe index 2ba4c55a4e..1fab6775b0 100644 --- a/recipes/hindu.recipe +++ b/recipes/hindu.recipe @@ -3,7 +3,7 @@ __license__ = 'GPL 3' __copyright__ = '2009, Kovid Goyal ' from calibre.web.feeds.news import BasicNewsRecipe -import string, re +import string def classes(classes): @@ -32,9 +32,11 @@ class TheHindu(BasicNewsRecipe): def preprocess_html(self, soup): img = soup.find('img', attrs={'class': 'lead-img'}) try: - src = img.parent.find('source').get('srcset') - img['src'] = re.sub(r'(ALTERNATES)/.+?/', r'\1/FREE_660/', src) - except (TypeError, AttributeError): + for i, source in enumerate(tuple(img.parent.findAll('source', srcset=True))): + if i == 0: + img['src'] = source['srcset'].split()[0] + source.extract() + except Exception: pass # Remove duplicate intro for h in soup.findAll('h2', attrs={'class': 'intro'})[1:]: