Debian Codegraph @

recipes/unz.recipe

raw
1 #!/usr/bin/env python
2 # vim:fileencoding=utf-8
3 from calibre.web.feeds.news import BasicNewsRecipe, classes
4
5
6 class Unz(BasicNewsRecipe):
7 title = 'The Unz Review'
8 description = 'A Collection of Interesting, Important, and Controversial Perspectives Largely Excluded from the American Mainstream Media.'
9 __author__ = 'unkn0wn'
10 oldest_article = 7
11 language = 'en_US'
12 max_articles_per_feed = 100
13 use_embedded_content = False
14 cover_url = 'https://www.unz.com/wp-content/themes/unzSite/IMAGES/unz_large_logo.png'
15 encoding = 'utf-8'
16 # browser_type = 'webengine'
17 no_stylesheets = True
18 remove_attributes = ['style', 'height', 'width']
19 extra_css = '.byline, .caption { font-size: small; }'
20
21 keep_only_tags = [
22 dict(
23 name='div',
24 attrs={'class': ['head', 'byline', 'page-thumb', 'section-holder']},
25 ),
26 ]
27
28 remove_tags = [
29 dict(name=['audio', 'iframe', 'svg']),
30 classes('commentlink replylink'),
31 ]
32
33 remove_tags_after = [dict(name='div', attrs={'class': 'section-holder'})]
34
35 recipe_specific_options = {
36 'days': {
37 'short': 'Oldest article to download from this news source. In days ',
38 'long': 'For example, 0.5, gives you articles from the past 12 hours',
39 'default': str(oldest_article),
40 },
41 }
42
43 def __init__(self, *args, **kwargs):
44 BasicNewsRecipe.__init__(self, *args, **kwargs)
45 d = self.recipe_specific_options.get('days')
46 if d and isinstance(d, str):
47 self.oldest_article = float(d)
48
49 feeds = ['https://www.unz.com/feed']
50
51 def preprocess_html(self, soup):
52 head = soup.find(**classes('head'))
53 if head:
54 head.name = 'h1'
55 return soup