Debian Codegraph @

recipes/adventuregamers.recipe

raw
1 __license__ = 'GPL v3'
2 __copyright__ = '2009-2012, Darko Miletic <darko.miletic at gmail.com>'
3 '''
4 www.adventuregamers.com
5 '''
6
7 from calibre.web.feeds.news import BasicNewsRecipe
8
9
10 class AdventureGamers(BasicNewsRecipe):
11 title = 'Adventure Gamers'
12 language = 'en'
13 __author__ = 'Darko Miletic'
14 description = 'Adventure games portal'
15 publisher = 'Adventure Gamers'
16 category = 'news, games, adventure, technology'
17 oldest_article = 10
18 max_articles_per_feed = 100
19 no_stylesheets = True
20 encoding = 'utf8'
21 remove_javascript = True
22 use_embedded_content = False
23 INDEX = 'http://www.adventuregamers.com'
24 extra_css = '''
25 .pageheader_type{font-size: x-large; font-weight: bold; color: #828D74}
26 .pageheader_title,.page_title{font-size: xx-large; color: #394128}
27 .pageheader_byline{font-size: small; font-weight: bold; color: #394128}
28 .score_bg {display: inline; width: 100%; margin-bottom: 2em}
29 .score_column_1{ padding-left: 10px; font-size: small; width: 50%}
30 .score_column_2{ padding-left: 10px; font-size: small; width: 50%}
31 .score_column_3{ padding-left: 10px; font-size: small; width: 50%}
32 .score_header{font-size: large; color: #50544A}
33 img{margin-bottom: 1em;}
34 body{font-family: 'Open Sans',Helvetica,Arial,sans-serif}
35 '''
36
37 conversion_options = {'comment': description, 'tags': category, 'publisher': publisher, 'language': language}
38
39 keep_only_tags = [dict(name='div', attrs={'class': 'cleft_inn'})]
40 remove_tags = [
41 dict(name=['object', 'link', 'embed', 'form', 'iframe', 'meta']),
42 dict(name='a', attrs={'href': 'http://www.adventuregamers.com/about/scoring'}),
43 dict(name='a', attrs={'href': 'http://www.adventuregamers.com/about/policies'}),
44 ]
45 remove_tags_after = [dict(name='div', attrs={'class': 'bodytext'})]
46 remove_attributes = ['width', 'height']
47
48 feeds = [('Articles', 'http://www.adventuregamers.com/rss/')]
49
50 def get_article_url(self, article):
51 url = BasicNewsRecipe.get_article_url(self, article)
52 if '/videos/' in url or '/hypeometer/' in url:
53 return None
54 return url
55
56 def append_page(self, soup, appendtag, position):
57 pager = soup.find('div', attrs={'class': 'pagination_big'})
58 if pager:
59 nextpage = soup.find('a', attrs={'class': 'next-page'})
60 if nextpage:
61 nexturl = nextpage['href']
62 soup2 = self.index_to_soup(nexturl)
63 texttag = soup2.find('div', attrs={'class': 'bodytext'})
64 for it in texttag.findAll(style=True):
65 del it['style']
66 newpos = len(texttag.contents)
67 self.append_page(soup2, texttag, newpos)
68 texttag.extract()
69 pager.extract()
70 appendtag.insert(position, texttag)
71
72 def preprocess_html(self, soup):
73 for item in soup.findAll(style=True):
74 del item['style']
75 for item in soup.findAll('div', attrs={'class': 'floatright'}):
76 item.extract()
77 self.append_page(soup, soup.body, 3)
78 pager = soup.find('div', attrs={'class': 'pagination_big'})
79 if pager:
80 pager.extract()
81 return self.adeify_images(soup)