Debian Codegraph @

recipes/cnetjapan.recipe

raw
1 import re
2
3 from calibre.web.feeds.news import BasicNewsRecipe
4
5
6 class CNetJapan(BasicNewsRecipe):
7 title = 'CNET Japan'
8 oldest_article = 3
9 max_articles_per_feed = 30
10 __author__ = 'Hiroshi Miura'
11
12 feeds = [('CNet News', 'http://feed.japan.cnet.com/rss/index.rdf'), ('CNet Blog', 'http://feed.japan.cnet.com/rss/blog/index.rdf')]
13 language = 'ja'
14 encoding = 'utf-8'
15 remove_javascript = True
16
17 preprocess_regexps = [
18 (re.compile(type('')(r'<!--\u25B2contents_left END\u25B2-->.*</body>'), re.DOTALL | re.IGNORECASE | re.UNICODE), lambda match: '</body>'),
19 (re.compile(r'<!--AD_ELU_HEADER-->.*</body>', re.DOTALL | re.IGNORECASE), lambda match: '</body>'),
20 (re.compile(type('')(r'<!-- \u25B2\u95A2\u9023\u30BF\u30B0\u25B2 -->.*<!-- \u25B2ZDNet\u25B2 -->'), re.UNICODE), lambda match: '<!-- removed -->'),
21 ]
22
23 remove_tags_before = dict(id='contents_l')
24 remove_tags = [
25 {'class': 'social_bkm_share'},
26 {'class': 'social_bkm_print'},
27 {'class': 'block20 clearfix'},
28 dict(name='div', attrs={'id': 'bookreview'}),
29 {'class': 'tag_left_ttl'},
30 {'class': 'tag_right'},
31 ]
32 remove_tags_after = {'class': 'block20'}
33
34 def parse_feeds(self):
35
36 feeds = BasicNewsRecipe.parse_feeds(self)
37
38 for curfeed in feeds:
39 delList = []
40 for a, curarticle in enumerate(curfeed.articles):
41 if re.search(r'pheedo.jp', curarticle.url):
42 delList.append(curarticle)
43 if len(delList) > 0:
44 for d in delList:
45 index = curfeed.articles.index(d)
46 curfeed.articles[index : index + 1] = []
47
48 return feeds