Debian Codegraph @

recipes/hindustan_times.recipe

raw
1 #!/usr/bin/env python
2
3 from calibre.web.feeds.news import BasicNewsRecipe, classes
4
5
6 class HindustanTimes(BasicNewsRecipe):
7 title = 'Hindustan Times'
8 description = 'News from India.'
9 language = 'en_IN'
10 __author__ = 'unkn0wn'
11 oldest_article = 1 # days
12 max_articles_per_feed = 50
13 encoding = 'utf-8'
14 use_embedded_content = False
15 masthead_url = 'https://epaper.hindustantimes.com//Images/logo/logo.png'
16 no_stylesheets = True
17 remove_attributes = ['style', 'height', 'width']
18 ignore_duplicate_articles = {'url'}
19 extra_css = '.about-authors { font-size: smaller }'
20
21 keep_only_tags = [
22 classes('fullStory dateTime storyBy storyDetails detail freemiumText paywall'),
23 ]
24
25 remove_tags = [
26 classes(
27 'htsWrapper shareArticle new__newsletter__signup signup__box subscribe freemium-card adMinHeight313'
28 ' storyTopics embed_div shareIcons close-btn mainCoachmarks sharePopUp'
29 ),
30 dict(name='div', attrs={'class': []}),
31 dict(name=['footer', 'button']),
32 ]
33
34 feeds = [
35 ('Editorial', 'https://www.hindustantimes.com/feeds/rss/editorials/rssfeed.xml'),
36 ('Opinion', 'https://www.hindustantimes.com/feeds/rss/opinion/rssfeed.xml'),
37 ('HT Insight', 'https://www.hindustantimes.com/feeds/rss/ht-insight/rssfeed.xml'),
38 ('Analysis', 'https://www.hindustantimes.com/feeds/rss/analysis/rssfeed.xml'),
39 ('India News', 'https://www.hindustantimes.com/feeds/rss/india-news/rssfeed.xml'),
40 ('World News', 'https://www.hindustantimes.com/feeds/rss/world-news/rssfeed.xml'),
41 ('Business', 'https://www.hindustantimes.com/feeds/rss/business/rssfeed.xml'),
42 ('Science', 'https://www.hindustantimes.com/feeds/rss/science/rssfeed.xml'),
43 ('Education', 'https://www.hindustantimes.com/feeds/rss/education/rssfeed.xml'),
44 ('Elections', 'https://www.hindustantimes.com/feeds/rss/elections/rssfeed.xml'),
45 ('Sports', 'https://www.hindustantimes.com/feeds/rss/sports/rssfeed.xml'),
46 ('Books', 'https://www.hindustantimes.com/feeds/rss/books/rssfeed.xml'),
47 ('HT Weekend', 'https://www.hindustantimes.com/feeds/rss/ht-weekend/rssfeed.xml'),
48 # ('Entertainment','https://www.hindustantimes.com/feeds/rss/entertainment/rssfeed.xml'),
49 # ('Lifestyle',''https://www.hindustantimes.com/feeds/rss/lifestyle/rssfeed.xml'),
50 # ('Cities',''https://www.hindustantimes.com/feeds/rss/cities/rssfeed.xml'),
51 # ('Budget',''https://www.hindustantimes.com/feeds/rss/budget/rssfeed.xml')
52 ]
53
54 def get_cover_url(self):
55 soup = self.index_to_soup('https://www.magzter.com/IN/HT-Digital-Streams-Ltd./Hindustan-Times-Delhi/Newspaper/')
56 return soup.find('img', id=lambda s: s and 'mgd__lhd__cover' in s.split())['src']
57
58 def preprocess_html(self, soup):
59 for img in soup.findAll('img', attrs={'data-src': True}):
60 img['src'] = img['data-src']
61 return soup