From fe7876189cf792cb80bc1de3989635dba5e1e42b Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 25 May 2009 20:31:00 -0700 Subject: [PATCH] Updated recipe for The New Yorker --- .../web/feeds/recipes/recipe_new_yorker.py | 50 ++++++++++--------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/src/calibre/web/feeds/recipes/recipe_new_yorker.py b/src/calibre/web/feeds/recipes/recipe_new_yorker.py index 3ebc275d99..a3c01df8e9 100644 --- a/src/calibre/web/feeds/recipes/recipe_new_yorker.py +++ b/src/calibre/web/feeds/recipes/recipe_new_yorker.py @@ -1,53 +1,57 @@ #!/usr/bin/env python __license__ = 'GPL v3' -__copyright__ = '2008, Darko Miletic ' +__copyright__ = '2008-2009, Darko Miletic ' ''' newyorker.com ''' from calibre.web.feeds.news import BasicNewsRecipe +from calibre.ebooks.BeautifulSoup import BeautifulSoup, Tag class NewYorker(BasicNewsRecipe): - - title = u'The New Yorker' + title = 'The New Yorker' __author__ = 'Darko Miletic' - description = 'The best of US journalism' + description = 'The best of US journalism' oldest_article = 7 language = _('English') max_articles_per_feed = 100 - no_stylesheets = False + no_stylesheets = True use_embedded_content = False - extra_css = ''' - .calibre_feed_list {font-size:xx-small} - .calibre_article_list {font-size:xx-small} - .calibre_feed_title {font-size:normal} - .calibre_recipe_title {font-size:normal} - .calibre_feed_description {font-size:xx-small} - ''' + publisher = 'Conde Nast Publications' + category = 'news, politics, USA' + encoding = 'cp1252' + + html2lrf_options = [ + '--comment', description + , '--category', category + , '--publisher', publisher + ] + + html2epub_options = 'publisher="' + publisher + '"\ncomments="' + description + '"\ntags="' + category + '"' - - keep_only_tags = [ - dict(name='div' , attrs={'id':'printbody' }) - ] + keep_only_tags = [dict(name='div', attrs={'id':'printbody'})] + remove_tags_after = dict(name='div',attrs={'id':'articlebody'}) remove_tags = [ - dict(name='div' , attrs={'class':'utils' }) - ,dict(name='div' , attrs={'id':'bottomFeatures' }) - ,dict(name='div' , attrs={'id':'articleBottom' }) + dict(name='div', attrs={'class':['utils','articleRailLinks','icons'] }) + ,dict(name='link') ] - feeds = [ - (u'The New Yorker', u'http://feeds.newyorker.com/services/rss/feeds/everything.xml') - ] + feeds = [(u'The New Yorker', u'http://feeds.newyorker.com/services/rss/feeds/everything.xml')] def print_version(self, url): return url + '?printable=true' + def get_article_url(self, article): + return article.get('guid', None) + def postprocess_html(self, soup, x): body = soup.find('body') if body: html = soup.find('html') if html: body.extract() - html.insert(-1, body) + html.insert(2, body) + mcharset = Tag(soup,'meta',[("http-equiv","Content-Type"),("content","text/html; charset=utf-8")]) + soup.head.insert(1,mcharset) return soup