From f3635ab09c896470f1262dd306028816e305f4b1 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 3 Aug 2009 13:57:42 -0600 Subject: [PATCH] Fix downloading of news that has non-English characters in its title on windows. Fixes #3005 (RSS Fetching from zaobao.com still fail) --- src/calibre/ebooks/conversion/plumber.py | 3 +++ src/calibre/web/feeds/input.py | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/calibre/ebooks/conversion/plumber.py b/src/calibre/ebooks/conversion/plumber.py index 8df5689983..a2b00e1998 100644 --- a/src/calibre/ebooks/conversion/plumber.py +++ b/src/calibre/ebooks/conversion/plumber.py @@ -51,6 +51,7 @@ class Plumber(object): :param input: Path to input file. :param output: Path to output file/directory ''' + self.original_input_arg = input self.input = os.path.abspath(input) self.output = os.path.abspath(output) self.log = log @@ -636,6 +637,8 @@ OptionRecommendation(name='language', tdir = PersistentTemporaryDirectory('_plumber') stream = self.input if self.input_fmt == 'recipe' else \ open(self.input, 'rb') + if self.input_fmt == 'recipe': + self.opts.original_recipe_input_arg = self.original_input_arg if hasattr(self.opts, 'lrf') and self.output_plugin.file_type == 'lrf': self.opts.lrf = True diff --git a/src/calibre/web/feeds/input.py b/src/calibre/web/feeds/input.py index 6078efe883..39f7be154f 100644 --- a/src/calibre/web/feeds/input.py +++ b/src/calibre/web/feeds/input.py @@ -48,11 +48,12 @@ class RecipeInput(InputFormatPlugin): if os.access(recipe_or_file, os.R_OK): recipe = compile_recipe(open(recipe_or_file, 'rb').read()) else: - title = os.path.basename(recipe_or_file).rpartition('.')[0] + title = getattr(opts, 'original_recipe_input_arg', recipe_or_file) + title = os.path.basename(title).rpartition('.')[0] recipe = get_builtin_recipe(title) if recipe is None: - raise ValueError('%s is not a valid recipe file or builtin recipe' % + raise ValueError('%r is not a valid recipe file or builtin recipe' % recipe_or_file) ro = recipe(opts, log, self.report_progress)