mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-05 06:08:46 -05:00
Import the recipe image from the zip file.
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user