mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Use larger images in Hindu
Also remove <source> tags since browsers tend to use them in preference to <img>
This commit is contained in:
parent
e8cc06935d
commit
09b3c95ac9
@ -3,7 +3,7 @@ __license__ = 'GPL 3'
|
|||||||
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
|
|
||||||
from calibre.web.feeds.news import BasicNewsRecipe
|
from calibre.web.feeds.news import BasicNewsRecipe
|
||||||
import string, re
|
import string
|
||||||
|
|
||||||
|
|
||||||
def classes(classes):
|
def classes(classes):
|
||||||
@ -32,9 +32,11 @@ class TheHindu(BasicNewsRecipe):
|
|||||||
def preprocess_html(self, soup):
|
def preprocess_html(self, soup):
|
||||||
img = soup.find('img', attrs={'class': 'lead-img'})
|
img = soup.find('img', attrs={'class': 'lead-img'})
|
||||||
try:
|
try:
|
||||||
src = img.parent.find('source').get('srcset')
|
for i, source in enumerate(tuple(img.parent.findAll('source', srcset=True))):
|
||||||
img['src'] = re.sub(r'(ALTERNATES)/.+?/', r'\1/FREE_660/', src)
|
if i == 0:
|
||||||
except (TypeError, AttributeError):
|
img['src'] = source['srcset'].split()[0]
|
||||||
|
source.extract()
|
||||||
|
except Exception:
|
||||||
pass
|
pass
|
||||||
# Remove duplicate intro
|
# Remove duplicate intro
|
||||||
for h in soup.findAll('h2', attrs={'class': 'intro'})[1:]:
|
for h in soup.findAll('h2', attrs={'class': 'intro'})[1:]:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user