mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-06 22:58:19 -05:00
import local image, download if fails.
This commit is contained in:
@@ -90,10 +90,17 @@ class RecetteTek(Integration):
|
|||||||
|
|
||||||
# TODO: Parse Nutritional Information
|
# TODO: Parse Nutritional Information
|
||||||
|
|
||||||
# Grab the original image that was used for the recipe
|
# Import the original image from the zip file, if we cannot do that, attempt to download it again.
|
||||||
try:
|
try:
|
||||||
if file['originalPicture']!= '':
|
if file['pictures'][0] !='':
|
||||||
response = requests.get(file['originalPicture'])
|
image_file_name = file['pictures'][0].split('/')[-1]
|
||||||
|
for f in self.files:
|
||||||
|
if '.rtk' in f['name']:
|
||||||
|
import_zip = ZipFile(f['file'])
|
||||||
|
self.import_recipe_image(recipe, BytesIO(import_zip.read(image_file_name)))
|
||||||
|
else:
|
||||||
|
if file['originalPicture'] != '':
|
||||||
|
response=requests.get(file['originalPicture'])
|
||||||
if imghdr.what(BytesIO(response.content)) != None:
|
if imghdr.what(BytesIO(response.content)) != None:
|
||||||
self.import_recipe_image(recipe, BytesIO(response.content))
|
self.import_recipe_image(recipe, BytesIO(response.content))
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user