From a1e70d8ac5a682fd7ee340ff6327537cbea37479 Mon Sep 17 00:00:00 2001 From: Alexander Detsch Date: Sat, 10 Dec 2022 21:25:51 +0100 Subject: [PATCH 1/2] removed wrongfully added recipe yield reduction --- kptncook/mealie.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/kptncook/mealie.py b/kptncook/mealie.py index c0a818e..1d0e4a7 100644 --- a/kptncook/mealie.py +++ b/kptncook/mealie.py @@ -372,8 +372,6 @@ def kptncook_to_mealie_ingredients(kptncook_ingredients): title, note, *parts = (p.strip() for p in title.split(",")) food = {"name": title} quantity = ingredient.quantity - if quantity is not None: - quantity /= 2 measure = None if hasattr(ingredient, "measure"): if ingredient.measure is not None: @@ -411,7 +409,7 @@ def kptncook_to_mealie( ), # type: ignore "prep_time": kcin.preparation_time, "cook_time": kcin.cooking_time, - "recipe_yield": "1 Portionen", # kptncook serves for default 2 portions, but we want it more granular + "recipe_yield": "1 Portionen", "recipe_instructions": kptncook_to_mealie_steps(kcin.steps, api_key), "recipe_ingredient": kptncook_to_mealie_ingredients(kcin.ingredients), "image_url": kcin.get_image_url(api_key), From 07108ae9b212d2d0a91c6a524bc9cfb28707e87e Mon Sep 17 00:00:00 2001 From: Alexander Detsch Date: Thu, 29 Feb 2024 19:16:38 +0100 Subject: [PATCH 2/2] adding uploaded assets to recipe-json Signed-off-by: Alexander Detsch --- kptncook/mealie.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/kptncook/mealie.py b/kptncook/mealie.py index 460103c..cb5171f 100644 --- a/kptncook/mealie.py +++ b/kptncook/mealie.py @@ -216,18 +216,22 @@ def upload_asset(self, recipe_slug, image: Image): ) r.raise_for_status() - return r.json()["fileName"] + return r.json() @staticmethod def _build_recipestep_text(recipe_uuid, text, image_name): return f'{text} ' def enrich_recipe_with_step_images(self, recipe): + assets = [] for instruction in recipe.recipe_instructions: - uploaded_image_name = self.upload_asset(recipe.slug, instruction.image) + asset_properties = self.upload_asset(recipe.slug, instruction.image) + uploaded_image_name = asset_properties["fileName"] instruction.text = self._build_recipestep_text( recipe.id, instruction.text, uploaded_image_name ) + assets.append(RecipeAsset(name=asset_properties["name"], icon=asset_properties["icon"], file_name=asset_properties["fileName"])) + recipe.assets = assets return recipe def _post_recipe_trunk_and_get_slug(self, recipe_name):