mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2025-12-24 02:39:20 -05:00
Add original source url to the first recipe step
This commit is contained in:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user