add rudimentary support for recipe sections
This commit is contained in:
parent
798f81f01f
commit
669914c0c6
3 changed files with 19 additions and 2 deletions
|
@ -18,7 +18,7 @@ If you print the recipe, shows with minimal formatting:
|
|||
Deploy
|
||||
------
|
||||
|
||||
gcloud app deploy --account=gargoylemusic@gmail.com --project=plainoldrecipe
|
||||
Run deploy.sh
|
||||
|
||||
Acknowledgements
|
||||
----------------
|
||||
|
|
3
deploy.sh
Executable file
3
deploy.sh
Executable file
|
@ -0,0 +1,3 @@
|
|||
#!/bin/bash
|
||||
|
||||
gcloud app deploy --account=gargoylemusic@gmail.com --project=plainoldrecipe
|
|
@ -43,7 +43,21 @@ class WpJsonRecipe(Recipe):
|
|||
recipe['name'] = r['name']
|
||||
recipe['description'] = r['description']
|
||||
recipe['ingredients'] = r['recipeIngredient']
|
||||
recipe['instructions'] = [i['text'] for i in r['recipeInstructions']]
|
||||
|
||||
instructions = []
|
||||
|
||||
if len(r.get('recipeInstructions', [])) > 0:
|
||||
if 'text' in r['recipeInstructions'][0]:
|
||||
instructions = [i['text'] for i in r['recipeInstructions']]
|
||||
else:
|
||||
print(r['recipeInstructions'][0])
|
||||
for how_to_section in r['recipeInstructions']:
|
||||
for instruction in how_to_section.get('itemListElement', []):
|
||||
if instruction.get('@type') == 'HowToStep':
|
||||
instructions.append(instruction['text'].replace(' ', ''))
|
||||
|
||||
recipe['instructions'] = instructions
|
||||
|
||||
recipe['image'] = r['image'][0]
|
||||
|
||||
return recipe
|
||||
|
|
Loading…
Reference in a new issue