Debian Codegraph @

recipes/national_post.recipe

raw
1 #!/usr/bin/env python
2 # vim:fileencoding=utf-8
3 # License: GPLv3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
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 NationalPost(BasicNewsRecipe):
15 title = 'National Post'
16 __author__ = 'Kovid Goyal'
17 description = 'Canadian national newspaper'
18 timefmt = ' [%d %b, %Y]'
19 language = 'en_CA'
20 no_stylesheets = True
21 oldest_article = 1.5
22 use_embedded_content = False
23
24 recipe_specific_options = {
25 'days': {
26 'short': 'Oldest article to download from this news source. In days ',
27 'long': 'For example, 0.5, gives you articles from the past 12 hours',
28 'default': str(oldest_article),
29 }
30 }
31
32 def __init__(self, *args, **kwargs):
33 BasicNewsRecipe.__init__(self, *args, **kwargs)
34 d = self.recipe_specific_options.get('days')
35 if d and isinstance(d, str):
36 self.oldest_article = float(d)
37
38 keep_only_tags = [
39 dict(itemprop='headline'),
40 classes('featured-image'),
41 dict(itemprop='articleBody'),
42 ]
43
44 feeds = ['http://nationalpost.com/rss']