mirror of
https://github.com/hay-kot/mealie.git
synced 2025-08-22 14:33:33 -07:00
proper image name association on rename
This commit is contained in:
parent
93ef4b83e2
commit
a0febc3f7e
1 changed files with 5 additions and 1 deletions
|
@ -33,11 +33,14 @@ def clean_nextcloud_tags(nextcloud_tags: str):
|
||||||
|
|
||||||
def import_recipes(recipe_dir: Path) -> Recipe:
|
def import_recipes(recipe_dir: Path) -> Recipe:
|
||||||
image = False
|
image = False
|
||||||
|
|
||||||
for file in recipe_dir.glob("full.*"):
|
for file in recipe_dir.glob("full.*"):
|
||||||
image = file
|
image = file
|
||||||
|
break
|
||||||
|
|
||||||
for file in recipe_dir.glob("*.json"):
|
for file in recipe_dir.glob("*.json"):
|
||||||
recipe_file = file
|
recipe_file = file
|
||||||
|
break
|
||||||
|
|
||||||
with open(recipe_file, "r") as f:
|
with open(recipe_file, "r") as f:
|
||||||
recipe_dict = json.loads(f.read())
|
recipe_dict = json.loads(f.read())
|
||||||
|
@ -45,12 +48,13 @@ def import_recipes(recipe_dir: Path) -> Recipe:
|
||||||
recipe_data = Cleaner.clean(recipe_dict)
|
recipe_data = Cleaner.clean(recipe_dict)
|
||||||
|
|
||||||
image_name = recipe_data["slug"]
|
image_name = recipe_data["slug"]
|
||||||
|
recipe_data["image"] = recipe_data["slug"]
|
||||||
recipe_data["tags"] = clean_nextcloud_tags(recipe_data.get("keywords"))
|
recipe_data["tags"] = clean_nextcloud_tags(recipe_data.get("keywords"))
|
||||||
|
|
||||||
recipe = Recipe(**recipe_data)
|
recipe = Recipe(**recipe_data)
|
||||||
|
|
||||||
if image:
|
if image:
|
||||||
shutil.copy(image, app_dirs.IMG_DIR.joinpath(image_name))
|
shutil.copy(image, app_dirs.IMG_DIR.joinpath(image_name + image.suffix))
|
||||||
|
|
||||||
return recipe
|
return recipe
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue