diff --git a/src/calibre/constants.py b/src/calibre/constants.py index 012ac856d2..b02f92bc17 100644 --- a/src/calibre/constants.py +++ b/src/calibre/constants.py @@ -2,7 +2,7 @@ __license__ = 'GPL v3' __copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net' __docformat__ = 'restructuredtext en' __appname__ = 'calibre' -__version__ = '0.6.0b11' +__version__ = '0.6.0b12' __author__ = "Kovid Goyal " import re diff --git a/src/calibre/customize/conversion.py b/src/calibre/customize/conversion.py index 4d19ba4fad..4f2b279f85 100644 --- a/src/calibre/customize/conversion.py +++ b/src/calibre/customize/conversion.py @@ -228,6 +228,8 @@ class InputFormatPlugin(Plugin): return ret + def postprocess_book(self, oeb, opts, log): + pass class OutputFormatPlugin(Plugin): ''' diff --git a/src/calibre/ebooks/conversion/plumber.py b/src/calibre/ebooks/conversion/plumber.py index 3c52ec2d7b..39170c69b5 100644 --- a/src/calibre/ebooks/conversion/plumber.py +++ b/src/calibre/ebooks/conversion/plumber.py @@ -14,7 +14,6 @@ from calibre.ptempfile import PersistentTemporaryDirectory from calibre import extract, walk def supported_input_formats(): - from calibre.customize.ui import available_input_formats fmts = available_input_formats() for x in ('zip', 'rar', 'oebzip'): fmts.add(x) @@ -333,7 +332,7 @@ OptionRecommendation(name='remove_footer', help=_('Use a regular expression to try and remove the footer.' ) ), - + OptionRecommendation(name='footer_regex', recommended_value='(?i)(?<=
)((\s*(()*
\s*)?\d+
\s*.*?\s*)|(\s*(()*
\s*)?.*?
\s*\d+))(?=
)', level=OptionRecommendation.LOW, @@ -643,6 +642,7 @@ OptionRecommendation(name='list_recipes', if not hasattr(self.oeb, 'manifest'): self.oeb = create_oebbook(self.log, self.oeb, self.opts, self.input_plugin) + self.input_plugin.postprocess_book(self.oeb, self.opts, self.log) pr = CompositeProgressReporter(0.34, 0.67, self.ui_reporter) self.flush() pr(0., _('Running transforms on ebook...')) diff --git a/src/calibre/web/feeds/input.py b/src/calibre/web/feeds/input.py index 3052ffebed..6078efe883 100644 --- a/src/calibre/web/feeds/input.py +++ b/src/calibre/web/feeds/input.py @@ -57,6 +57,7 @@ class RecipeInput(InputFormatPlugin): ro = recipe(opts, log, self.report_progress) ro.download() + self.recipe_object = ro for key, val in recipe.conversion_options.items(): setattr(opts, key, val) @@ -66,6 +67,6 @@ class RecipeInput(InputFormatPlugin): if f.endswith('.opf'): return os.path.abspath(f) - - + def postprocess_book(self, oeb, opts, log): + self.recipe_object.postprocess_book(oeb, opts, log) diff --git a/src/calibre/web/feeds/news.py b/src/calibre/web/feeds/news.py index 2bf9d04ca6..6ca0f8318f 100644 --- a/src/calibre/web/feeds/news.py +++ b/src/calibre/web/feeds/news.py @@ -451,6 +451,15 @@ class BasicNewsRecipe(Recipe): ''' raise NotImplementedError + def postprocess_book(self, oeb, opts, log): + ''' + Run any needed post processing on the parsed downloaded e-book. + + :param oeb: An OEBBook object + :param opts: Conversion options + ''' + pass + def __init__(self, options, log, progress_reporter): ''' Initialize the recipe. @@ -959,13 +968,13 @@ class BasicNewsRecipe(Recipe): a = request.requestID[1] article = request.article - self.log.debug(_('\nDownloaded article %s from %s')%(article.title, article.url)) + self.log.debug(_(u'\nDownloaded article %s from %s')%(article.title, article.url)) article.orig_url = article.url article.url = 'article_%d/index.html'%a article.downloaded = True article.sub_pages = result[1][1:] self.jobs_done += 1 - self.report_progress(float(self.jobs_done)/len(self.jobs), _('Article downloaded: %s')%article.title) + self.report_progress(float(self.jobs_done)/len(self.jobs), _(u'Article downloaded: %s')%article.title) if result[2]: self.partial_failures.append((request.feed.title, article.title, article.url, result[2]))