From b115c37eb8b387ff61521d68b29039c98c8ebfa8 Mon Sep 17 00:00:00 2001 From: smilerz Date: Wed, 14 Apr 2021 19:32:33 -0500 Subject: [PATCH] catch error on scrape.image() --- cookbook/helper/recipe_url_import.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cookbook/helper/recipe_url_import.py b/cookbook/helper/recipe_url_import.py index 6cdf0107c..34b91eec8 100644 --- a/cookbook/helper/recipe_url_import.py +++ b/cookbook/helper/recipe_url_import.py @@ -6,6 +6,7 @@ from isodate.isoerror import ISO8601Error from cookbook.helper.ingredient_parser import parse as parse_single_ingredient from cookbook.models import Keyword from django.utils.dateparse import parse_duration +from recipe_scrapers._schemaorg import SchemaOrgException from recipe_scrapers._utils import get_minutes, normalize_string @@ -42,9 +43,9 @@ def get_from_scraper(scrape, space): pass try: - recipe_json['image'] = scrape.image() - except AttributeError: - pass + recipe_json['image'] = parse_image(scrape.image()) or '' + except (AttributeError, TypeError, SchemaOrgException): + recipe_json['image'] = '' keywords = [] try: