diff --git a/resources/recipes/harpers_full.recipe b/resources/recipes/harpers_full.recipe index 15408f268e..ff558e9c5b 100644 --- a/resources/recipes/harpers_full.recipe +++ b/resources/recipes/harpers_full.recipe @@ -1,7 +1,5 @@ -#!/usr/bin/env python - __license__ = 'GPL v3' -__copyright__ = '2008-2009, Darko Miletic ' +__copyright__ = '2008-2010, Darko Miletic ' ''' harpers.org - paid subscription/ printed issue articles This recipe only get's article's published in text format @@ -10,39 +8,40 @@ 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 max_articles_per_feed = 100 no_stylesheets = True use_embedded_content = False - delay = 1 - language = 'en' + 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} ' - needs_subscription = True - 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') - - 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 diff --git a/resources/recipes/lemonde_dip.recipe b/resources/recipes/lemonde_dip.recipe index fa20e43aa2..a5fa97c22e 100644 --- a/resources/recipes/lemonde_dip.recipe +++ b/resources/recipes/lemonde_dip.recipe @@ -1,7 +1,5 @@ -#!/usr/bin/env python - __license__ = 'GPL v3' -__copyright__ = '2008-2009, Darko Miletic ' +__copyright__ = '2008-2010, Darko Miletic ' ''' 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): diff --git a/src/calibre/web/feeds/__init__.py b/src/calibre/web/feeds/__init__.py index 2d22ddd3a3..c633e3b62b 100644 --- a/src/calibre/web/feeds/__init__.py +++ b/src/calibre/web/feeds/__init__.py @@ -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) diff --git a/src/calibre/web/feeds/news.py b/src/calibre/web/feeds/news.py index f97298c9bb..36260b2535 100644 --- a/src/calibre/web/feeds/news.py +++ b/src/calibre/web/feeds/news.py @@ -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)