Creation of custom news sources failing. Fixes #1363666 [Can't add news recipe](https://bugs.launchpad.net/calibre/+bug/1363666)

This commit is contained in:
Kovid Goyal 2014-08-31 20:24:03 +05:30
parent 680f599f32
commit db3ab1d874

View File

@ -120,7 +120,7 @@ def get_custom_recipe_collection(*args):
def update_custom_recipe(id_, title, script): def update_custom_recipe(id_, title, script):
update_custom_recipes( [(id_, title, script)] ) update_custom_recipes([(id_, title, script)])
def update_custom_recipes(script_ids): def update_custom_recipes(script_ids):
from calibre.web.feeds.recipes import custom_recipes, \ from calibre.web.feeds.recipes import custom_recipes, \
@ -141,6 +141,9 @@ def update_custom_recipes(script_ids):
custom_recipes[id_] = (title, fname) custom_recipes[id_] = (title, fname)
if not os.path.exists(bdir):
os.makedirs(bdir)
with open(os.path.join(bdir, fname), 'wb') as f: with open(os.path.join(bdir, fname), 'wb') as f:
f.write(script) f.write(script)
@ -166,6 +169,9 @@ def add_custom_recipes(script_map):
custom_recipes[fid] = (title, fname) custom_recipes[fid] = (title, fname)
if not os.path.exists(bdir):
os.makedirs(bdir)
with open(os.path.join(bdir, fname), 'wb') as f: with open(os.path.join(bdir, fname), 'wb') as f:
f.write(script) f.write(script)
id_ += 1 id_ += 1
@ -538,4 +544,3 @@ class SchedulerConfig(object):
recipe = {'id':urn, 'title':r['title']} recipe = {'id':urn, 'title':r['title']}
self.schedule_recipe(recipe, typ, schedule, self.schedule_recipe(recipe, typ, schedule,
last_downloaded=r['last_downloaded']) last_downloaded=r['last_downloaded'])