Skip to content

Commit

Permalink
fix self.__soup.find("amp-img").find("img")["src"]
Browse files Browse the repository at this point in the history
  • Loading branch information
FaserF committed Aug 30, 2024
1 parent 2c67529 commit 085bc70
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions custom_components/chefkoch_ha/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
_LOGGER = logging.getLogger(__name__)
SCAN_INTERVAL = timedelta(days=1)

# Executor für die Ausführung synchroner Code-Teile in einem separaten Thread
# Executor for running synchronous code in a separate thread
executor = ThreadPoolExecutor()

async def async_setup_entry(
Expand Down Expand Up @@ -82,17 +82,17 @@ async def async_update_data():

def get_recipe_url(recipe):
"""Get recipe URL safely."""
return recipe.url if hasattr(recipe, 'url') else ""
return recipe.url if hasattr(recipe, 'url') and recipe.url else ""

def extract_recipe_attributes(recipe_url):
"""Extract attributes from the recipe using a separate thread."""
if recipe_url:
try:
recipe = Recipe(recipe_url)
return {
"title": recipe.title,
"url": recipe_url,
"image_url": recipe.image_url if recipe.image_url else "",
"title": recipe.title or "Unknown",
"url": recipe_url or "",
"image_url": recipe.image_url if recipe.image_url is not None else "",
"totalTime": str(recipe.total_time) if recipe.total_time else "",
"ingredients": recipe.ingredients if recipe.ingredients else [],
"calories": recipe.calories if recipe.calories else "",
Expand All @@ -102,7 +102,7 @@ def extract_recipe_attributes(recipe_url):
_LOGGER.error("Error extracting recipe attributes: %s", e, exc_info=True)
return {
"title": "Unknown",
"url": recipe_url,
"url": recipe_url or "",
"image_url": "",
"totalTime": "",
"ingredients": [],
Expand All @@ -111,7 +111,7 @@ def extract_recipe_attributes(recipe_url):
}
return {
"title": "Unknown",
"url": recipe_url,
"url": recipe_url or "",
"image_url": "",
"totalTime": "",
"ingredients": [],
Expand Down

0 comments on commit 085bc70

Please sign in to comment.