Update Saechsische Zeitung

This commit is contained in:
Kovid Goyal 2023-03-31 22:49:34 +05:30
parent c466c04db4
commit eacbbc1f88
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -1,22 +1,21 @@
#!/usr/bin/env python
##
# Written: March 2020
# Version: 1.0
# Last update: 2020-03-27
## Written: March 2020
## Version: 1.1
## Last update: 2023-03-31
##
from __future__ import unicode_literals, division, absolute_import, print_function
'''
Fetch RSS-Feeds from saechsische.de
'''
from calibre.web.feeds.news import BasicNewsRecipe
def classes(classes):
q = frozenset(classes.split(' '))
return dict(
attrs={'class': lambda x: x and frozenset(x.split()).intersection(q)}
)
return dict(attrs={'class': lambda x: x and frozenset(x.split()).intersection(q)})
class Saechsische(BasicNewsRecipe):
@ -32,19 +31,23 @@ class Saechsische(BasicNewsRecipe):
no_stylesheets = True
remove_javascript = True
remove_empty_feeds = True
compress_news_images = True
compress_news_images_auto_size = 8
scale_news_images_to_device = True
delay = 1
ignore_duplicate_articles = {'title', 'url'}
cover_url = 'https://www.saechsische.de/img/logo.svg'
feeds = [
('Dresden', 'feed://www.saechsische.de/rss/dresden'),
('Sachsen', 'feed://saechsische.de/rss/sachsen'),
('Dynamo', 'feed://www.saechsische.de/rss/dynamo'),
('Deutschland und Welt', 'feed://www.saechsische.de/rss/deutschland-welt'),
('Politik', 'feed://www.saechsische.de/rss/politik'),
('Wirtschaft', 'feed://www.saechsische.de/rss/wirtschaft'),
('Feuilleton', 'feed://www.saechsische.de/rss/feuilleton'),
('Sport', 'feed://www.saechsische.de/rss/sport'),
('Deutschland und Welt', 'feed://www.saechsische.de/rss/deutschland-welt'),
#('Dynamo', 'feed://www.saechsische.de/rss/dynamo'),
#('Bautzen', 'feed://www.saechsische.de/rss/bautzen'),
#('Bischofswerda', 'feed://www.saechsische.de/rss/bischofswerda'),
#('Dippoldiswalde', 'feed://www.saechsische.de/rss/dippoldiswalde'),
@ -64,13 +67,59 @@ class Saechsische(BasicNewsRecipe):
#('Zittau', 'feed://www.saechsische.de/rss/zittau'),
]
template_css = '''
.article_date { color: gray; font-family: monospace;}
.article_description { text-indent: 0pt; }
a.article { font-weight: bold; text-align:left; }
a.feed { font-weight: bold; }
.calibre_navbar { font-size: 200% !important; }
'''
extra_css = '''
h2 {margin-top: 0em;}
'''
keep_only_tags = [
dict(name='article', attrs={'class':'article-detail'}),
]
remove_tags = [
classes('article-fill'),
dict(name='div', attrs={'class': 'article-related-container'}),
dict(name='div', attrs={'id': 'article-header'}),
dict(name='span', attrs={'class': 'article-plus'}),
remove_tags = [ classes('article-fill'),
dict(name='div', attrs={'class':'related-articles'}),
dict(name='a', attrs={'class':'article-remember-link'}),
dict(name='a', attrs={'href':'https://www.saechsische.de/dresden'}),
dict(name='a', attrs={'href':'https://www.saechsische.de/content/newsletter-lp?utm_content=dresden_kompakt'}),
dict(name='div', attrs={'class':'article-detail-socials'}),
dict(name='div', attrs={'class':'d-desktop-none'}),
dict(name='div', attrs={'class':'floating-share-icon'}),
]
def parse_feeds(self):
# Call parent's method.
feeds = BasicNewsRecipe.parse_feeds(self)
# Loop through all feeds.
for feed in feeds:
# Loop through all articles in feed.
for article in feed.articles[:]:
# Remove articles with '...' in the url.
if '/anzeige/' in article.url:
print('Removing:',article.title)
feed.articles.remove(article)
elif 'newsletter-dresden' in article.url:
print('Removing:',article.title)
feed.articles.remove(article)
# Remove articles with '...' in the title.
elif 'Newsblog' in article.title:
print('Removing:',article.title)
feed.articles.remove(article)
elif 'Podcast' in article.title:
print('Removing:',article.title)
feed.articles.remove(article)
return feeds
def preprocess_raw_html(self, raw, url):
# remove Newsblogs, articles requiring login and advertisements
unwanted_article_keywords = ['unser Newsblog', 'Zum Login', '00:00 Uhr',]
for keyword in unwanted_article_keywords:
if keyword in raw:
print('Skipping unwanted article with keyword(s):',keyword)
self.abort_article('Skipping unwanted article')
return raw