diff --git a/recipe_scrapers/sallysbakingaddiction.py b/recipe_scrapers/sallysbakingaddiction.py index 2c3be5b19..b32cbb02f 100644 --- a/recipe_scrapers/sallysbakingaddiction.py +++ b/recipe_scrapers/sallysbakingaddiction.py @@ -1,5 +1,6 @@ # mypy: disallow_untyped_defs=False from ._abstract import AbstractScraper +from ._exceptions import SchemaOrgException class SallysBakingAddiction(AbstractScraper): @@ -29,7 +30,21 @@ def yields(self): return self.schema.yields() def image(self): - return self.schema.image() + image = self.data.get("image") + + if image is None: + raise SchemaOrgException("Image not found in SchemaOrg") + + if isinstance(image, list): + image = image[-1] + + if isinstance(image, dict): + image = image.get("url") + + if "http://" not in image and "https://" not in image: + image = "" + + return image def ingredients(self): return self.schema.ingredients() diff --git a/tests/test_data/sallysbakingaddiction.com/sallysbakingaddiction.json b/tests/test_data/sallysbakingaddiction.com/sallysbakingaddiction.json index d7be321de..1aa254598 100644 --- a/tests/test_data/sallysbakingaddiction.com/sallysbakingaddiction.json +++ b/tests/test_data/sallysbakingaddiction.com/sallysbakingaddiction.json @@ -6,7 +6,7 @@ "description": "Make a flavorful pull apart bread using this delicious rosemary-infused yeasted dough. You can use your favorite cheese in the filling. I love and usually use shredded parmesan.", "cook_time": 50, "host": "sallysbakingaddiction.com", - "image": "https://sallysbakingaddiction.com/wp-content/uploads/2020/12/garlic-rosemary-pull-apart-bread-225x225.jpg", + "image": "https://sallysbakingaddiction.com/wp-content/uploads/2020/12/garlic-rosemary-pull-apart-bread.jpg", "ingredient_groups": [ { "ingredients": [