Debian Codegraph @

recipes/billorielly.recipe

raw
1 #!/usr/bin/env python
2
3 # ebook-convert.exe c:\billorielly.recipe c:\test -vv
4
5 from calibre.web.feeds.recipes import BasicNewsRecipe
6
7
8 class BillOReilly(BasicNewsRecipe):
9 cover_url = 'http://images.billoreilly.com/images/headers/borbanner.jpg'
10 title = "Bill O'Reilly"
11 __author__ = 'Rob Lammert - rob.lammert[at]gmail.com'
12 description = "Articles from Bill O'Reilly's website and his Fox New's website"
13 language = 'en'
14 oldest_article = 7.0
15 max_articles_per_feed = 100
16 recursions = 0
17 encoding = 'utf8'
18 no_stylesheets = True
19 remove_javascript = True
20
21 def parse_index(self):
22 feeds = []
23
24 articles_shows = self.bo_parse_shows('http://www.billoreilly.com/show?action=tvShowArchive')
25 articles_columns = self.bo_parse_columns('http://www.billoreilly.com/columns')
26
27 if articles_shows:
28 feeds.append(("O'Reilly Factor", articles_shows))
29
30 if articles_columns:
31 feeds.append(('Newspaper Column', articles_columns))
32
33 return feeds
34
35 def bo_parse_shows(self, url):
36 soup = self.index_to_soup(url)
37 links = soup.find(attrs={'class': 'showLinks'})
38
39 current_articles = []
40 counter = 0
41 for lnk in links.findAllNext(attrs={'class': ['showLinks']}):
42 if counter <= 5:
43 title = self.tag_to_string(lnk)
44 url = lnk.get('href', False)
45
46 if not url or not title:
47 continue
48
49 if url.startswith('/'):
50 url = 'http://www.billoreilly.com' + url + '&dest=/pg/jsp/community/tvshowprint.jsp'
51
52 self.log('\t\tFound article:', title)
53 self.log('\t\t\t', url)
54 current_articles.append({'title': title, 'url': url, 'description': '', 'date': ''})
55 counter += 1
56 return current_articles
57
58 def bo_parse_columns(self, url):
59 soup = self.index_to_soup(url)
60 links = soup.find(attrs={'id': 'bold'})
61
62 current_articles = []
63 counter = 0
64 for lnk in links.findAllNext(attrs={'id': ['bold']}):
65 test = lnk.get('class', False)
66 if counter <= 5 and test == 'defaultLinks':
67 title = self.tag_to_string(lnk)
68 url = lnk.get('href', False)
69
70 if not url or not title:
71 continue
72
73 if url.startswith('/'):
74 url = 'http://www.billoreilly.com' + url + '&printerFriendly=true"'
75
76 self.log('\t\tFound article:', title)
77 self.log('\t\t\t', url)
78 current_articles.append({'title': title, 'url': url, 'description': '', 'date': ''})
79 counter += 1
80 return current_articles