From 20f608294daa00bf2f62c8caa1542c2cf307d4d6 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 7 Oct 2008 17:49:34 -0700 Subject: [PATCH] Added recipe for The Guardian --- src/calibre/utils/config.py | 5 ++- src/calibre/web/feeds/recipes/__init__.py | 2 +- src/calibre/web/feeds/recipes/guardian.py | 39 +++++++++++++++++++++++ 3 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 src/calibre/web/feeds/recipes/guardian.py diff --git a/src/calibre/utils/config.py b/src/calibre/utils/config.py index cd5944d3c4..190c1ff37c 100644 --- a/src/calibre/utils/config.py +++ b/src/calibre/utils/config.py @@ -479,7 +479,10 @@ class DynamicConfig(dict): if os.path.exists(self.file_path): with ExclusiveFile(self.file_path) as f: raw = f.read() - d = cPickle.loads(raw) if raw.strip() else {} + try: + d = cPickle.loads(raw) if raw.strip() else {} + except: + d = {} dict.__init__(self, d) def __getitem__(self, key): diff --git a/src/calibre/web/feeds/recipes/__init__.py b/src/calibre/web/feeds/recipes/__init__.py index 375996bf37..5eddc410fe 100644 --- a/src/calibre/web/feeds/recipes/__init__.py +++ b/src/calibre/web/feeds/recipes/__init__.py @@ -10,7 +10,7 @@ recipes = [ 'wired', 'globe_and_mail', 'smh', 'espn', 'business_week', 'ars_technica', 'upi', 'new_yorker', 'irish_times', 'iht', 'discover_magazine', 'scientific_american', 'new_york_review_of_books', - 'daily_telegraph', + 'daily_telegraph', 'guardian', ] import re, imp, inspect, time, os diff --git a/src/calibre/web/feeds/recipes/guardian.py b/src/calibre/web/feeds/recipes/guardian.py new file mode 100644 index 0000000000..3fccd7c328 --- /dev/null +++ b/src/calibre/web/feeds/recipes/guardian.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python +__license__ = 'GPL v3' +__copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net' +__docformat__ = 'restructuredtext en' + +''' +www.guardian.co.uk +''' + +from calibre.web.feeds.news import BasicNewsRecipe + +class Guardian(BasicNewsRecipe): + + title = u'The Guardian' + __author__ = 'Seabound' + oldest_article = 7 + max_articles_per_feed = 20 + + timefmt = ' [%a, %d %b %Y]' + + remove_tags_before = dict(id='main-article-info') + remove_tags_after = dict(id='article-wrapper') + remove_tags_after = dict(id='content') + no_stylesheets = True + extra_css = 'h2 {font-size: medium;} \n h1 {text-align: left;}' + + feeds = [ + + ('Front Page', 'http://www.guardian.co.uk/rss'), + ('Business', 'http://www.guardian.co.uk/business/rss'), + ('Sport', 'http://www.guardian.co.uk/sport/rss'), + ('Culture', 'http://www.guardian.co.uk/culture/rss'), + ('Money', 'http://www.guardian.co.uk/money/rss'), + ('Life & Style', 'http://www.guardian.co.uk/lifeandstyle/rss'), + ('Travel', 'http://www.guardian.co.uk/travel/rss'), + ('Environment', 'http://www.guardian.co.uk/environment/rss'), + ('Comment','http://www.guardian.co.uk/commentisfree/rss'), + ] + \ No newline at end of file