Changed: Use set instead of list to sore Mealie recipes
This commit is contained in:
@@ -116,7 +116,7 @@ class Mealie(HttpResponder):
|
|||||||
"accept": "application/json",
|
"accept": "application/json",
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
}
|
}
|
||||||
self.tagged_recipes = []
|
self.tagged_recipes = set()
|
||||||
|
|
||||||
def create_tag(self, tag) -> None:
|
def create_tag(self, tag) -> None:
|
||||||
self.tag = self.json_request(
|
self.tag = self.json_request(
|
||||||
@@ -158,9 +158,9 @@ class Mealie(HttpResponder):
|
|||||||
headers=self.headers,
|
headers=self.headers,
|
||||||
params={"tags": self.tag, "perPage": tagged_recipes_nb},
|
params={"tags": self.tag, "perPage": tagged_recipes_nb},
|
||||||
)
|
)
|
||||||
self.tagged_recipes = [
|
self.tagged_recipes = {
|
||||||
recipe["orgURL"] for recipe in tagged_recipes_res["items"]
|
recipe["orgURL"] for recipe in tagged_recipes_res["items"]
|
||||||
]
|
}
|
||||||
|
|
||||||
def add_mealie_recipe(self, recipe_url):
|
def add_mealie_recipe(self, recipe_url):
|
||||||
logging.info(f"Creating new recipe with url: {recipe_url}")
|
logging.info(f"Creating new recipe with url: {recipe_url}")
|
||||||
@@ -291,8 +291,8 @@ def main():
|
|||||||
else:
|
else:
|
||||||
logging.info("All fetched recipes already exist in Mealie!")
|
logging.info("All fetched recipes already exist in Mealie!")
|
||||||
exit(0)
|
exit(0)
|
||||||
for new_recipe in hellofresh_client.recipes:
|
new_recipes = hellofresh_client.recipes - mealie_client.tagged_recipes
|
||||||
if new_recipe not in mealie_client.tagged_recipes:
|
for new_recipe in new_recipes:
|
||||||
recipe_slug = mealie_client.add_mealie_recipe(new_recipe)
|
recipe_slug = mealie_client.add_mealie_recipe(new_recipe)
|
||||||
mealie_client.update_mealie_recipe(recipe_slug)
|
mealie_client.update_mealie_recipe(recipe_slug)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user