from calibre.web.feeds.news import BasicNewsRecipe, classes class DeutscheWelle_sr(BasicNewsRecipe): title = 'Deutsche Welle' __author__ = 'unkn0wn' description = 'Vesti iz Nemacke i sveta' publisher = 'Deutsche Welle' category = 'news, politics, Germany' oldest_article = 2 max_articles_per_feed = 100 use_embedded_content = False no_stylesheets = True language = 'sr' publication_type = 'newsportal' remove_empty_feeds = True masthead_url = 'http://www.dw-world.de/skins/std/channel1/pics/dw_logo1024.gif' remove_javascript = True ignore_duplicate_articles = {'title', 'url'} remove_attributes = ['height', 'width', 'style'] recipe_specific_options = { 'days': { 'short': 'Oldest article to download from this news source. In days ', 'long': 'For example, 0.5, gives you articles from the past 12 hours', 'default': str(oldest_article), } } def __init__(self, *args, **kwargs): BasicNewsRecipe.__init__(self, *args, **kwargs) d = self.recipe_specific_options.get('days') if d and isinstance(d, str): self.oldest_article = float(d) def preprocess_html(self, soup): for img in soup.findAll('img', srcset=True): img['src'] = img['srcset'].split()[6] return soup keep_only_tags = [dict(name='article')] remove_tags = [dict(name=['footer', 'source']), dict(attrs={'data-tracking-name': 'sharing-icons-inline'}), classes('kicker advertisement vjs-wrapper')] feeds = [ ('Politika', 'http://rss.dw-world.de/rdf/rss-ser-pol'), ('Srbija', 'http://rss.dw-world.de/rdf/rss-ser-pol-ser'), ('Region', 'http://rss.dw-world.de/rdf/rss-ser-pol-region'), ('Evropa', 'http://rss.dw-world.de/rdf/rss-ser-pol-eu'), ('Nemacka', 'http://rss.dw-world.de/rdf/rss-ser-pol-ger'), ('Svet', 'http://rss.dw-world.de/rdf/rss-ser-pol-ger'), ('Pregled stampe', 'http://rss.dw-world.de/rdf/rss-ser-pol-ger'), ('Nauka Tehnika Medicina', 'http://rss.dw-world.de/rdf/rss-ser-science'), ('Kultura', 'feed:http://rss.dw-world.de/rdf/rss-ser-cul'), ]