Debian Codegraph @

recipes/readers_digest.recipe

raw
1 #!/usr/bin/env python
2 __license__ = 'GPL v3'
3 '''
4 '''
5
6 from calibre.web.feeds.recipes import BasicNewsRecipe
7
8
9 def classes(classes):
10 q = frozenset(classes.split(' '))
11 return dict(attrs={'class': lambda x: x and frozenset(x.split()).intersection(q)})
12
13
14 class ReadersDigest(BasicNewsRecipe):
15 title = 'Readers Digest'
16 __author__ = 'BrianG, Gobelinus'
17 language = 'en'
18 description = 'Readers Digest Feeds'
19 no_stylesheets = True
20 use_embedded_content = False
21 oldest_article = 60
22 max_articles_per_feed = 200
23
24 remove_javascript = True
25 remove_attributes = ['style']
26
27 extra_css = ''' h1 {font-family:georgia,serif;color:#000000;}
28 .mainHd{font-family:georgia,serif;color:#000000;}
29 h2 {font-family:Arial,Sans-serif;}
30 .name{font-family:Arial,Sans-serif; font-size:x-small;font-weight:bold; }
31 .date{font-family:Arial,Sans-serif; font-size:x-small ;color:#999999;}
32 .byline{font-family:Arial,Sans-serif; font-size:x-small ;}
33 .photoBkt{ font-size:x-small ;}
34 .vertPhoto{font-size:x-small ;}
35 .credits{font-family:Arial,Sans-serif; font-size:x-small ;color:gray;}
36 .credit{font-family:Arial,Sans-serif; font-size:x-small ;color:gray;}
37 .artTxt{font-family:georgia,serif;}
38 .caption{font-family:georgia,serif; font-size:x-small;color:#333333;}
39 .credit{font-family:georgia,serif; font-size:x-small;color:#999999;}
40 a:link{color:#CC0000;}
41 .breadcrumb{font-family:Arial,Sans-serif;font-size:x-small;}
42 '''
43
44 feeds = [
45 ('Food', 'http://www.rd.com/food/feed'),
46 ('Health', 'http://www.rd.com/health/feed'),
47 ('Home', 'http://www.rd.com/home/feed'),
48 # ('Family', 'http://www.rd.com/family/feed'),
49 # ('Money', 'http://www.rd.com/money/feed'),
50 # ('Travel', 'http://www.rd.com/travel/feed'),
51 ('True Stories', 'http://www.rd.com/true-stories/feed'),
52 ('Advice', 'http://www.rd.com/advice/feed'),
53 ]
54
55 keep_only_tags = [classes('post-title post-author post-updated-date post-date featured-image post-body entry-title dek listicle-card')]
56
57 remove_tags = [classes('single-card ad brand-info pure-g')]
58
59 def preprocess_html(self, soup):
60 for img in soup.findAll('img', attrs={'data-lazy-src': True}):
61 img['src'] = img['data-lazy-src']
62 return soup