mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-01 04:10:06 -05:00
Merge branch 'develop' into feature/spaces
# Conflicts: # cookbook/views/data.py # cookbook/views/views.py
This commit is contained in:
@@ -69,8 +69,10 @@ def find_recipe_json(ld_json, url, space):
|
||||
if 'recipeIngredient' in ld_json:
|
||||
# some pages have comma separated ingredients in a single array entry
|
||||
if (len(ld_json['recipeIngredient']) == 1
|
||||
and len(ld_json['recipeIngredient'][0]) > 30):
|
||||
and type(ld_json['recipeIngredient']) == list):
|
||||
ld_json['recipeIngredient'] = ld_json['recipeIngredient'][0].split(',') # noqa: E501
|
||||
elif type(ld_json['recipeIngredient']) == str:
|
||||
ld_json['recipeIngredient'] = ld_json['recipeIngredient'].split(',')
|
||||
|
||||
for x in ld_json['recipeIngredient']:
|
||||
if '\n' in x:
|
||||
@@ -218,13 +220,15 @@ def find_recipe_json(ld_json, url, space):
|
||||
else:
|
||||
ld_json['prepTime'] = 0
|
||||
|
||||
ld_json['servings'] = 1
|
||||
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])
|
||||
elif type(ld_json['recipeYield']) == list:
|
||||
ld_json['servings'] = int(re.findall(r'\b\d+\b', ld_json['recipeYield'][0])[0])
|
||||
except Exception as e:
|
||||
print(e)
|
||||
ld_json['servings'] = 1
|
||||
|
||||
for key in list(ld_json):
|
||||
if key not in [
|
||||
|
||||
Reference in New Issue
Block a user