diff --git a/app/mealie.py b/app/mealie.py index 0f691f3..db6762b 100644 --- a/app/mealie.py +++ b/app/mealie.py @@ -69,6 +69,7 @@ class MealieClient: ingredients = [] for line in recipe.get("ingredients", []): ingredients.append({ + "referenceId": uuid.uuid4().hex, "note": line, "isFood": False, "disableAmount": True, diff --git a/app/scraper.py b/app/scraper.py index a40adc0..1693f4e 100644 --- a/app/scraper.py +++ b/app/scraper.py @@ -66,11 +66,19 @@ def _parse_mindmegette(soup: BeautifulSoup, url: str) -> dict: if ing_container: for row in ing_container.find_all("div", class_="ingredients-meta"): parts = [] - # Quantity spans: 1 kg - qty_el = row.find("span", class_="quantity") - unit_el = row.find("span", class_="unit") - name_el = row.find("span", class_="name") - extra_el = row.find("span", class_="extra") + # Actual HTML: qty unit + # name + qty_el = row.find("strong") + # Unit: first plain (not one with a specific class like + # "ingredients-checkbox" etc.) + unit_el = None + for sp in row.find_all("span"): + if not sp.get("class"): + unit_el = sp + break + name_el = row.find("a", class_="ingredients-link") + # Extra info: (darált) or + extra_el = row.find("small") or row.find("span", class_="extra") if qty_el: parts.append(_text(qty_el)) @@ -79,12 +87,17 @@ def _parse_mindmegette(soup: BeautifulSoup, url: str) -> dict: if name_el: parts.append(_text(name_el)) if extra_el: - parts.append(_text(extra_el)) + extra = _text(extra_el) + if extra: + # Wrap in parens if not already + if not extra.startswith("("): + extra = f"({extra})" + parts.append(extra) line = " ".join(p for p in parts if p) if not line: - # Fallback: just grab the whole text of the row - line = _text(row) + # Fallback: grab whole row text with spaces between elements + line = row.get_text(separator=" ", strip=True) if line: ingredients.append(line)