Add framework to disable builtin recipes and disable Aftenposten, at the publishers request

This commit is contained in:
Kovid Goyal 2009-12-29 09:04:28 -07:00
parent 369fbc48db
commit 176d9728d7
5 changed files with 25 additions and 2 deletions

View File

@ -7,6 +7,9 @@ class Aftenposten(BasicNewsRecipe):
language = 'no' language = 'no'
oldest_article = 5 oldest_article = 5
max_articles_per_feed = 100 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 no_stylesheets = True
encoding = 'ISO-8859-1' encoding = 'ISO-8859-1'

View File

@ -3,7 +3,7 @@ from calibre.web.feeds.news import BasicNewsRecipe
class Independent(BasicNewsRecipe): class Independent(BasicNewsRecipe):
title = u'The Independent' title = u'The Independent'
oldest_article = 1 oldest_article = 1
language = 'en_UK' language = 'en_GB'
__author__ = 'Jimmy Patrick' __author__ = 'Jimmy Patrick'
max_articles_per_feed = 100 max_articles_per_feed = 100

View File

@ -1736,6 +1736,16 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
d.show() d.show()
self._modeless_dialogs.append(d) self._modeless_dialogs.append(d)
return 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'),
'<p>%s</p>'%msg)
d.setModal(False)
d.show()
self._modeless_dialogs.append(d)
return
except: except:
pass pass
if job.killed: if job.killed:

View File

@ -11,6 +11,9 @@ import os
from calibre.customize.conversion import InputFormatPlugin, OptionRecommendation from calibre.customize.conversion import InputFormatPlugin, OptionRecommendation
from calibre.constants import numeric_version from calibre.constants import numeric_version
class RecipeDisabled(Exception):
pass
class RecipeInput(InputFormatPlugin): class RecipeInput(InputFormatPlugin):
name = 'Recipe Input' name = 'Recipe Input'
@ -83,6 +86,9 @@ class RecipeInput(InputFormatPlugin):
recipe_or_file) recipe_or_file)
ro = recipe(opts, log, self.report_progress) ro = recipe(opts, log, self.report_progress)
disabled = getattr(ro, 'recipe_disabled', None)
if disabled is not None:
raise RecipeDisabled(disabled)
ro.download() ro.download()
self.recipe_object = ro self.recipe_object = ro
for key, val in recipe.conversion_options.items(): for key, val in recipe.conversion_options.items():

View File

@ -272,6 +272,10 @@ class BasicNewsRecipe(Recipe):
} }
''' '''
#: 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. # See the built-in profiles for examples of these settings.