mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Update Washington Post. Fixes #786609 (Updated recipe for The Washington Post)
This commit is contained in:
parent
f97bcfb1a8
commit
8336bd6e49
BIN
recipes/icons/wash_post.png
Normal file
BIN
recipes/icons/wash_post.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
@ -1,64 +1,75 @@
|
||||
__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.'
|
||||
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 }
|
||||
"""
|
||||
|
||||
class WashingtonPost(BasicNewsRecipe):
|
||||
conversion_options = {
|
||||
'comment' : description
|
||||
, 'tags' : category
|
||||
, 'publisher' : publisher
|
||||
, 'language' : language
|
||||
}
|
||||
|
||||
title = 'Washington Post'
|
||||
description = 'US political news'
|
||||
__author__ = 'Kovid Goyal'
|
||||
use_embedded_content = False
|
||||
max_articles_per_feed = 20
|
||||
language = 'en'
|
||||
encoding = 'utf-8'
|
||||
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']
|
||||
|
||||
|
||||
remove_javascript = True
|
||||
no_stylesheets = True
|
||||
|
||||
feeds = [
|
||||
('Politics', 'http://www.washingtonpost.com/rss/politics'),
|
||||
('Nation', 'http://www.washingtonpost.com/rss/national'),
|
||||
('World', 'http://www.washingtonpost.com/rss/world'),
|
||||
('Business', 'http://www.washingtonpost.com/rss/business'),
|
||||
('Lifestyle', 'http://www.washingtonpost.com/rss/lifestyle'),
|
||||
('Sports', 'http://www.washingtonpost.com/rss/sports'),
|
||||
('Redskins', 'http://www.washingtonpost.com/rss/sports/redskins'),
|
||||
('Opinions', 'http://www.washingtonpost.com/rss/opinions'),
|
||||
('Entertainment', 'http://www.washingtonpost.com/rss/entertainment'),
|
||||
('Local', 'http://www.washingtonpost.com/rss/local'),
|
||||
('Investigations',
|
||||
'http://www.washingtonpost.com/rss/investigations'),
|
||||
]
|
||||
|
||||
remove_tags = [
|
||||
{'class':lambda x: x and 'article-toolbar' in x},
|
||||
{'class':lambda x: x and 'quick-comments' in x},
|
||||
{'class':lambda x: x and 'tweet' in x},
|
||||
{'class':lambda x: x and 'article-related' in x},
|
||||
{'class':lambda x: x and 'hidden' in x.split()},
|
||||
{'class':lambda x: x and 'also-read' in x.split()},
|
||||
{'class':lambda x: x and 'partners-content' in x.split()},
|
||||
{'class':['module share', 'module ads', 'comment-vars', 'hidden',
|
||||
'share-icons-wrap', 'comments', 'flipper']},
|
||||
{'id':['right-rail', 'save-and-share']},
|
||||
{'width':'1', 'height':'1'},
|
||||
|
||||
]
|
||||
|
||||
keep_only_tags = dict(id=['content', 'article'])
|
||||
|
||||
def get_article_url(self, *args):
|
||||
ans = BasicNewsRecipe.get_article_url(self, *args)
|
||||
ans = ans.rpartition('?')[0]
|
||||
if ans.endswith('_video.html'):
|
||||
return None
|
||||
if 'ads.pheedo.com' in ans:
|
||||
return None
|
||||
#if not ans.endswith('_blog.html'):
|
||||
# return None
|
||||
return ans
|
||||
|
||||
(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):
|
||||
return url.replace('_story.html', '_singlePage.html')
|
||||
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 not 'washingtonpost.com' in link:
|
||||
self.log('Skipping adds:', 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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user