From b3075865bb173b4ca7147da88170da8a405742c7 Mon Sep 17 00:00:00 2001 From: syrell Date: Thu, 18 Dec 2025 21:19:59 +0100 Subject: [PATCH] Changed: Use set instead of list to sore Mealie recipes --- recipe_bridge.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/recipe_bridge.py b/recipe_bridge.py index 4d3eded..7906a29 100644 --- a/recipe_bridge.py +++ b/recipe_bridge.py @@ -116,7 +116,7 @@ class Mealie(HttpResponder): "accept": "application/json", "Content-Type": "application/json", } - self.tagged_recipes = [] + self.tagged_recipes = set() def create_tag(self, tag) -> None: self.tag = self.json_request( @@ -158,9 +158,9 @@ class Mealie(HttpResponder): headers=self.headers, params={"tags": self.tag, "perPage": tagged_recipes_nb}, ) - self.tagged_recipes = [ + self.tagged_recipes = { recipe["orgURL"] for recipe in tagged_recipes_res["items"] - ] + } def add_mealie_recipe(self, recipe_url): logging.info(f"Creating new recipe with url: {recipe_url}") @@ -291,10 +291,10 @@ def main(): else: logging.info("All fetched recipes already exist in Mealie!") exit(0) - for new_recipe in hellofresh_client.recipes: - if new_recipe not in mealie_client.tagged_recipes: - recipe_slug = mealie_client.add_mealie_recipe(new_recipe) - mealie_client.update_mealie_recipe(recipe_slug) + new_recipes = hellofresh_client.recipes - mealie_client.tagged_recipes + for new_recipe in new_recipes: + recipe_slug = mealie_client.add_mealie_recipe(new_recipe) + mealie_client.update_mealie_recipe(recipe_slug) if __name__ == "__main__":