Updated Harpers and Le Monde Diplomatique. Fixes #5205 (Updated recipes for Le monde diplomatique and Harper's)

This commit is contained in:
Kovid Goyal 2010-04-01 23:12:38 +05:30
parent 4d5804c0ba
commit 86a24dd1c3
4 changed files with 35 additions and 35 deletions

View File

@ -1,7 +1,5 @@
#!/usr/bin/env python
__license__ = 'GPL v3'
__copyright__ = '2008-2009, Darko Miletic <darko.miletic at gmail.com>'
__copyright__ = '2008-2010, Darko Miletic <darko.miletic at gmail.com>'
'''
harpers.org - paid subscription/ printed issue articles
This recipe only get's article's published in text format
@ -10,12 +8,11 @@ images and pdf's are ignored
from calibre import strftime
from calibre.web.feeds.news import BasicNewsRecipe
from calibre.ebooks.BeautifulSoup import Tag
class Harpers_full(BasicNewsRecipe):
title = u"Harper's Magazine - articles from printed edition"
__author__ = u'Darko Miletic'
description = u"Harper's Magazine: Founded June 1850."
title = "Harper's Magazine - articles from printed edition"
__author__ = 'Darko Miletic'
description = "Harper's Magazine: Founded June 1850."
publisher = "Harpers's"
category = 'news, politics, USA'
oldest_article = 30
@ -24,25 +21,27 @@ class Harpers_full(BasicNewsRecipe):
use_embedded_content = False
delay = 1
language = 'en'
needs_subscription = True
masthead_url = 'http://www.harpers.org/media/image/Harpers_305x100.gif'
publication_type = 'magazine'
INDEX = strftime('http://www.harpers.org/archive/%Y/%m')
LOGIN = 'http://www.harpers.org'
cover_url = strftime('http://www.harpers.org/media/pages/%Y/%m/gif/0001.gif')
extra_css = ' body{font-family: "Georgia",serif} '
html2lrf_options = [
'--comment', description
, '--category', category
, '--publisher', publisher
]
html2epub_options = 'publisher="' + publisher + '"\ncomments="' + description + '"\ntags="' + category + '"\noverride_css=" p {text-indent: 0em; margin-top: 0em; margin-bottom: 0.5em} img {margin-top: 0em; margin-bottom: 0.4em}"'
conversion_options = {
'comment' : description
, 'tags' : category
, 'publisher' : publisher
, 'language' : language
}
keep_only_tags = [ dict(name='div', attrs={'id':'cached'}) ]
remove_tags = [
dict(name='table', attrs={'class':['rcnt','rcnt topline']})
,dict(name='link')
]
remove_attributes=['xmlns']
def get_browser(self):
br = BasicNewsRecipe.get_browser()
@ -71,12 +70,3 @@ class Harpers_full(BasicNewsRecipe):
,'description':''
})
return [(soup.head.title.string, articles)]
def preprocess_html(self, soup):
mcharset = Tag(soup,'meta',[("http-equiv","Content-Type"),("content","text/html; charset=utf-8")])
soup.head.insert(1,mcharset)
for item in soup.findAll(style=True):
del item['style']
for item in soup.findAll(xmlns=True):
del item['xmlns']
return soup

View File

@ -1,7 +1,5 @@
#!/usr/bin/env python
__license__ = 'GPL v3'
__copyright__ = '2008-2009, Darko Miletic <darko.miletic at gmail.com>'
__copyright__ = '2008-2010, Darko Miletic <darko.miletic at gmail.com>'
'''
mondediplo.com
'''
@ -21,11 +19,14 @@ class LeMondeDiplomatiqueEn(BasicNewsRecipe):
delay = 1
encoding = 'utf-8'
needs_subscription = True
masthead_url = 'http://mondediplo.com/squelettes/pics/logo-30.gif'
publication_type = 'magazine'
PREFIX = 'http://mondediplo.com/'
LOGIN = PREFIX + '2009/09/02congo'
INDEX = PREFIX + strftime('%Y/%m/')
use_embedded_content = False
language = 'en'
extra_css = ' body{font-family: "Luxi sans","Lucida sans","Lucida Grande",Lucida,"Lucida Sans Unicode",sans-serif} .surtitre{font-size: 1.2em; font-variant: small-caps; margin-bottom: 0.5em} .chapo{font-size: 1.2em; font-weight: bold; margin: 1em 0 0.5em} .texte{font-family: Georgia,"Times New Roman",serif} h1{color: #990000} .notes{border-top: 1px solid #CCCCCC; font-size: 0.9em; line-height: 1.4em} '
conversion_options = {
'comment' : description
@ -45,7 +46,10 @@ class LeMondeDiplomatiqueEn(BasicNewsRecipe):
br.open(self.LOGIN,data)
return br
keep_only_tags =[dict(name='div', attrs={'id':'contenu'})]
keep_only_tags =[
dict(name='div', attrs={'id':'contenu'})
, dict(name='div',attrs={'class':'notes surlignable'})
]
remove_tags = [dict(name=['object','link','script','iframe','base'])]
def parse_index(self):

View File

@ -193,6 +193,9 @@ class Feed(object):
title = title.decode('utf-8', 'replace')
self.logger.debug('Skipping article %s as it is too old'%title)
def reverse(self):
self.articles.reverse()
def __iter__(self):
return iter(self.articles)

View File

@ -801,7 +801,10 @@ class BasicNewsRecipe(Recipe):
self.jobs = []
if self.reverse_article_order:
feeds = [list(reversed(list(feed))) for feed in feeds]
for feed in feeds:
if hasattr(feed, 'reverse'):
print 111111
feed.reverse()
for f, feed in enumerate(feeds):
feed_dir = os.path.join(self.output_dir, 'feed_%d'%f)