mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-04 21:58:54 -05:00
added origianl image import to paprika
This commit is contained in:
@@ -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,6 +84,13 @@ class Paprika(Integration):
|
|||||||
|
|
||||||
recipe.steps.add(step)
|
recipe.steps.add(step)
|
||||||
|
|
||||||
|
try:
|
||||||
|
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):
|
if recipe_json.get("photo_data", None):
|
||||||
self.import_recipe_image(recipe, BytesIO(base64.b64decode(recipe_json['photo_data'])), filetype='.jpeg')
|
self.import_recipe_image(recipe, BytesIO(base64.b64decode(recipe_json['photo_data'])), filetype='.jpeg')
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user