Debian Codegraph @

recipes/seminar_magazine.recipe

raw
1 from datetime import datetime
2
3 from calibre.web.feeds.news import BasicNewsRecipe
4
5
6 class Seminar(BasicNewsRecipe):
7 title = 'Seminar Magazine'
8 __author__ = 'unkn0wn'
9 description = (
10 'Seminar - attempts a departure from the usual journal. Problems, national and international,'
11 ' are posed and discussed. Each issue deals with a single problem. Those who hold different'
12 ' and at times opposing viewpoints express their thoughts'
13 )
14 language = 'en_IN'
15 use_embedded_content = False
16 remove_javascript = True
17 masthead_url = 'https://www.india-seminar.com/semlogo/semlogo_top_1.jpg'
18 ignore_duplicate_articles = {'url'}
19 remove_attributes = ['style', 'height', 'width']
20
21 def get_cover_url(self):
22 cover_url = None
23 soup = self.index_to_soup('https://www.india-seminar.com/')
24 citem = soup.find('img', src=lambda x: x and 'covers' in x)
25 if citem:
26 cover_url = 'https://www.india-seminar.com/' + citem['src']
27 return cover_url
28
29 def parse_index(self):
30 soup = self.index_to_soup('https://www.india-seminar.com/semframe.html')
31 d = datetime.today()
32 a = soup.find('frame', src=lambda x: x and x.startswith('' + d.strftime('%Y') + ''))
33 url = a['src']
34 self.log('Downloading issue:', url)
35 soup = self.index_to_soup('https://www.india-seminar.com/' + url)
36 ans = []
37
38 for a in soup.findAll('a', href=lambda x: x):
39 url = a['href']
40 if url.endswith('.htm'):
41 url = 'https://www.india-seminar.com/' + d.strftime('%Y') + '/' + url
42 title = self.tag_to_string(a).strip()
43 if title:
44 self.log(title, ' at ', url)
45 ans.append({'title': title, 'url': url})
46 return [('Articles', ans)]