added origianl image import to paprika
This commit is contained in:
parent
a60f1a3e92
commit
008a61823d
@ -5,6 +5,9 @@ import re
|
|||||||
from gettext import gettext as _
|
from gettext import gettext as _
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
|
||||||
|
import requests
|
||||||
|
import validators
|
||||||
|
|
||||||
from cookbook.helper.ingredient_parser import IngredientParser
|
from cookbook.helper.ingredient_parser import IngredientParser
|
||||||
from cookbook.helper.recipe_url_import import parse_servings, parse_servings_text
|
from cookbook.helper.recipe_url_import import parse_servings, parse_servings_text
|
||||||
from cookbook.integration.integration import Integration
|
from cookbook.integration.integration import Integration
|
||||||
@ -81,7 +84,14 @@ class Paprika(Integration):
|
|||||||
|
|
||||||
recipe.steps.add(step)
|
recipe.steps.add(step)
|
||||||
|
|
||||||
if recipe_json.get("photo_data", None):
|
try:
|
||||||
self.import_recipe_image(recipe, BytesIO(base64.b64decode(recipe_json['photo_data'])), filetype='.jpeg')
|
if recipe_json.get("image_url", None):
|
||||||
|
url = recipe_json.get("image_url", None)
|
||||||
|
if validators.url(url, public=True):
|
||||||
|
response = requests.get(url)
|
||||||
|
self.import_recipe_image(recipe, BytesIO(response.content))
|
||||||
|
except:
|
||||||
|
if recipe_json.get("photo_data", None):
|
||||||
|
self.import_recipe_image(recipe, BytesIO(base64.b64decode(recipe_json['photo_data'])), filetype='.jpeg')
|
||||||
|
|
||||||
return recipe
|
return recipe
|
||||||
|
Loading…
Reference in New Issue
Block a user