Add original source url to the first recipe step

This commit is contained in:
its_me_gb
2021-04-30 09:14:31 +01:00
parent d00fa10b9f
commit 0ec29636b3

View File

@@ -35,6 +35,7 @@ class RecipeKeeper(Integration):
# TODO: import prep and cook times
# Recipe Keeper uses ISO 8601 format for its duration periods.
source_url_added = False
ingredients_added = False
for s in file.find("div", {"itemprop": "recipeDirections"}).find_all("p"):
@@ -44,6 +45,14 @@ class RecipeKeeper(Integration):
step = Step.objects.create(
instruction=s.text
)
if not source_url_added:
# If there is a source URL, add it to the first step field.
if file.find("span", {"itemprop": "recipeSource"}).text != '':
step.instruction += "\n\nImported from: " + file.find("span", {"itemprop": "recipeSource"}).text
step.save()
source_url_added = True
if not ingredients_added:
ingredients_added = True
for ingredient in file.find("div", {"itemprop": "recipeIngredients"}).findChildren("p"):
@@ -66,11 +75,6 @@ class RecipeKeeper(Integration):
except Exception as e:
pass
# TODO: Import the source url
# if source_url != '':
# step.instruction += '\n' + source_url
# step.save()
return recipe
def get_file_from_recipe(self, recipe):