catch error on scrape.image()

This commit is contained in:
smilerz
2021-04-14 19:32:33 -05:00
parent 1e17f3703a
commit b115c37eb8

View File

@ -6,6 +6,7 @@ from isodate.isoerror import ISO8601Error
from cookbook.helper.ingredient_parser import parse as parse_single_ingredient from cookbook.helper.ingredient_parser import parse as parse_single_ingredient
from cookbook.models import Keyword from cookbook.models import Keyword
from django.utils.dateparse import parse_duration from django.utils.dateparse import parse_duration
from recipe_scrapers._schemaorg import SchemaOrgException
from recipe_scrapers._utils import get_minutes, normalize_string from recipe_scrapers._utils import get_minutes, normalize_string
@ -42,9 +43,9 @@ def get_from_scraper(scrape, space):
pass pass
try: try:
recipe_json['image'] = scrape.image() recipe_json['image'] = parse_image(scrape.image()) or ''
except AttributeError: except (AttributeError, TypeError, SchemaOrgException):
pass recipe_json['image'] = ''
keywords = [] keywords = []
try: try: