fix URL import when recipeYield is a list

This commit is contained in:
smilerz
2021-02-24 17:52:40 -06:00
parent c60c3f1876
commit cc62b088fd

View File

@@ -222,6 +222,8 @@ def find_recipe_json(ld_json, url):
if 'recipeYield' in ld_json: if 'recipeYield' in ld_json:
if type(ld_json['recipeYield']) == str: if type(ld_json['recipeYield']) == str:
ld_json['servings'] = int(re.findall(r'\b\d+\b', ld_json['recipeYield'])[0]) 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: except Exception as e:
print(e) print(e)
ld_json['servings'] = 1 ld_json['servings'] = 1