Import tags on mealie recipes

This commit is contained in:
blowk
2023-10-22 20:09:27 +02:00
committed by GitHub
parent 9cb1c21cd8
commit eb8422cb51

View File

@@ -7,7 +7,7 @@ from cookbook.helper.image_processing import get_filetype
from cookbook.helper.ingredient_parser import IngredientParser
from cookbook.helper.recipe_url_import import parse_servings, parse_servings_text, parse_time
from cookbook.integration.integration import Integration
from cookbook.models import Ingredient, Recipe, Step
from cookbook.models import Ingredient, Keyword, Recipe, Step
class Mealie(Integration):
@@ -56,6 +56,11 @@ class Mealie(Integration):
except Exception:
pass
if 'tags' in recipe_json and len(recipe_json['tags']) > 0:
for k in recipe_json['tags']:
keyword, created = Keyword.objects.get_or_create(name=k["name"].strip(), space=self.request.space)
recipe.keywords.add(keyword)
if 'notes' in recipe_json and len(recipe_json['notes']) > 0:
notes_text = "#### Notes \n\n"
for n in recipe_json['notes']: