Debian Codegraph @

recipes/newsminute.recipe

raw
1 #!/usr/bin/env python
2 from calibre.web.feeds.news import BasicNewsRecipe, classes
3
4
5 class newsminute(BasicNewsRecipe):
6 title = 'The News Minute'
7 __author__ = 'unkn0wn'
8 description = (
9 'The News Minute is a digital news platform reporting and writing on issues in India, with a '
10 'specific focus on the 5 southern states. Our content includes news, ground reportage, news '
11 'analysis, opinion and blogs. Our core strengths include our deep access in the southern states, '
12 'incisive editorial acumen and insightful news analysis and opinions.'
13 )
14 language = 'en_IN'
15
16 no_stylesheets = True
17 remove_javascript = True
18 masthead_url = 'https://pkcindia.com/wp-content/uploads/2021/09/TMN-Logo-1.png'
19 ignore_duplicate_articles = {'title', 'url'}
20 resolve_internal_links = True
21 remove_empty_feeds = True
22 remove_attributes = ['style', 'height', 'width']
23
24 keep_only_tags = [
25 classes('arr--section-name arr--story--headline-h1 arr--sub-headline arr--hero-image author-card-wrapper arr--story-page-card-wrapper'),
26 ]
27
28 def preprocess_html(self, soup):
29 for img in soup.findAll('img', attrs={'data-src': True}):
30 img['src'] = img['data-src']
31 return soup
32
33 def parse_index(self):
34 index = 'https://www.thenewsminute.com/'
35 sections = ['tamil-nadu', 'telangana', 'andhra-pradesh', 'karnataka', 'kerala']
36 feeds = []
37 soup = self.index_to_soup(index)
38 for sec in sections:
39 section = sec.capitalize()
40 self.log(section)
41 articles = []
42 for a in soup.findAll('a', attrs={'href': lambda x: x and x.startswith(index + sec + '/')}):
43 url = a['href']
44 if url in {index + sec + '/', index + sec}:
45 continue
46 title = self.tag_to_string(a)
47 self.log('\t', title, '\n\t\t', url)
48 articles.append({'title': title, 'url': url})
49 if articles:
50 feeds.append((section, articles))
51 return feeds