improved recipe import

This commit is contained in:
vabene1111
2020-06-24 20:21:48 +02:00
parent 525ad6dd98
commit b6d98397b5
2 changed files with 1585 additions and 1 deletions

View File

@@ -96,7 +96,16 @@ def find_recipe_json(ld_json, url):
if type(i) == str:
instructions += i
else:
instructions += i['text'] + '\n\n'
if 'text' in i:
instructions += i['text'] + '\n\n'
elif 'itemListElement' in i:
for ile in i['itemListElement']:
if type(ile) == str:
instructions += ile + '\n\n'
elif 'text' in ile:
instructions += ile['text'] + '\n\n'
else:
instructions += str(i)
ld_json['recipeInstructions'] = instructions
ld_json['recipeInstructions'] = re.sub(r'\n\s*\n', '\n\n', ld_json['recipeInstructions'])