calibre/recipes/readers_digest.recipe
2020-08-27 09:39:35 +05:30

70 lines
2.6 KiB
Python

#!/usr/bin/env python
__license__ = 'GPL v3'
'''
'''
from calibre.web.feeds.recipes import BasicNewsRecipe
def classes(classes):
q = frozenset(classes.split(' '))
return dict(attrs={
'class': lambda x: x and frozenset(x.split()).intersection(q)})
class ReadersDigest(BasicNewsRecipe):
title = 'Readers Digest'
__author__ = 'BrianG, Gobelinus'
language = 'en'
description = 'Readers Digest Feeds'
no_stylesheets = True
use_embedded_content = False
oldest_article = 60
max_articles_per_feed = 200
language = 'en'
remove_javascript = True
remove_attributes = ['style']
extra_css = ''' h1 {font-family:georgia,serif;color:#000000;}
.mainHd{font-family:georgia,serif;color:#000000;}
h2 {font-family:Arial,Sans-serif;}
.name{font-family:Arial,Sans-serif; font-size:x-small;font-weight:bold; }
.date{font-family:Arial,Sans-serif; font-size:x-small ;color:#999999;}
.byline{font-family:Arial,Sans-serif; font-size:x-small ;}
.photoBkt{ font-size:x-small ;}
.vertPhoto{font-size:x-small ;}
.credits{font-family:Arial,Sans-serif; font-size:x-small ;color:gray;}
.credit{font-family:Arial,Sans-serif; font-size:x-small ;color:gray;}
.artTxt{font-family:georgia,serif;}
.caption{font-family:georgia,serif; font-size:x-small;color:#333333;}
.credit{font-family:georgia,serif; font-size:x-small;color:#999999;}
a:link{color:#CC0000;}
.breadcrumb{font-family:Arial,Sans-serif;font-size:x-small;}
'''
feeds = [
('Food', 'http://www.rd.com/food/feed'),
('Health', 'http://www.rd.com/health/feed'),
('Home', 'http://www.rd.com/home/feed'),
# ('Family', 'http://www.rd.com/family/feed'),
# ('Money', 'http://www.rd.com/money/feed'),
# ('Travel', 'http://www.rd.com/travel/feed'),
('True Stories', 'http://www.rd.com/true-stories/feed'),
('Advice', 'http://www.rd.com/advice/feed'),
]
keep_only_tags = [
classes('post-title post-author post-updated-date post-date featured-image post-body entry-title dek listicle-card')
]
remove_tags = [
classes('single-card ad brand-info pure-g')
]
def preprocess_html(self, soup):
for img in soup.findAll('img', attrs={'data-lazy-src': True}):
img['src'] = img['data-lazy-src']
return soup