From 176d9728d7a99e6c6fed0d69e6b9952f4a5a24ec Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 29 Dec 2009 09:04:28 -0700 Subject: [PATCH] Add framework to disable builtin recipes and disable Aftenposten, at the publishers request --- resources/recipes/aftenposten.recipe | 3 +++ resources/recipes/independent.recipe | 2 +- src/calibre/gui2/ui.py | 10 ++++++++++ src/calibre/web/feeds/input.py | 6 ++++++ src/calibre/web/feeds/news.py | 6 +++++- 5 files changed, 25 insertions(+), 2 deletions(-) diff --git a/resources/recipes/aftenposten.recipe b/resources/recipes/aftenposten.recipe index 304c7c0e02..fcc73658e9 100644 --- a/resources/recipes/aftenposten.recipe +++ b/resources/recipes/aftenposten.recipe @@ -7,6 +7,9 @@ class Aftenposten(BasicNewsRecipe): language = 'no' oldest_article = 5 max_articles_per_feed = 100 + recipe_disabled = ('The recipe to download Aftenposten has been ' + 'temporarily disabled at the publisher\'s request, while ' + 'they finalize their digital strategy.') no_stylesheets = True encoding = 'ISO-8859-1' diff --git a/resources/recipes/independent.recipe b/resources/recipes/independent.recipe index d964fe39d0..4d677b58a6 100644 --- a/resources/recipes/independent.recipe +++ b/resources/recipes/independent.recipe @@ -3,7 +3,7 @@ from calibre.web.feeds.news import BasicNewsRecipe class Independent(BasicNewsRecipe): title = u'The Independent' oldest_article = 1 - language = 'en_UK' + language = 'en_GB' __author__ = 'Jimmy Patrick' max_articles_per_feed = 100 diff --git a/src/calibre/gui2/ui.py b/src/calibre/gui2/ui.py index 4e30c0fab5..b847186c2a 100644 --- a/src/calibre/gui2/ui.py +++ b/src/calibre/gui2/ui.py @@ -1736,6 +1736,16 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI): d.show() self._modeless_dialogs.append(d) return + if 'calibre.web.feeds.input.RecipeDisabled' in job.details: + msg = job.details + msg = msg[msg.find('calibre.web.feeds.input.RecipeDisabled:'):] + msg = msg.partition(':')[-1] + d = error_dialog(self, _('Recipe Disabled'), + '

%s

'%msg) + d.setModal(False) + d.show() + self._modeless_dialogs.append(d) + return except: pass if job.killed: diff --git a/src/calibre/web/feeds/input.py b/src/calibre/web/feeds/input.py index 4f7fa64869..5015c1bef2 100644 --- a/src/calibre/web/feeds/input.py +++ b/src/calibre/web/feeds/input.py @@ -11,6 +11,9 @@ import os from calibre.customize.conversion import InputFormatPlugin, OptionRecommendation from calibre.constants import numeric_version +class RecipeDisabled(Exception): + pass + class RecipeInput(InputFormatPlugin): name = 'Recipe Input' @@ -83,6 +86,9 @@ class RecipeInput(InputFormatPlugin): recipe_or_file) ro = recipe(opts, log, self.report_progress) + disabled = getattr(ro, 'recipe_disabled', None) + if disabled is not None: + raise RecipeDisabled(disabled) ro.download() self.recipe_object = ro for key, val in recipe.conversion_options.items(): diff --git a/src/calibre/web/feeds/news.py b/src/calibre/web/feeds/news.py index bac0023688..789710d764 100644 --- a/src/calibre/web/feeds/news.py +++ b/src/calibre/web/feeds/news.py @@ -270,7 +270,11 @@ class BasicNewsRecipe(Recipe): .navbar { font-family:monospace; } -''' + ''' + + #: Set to a non empty string to disable this recipe + #: The string will be used as the disabled message + recipe_disabled = None # See the built-in profiles for examples of these settings.