calibre/recipes/deutsche_welle_bs.recipe
un-pogaz 8c9d880f41 pep8
improvement of Ruff settings
2024-12-15 13:17:49 +01:00

60 lines
2.0 KiB
Python

from calibre.web.feeds.news import BasicNewsRecipe, classes
class DeutscheWelle_bs(BasicNewsRecipe):
title = 'Deutsche Welle'
__author__ = 'unkn0wn'
description = 'Vijesti iz Njemacke i svijeta'
publisher = 'Deutsche Welle'
category = 'news, politics, Germany'
oldest_article = 2
max_articles_per_feed = 100
use_embedded_content = False
no_stylesheets = True
language = 'bs'
publication_type = 'newsportal'
remove_empty_feeds = True
remove_javascript = True
masthead_url = 'http://www.dw-world.de/skins/std/channel1/pics/dw_logo1024.gif'
ignore_duplicate_articles = {'title', 'url'}
remove_attributes = ['height', 'width', 'style']
keep_only_tags = [
dict(name='article')
]
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)
remove_tags = [
dict(name=['footer', 'source']),
dict(attrs={'data-tracking-name':'sharing-icons-inline'}),
classes('kicker advertisement vjs-wrapper')
]
feeds = [
(u'Politika', u'http://rss.dw-world.de/rdf/rss-bos-pol'),
(u'Evropa', u'http://rss.dw-world.de/rdf/rss-bos-eu'),
(u'Kiosk', u'http://rss.dw-world.de/rdf/rss-bos-eu'),
(u'Ekonomija i Nuka', u'http://rss.dw-world.de/rdf/rss-bos-eco'),
(u'Kultura', u'http://rss.dw-world.de/rdf/rss-bos-cul'),
(u'Sport', u'http://rss.dw-world.de/rdf/rss-bos-sp')
]
def preprocess_html(self, soup):
for img in soup.findAll('img', srcset=True):
img['src'] = img['srcset'].split()[6]
return soup