mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-01 04:10:06 -05:00
added servings to url import
This commit is contained in:
@@ -217,10 +217,18 @@ def find_recipe_json(ld_json, url):
|
||||
else:
|
||||
ld_json['prepTime'] = 0
|
||||
|
||||
try:
|
||||
if 'recipeYield' in ld_json:
|
||||
if type(ld_json['recipeYield']) == str:
|
||||
ld_json['servings'] = int(re.findall(r'\b\d+\b', ld_json['recipeYield'])[0])
|
||||
except Exception as e:
|
||||
print(e)
|
||||
ld_json['servings'] = 0
|
||||
|
||||
for key in list(ld_json):
|
||||
if key not in [
|
||||
'prepTime', 'cookTime', 'image', 'recipeInstructions',
|
||||
'keywords', 'name', 'recipeIngredient'
|
||||
'keywords', 'name', 'recipeIngredient', 'servings'
|
||||
]:
|
||||
ld_json.pop(key, None)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user