cookmate fixes
This commit is contained in:
parent
877b7799df
commit
11cb40702d
@ -301,7 +301,7 @@ def parse_servings_text(servings):
|
|||||||
servings = re.sub("\d+", '', servings).strip()
|
servings = re.sub("\d+", '', servings).strip()
|
||||||
except Exception:
|
except Exception:
|
||||||
servings = ''
|
servings = ''
|
||||||
return servings
|
return servings[:32]
|
||||||
|
|
||||||
|
|
||||||
def parse_time(recipe_time):
|
def parse_time(recipe_time):
|
||||||
|
@ -46,22 +46,30 @@ class Cookmate(Integration):
|
|||||||
if len(recipe_xml.find('description')) > 0:
|
if len(recipe_xml.find('description')) > 0:
|
||||||
recipe.description = recipe_xml.find('description')[0].text[:512]
|
recipe.description = recipe_xml.find('description')[0].text[:512]
|
||||||
|
|
||||||
for step in recipe_xml.find('recipetext').getchildren():
|
if recipe_text := recipe_xml.find('recipetext'):
|
||||||
step = Step.objects.create(
|
for step in recipe_text.getchildren():
|
||||||
instruction=step.text.strip(), space=self.request.space,
|
if step.text:
|
||||||
)
|
step = Step.objects.create(
|
||||||
recipe.steps.add(step)
|
instruction=step.text.strip(), space=self.request.space,
|
||||||
|
)
|
||||||
|
recipe.steps.add(step)
|
||||||
|
|
||||||
ingredient_parser = IngredientParser(self.request, True)
|
ingredient_parser = IngredientParser(self.request, True)
|
||||||
|
|
||||||
for ingredient in recipe_xml.find('ingredient').getchildren():
|
if recipe_ingredients := recipe_xml.find('ingredient'):
|
||||||
if ingredient.text.strip() != '':
|
ingredient_step = recipe.steps.first()
|
||||||
amount, unit, food, note = ingredient_parser.parse(ingredient.text.strip())
|
if ingredient_step is None:
|
||||||
f = ingredient_parser.get_food(food)
|
ingredient_step = Step.objects.create(space=self.request.space, instruction='')
|
||||||
u = ingredient_parser.get_unit(unit)
|
|
||||||
recipe.steps.first().ingredients.add(Ingredient.objects.create(
|
for ingredient in recipe_ingredients.getchildren():
|
||||||
food=f, unit=u, amount=amount, note=note, original_text=ingredient.text.strip(), space=self.request.space,
|
if ingredient.text:
|
||||||
))
|
if ingredient.text.strip() != '':
|
||||||
|
amount, unit, food, note = ingredient_parser.parse(ingredient.text.strip())
|
||||||
|
f = ingredient_parser.get_food(food)
|
||||||
|
u = ingredient_parser.get_unit(unit)
|
||||||
|
ingredient_step.ingredients.add(Ingredient.objects.create(
|
||||||
|
food=f, unit=u, amount=amount, note=note, original_text=ingredient.text.strip(), space=self.request.space,
|
||||||
|
))
|
||||||
|
|
||||||
if recipe_xml.find('imageurl') is not None:
|
if recipe_xml.find('imageurl') is not None:
|
||||||
try:
|
try:
|
||||||
|
Loading…
Reference in New Issue
Block a user