Debian Codegraph @

recipes/deutsche_welle_en.recipe

raw
1 from calibre.web.feeds.news import BasicNewsRecipe, classes
2
3
4 class DeutscheWelle_en(BasicNewsRecipe):
5 title = 'Deutsche Welle'
6 __author__ = 'unkn0wn'
7 description = 'News from Germany and the world'
8 publisher = 'Deutsche Welle'
9 language = 'en'
10
11 oldest_article = 2
12 max_articles_per_feed = 50
13 no_stylesheets = True
14 remove_javascript = True
15 remove_empty_feeds = True
16 ignore_duplicate_articles = {'title', 'url'}
17 remove_attributes = ['height', 'width', 'style']
18
19 recipe_specific_options = {
20 'days': {
21 'short': 'Oldest article to download from this news source. In days ',
22 'long': 'For example, 0.5, gives you articles from the past 12 hours',
23 'default': str(oldest_article),
24 }
25 }
26
27 def __init__(self, *args, **kwargs):
28 BasicNewsRecipe.__init__(self, *args, **kwargs)
29 d = self.recipe_specific_options.get('days')
30 if d and isinstance(d, str):
31 self.oldest_article = float(d)
32
33 keep_only_tags = [dict(name='article')]
34
35 remove_tags = [dict(name=['footer', 'source']), dict(attrs={'data-tracking-name': 'sharing-icons-inline'}), classes('kicker advertisement vjs-wrapper')]
36
37 feeds = [
38 ('World', 'http://rss.dw.de/rdf/rss-en-world'),
39 ('Germany', 'http://rss.dw.de/rdf/rss-en-ger'),
40 ('Europe', 'http://rss.dw.de/rdf/rss-en-eu'),
41 ('Business', 'http://rss.dw.de/rdf/rss-en-bus'),
42 ('Culture & Lifestyle', 'http://rss.dw.de/rdf/rss-en-cul'),
43 ('Sports', 'http://rss.dw.de/rdf/rss-en-sports'),
44 ('Visit Germany', 'http://rss.dw.de/rdf/rss-en-visitgermany'),
45 ('Asia', 'http://rss.dw.de/rdf/rss-en-asia'),
46 ('Top Stories', 'http://rss.dw-world.de/rdf/rss-en-top'),
47 ]
48
49 def preprocess_html(self, soup):
50 for img in soup.findAll('img', srcset=True):
51 img['src'] = img['srcset'].split()[6]
52 return soup