Import the recipe image from the zip file.

This commit is contained in:
its_me_gb
2021-04-28 13:16:55 +01:00
parent eba3bfa828
commit d00fa10b9f

View File

@@ -1,5 +1,7 @@
import re
from bs4 import BeautifulSoup
from io import BytesIO
from zipfile import ZipFile
from django.utils.translation import gettext as _
@@ -55,6 +57,16 @@ class RecipeKeeper(Integration):
))
recipe.steps.add(step)
# import the Primary recipe image that is stored in the Zip
try:
for f in self.files:
if '.zip' in f['name']:
import_zip = ZipFile(f['file'])
self.import_recipe_image(recipe, BytesIO(import_zip.read(file.find("img", class_="recipe-photo").get("src"))))
except Exception as e:
pass
# TODO: Import the source url
# if source_url != '':
# step.instruction += '\n' + source_url
# step.save()