Debian Codegraph @

recipes/tagespost.recipe

raw
1 #!/usr/bin/env python
2 # vim:fileencoding=utf-8
3 """
4 Recipe for Die Tagespost
5 """
6
7 from calibre.web.feeds.news import BasicNewsRecipe, classes
8
9
10 class Tagespost(BasicNewsRecipe):
11 title = 'Tagespost'
12 language = 'de'
13 __author__ = 'unkn0wn'
14 description = (
15 'Die Tagespost trägt den Untertitel Katholische Wochenzeitung für Politik, Gesellschaft'
16 ' und Kultur und ist eine überregionale, wöchentlich im Johann Wilhelm Naumann Verlag '
17 'in Würzburg erscheinende Zeitung.'
18 )
19 oldest_article = 2
20 encoding = 'utf-8'
21 ignore_duplicate_articles = {'url'}
22 masthead_url = 'https://www.die-tagespost.de/design2020/images/tp_logo_small.webp'
23 remove_javascript = True
24 keep_only_tags = [classes('topline headline description datetime autor-name article_main')]
25 remove_tags = [
26 dict(name=['source', 'svg', 'aside', 'clearfix', 'footer']),
27 classes('content-box extras jwnIconTeaser behindWall'),
28 ]
29 remove_tags_after = [classes('abbinder-text')]
30 no_stylesheets = True
31 use_embedded_content = False
32 remove_attributes = ['style', 'height', 'width']
33 recipe_specific_options = {
34 'days': {
35 'short': 'Oldest article to download from this news source. In days ',
36 'long': 'For example, 0.5, gives you articles from the past 12 hours',
37 'default': str(oldest_article),
38 },
39 }
40
41 def __init__(self, *args, **kwargs):
42 BasicNewsRecipe.__init__(self, *args, **kwargs)
43 d = self.recipe_specific_options.get('days')
44 if d and isinstance(d, str):
45 self.oldest_article = float(d)
46
47 def get_cover_url(self):
48 soup = self.index_to_soup('https://www.ikiosk.de/shop/epaper/die-tagespost.html')
49 return soup.find('a', attrs={'class': 'preview-cover'})['href']
50
51 feeds = [
52 (
53 'Tagespost',
54 'https://www.die-tagespost.de/storage/rss/rss/die-tagespost-komplett.xml',
55 ),
56 ]
57 extra_css = '''
58 .abbinder-text,
59 .calibre-nuked-tag-figcaption,
60 .datetime,
61 .autor-name,
62 .topline {
63 font-size:small;
64 }
65 .description { font-style: italic; }
66 '''
67
68 def preprocess_html(self, soup):
69 desc = soup.find(**classes('description'))
70 if desc:
71 desc.name = 'p'
72 for h2 in soup.findAll(['h2', 'h3']):
73 h2.name = 'h4'
74 return soup