When downloading latest version of recipe fallback to builtin one if recipe cannot be compiled

This commit is contained in:
Kovid Goyal 2018-09-11 12:27:41 +05:30
parent 57f3db82e0
commit 08a8f41471
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 5 additions and 2 deletions

View File

@ -79,7 +79,7 @@ class RecipeInput(InputFormatPlugin):
if rtype == 'custom':
self.recipe_source = get_custom_recipe(recipe_id)
else:
self.recipe_source = get_builtin_recipe_by_id(urn)
self.recipe_source = get_builtin_recipe_by_id(urn, log=log, download_recipe=True)
if not self.recipe_source:
raise ValueError('Could not find recipe with urn: ' + urn)
if not isinstance(self.recipe_source, bytes):

View File

@ -218,8 +218,11 @@ def download_builtin_recipe(urn):
from calibre.utils.config_base import prefs
from calibre.utils.https import get_https_resource_securely
import bz2
return bz2.decompress(get_https_resource_securely(
recipe_source = bz2.decompress(get_https_resource_securely(
'https://code.calibre-ebook.com/recipe-compressed/'+urn, headers={'CALIBRE-INSTALL-UUID':prefs['installation_uuid']}))
from calibre.web.feeds.recipes import compile_recipe
compile_recipe(recipe_source) # ensure the downloaded recipe is at least compile-able
return recipe_source
def get_builtin_recipe(urn):