def get_custom_recipe(id_): from calibre.web.feeds.recipes import custom_recipes id_ = str(int(id_)) existing = custom_recipes.get(id_, None) if existing is not None: bdir = os.path.dirname(custom_recipes.file_path) fname = existing[1] with open(os.path.join(bdir, fname), 'rb') as f: return f.read().decode('utf-8')
def get_custom_recipe(id_): from calibre.web.feeds.recipes import custom_recipes id_ = str(int(id_)) existing = custom_recipes.get(id_, None) if existing is not None: bdir = os.path.dirname(custom_recipes.file_path) fname = existing[1] with open(os.path.join(bdir, fname), 'rb') as f: return f.read().decode('utf-8')
def remove_custom_recipe(id_): from calibre.web.feeds.recipes import custom_recipes id_ = str(int(id_)) existing = custom_recipes.get(id_, None) if existing is not None: bdir = os.path.dirname(custom_recipes.file_path) fname = existing[1] del custom_recipes[id_] try: delete_file(os.path.join(bdir, fname)) except: pass
def remove_custom_recipe(id_): from calibre.web.feeds.recipes import custom_recipes id_ = str(int(id_)) existing = custom_recipes.get(id_, None) if existing is not None: bdir = os.path.dirname(custom_recipes.file_path) fname = existing[1] del custom_recipes[id_] try: os.remove(os.path.join(bdir, fname)) except: pass
def update_custom_recipe(id_, title, script): from calibre.web.feeds.recipes import custom_recipes, \ custom_recipe_filename id_ = str(int(id_)) existing = custom_recipes.get(id_, None) bdir = os.path.dirname(custom_recipes.file_path) if existing is None: fname = custom_recipe_filename(id_, title) else: fname = existing[1] if isinstance(script, unicode): script = script.encode('utf-8') custom_recipes[id_] = (title, fname) with open(os.path.join(bdir, fname), 'wb') as f: f.write(script)
def update_custom_recipes(script_ids): from calibre.web.feeds.recipes import custom_recipes, \ custom_recipe_filename bdir = os.path.dirname(custom_recipes.file_path) for id_, title, script in script_ids: id_ = unicode_type(int(id_)) existing = custom_recipes.get(id_, None) if existing is None: fname = custom_recipe_filename(id_, title) else: fname = existing[1] if isinstance(script, unicode_type): script = script.encode('utf-8') custom_recipes[id_] = (title, fname) if not os.path.exists(bdir): os.makedirs(bdir) with open(os.path.join(bdir, fname), 'wb') as f: f.write(script)
def update_custom_recipes(script_ids): from calibre.web.feeds.recipes import custom_recipes, \ custom_recipe_filename bdir = os.path.dirname(custom_recipes.file_path) for id_, title, script in script_ids: id_ = unicode_type(int(id_)) existing = custom_recipes.get(id_, None) if existing is None: fname = custom_recipe_filename(id_, title) else: fname = existing[1] if isinstance(script, unicode_type): script = script.encode('utf-8') custom_recipes[id_] = (title, fname) if not os.path.exists(bdir): os.makedirs(bdir) with open(os.path.join(bdir, fname), 'wb') as f: f.write(script)