calibre/recipes/wash_post.recipe
Kovid Goyal 567040ee1e Perform PEP8 compliance checks on the entire codebase
Some bits of PEP 8 are turned off via setup.cfg
2016-07-29 21:25:17 +05:30

78 lines
3.2 KiB
Plaintext

__license__ = 'GPL v3'
__copyright__ = '2011, Darko Miletic <darko.miletic at gmail.com>'
'''
www.washingtonpost.com
'''
from calibre import strftime
from calibre.web.feeds.news import BasicNewsRecipe
class TheWashingtonPost(BasicNewsRecipe):
title = 'The Washington Post'
__author__ = 'Darko Miletic'
description = 'Leading source for news, video and opinion on politics, business, world and national news, science, travel, entertainment and more. Our local coverage includes reporting on education, crime, weather, traffic, real estate, jobs and cars for DC, Maryland and Virginia. Offering award-winning opinion writing, entertainment information and restaurant reviews.' # noqa
publisher = 'The Washington Post Company'
category = 'news, politics, USA'
oldest_article = 2
max_articles_per_feed = 200
no_stylesheets = True
encoding = 'utf8'
delay = 1
use_embedded_content = False
language = 'en'
remove_empty_feeds = True
publication_type = 'newspaper'
masthead_url = 'http://www.washingtonpost.com/rw/sites/twpweb/img/logos/twp_logo_300.gif'
cover_url = strftime(
'http://www.washingtonpost.com/rw/WashingtonPost/Content/Epaper/%Y-%m-%d/Ax1.pdf')
extra_css = """
body{font-family: Georgia,serif }
"""
conversion_options = {
'comment': description, 'tags': category, 'publisher': publisher, 'language': language
}
keep_only_tags = [
dict(attrs={'id': ['content', 'entryhead', 'entrytext']})]
remove_tags = [
dict(name=['meta', 'link', 'iframe', 'base']), dict(
attrs={'id': 'multimedia-leaf-page'})
]
remove_attributes = ['lang', 'property', 'epochtime',
'datetitle', 'pagetype', 'contenttype', 'comparetime']
feeds = [
(u'World', u'http://feeds.washingtonpost.com/rss/world'),
(u'National', u'http://feeds.washingtonpost.com/rss/national'),
(u'White House', u'http://feeds.washingtonpost.com/rss/politics/whitehouse'),
(u'Business', u'http://feeds.washingtonpost.com/rss/business'),
(u'Opinions', u'http://feeds.washingtonpost.com/rss/opinions'),
(u'Investigations', u'http://feeds.washingtonpost.com/rss/investigations'),
(u'Local', u'http://feeds.washingtonpost.com/rss/local'),
(u'Entertainment', u'http://feeds.washingtonpost.com/rss/entertainment'),
(u'Sports', u'http://feeds.washingtonpost.com/rss/sports'),
(u'Redskins', u'http://feeds.washingtonpost.com/rss/sports/redskins'),
(u'Special Reports', u'http://feeds.washingtonpost.com/rss/national/special-reports')
]
def print_version(self, url):
if '_story.html' in url:
return url.replace('_story.html', '_print.html')
return url
def get_article_url(self, article):
link = BasicNewsRecipe.get_article_url(self, article)
if article.id.startswith('http'):
link = article.id
if 'washingtonpost.com' not in link:
self.log('Skipping ads:', link)
return None
for it in ['_video.html', '_gallery.html', '_links.html']:
if it in link:
self.log('Skipping non-article:', link)
return None
return link